linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: v9fs@lists.linux.dev
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	ericvh@kernel.org, lucho@ionkov.net, asmadeus@codewreck.org,
	linux_oss@crudebyte.com, eadavis@qq.com,
	Remi Pommarel <repk@triplefau.lt>
Subject: [PATCH V3 6/4] 9p: fix new mount API cache option handling
Date: Tue, 2 Dec 2025 16:34:51 -0600	[thread overview]
Message-ID: <48cdeec9-5bb9-4c7a-a203-39bb8e0ef443@redhat.com> (raw)
In-Reply-To: <20251010214222.1347785-5-sandeen@redhat.com>

After commit 4eb3117888a92, 9p needs to be able to accept numerical
cache= mount options as well as the string "shortcuts" because the option
is printed numerically in /proc/mounts rather than by string. This was
missed in the mount API conversion, which used an enum for the shortcuts
and therefore could not handle a numeric equivalent as an argument
to the cache option.

Fix this by removing the enum and reverting to the slightly more
open-coded option handling for Opt_cache, with the reinstated
get_cache_mode() helper.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

If you wanted to fold this into my original mount api conversion patch
so there's no regression point, that would be fine with me as well,
of course. Sorry for the error.

diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index d684cb406ed6..dea2c5347933 100644
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -72,15 +72,6 @@ static const struct constant_table p9_versions[] = {
 	{}
 };
 
-static const struct constant_table p9_cache_mode[] = {
-	{ "loose",	CACHE_SC_LOOSE },
-	{ "fscache",	CACHE_SC_FSCACHE },
-	{ "mmap",	CACHE_SC_MMAP },
-	{ "readahead",	CACHE_SC_READAHEAD },
-	{ "none",	CACHE_SC_NONE },
-	{}
-};
-
 /*
  * This structure contains all parameters used for the core code,
  * the client, and all the transports.
@@ -97,7 +88,7 @@ const struct fs_parameter_spec v9fs_param_spec[] = {
 	fsparam_flag	("noxattr",	Opt_noxattr),
 	fsparam_flag	("directio",	Opt_directio),
 	fsparam_flag	("ignoreqv",	Opt_ignoreqv),
-	fsparam_enum	("cache",	Opt_cache, p9_cache_mode),
+	fsparam_string	("cache",	Opt_cache),
 	fsparam_string	("cachetag",	Opt_cachetag),
 	fsparam_string	("access",	Opt_access),
 	fsparam_flag	("posixacl",	Opt_posixacl),
@@ -124,6 +115,33 @@ const struct fs_parameter_spec v9fs_param_spec[] = {
 	{}
 };
 
+/* Interpret mount options for cache mode */
+static int get_cache_mode(char *s)
+{
+	int version = -EINVAL;
+
+	if (!strcmp(s, "loose")) {
+		version = CACHE_SC_LOOSE;
+		p9_debug(P9_DEBUG_9P, "Cache mode: loose\n");
+	} else if (!strcmp(s, "fscache")) {
+		version = CACHE_SC_FSCACHE;
+		p9_debug(P9_DEBUG_9P, "Cache mode: fscache\n");
+	} else if (!strcmp(s, "mmap")) {
+		version = CACHE_SC_MMAP;
+		p9_debug(P9_DEBUG_9P, "Cache mode: mmap\n");
+	} else if (!strcmp(s, "readahead")) {
+		version = CACHE_SC_READAHEAD;
+		p9_debug(P9_DEBUG_9P, "Cache mode: readahead\n");
+	} else if (!strcmp(s, "none")) {
+		version = CACHE_SC_NONE;
+		p9_debug(P9_DEBUG_9P, "Cache mode: none\n");
+	} else if (kstrtoint(s, 0, &version) != 0) {
+		version = -EINVAL;
+		pr_info("Unknown Cache mode or invalid value %s\n", s);
+	}
+	return version;
+}
+
 /*
  * Display the mount options in /proc/mounts.
  */
@@ -269,8 +287,10 @@ int v9fs_parse_param(struct fs_context *fc, struct fs_parameter *param)
 #endif
 		break;
 	case Opt_cache:
-		session_opts->cache = result.uint_32;
-		p9_debug(P9_DEBUG_9P, "Cache mode: %s\n", param->string);
+		r = get_cache_mode(param->string);
+		if (r < 0)
+			return r;
+		session_opts->cache = r;
 		break;
 	case Opt_access:
 		s = param->string;



      parent reply	other threads:[~2025-12-02 22:34 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-10 21:36 [PATCH V3 0/4] 9p: Convert to the new mount API Eric Sandeen
2025-10-10 21:36 ` [PATCH V3 1/4] fs/fs_parse: add back fsparam_u32hex Eric Sandeen
2025-10-10 21:36 ` [PATCH V3 2/4] net/9p: move structures and macros to header files Eric Sandeen
2025-10-10 21:36 ` [PATCH V3 3/4] 9p: create a v9fs_context structure to hold parsed options Eric Sandeen
2025-10-10 21:36 ` [PATCH V3 4/4] 9p: convert to the new mount API Eric Sandeen
2025-10-13 10:26   ` Dominique Martinet
2025-10-13 18:46     ` Eric Sandeen
2025-10-13 19:04       ` Dominique Martinet
2025-11-26 20:16     ` Remi Pommarel
2025-11-26 22:43       ` Dominique Martinet
2025-12-01 22:36         ` Eric Sandeen
2025-12-02  1:04           ` Dominique Martinet
2025-12-02 22:12             ` Eric Sandeen
2025-12-03 15:13               ` Dominique Martinet
2025-12-03 16:23                 ` Eric Sandeen
2025-12-05 11:53                 ` Remi Pommarel
2025-12-05 12:56                   ` Dominique Martinet
2025-12-02 22:30   ` [PATCH V3 5/4] 9p: fix cache option printing in v9fs_show_options Eric Sandeen
2025-12-02 23:13     ` Al Viro
2025-12-03  1:09       ` Eric Sandeen
2025-12-03 15:04         ` Dominique Martinet
2025-12-03 18:04           ` Al Viro
2025-12-02 22:34   ` Eric Sandeen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48cdeec9-5bb9-4c7a-a203-39bb8e0ef443@redhat.com \
    --to=sandeen@redhat.com \
    --cc=asmadeus@codewreck.org \
    --cc=eadavis@qq.com \
    --cc=ericvh@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux_oss@crudebyte.com \
    --cc=lucho@ionkov.net \
    --cc=repk@triplefau.lt \
    --cc=v9fs@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).