diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -405,8 +405,6 @@ "Name cache parameters"); static u_int __read_mostly ncsize; /* the size as computed on creation or resizing */ -SYSCTL_UINT(_vfs_cache_param, OID_AUTO, size, CTLFLAG_RW, &ncsize, 0, - "Total namecache capacity"); u_int ncsizefactor = 2; SYSCTL_UINT(_vfs_cache_param, OID_AUTO, sizefactor, CTLFLAG_RW, &ncsizefactor, 0, @@ -1021,6 +1019,29 @@ CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RW, NULL, 0, sysctl_negminpct, "I", "Negative entry \% of namecache capacity above which automatic eviction is allowed"); +static int +sysctl_ncsize(SYSCTL_HANDLER_ARGS) +{ + u_int val; + int error; + + val = ncsize; + error = sysctl_handle_int(oidp, &val, 0, req); + if (error != 0 || req->newptr == NULL) + return (error); + + if (val == ncsize) + return (0); + + ncsize = val; + cache_recalc_neg_min(); + return (0); +} + +SYSCTL_PROC(_vfs_cache_param, OID_AUTO, size, + CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RW, NULL, 0, sysctl_ncsize, + "I", "Total namecache capacity"); + #ifdef DEBUG_CACHE /* * Grab an atomic snapshot of the name cache hash chain lengths