If either of vnodes is shared locked, lock must not be recursed.
Details
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
just a note this is going to need a __freebsd_version bump due to zfs
sys/kern/vfs_vnops.c | ||
---|---|---|
3786 | does this matter? will not this transparently upgrade to exclusive internally? point is while lockmgr is the standard thing today, it adds knowledge about it when it perhaps can be avoided |
LGTM. mjg@ can decide if he needs this for his
patch against zfs_copy_file_range().
If/when it goes into main, I'll take a look at changing
nfs_copy_file_range() to use it as well.
sys/kern/vfs_vnops.c | ||
---|---|---|
3786 | I think this is needed here for the check |
sys/kern/vfs_vnops.c | ||
---|---|---|
3797 | How do you know that the vnode isn't locked by another thread? |
sys/kern/vfs_vnops.c | ||
---|---|---|
3786 | Yes the code needs to differentiate between vnode states for real, to properly unlock. If this causes a negative feeling, we can add a predicate function testing for LK_NOSHARE, to hide the implementation. | |
3797 | This is wrong, of course. Hopefully updated version corrects the block. |
Do not check sharers to detect recursion. Just handle the case where the current lock type does not match the request (i.e. LK_SHARED lock, but need LK_EXCLUSIVE).
sys/kern/vfs_vnops.c | ||
---|---|---|
3792 | Exactly what are you asking about? VOP_UNLOCK() unlock the lock once, if it is recursed, the lock is still owned. ASSERT_VOP_UNLOCKED() is false-positive-safe, in fact it only checks that the lock is not exclusively owned by the current thread. |
sys/kern/vfs_vnops.c | ||
---|---|---|
3792 | I see, I missed that it only checks for exclusive ownership. |