]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
unionfs: upgrade the vnode lock during fsync() if necessary
authorJason A. Harmening <jah@FreeBSD.org>
Sun, 24 Dec 2023 04:42:28 +0000 (22:42 -0600)
committerJason A. Harmening <jah@FreeBSD.org>
Sun, 18 Feb 2024 15:18:07 +0000 (09:18 -0600)
commit2656fc29be8b0fc1cd9e64ed52aa0a61fe87744c
treec55c03cef3bb0617e5f523addacf56bb1eab1cc3
parent9530182e371dee382b76d8594f65633a304b396f
unionfs: upgrade the vnode lock during fsync() if necessary

If the underlying upper FS supports shared locking for write ops,
as is the case with ZFS, VOP_FSYNC() may only be called with the vnode
lock held shared.  In this case, temporarily upgrade the lock for
those unionfs maintenance operations which require exclusive locking.

While here, make unionfs inherit the upper FS' support for shared
write locking.  Since the upper FS is the target of VOP_GETWRITEMOUNT()
this is what will dictate the locking behavior of any unionfs caller
that uses vn_start_write() + vn_lktype_write(), so unionfs must be
prepared for the caller to only hold a shared vnode lock in these
cases.

Found in local testing of unionfs atop ZFS with DEBUG_VFS_LOCKS.

MFC after: 2 weeks
Reviewed by: kib, olce
Differential Revision: https://reviews.freebsd.org/D43817
sys/fs/unionfs/union_vfsops.c
sys/fs/unionfs/union_vnops.c