Date: Wed, 10 Jun 2009 21:47:55 +0400 From: Chagin Dmitry <dchagin@freebsd.org> To: Paul Saab <ps@freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r193762 - in head/sys: kern sys Message-ID: <20090610174755.GA1927@dchagin.static.corbina.ru> In-Reply-To: <200906082123.n58LNsdd044147@svn.freebsd.org> References: <200906082123.n58LNsdd044147@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--YiEDa0DAkWCtVeE4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jun 08, 2009 at 09:23:54PM +0000, Paul Saab wrote: > Author: ps > Date: Mon Jun 8 21:23:54 2009 > New Revision: 193762 > URL: http://svn.freebsd.org/changeset/base/193762 >=20 > 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. > =20 > Reviewed by: jhb, kmacy, jeffr >=20 > Modified: > head/sys/kern/vfs_syscalls.c > head/sys/kern/vfs_vnops.c > head/sys/kern/vnode_if.src > head/sys/sys/mount.h >=20 > Modified: head/sys/kern/vfs_syscalls.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- 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; > =20 > AUDIT_ARG(fd, uap->fd); > if ((error =3D getvnode(td->td_proc->p_fd, uap->fd, &fp)) !=3D 0) > @@ -3485,7 +3485,13 @@ fsync(td, uap) > vfslocked =3D VFS_LOCK_GIANT(vp->v_mount); > if ((error =3D vn_start_write(vp, &mp, V_WAIT | PCATCH)) !=3D 0) > goto drop; > - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); > + if (MNT_SHARED_WRITES(mp) || > + ((mp =3D=3D NULL) && MNT_SHARED_WRITES(vp->v_mount))) { > + lock_flags =3D LK_SHARED; > + } else { > + lock_flags =3D LK_EXCLUSIVE; > + } > + vn_lock(vp, lock_flags | LK_RETRY); > AUDIT_ARG(vnode, vp, ARG_VNODE1); > if (vp->v_object !=3D NULL) { > VM_OBJECT_LOCK(vp->v_object); >=20 vnode_if.src needs to be changed: diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src index f54d046..49cc782 100644 --- a/sys/kern/vnode_if.src +++ b/sys/kern/vnode_if.src @@ -247,7 +247,7 @@ vop_revoke { }; -%% fsync vp E E E +%% fsync vp L L L vop_fsync { IN struct vnode *vp; > Modified: head/sys/kern/vfs_vnops.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- 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 =3D vn_start_write(vp, &mp, V_WAIT | PCATCH)) > !=3D 0) > return (error); > - if (mp !=3D NULL && > - (mp->mnt_kern_flag & MNTK_SHARED_WRITES)) { > + if (MNT_SHARED_WRITES(mp) || > + ((mp =3D=3D NULL) && MNT_SHARED_WRITES(vp->v_mount))) { > lock_flags =3D LK_SHARED; > } else { > lock_flags =3D LK_EXCLUSIVE; > @@ -592,7 +592,8 @@ vn_write(fp, uio, active_cred, flags, td > (error =3D vn_start_write(vp, &mp, V_WAIT | PCATCH)) !=3D 0) > goto unlock; > =20 > - if (mp !=3D NULL && (mp->mnt_kern_flag & MNTK_SHARED_WRITES) && > + if ((MNT_SHARED_WRITES(mp) || > + ((mp =3D=3D NULL) && MNT_SHARED_WRITES(vp->v_mount))) && > (flags & FOF_OFFSET) !=3D 0) { > lock_flags =3D LK_SHARED; > } else { >=20 > Modified: head/sys/kern/vnode_if.src > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- 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 { > }; > =20 > =20 > -%% write vp E E E > +%% write vp L L L > %! write pre VOP_WRITE_PRE > %! write post VOP_WRITE_POST > =20 >=20 > Modified: head/sys/sys/mount.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- 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 */ > =20 > +#define MNT_SHARED_WRITES(mp) (((mp) !=3D NULL) && \ > + ((mp)->mnt_kern_flag & MNTK_SHARED_WRITES)) > + > /* > * Sysctl CTL_VFS definitions. > * --=20 Have fun! chd --YiEDa0DAkWCtVeE4 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.10 (FreeBSD) iEYEARECAAYFAkov8coACgkQ0t2Tb3OO/O2tiQCg0T7p4lkPUwihE2YeixY/6hnz 1MsAoKv0De92PFd6N/a+93lI8wY5b2CQ =df3j -----END PGP SIGNATURE----- --YiEDa0DAkWCtVeE4--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090610174755.GA1927>