Generalize the VV_CROSSLOCK logic in vfs_lookup()
authorJason A. Harmening <jah@FreeBSD.org>
Wed, 26 Oct 2022 22:25:20 +0000 (17:25 -0500)
committerJason A. Harmening <jah@FreeBSD.org>
Sun, 11 Dec 2022 04:02:38 +0000 (22:02 -0600)
commit42442d7a6eeb860e00f76aae5858884b44f6cce5
tree8d7d0f9197e16d485bf73666da2e453b57ba7920
parentbc2ccf0e4f8f655c00ab5cb344bdff0ee9546060
Generalize the VV_CROSSLOCK logic in vfs_lookup()

When VV_CROSSLOCK is present, the lock for the vnode at the current
stage of lookup must be held across the VFS_ROOT() call for the
filesystem mounted at the vnode.  Since VV_CROSSLOCK implies that
the root vnode reuses the already-held lock, the possibility for
recursion should be made clear in the flags passed to VFS_ROOT().

For cases in which the lock is held exclusive, this means passing
LK_CANRECURSE.  For cases in which the lock is held shared, it
means clearing LK_NODDLKTREAT to allow VFS_ROOT() to potentially
recurse on the shared lock even in the presence of an exclusive
waiter.

That the existing code works for unionfs is due to a coincidence
of the current unionfs implementation.

Reviewed by: kib
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D37458
sys/kern/vfs_lookup.c