Date: Mon, 8 Jun 2009 21:23:54 +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: r193762 - in head/sys: kern sys Message-ID: <200906082123.n58LNsdd044147@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ps Date: Mon Jun 8 21:23:54 2009 New Revision: 193762 URL: http://svn.freebsd.org/changeset/base/193762 Log: Simply shared vnode locking and extend it to also include fsync. Also, in vop_write, no longer assert for exclusive locks on the vnode. Reviewed by: jhb, kmacy, jeffr Modified: head/sys/kern/vfs_syscalls.c head/sys/kern/vfs_vnops.c head/sys/kern/vnode_if.src head/sys/sys/mount.h Modified: head/sys/kern/vfs_syscalls.c ============================================================================== --- head/sys/kern/vfs_syscalls.c Mon Jun 8 21:16:06 2009 (r193761) +++ head/sys/kern/vfs_syscalls.c Mon Jun 8 21:23:54 2009 (r193762) @@ -3476,7 +3476,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) @@ -3485,7 +3485,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); + 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); AUDIT_ARG(vnode, vp, ARG_VNODE1); if (vp->v_object != NULL) { VM_OBJECT_LOCK(vp->v_object); Modified: head/sys/kern/vfs_vnops.c ============================================================================== --- head/sys/kern/vfs_vnops.c Mon Jun 8 21:16:06 2009 (r193761) +++ head/sys/kern/vfs_vnops.c Mon Jun 8 21:23:54 2009 (r193762) @@ -376,8 +376,8 @@ 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)) { + if (MNT_SHARED_WRITES(mp) || + ((mp == NULL) && MNT_SHARED_WRITES(vp->v_mount))) { lock_flags = LK_SHARED; } else { lock_flags = LK_EXCLUSIVE; @@ -592,7 +592,8 @@ vn_write(fp, uio, active_cred, flags, td (error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) goto unlock; - if (mp != NULL && (mp->mnt_kern_flag & MNTK_SHARED_WRITES) && + if ((MNT_SHARED_WRITES(mp) || + ((mp == NULL) && MNT_SHARED_WRITES(vp->v_mount))) && (flags & FOF_OFFSET) != 0) { lock_flags = LK_SHARED; } else { Modified: head/sys/kern/vnode_if.src ============================================================================== --- head/sys/kern/vnode_if.src Mon Jun 8 21:16:06 2009 (r193761) +++ head/sys/kern/vnode_if.src Mon Jun 8 21:23:54 2009 (r193762) @@ -197,7 +197,7 @@ vop_read { }; -%% write vp E E E +%% write vp L L L %! write pre VOP_WRITE_PRE %! write post VOP_WRITE_POST Modified: head/sys/sys/mount.h ============================================================================== --- head/sys/sys/mount.h Mon Jun 8 21:16:06 2009 (r193761) +++ head/sys/sys/mount.h Mon Jun 8 21:23:54 2009 (r193762) @@ -336,6 +336,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?200906082123.n58LNsdd044147>