vn_lock(9)' LK_UPGRADE|LK_RETRY safety

Kostik Belousov kostikbel at gmail.com
Thu Mar 2 05:45:51 PST 2006


Assume that thread owns LK_SHARED lock on vnode vp, and the call
vn_lock(vp, LK_UPGRADE|LK_RETRY, curthread) is made. Is this upgrade
safe from dropping shared lock during the retries made in vn_lock ?

Man page for lockmgr says that failed LK_UPGRADE request
returns with shared lock dropped. But, from the review
of the code for lockmgr() and esp. acquire(), it seems
that it is impossible to get error (due to absence of LK_NOWAIT
and empty flags & zero timeout for msleep). Consequently,
it seems that shared lock will not be dropped. Is this true ?

Anyway, for instance, lookup(9) (sys/kern/vfs_lookup.c, line 552,
rev. 1.88) uses such call and does not check for errors. 

Best regards,
Kostik Belousov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20060302/67148847/attachment.bin


More information about the freebsd-hackers mailing list