git: adcb01c08e84 - stable/14 - nullfs: add -o cache

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

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

commit adcb01c08e849bee32b10b214f59d6bcf8ea46ea
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:30:41 +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 dde69d444923..3df24305f3ff 100644
--- a/sys/fs/nullfs/null_vfsops.c
+++ b/sys/fs/nullfs/null_vfsops.c
@@ -209,12 +209,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;
+	}
+	      
 	if ((xmp->nullm_flags & NULLM_CACHE) != 0) {
 		vfs_register_for_notification(xmp->nullm_vfs, mp,
 		    &xmp->notify_node);