Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Aug 2008 12:54:26 -0400 (EDT)
From:      Rick Macklem <rmacklem@uoguelph.ca>
To:        Kostik Belousov <kostikbel@gmail.com>
Cc:        freebsd-fs@freebsd.org
Subject:   Re: doing vfs_hash_get when vnode locked
Message-ID:  <Pine.GSO.4.63.0808051242110.23305@muncher.cs.uoguelph.ca>
In-Reply-To: <20080805153221.GG97161@deviant.kiev.zoral.com.ua>
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>

next in thread | previous in thread | raw e-mail | index | archive | help


On Tue, 5 Aug 2008, Kostik Belousov wrote:

[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"?

I suppose I can test for the lock and grab it, if no other thread already
has it locked.

> 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 == 0 under FreeBSD7.

> 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.)

rick




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.63.0808051242110.23305>