Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Jun 2009 16:18:08 +0000 (UTC)
From:      Paul Saab <ps@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r193440 - in head/sys: cddl/contrib/opensolaris/uts/common/fs/zfs kern sys
Message-ID:  <200906041618.n54GI851097005@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ps
Date: Thu Jun  4 16:18:07 2009
New Revision: 193440
URL: http://svn.freebsd.org/changeset/base/193440

Log:
  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.
  
  Reviewed by:	jhb, kmacy, jeffr

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
  head/sys/kern/vfs_vnops.c
  head/sys/sys/mount.h

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c	Thu Jun  4 15:57:38 2009	(r193439)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c	Thu Jun  4 16:18:07 2009	(r193440)
@@ -573,6 +573,7 @@ zfs_domount(vfs_t *vfsp, char *osname)
 	vfsp->mnt_flag |= MNT_LOCAL;
 	vfsp->mnt_kern_flag |= MNTK_MPSAFE;
 	vfsp->mnt_kern_flag |= MNTK_LOOKUP_SHARED;
+	vfsp->mnt_kern_flag |= MNTK_SHARED_WRITES;
 
 	if (error = dsl_prop_get_integer(osname, "readonly", &readonly, NULL))
 		goto out;

Modified: head/sys/kern/vfs_vnops.c
==============================================================================
--- head/sys/kern/vfs_vnops.c	Thu Jun  4 15:57:38 2009	(r193439)
+++ head/sys/kern/vfs_vnops.c	Thu Jun  4 16:18:07 2009	(r193440)
@@ -367,7 +367,7 @@ vn_rdwr(rw, vp, base, len, offset, segfl
 	struct iovec aiov;
 	struct mount *mp;
 	struct ucred *cred;
-	int error;
+	int error, lock_flags;
 
 	VFS_ASSERT_GIANT(vp->v_mount);
 
@@ -378,7 +378,13 @@ vn_rdwr(rw, vp, base, len, offset, segfl
 			    (error = vn_start_write(vp, &mp, V_WAIT | PCATCH))
 			    != 0)
 				return (error);
-			vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+			if (mp != NULL &&
+			    (mp->mnt_kern_flag & MNTK_SHARED_WRITES)) {
+				lock_flags = LK_SHARED;
+			} else {
+				lock_flags = LK_EXCLUSIVE;
+			}
+			vn_lock(vp, lock_flags | LK_RETRY);
 		} else
 			vn_lock(vp, LK_SHARED | LK_RETRY);
 
@@ -564,7 +570,7 @@ vn_write(fp, uio, active_cred, flags, td
 {
 	struct vnode *vp;
 	struct mount *mp;
-	int error, ioflag;
+	int error, ioflag, lock_flags;
 	int vfslocked;
 
 	KASSERT(uio->uio_td == td, ("uio_td %p is not td %p",
@@ -587,7 +593,16 @@ vn_write(fp, uio, active_cred, flags, td
 	if (vp->v_type != VCHR &&
 	    (error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0)
 		goto unlock;
-	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+ 
+	if (vp->v_mount != NULL &&
+	    (vp->v_mount->mnt_kern_flag & MNTK_SHARED_WRITES) &&
+	    (flags & FOF_OFFSET) != 0) {
+		lock_flags = LK_SHARED;
+	} else {
+		lock_flags = LK_EXCLUSIVE;
+	}
+
+	vn_lock(vp, lock_flags | LK_RETRY);
 	if ((flags & FOF_OFFSET) == 0)
 		uio->uio_offset = fp->f_offset;
 	ioflag |= sequential_heuristic(uio, fp);

Modified: head/sys/sys/mount.h
==============================================================================
--- head/sys/sys/mount.h	Thu Jun  4 15:57:38 2009	(r193439)
+++ head/sys/sys/mount.h	Thu Jun  4 16:18:07 2009	(r193440)
@@ -326,6 +326,7 @@ void          __mnt_vnode_markerfree(str
 #define	MNTK_DRAINING	0x00000010	/* lock draining is happening */
 #define	MNTK_REFEXPIRE	0x00000020	/* refcount expiring is happening */
 #define MNTK_EXTENDED_SHARED	0x00000040 /* Allow shared locking for more ops */
+#define	MNTK_SHARED_WRITES	0x00000080 /* Allow shared locking for writes */
 #define MNTK_UNMOUNT	0x01000000	/* unmount in progress */
 #define	MNTK_MWAIT	0x02000000	/* waiting for unmount to finish */
 #define	MNTK_SUSPEND	0x08000000	/* request write suspension */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906041618.n54GI851097005>