aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Certner <olce@FreeBSD.org>2025-10-06 13:22:13 +0000
committerOlivier Certner <olce@FreeBSD.org>2025-10-06 15:21:45 +0000
commit09f925b57aeb171318a9d54df500bf22b4cdd986 (patch)
treebab93f1021d0262de2fc08ba067b67fe6aa0392f
parentc8141e273a3eaf2f3fa05e9e5c2407c9538dd8f8 (diff)
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
-rw-r--r--sys/fs/nullfs/null_vnops.c7
1 files 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);