doing vfs_hash_get when vnode locked

Kostik Belousov kostikbel at gmail.com
Tue Aug 5 19:43:47 UTC 2008


On Tue, Aug 05, 2008 at 01:51:40PM -0400, Rick Macklem wrote:
> 
> 
> 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.
Yes, exactly.

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

But, what guarantees that the vnode would not be reclaimed before/under
your vref() it ? For instance, what if the vnode is locked due to reclaim
being in progress ?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-fs/attachments/20080805/49857b15/attachment.pgp


More information about the freebsd-fs mailing list