nullfs: Add the vfs.nullfs.cache_nodes sysctl to control nocache default

Differential revision:	https://reviews.freebsd.org/D44217
MFC after:	1 week
This commit is contained in:
Seigo Tanimura 2024-03-04 22:50:25 +09:00 committed by Konstantin Belousov
parent 4fefe1b763
commit c849eb8f19

View file

@ -46,6 +46,7 @@
#include <sys/mount.h>
#include <sys/namei.h>
#include <sys/proc.h>
#include <sys/sysctl.h>
#include <sys/vnode.h>
#include <sys/jail.h>
@ -63,6 +64,13 @@ static vfs_unmount_t nullfs_unmount;
static vfs_vget_t nullfs_vget;
static vfs_extattrctl_t nullfs_extattrctl;
SYSCTL_NODE(_vfs, OID_AUTO, nullfs, CTLFLAG_RW, 0, "nullfs");
static bool null_cache_vnodes = true;
SYSCTL_BOOL(_vfs_nullfs, OID_AUTO, cache_vnodes, CTLFLAG_RWTUN,
&null_cache_vnodes, 0,
"cache free nullfs vnodes");
/*
* Mount null layer
*/
@ -198,7 +206,8 @@ nullfs_mount(struct mount *mp)
}
xmp->nullm_flags |= NULLM_CACHE;
if (vfs_getopt(mp->mnt_optnew, "nocache", NULL, NULL) == 0 ||
if (!null_cache_vnodes ||
vfs_getopt(mp->mnt_optnew, "nocache", NULL, NULL) == 0 ||
(xmp->nullm_vfs->mnt_kern_flag & MNTK_NULL_NOCACHE) != 0)
xmp->nullm_flags &= ~NULLM_CACHE;