git: cfa5b2a501c9 - stable/13 - nullfs: add -o cache

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Thu, 14 Mar 2024 00:47:38 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=cfa5b2a501c9062d3495aa73d5deac8a33992146

commit cfa5b2a501c9062d3495aa73d5deac8a33992146
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-03-08 18:26:02 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-03-13 00:31:20 +0000

    nullfs: add -o cache
    
    (cherry picked from commit 8921216dbee6884532e22d5347cff4d9ed23e782)
---
 sys/fs/nullfs/null_vfsops.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/sys/fs/nullfs/null_vfsops.c b/sys/fs/nullfs/null_vfsops.c
index e08ed2f55d38..6a3f77a11734 100644
--- a/sys/fs/nullfs/null_vfsops.c
+++ b/sys/fs/nullfs/null_vfsops.c
@@ -202,12 +202,15 @@ nullfs_mount(struct mount *mp)
 		MNT_IUNLOCK(mp);
 	}
 
-	xmp->nullm_flags |= NULLM_CACHE;
-	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;
-
+	if (vfs_getopt(mp->mnt_optnew, "cache", NULL, NULL) == 0) {
+		xmp->nullm_flags |= NULLM_CACHE;
+	} else if (vfs_getopt(mp->mnt_optnew, "nocache", NULL, NULL) == 0) {
+		;
+	} else if (null_cache_vnodes &&
+	    (xmp->nullm_vfs->mnt_kern_flag & MNTK_NULL_NOCACHE) == 0) {
+		xmp->nullm_flags |= NULLM_CACHE;
+	}
+	      
 	MNT_ILOCK(mp);
 	if ((xmp->nullm_flags & NULLM_CACHE) != 0) {
 		mp->mnt_kern_flag |= lowerrootvp->v_mount->mnt_kern_flag &