Date: Fri, 5 Oct 2007 22:11:34 +0300 From: Kostik Belousov <kostikbel@gmail.com> To: John Baldwin <jhb@freebsd.org> Cc: Jeff Roberson <jroberson@chesapeake.net>, src-committers@freebsd.org, cvs-all@freebsd.org, cvs-src@freebsd.org Subject: Re: cvs commit: src/sys/fs/devfs devfs_vnops.c src/sys/fs/fifofs fifo_vnops.c src/sys/kern uipc_usrreq.c vfs_vnops.c src/sys/vm vnode_pager.c Message-ID: <20071005191134.GA2180@deviant.kiev.zoral.com.ua> In-Reply-To: <200710051350.39581.jhb@freebsd.org> References: <200710032106.l93L65bv095725@repoman.freebsd.org> <200710041219.13202.jhb@freebsd.org> <20071004182759.U912@10.0.0.1> <200710051350.39581.jhb@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] On Fri, Oct 05, 2007 at 01:50:39PM -0400, John Baldwin wrote: > On Thursday 04 October 2007 09:29:25 pm Jeff Roberson wrote: > > On Thu, 4 Oct 2007, John Baldwin wrote: > > > > > On Wednesday 03 October 2007 07:48:00 pm Jeff Roberson wrote: > > >> On Wed, 3 Oct 2007, John Baldwin wrote: > > >> > > >>> jhb 2007-10-03 21:06:05 UTC > > >>> > > >>> FreeBSD src repository > > >>> > > >>> Modified files: (Branch: RELENG_6) > > >>> sys/fs/devfs devfs_vnops.c > > >>> sys/fs/fifofs fifo_vnops.c > > >>> sys/kern uipc_usrreq.c vfs_vnops.c > > >>> sys/vm vnode_pager.c > > >>> Log: > > >>> MFC: Always use an exclusive lock on the leaf vnode during an open() > when > > >>> shared lookups are enabled. This closes a few races including a race > > > where > > >>> concurrent opens of a fifo could result in different v_fifoinfo > > > structures > > >>> in different threads. > > >> > > >> Long term we should really look for a better solution to this problem. > > >> There are a number of was to improve snapshots in ffs by fixing shared > > >> locking. > > > > > > I don't disagree. The fifo case can be fixed easily enough in the fifo > code > > > by using fifo_mtx to protect v_fifoinfo perhaps (or doing an upgrade on > the > > > vnode lock?), but for the MFC I didn't want to have to fix each of the > races > > > with open(2). Probably better to fix it more properly in HEAD first. > > > > Definitely someting for head. Were there any others that you ran into > > besides v_fifoinfo? We should audit this more closely anyhow. I have > > been reluctant to push too much shared locking into VFS because it's not > > been so carefully studied. > > I just saw v_fifoinfo, but Pawel's original commit referenced updates to > v_writecount, etc. The v_writecount one is in vn_open() itself: > > if ((error = VOP_OPEN(vp, fmode, cred, td, fp)) != 0) > goto bad; > > if (fmode & FWRITE) > vp->v_writecount++; > *flagp = fmode; > ASSERT_VOP_ELOCKED(vp, "vn_open_cred"); > if (!mpsafe) > VFS_UNLOCK_GIANT(vfslocked); > return (0); > > If you just held a shared lock there, you could use atomic ops for > vp->v_writecount (and still hold at least a shared vnode lock everywhere > v_writecount is updated) and still be able to read vp->v_writecount safely > while holding an exclusive lock on the vnode. Another is the vm/vnode_pager.c handling of the v_object. [-- Attachment #2 --] -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4 (FreeBSD) iD8DBQFHBoxlC3+MBN1Mb4gRAqH2AJ9niEBYlR9SKGUgmIDChfVlhg9RnQCePY+k ww4Jedi/GQ4M2FxzZ5abWqY= =8UIa -----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071005191134.GA2180>
