HomeFreeBSD

unionfs: rework locking scheme to only lock a single vnode

Description

unionfs: rework locking scheme to only lock a single vnode

Instead of locking both the lower and upper vnodes, which is both
complex and deadlock-prone, only lock the upper vnode, or the lower
vnode if no upper vnode is present.

In most cases this is all that is needed; for the cases in which
both vnodes do need to be locked, this change also employs deadlock-
avoiding techniques such as LK_NOWAIT and vn_lock_pair().

There are still some corner cases in which the current implementation
ends up taking multiple vnode locks across different filesystems
without taking special steps to avoid deadlock; those cases have
been noted in the comments.

Differential Revision: https://reviews.freebsd.org/D45398
Reviewed by: olce
Tested by: pho

Details

Provenance
jahAuthored on Feb 28 2024, 5:45 PM
Reviewer
olce
Differential Revision
D45398: unionfs: rework locking scheme to only lock a single vnode
Parents
rG6ac0f711ad9e: nvmecontrol: Fix "Workloadd" typo
Branches
Unknown
Tags
Unknown