From owner-svn-src-all@FreeBSD.ORG Fri Jan 22 14:44:16 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4B0471065694; Fri, 22 Jan 2010 14:44:16 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3A2998FC13; Fri, 22 Jan 2010 14:44:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o0MEiGPT099064; Fri, 22 Jan 2010 14:44:16 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0MEiGMp099059; Fri, 22 Jan 2010 14:44:16 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201001221444.o0MEiGMp099059@svn.freebsd.org> From: John Baldwin Date: Fri, 22 Jan 2010 14:44:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r202810 - in stable/7/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jan 2010 14:44:16 -0000 Author: jhb Date: Fri Jan 22 14:44:15 2010 New Revision: 202810 URL: http://svn.freebsd.org/changeset/base/202810 Log: MFC 193440,193442,193762,194019: - Support shared vnode locks for write operations when the offset is provided on filesystems that support it. This really improves mysql + innodb performance on ZFS. - When checking for shared writes, use the struct mount returned from vn_start_write. - Simply shared vnode locking and extend it to also include fsync. Also, in vop_write, no longer assert for exclusive locks on the vnode. - Stop asserting on exclusive locks in fsync since it can now support shared vnode locking on ZFS. Modified: stable/7/sys/kern/vfs_syscalls.c stable/7/sys/kern/vfs_vnops.c stable/7/sys/kern/vnode_if.src stable/7/sys/sys/mount.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/kern/vfs_syscalls.c ============================================================================== --- stable/7/sys/kern/vfs_syscalls.c Fri Jan 22 14:25:17 2010 (r202809) +++ stable/7/sys/kern/vfs_syscalls.c Fri Jan 22 14:44:15 2010 (r202810) @@ -3267,7 +3267,7 @@ fsync(td, uap) struct mount *mp; struct file *fp; int vfslocked; - int error; + int error, lock_flags; AUDIT_ARG(fd, uap->fd); if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0) @@ -3276,7 +3276,13 @@ fsync(td, uap) vfslocked = VFS_LOCK_GIANT(vp->v_mount); if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) goto drop; - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + if (MNT_SHARED_WRITES(mp) || + ((mp == NULL) && MNT_SHARED_WRITES(vp->v_mount))) { + lock_flags = LK_SHARED; + } else { + lock_flags = LK_EXCLUSIVE; + } + vn_lock(vp, lock_flags | LK_RETRY, td); AUDIT_ARG(vnode, vp, ARG_VNODE1); if (vp->v_object != NULL) { VM_OBJECT_LOCK(vp->v_object); Modified: stable/7/sys/kern/vfs_vnops.c ============================================================================== --- stable/7/sys/kern/vfs_vnops.c Fri Jan 22 14:25:17 2010 (r202809) +++ stable/7/sys/kern/vfs_vnops.c Fri Jan 22 14:44:15 2010 (r202810) @@ -370,13 +370,9 @@ vn_rdwr(rw, vp, base, len, offset, segfl (error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) return (error); - if (mp != NULL && - (mp->mnt_kern_flag & MNTK_SHARED_WRITES)) { - /* - * XXX See the next comment what should - * be done here too. - */ - lock_flags = LK_EXCLUSIVE; + if (MNT_SHARED_WRITES(mp) || + ((mp == NULL) && MNT_SHARED_WRITES(vp->v_mount))) { + lock_flags = LK_SHARED; } else { lock_flags = LK_EXCLUSIVE; } @@ -594,15 +590,10 @@ vn_write(fp, uio, active_cred, flags, td (error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) goto unlock; - if (vp->v_mount != NULL && - (vp->v_mount->mnt_kern_flag & MNTK_SHARED_WRITES) && + if ((MNT_SHARED_WRITES(mp) || + ((mp == NULL) && MNT_SHARED_WRITES(vp->v_mount))) && (flags & FOF_OFFSET) != 0) { - /* - * XXX This should be LK_SHARED but the VFS in releng7 - * needs some patches before this can be done. - * See the similar comment above. - */ - lock_flags = LK_EXCLUSIVE; + lock_flags = LK_SHARED; } else { lock_flags = LK_EXCLUSIVE; } Modified: stable/7/sys/kern/vnode_if.src ============================================================================== --- stable/7/sys/kern/vnode_if.src Fri Jan 22 14:25:17 2010 (r202809) +++ stable/7/sys/kern/vnode_if.src Fri Jan 22 14:44:15 2010 (r202810) @@ -185,7 +185,7 @@ vop_read { }; -%% write vp E E E +%% write vp L L L %! write pre VOP_WRITE_PRE %! write post VOP_WRITE_POST @@ -245,7 +245,7 @@ vop_revoke { }; -%% fsync vp E E E +%% fsync vp L L L vop_fsync { IN struct vnode *vp; Modified: stable/7/sys/sys/mount.h ============================================================================== --- stable/7/sys/sys/mount.h Fri Jan 22 14:25:17 2010 (r202809) +++ stable/7/sys/sys/mount.h Fri Jan 22 14:44:15 2010 (r202810) @@ -339,6 +339,9 @@ void __mnt_vnode_markerfree(str #define MNTK_LOOKUP_SHARED 0x40000000 /* FS supports shared lock lookups */ #define MNTK_NOKNOTE 0x80000000 /* Don't send KNOTEs from VOP hooks */ +#define MNT_SHARED_WRITES(mp) (((mp) != NULL) && \ + ((mp)->mnt_kern_flag & MNTK_SHARED_WRITES)) + /* * Sysctl CTL_VFS definitions. *