diff --git a/sys/fs/nullfs/null_vfsops.c b/sys/fs/nullfs/null_vfsops.c --- a/sys/fs/nullfs/null_vfsops.c +++ b/sys/fs/nullfs/null_vfsops.c @@ -48,6 +48,7 @@ #include #include #include +#include #include @@ -63,6 +64,14 @@ static vfs_vget_t nullfs_vget; static vfs_extattrctl_t nullfs_extattrctl; +SYSCTL_DECL(_vfs); + +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_RW, + &null_cache_vnodes, 0, "cache free nullfs vnodes"); + /* * Mount null layer */ @@ -89,6 +98,9 @@ if (mp->mnt_flag & MNT_UPDATE) { /* * Only support update mounts for NFS export. + * + * XXX nocache should also be updated for the tuning of the nullfs + * vnode caching on the fly. */ if (vfs_flagopt(mp->mnt_optnew, "export", NULL, 0)) return (0); @@ -198,7 +210,8 @@ } 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;