doing vfs_hash_get when vnode locked

Rick Macklem rmacklem at uoguelph.ca
Tue Aug 5 16:43:11 UTC 2008



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



More information about the freebsd-fs mailing list