freebsd-dev/sys/fs
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
..
autofs vfs: remove cn_thread 2021-10-11 13:21:47 +00:00
cd9660 cd9660: Use ANSI (c89) prototypes 2022-07-17 08:14:49 -04:00
cuse cuse(3): Cosmetic change about testing boolean values. 2022-10-04 13:51:06 +02:00
deadfs vn_open(): If the vnode is reclaimed during open(2), do not return error. 2021-02-12 03:02:20 +02:00
devfs vfs: always retain path buffer after lookup 2022-09-17 09:10:38 +00:00
ext2fs filesystems: return error from vn_rlimit_fsize() instead of EFBIG 2022-09-24 19:41:14 +03:00
fdescfs vfs: introduce V_PCATCH to stop abusing PCATCH 2022-09-17 15:41:37 +00:00
fifofs fifos: delegate unhandled kqueue filters to underlying filesystem 2021-10-12 02:43:07 -05:00
fuse fusefs: fix VOP_ADVLOCK with SEEK_END 2022-10-18 19:11:49 -06:00
mntfs mntfs: lock mntfs pseudo devfs vnode properly 2021-11-13 01:00:41 +02:00
msdosfs msdosfs: truncate write if it would exceed the fs max file size or RLIMIT_FSIZE 2022-09-24 19:42:01 +03:00
nfs nfscl: Fix parameter order in the calls to MGET(). 2022-09-23 15:07:24 -06:00
nfsclient nfscl: Fix the NFSv4.0 mount so that it does not crash 2022-10-15 08:38:07 -07:00
nfsserver nfsd: Make the pNFS server update Change for Setxattr/Rmxattr 2022-10-18 15:47:07 -07:00
nullfs nullfs(5): Fix a typo in a source code comment 2022-08-07 14:04:53 +02:00
procfs vm_pager: Remove references to KVME_TYPE_DEFAULT in the kernel 2022-07-17 07:09:48 -04:00
pseudofs pseudofs: use the vget_prep/vget_finish idiom 2022-09-19 20:08:40 +00:00
smbfs filesystems: return error from vn_rlimit_fsize() instead of EFBIG 2022-09-24 19:41:14 +03:00
tmpfs tmpfs: report minimal hole size 2022-10-19 20:24:07 +03:00
udf vfs: NDFREE(&nd, NDF_ONLY_PNBUF) -> NDFREE_PNBUF(&nd) 2022-03-24 10:20:51 +00:00
unionfs Add VV_CROSSLOCK vnode flag to avoid cross-mount lookup LOR 2022-10-26 19:33:03 -05:00