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)
Sep 27 2024, 5:46 PM
Unknown Object (File)
Sep 27 2024, 5:21 PM
Unknown Object (File)
Sep 27 2024, 5:21 PM
Unknown Object (File)
Sep 27 2024, 5:21 PM
Unknown Object (File)
Sep 26 2024, 11:26 AM
Unknown Object (File)
Sep 22 2024, 7:55 PM
Unknown Object (File)
Sep 22 2024, 11:18 AM
Unknown Object (File)
Sep 19 2024, 9:37 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