Date: Tue, 5 Aug 2008 19:51:14 +0300 From: Kostik Belousov <kostikbel@gmail.com> To: Rick Macklem <rmacklem@uoguelph.ca> Cc: freebsd-fs@freebsd.org Subject: Re: doing vfs_hash_get when vnode locked Message-ID: <20080805165114.GH97161@deviant.kiev.zoral.com.ua> In-Reply-To: <Pine.GSO.4.63.0808051242110.23305@muncher.cs.uoguelph.ca> References: <Pine.GSO.4.63.0808041657200.3482@muncher.cs.uoguelph.ca> <20080805083229.GB97161@deviant.kiev.zoral.com.ua> <Pine.GSO.4.63.0808051052350.27663@muncher.cs.uoguelph.ca> <20080805153221.GG97161@deviant.kiev.zoral.com.ua> <Pine.GSO.4.63.0808051242110.23305@muncher.cs.uoguelph.ca>
next in thread | previous in thread | raw e-mail | index | archive | help
--aRuUY7KzmetiZjaI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Aug 05, 2008 at 12:54:26PM -0400, Rick Macklem wrote: >=20 >=20 > On Tue, 5 Aug 2008, Kostik Belousov wrote: >=20 > [stuff snipped] > >>> > >>I need a referenced vnode (v_usecount incremented, which I thought would > >>avoid it being recycled) when another blocked thread in the kernel has > >No, this is a wrong assumption. Use count does not prevent the vnode > >from being reclaimed. > > > What does v_usecount mean then, if it doesn't say "I have it in use, so > you can't recycle it until I vrele() it"? It means that the vnode memory will not be freed until vrele(). But the VOP_RECLAIM may be called any time, and it requires exclusive lock. After vnode is reclaimed, it is reassigned to the deadfs. In particular, VOP_RECLAIM implementation must clear v_data. For the reclaimed vnode you still hold a reference to, you can reliably obtain the vnode lock. >=20 > I suppose I can test for the lock and grab it, if no other thread already > has it locked. >=20 > >Unless you held the vnode lock, it may be reclaimed. To set the > >VI_DOOMED flag, both exclusive vnode lock and vnode interlock must be > >held. > > > I don't care about VI_DOOMED nor want to set it. It is just what vget() > checked for the case of LK_TYPE_MASK =3D=3D 0 under FreeBSD7. >=20 > >If you can guarantee that the other thread does not relinquish the vnode > >lock while curthread operates on the vnode, you may use vref() and > >direct check on VI_DOOMED. I shall admit that this is quite perversive > >and fragile. > > > I'll have to think about it but, yes, I think I can guarantee that if > another thread holds the vnode lock then it is blocked waiting for this > thread to complete recovery. (The only other way to do this recovery is > without the vnode and that means I have to do a lot of coding. I'm > pretty sure holding a v_usecount works for OpenBSD and Mac OS X. I've > done quite a bit of testing on both and not had a problem.) I do not know about these systems, esp. whether and how they implement a forced unmount. --aRuUY7KzmetiZjaI Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkiYhQIACgkQC3+MBN1Mb4hX1wCgjLV/Tr/QaTG+1hiMbVzDifOA 0bYAn0MDZtboyjCEBXxBU4QTSyJIQU8t =W7MY -----END PGP SIGNATURE----- --aRuUY7KzmetiZjaI--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080805165114.GH97161>