git: 09f925b57aeb - main - nullfs: Slightly reduce contention by reducing concurrent sections
Date: Mon, 06 Oct 2025 15:22:46 UTC
The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=09f925b57aeb171318a9d54df500bf22b4cdd986 commit 09f925b57aeb171318a9d54df500bf22b4cdd986 Author: Olivier Certner <olce@FreeBSD.org> AuthorDate: 2025-10-06 13:22:13 +0000 Commit: Olivier Certner <olce@FreeBSD.org> CommitDate: 2025-10-06 15:21:45 +0000 nullfs: Slightly reduce contention by reducing concurrent sections In null_lock_prep_with_smr(), initialize 'lvp' outside of the SMR-protected section. In null_lock(), if after locking the lower vnode we notice that we have been reclaimed, we have to unlock the lower vnode and then relock our own now that the lock isn't shared anymore. Call VOP_UNLOCK() on the lower vnode as soon as this condition is known. This applies comments from D38761, one of which was missed and the other added too late. Reviewed by: kib MFC with: 641a58239520 ("nullfs: avoid the interlock in null_lock with smr") Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52935 --- sys/fs/nullfs/null_vnops.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/fs/nullfs/null_vnops.c b/sys/fs/nullfs/null_vnops.c index 375b6aa27531..ec8a6b10b13f 100644 --- a/sys/fs/nullfs/null_vnops.c +++ b/sys/fs/nullfs/null_vnops.c @@ -788,10 +788,10 @@ null_lock_prep_with_smr(struct vop_lock1_args *ap) struct null_node *nn; struct vnode *lvp; - vfs_smr_enter(); - lvp = NULL; + vfs_smr_enter(); + nn = VTONULL_SMR(ap->a_vp); if (__predict_true(nn != NULL)) { lvp = nn->null_lowervp; @@ -855,6 +855,8 @@ null_lock(struct vop_lock1_args *ap) * case by reacquiring correct lock in requested mode. */ if (VTONULL(ap->a_vp) == NULL && error == 0) { + VOP_UNLOCK(lvp); + flags = ap->a_flags; ap->a_flags &= ~LK_TYPE_MASK; switch (flags & LK_TYPE_MASK) { @@ -869,7 +871,6 @@ null_lock(struct vop_lock1_args *ap) panic("Unsupported lock request %d\n", flags); } - VOP_UNLOCK(lvp); error = vop_stdlock(ap); } vdrop(lvp);