Page MenuHomeFreeBSD

vn_lock_pair(): reasonably handle vp1 == vp2 case
ClosedPublic

Authored by kib on Nov 16 2023, 10:52 PM.
Tags
None
Referenced Files
Unknown Object (File)
Apr 25 2024, 8:21 PM
Unknown Object (File)
Apr 11 2024, 6:24 AM
Unknown Object (File)
Feb 29 2024, 2:16 AM
Unknown Object (File)
Jan 21 2024, 3:07 PM
Unknown Object (File)
Dec 21 2023, 3:59 AM
Unknown Object (File)
Dec 20 2023, 12:28 AM
Unknown Object (File)
Dec 9 2023, 10:16 PM
Unknown Object (File)
Dec 9 2023, 7:47 PM
Subscribers

Details

Summary
Lock the vnode in the most exclusive lock mode requested, once.
All callers already ensure that vp1 != vp2 or are careful enough to only
unlock once otherwise.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Nov 16 2023, 10:52 PM
kib added a subscriber: pho.
sys/kern/vfs_vnops.c
4045–4048

This comment should mention that they may be equal.

4081

Don't we need to check LK_NOSHARE too?

kib marked 2 inline comments as done.Nov 16 2023, 11:21 PM
kib added inline comments.
sys/kern/vfs_vnops.c
4081

This is micro-optimization, not strictly needed for correctness. Added.

kib marked an inline comment as done.

Update herald comment.
Optimize for LK_NOSHARE lock mode.

sys/kern/vfs_vnops.c
4081

LK_NOSHARE seems to mean, "silently upgrade share lock requests to exclusive lock requests." I don't see how that's just an optimization. In particular, if the caller requests LK_SHARE, we should honour LK_NOSHARE and change the request to LK_EXCLUSIVE.

sys/kern/vfs_vnops.c
4081

The change happens inside lockmgr. If passed vnode is lk_noshare and locked, it is locked exlusive. Optimization then consists in avoiding unlock.

This revision is now accepted and ready to land.Nov 17 2023, 1:10 AM