doing vfs_hash_get when vnode locked

Kostik Belousov kostikbel at gmail.com
Tue Aug 5 08:32:35 UTC 2008


On Mon, Aug 04, 2008 at 05:04:58PM -0400, Rick Macklem wrote:
> There's a place in my nfsv4 client where I need to vfs_hash_get() when
> another blocked thread may be holding a lock on the vnode. (It's during
> a recovery case where the other threads are blocked, so there isn't a
> race problem, as far as I understand it.)
> 
> For FreeBSD7, all I did was call vfs_hash_get() with flags == 0 and it
> gave me what I wanted (the vnode for the file handle with a reference
> count, but no lock).
> 
> For FreeBSD-CURRENT/8, this no longer works, because vfs_hash_get() calls
> vget(), which calls _vn_lock() and _vn_lock() now complains if the lock
> type field of "flags" is 0. I came up with a really ugly workaround, by
> setting the flags arg. to LK_EXCLOTHER for vfs_hash_get() and then
> providing my own VOP_LOCK1() which just VI_UNLOCK()s and returns 0 for
> this case (doing the same as vop_stdlock() for other cases). Yuck!!
> 
> Is it possible to re-enable the case of _vn_lock() getting a locktype
> field == 0 (or defining one that says "just return 0 unless VI_DOOMED"),
> so I don't need the dirty hack?

I do not quite understand what you really need there. The non-locked
vnode may be reclaimed at any moment, so the check for !VI_DOOMED
returns no useful information.
-------------- 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/2e7236f7/attachment.pgp


More information about the freebsd-fs mailing list