doing vfs_hash_get when vnode locked

Rick Macklem rmacklem at uoguelph.ca
Tue Aug 5 17:40:26 UTC 2008



On Tue, 5 Aug 2008, Kostik Belousov wrote:

[stuff snipped]
>> 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.
>
[stuff snipped]
> I do not know about these systems, esp. whether and how they implement
> a forced unmount.
>
Ok, I just spent a few minutes snooping around in vfs_subr.c and I think
I see the problem. vget() has called vholdl() and then 
v_upgrade_usecount(), which has incremented the usecount and taken the
vnode off the free list. This appears to prevent vgonel() from being
called on it for most cases, but there is still the case in vflush()
where the FORCECLOSE flag is set.

But, it seems that it is my nfs_unmount() that calls this, so I can just
delay the FORCECLOSE for this weird case.

In fact, it looks like vgonel() would call VOP_CLOSE() because v_usecount
is still non-zero (active) and that would block during the recovery in my
code, anyhow.

Thanks for clarifying it, rick



More information about the freebsd-fs mailing list