HomeFreeBSD

unionfs: upgrade the vnode lock during fsync() if necessary

Description

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

Details

Provenance
jahAuthored on Dec 24 2023, 4:42 AM
Reviewer
kib
Differential Revision
D43817: unionfs: upgrade the vnode lock during fsync() if necessary
Parents
rG9530182e371d: VFS: update VOP_FSYNC() debug check to reflect actual locking policy
Branches
Unknown
Tags
Unknown