freebsd-src/sys/fs/unionfs
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
..
union_subr.c unionfs: accommodate underlying FS calls that may re-lock 2024-03-09 19:54:04 -06:00
union_vfsops.c unionfs: upgrade the vnode lock during fsync() if necessary 2024-02-18 09:18:07 -06:00
union_vnops.c unionfs_rename: fix numerous locking issues 2024-04-28 20:19:48 -05:00
union.h unionfs: accommodate underlying FS calls that may re-lock 2024-03-09 19:54:04 -06:00