freebsd-src/sys/fs
Jason A. Harmening 05e8ab627b unionfs_rename: fix numerous locking issues
There are a few places in which unionfs_rename() accesses fvp's private
data without holding the necessary lock/interlock.  Moreover, the
implementation completely fails to handle the case in which fdvp is not
the same as tdvp; in this case it simply fails to lock fdvp at all.
Finally, it locks fvp while potentially already holding tvp's lock, but
makes no attempt to deal with possible LOR there.

Fix this by optimistically using the vnode interlock to protect
the short accesses to fdvp and fvp private data, sequentially.
If a file copy or shadow directory creation is required to prepare
the upper FS for the rename operation, the interlock must be dropped
and fdvp/fvp locked as necessary.

Additionally, use ERELOOKUP (as suggested by kib@) to simplify the
locking logic and eliminate unionfs_relookup() calls for file-copy/
shadow-directory cases that require tdvp's lock to be dropped.

Reviewed by:		kib (earlier version), olce
Tested by:		pho
Differential Revision:	https://reviews.freebsd.org/D44788
2024-04-28 20:19:48 -05:00
..
autofs Reduce reliance on sys/sysproto.h pollution 2024-04-15 21:35:40 +01:00
cd9660 cd9660: Add support for mask,dirmask,uid,gid options 2024-01-12 14:51:31 -08:00
cuse sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
deadfs sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
devfs cdevpriv(9): add iterator 2024-03-23 08:59:00 +02:00
ext2fs sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
fdescfs sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
fifofs sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
fuse fusefs: correct a comment 2024-04-04 14:18:56 -06:00
mntfs sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
msdosfs fs/msdosfs fatblock: use ulmin() rather than min() 2024-02-23 19:37:52 +02:00
nfs nfscl: Clear out a lot of cruft related to B_DIRECT 2024-04-27 17:10:48 -07:00
nfsclient nfscl: Clear out a lot of cruft related to B_DIRECT 2024-04-27 17:10:48 -07:00
nfsserver Revert "nfsd: Fix NFSv4.1/4.2 Claim_Deleg_Cur_FH" 2024-04-25 09:41:23 -07:00
nullfs nullfs: Show correct exported flag. 2024-04-13 17:21:01 +02:00
procfs procfs: Add self & exe symlinks like NetBSD does 2024-02-02 18:34:59 -07:00
pseudofs pseudofs: fix off by one in hash iteration in pfs_purge 2023-11-20 05:57:25 +00:00
smbfs Add vnode_pager_clean_{a,}sync(9) 2024-01-11 18:44:53 +02:00
tarfs tarfs(5): Grammar fix for a source code comment 2024-04-20 11:21:54 +02:00
tmpfs Reduce reliance on sys/sysproto.h pollution 2024-04-15 21:35:40 +01:00
udf udf: uma_zcreate() does not fail 2024-04-24 08:45:59 -04:00
unionfs unionfs_rename: fix numerous locking issues 2024-04-28 20:19:48 -05:00