diff --git a/sys/fs/nullfs/null_subr.c b/sys/fs/nullfs/null_subr.c --- a/sys/fs/nullfs/null_subr.c +++ b/sys/fs/nullfs/null_subr.c @@ -41,6 +41,7 @@ #include #include #include +#include #include @@ -63,6 +64,10 @@ static void null_hashins(struct mount *, struct null_node *); +SYSCTL_DECL(_vfs); + +SYSCTL_NODE(_vfs, OID_AUTO, nullfs, CTLFLAG_RW, 0, "nullfs"); + /* * Initialise cache headers */ 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,12 @@ static vfs_vget_t nullfs_vget; static vfs_extattrctl_t nullfs_extattrctl; +SYSCTL_DECL(_vfs_nullfs); + +static bool null_cache_nodes = true; +SYSCTL_BOOL(_vfs_nullfs, OID_AUTO, cache_nodes, CTLFLAG_RW, + &null_cache_nodes, 0, "cache free nullfs vnodes"); + /* * Mount null layer */ @@ -89,6 +96,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); @@ -197,10 +207,12 @@ MNT_IUNLOCK(mp); } - xmp->nullm_flags |= NULLM_CACHE; - if (vfs_getopt(mp->mnt_optnew, "nocache", NULL, NULL) == 0 || - (xmp->nullm_vfs->mnt_kern_flag & MNTK_NULL_NOCACHE) != 0) - xmp->nullm_flags &= ~NULLM_CACHE; + if (null_cache_nodes) { + xmp->nullm_flags |= NULLM_CACHE; + if (vfs_getopt(mp->mnt_optnew, "nocache", NULL, NULL) == 0 || + (xmp->nullm_vfs->mnt_kern_flag & MNTK_NULL_NOCACHE) != 0) + xmp->nullm_flags &= ~NULLM_CACHE; + } if ((xmp->nullm_flags & NULLM_CACHE) != 0) { vfs_register_for_notification(xmp->nullm_vfs, mp,