summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorOlivier Certner <olce@FreeBSD.org>2025-05-13 13:47:42 +0000
committerOlivier Certner <olce@FreeBSD.org>2025-05-21 10:07:15 +0000
commit7a9ea03e4bbfee1b2192d9a5b4da89a53d3a2c14 (patch)
tree56b88a9ce86bd34a1c59d735e3ba41486baed5a4 /sys
parent361a8fdefac70e0e5ff19473c952e5d0c0ff274f (diff)
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/vfs_subr.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 009d305b8c1f..a640bede85b9 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1964,11 +1964,24 @@ vn_alloc_hard(struct mount *mp, u_long rnumvnodes, bool bumped)
mtx_lock(&vnode_list_mtx);
+ /*
+ * Reload 'numvnodes', as since we acquired the lock, it may have
+ * changed significantly if we waited, and 'rnumvnodes' above was only
+ * actually passed if 'bumped' is true (else it is 0).
+ */
+ rnumvnodes = atomic_load_long(&numvnodes);
+ if (rnumvnodes + !bumped < desiredvnodes) {
+ vn_alloc_cyclecount = 0;
+ mtx_unlock(&vnode_list_mtx);
+ goto alloc;
+ }
+
rfreevnodes = vnlru_read_freevnodes();
if (vn_alloc_cyclecount++ >= rfreevnodes) {
vn_alloc_cyclecount = 0;
vstir = true;
}
+
/*
* Grow the vnode cache if it will not be above its target max
* after growing. Otherwise, if the free list is nonempty, try