summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2025-12-02 16:34:51 -0600
committerDominique Martinet <asmadeus@codewreck.org>2025-12-05 12:54:05 +0000
commit3e281113f871d7f9c69ca55a4d806a72180b7e8a (patch)
tree73ff0534d7ea8959a009cc242240646f42d06927
parentf0445613314f474c1a0ec6fa8a5cd153a618f1b6 (diff)
9p: fix new mount API cache option handling
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> Message-ID: <48cdeec9-5bb9-4c7a-a203-39bb8e0ef443@redhat.com> Tested-by: Remi Pommarel <repk@triplefau.lt> Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
-rw-r--r--fs/9p/v9fs.c44
1 files changed, 32 insertions, 12 deletions
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index 2f5c5f3123b7..057487efaaeb 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;