freebsd-dev/sys/fs/unionfs
Jason A. Harmening 080ef8a418 Add VV_CROSSLOCK vnode flag to avoid cross-mount lookup LOR
When a lookup operation crosses into a new mountpoint, the mountpoint
must first be busied before the root vnode can be locked. When a
filesystem is unmounted, the vnode covered by the mountpoint must
first be locked, and then the busy count for the mountpoint drained.
Ordinarily, these two operations work fine if executed concurrently,
but with a stacked filesystem the root vnode may in fact use the
same lock as the covered vnode. By design, this will always be
the case for unionfs (with either the upper or lower root vnode
depending on mount options), and can also be the case for nullfs
if the target and mount point are the same (which admittedly is
very unlikely in practice).

In this case, we have LOR. The lookup path holds the mountpoint
busy while waiting on what is effectively the covered vnode lock,
while a concurrent unmount holds the covered vnode lock and waits
for the mountpoint's busy count to drain.

Attempt to resolve this LOR by allowing the stacked filesystem
to specify a new flag, VV_CROSSLOCK, on a covered vnode as necessary.
Upon observing this flag, the vfs_lookup() will leave the covered
vnode lock held while crossing into the mountpoint. Employ this flag
for unionfs with the caveat that it can't be used for '-o below' mounts
until other unionfs locking issues are resolved.

Reported by:	pho
Tested by:	pho
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D35054
2022-10-26 19:33:03 -05:00
..
union_subr.c vfs: introduce V_PCATCH to stop abusing PCATCH 2022-09-17 15:41:37 +00:00
union_vfsops.c Add VV_CROSSLOCK vnode flag to avoid cross-mount lookup LOR 2022-10-26 19:33:03 -05:00
union_vnops.c vfs: always retain path buffer after lookup 2022-09-17 09:10:38 +00:00
union.h Remove unnecessary thread argument from unionfs_nodeget() and _noderem() 2021-12-07 16:20:02 -08:00