Date: Fri, 22 Jan 2010 14:44:16 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org Subject: svn commit: r202810 - in stable/7/sys: kern sys Message-ID: <201001221444.o0MEiGMp099059@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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. *
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001221444.o0MEiGMp099059>