aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2020-02-08 13:26:41 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2020-02-08 13:26:41 -0800
commitc9d35ee049b40f1d73e890bf88dd55f83b1e9be8 (patch)
tree7b942b7ee530f5a183df80f506d1292b9966d53c /fs/nfs
parentMerge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs (diff)
parenttmpfs: switch to use of invalfc() (diff)
downloadlinux-dev-c9d35ee049b40f1d73e890bf88dd55f83b1e9be8.tar.xz
linux-dev-c9d35ee049b40f1d73e890bf88dd55f83b1e9be8.zip
Merge branch 'merge.nfs-fs_parse.1' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs file system parameter updates from Al Viro: "Saner fs_parser.c guts and data structures. The system-wide registry of syntax types (string/enum/int32/oct32/.../etc.) is gone and so is the horror switch() in fs_parse() that would have to grow another case every time something got added to that system-wide registry. New syntax types can be added by filesystems easily now, and their namespace is that of functions - not of system-wide enum members. IOW, they can be shared or kept private and if some turn out to be widely useful, we can make them common library helpers, etc., without having to do anything whatsoever to fs_parse() itself. And we already get that kind of requests - the thing that finally pushed me into doing that was "oh, and let's add one for timeouts - things like 15s or 2h". If some filesystem really wants that, let them do it. Without somebody having to play gatekeeper for the variants blessed by direct support in fs_parse(), TYVM. Quite a bit of boilerplate is gone. And IMO the data structures make a lot more sense now. -200LoC, while we are at it" * 'merge.nfs-fs_parse.1' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (25 commits) tmpfs: switch to use of invalfc() cgroup1: switch to use of errorfc() et.al. procfs: switch to use of invalfc() hugetlbfs: switch to use of invalfc() cramfs: switch to use of errofc() et.al. gfs2: switch to use of errorfc() et.al. fuse: switch to use errorfc() et.al. ceph: use errorfc() and friends instead of spelling the prefix out prefix-handling analogues of errorf() and friends turn fs_param_is_... into functions fs_parse: handle optional arguments sanely fs_parse: fold fs_parameter_desc/fs_parameter_spec fs_parser: remove fs_parameter_description name field add prefix to fs_context->log ceph_parse_param(), ceph_parse_mon_ips(): switch to passing fc_log new primitive: __fs_parse() switch rbd and libceph to p_log-based primitives struct p_log, variants of warnf() et.al. taking that one instead teach logfc() to handle prefices, give it saner calling conventions get rid of cg_invalf() ...
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/fs_context.c93
1 files changed, 48 insertions, 45 deletions
diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c
index 2c6dc1b6cc92..e1b938457ab9 100644
--- a/fs/nfs/fs_context.c
+++ b/fs/nfs/fs_context.c
@@ -45,6 +45,7 @@ enum nfs_param {
Opt_cto,
Opt_fg,
Opt_fscache,
+ Opt_fscache_flag,
Opt_hard,
Opt_intr,
Opt_local_lock,
@@ -83,7 +84,35 @@ enum nfs_param {
Opt_wsize,
};
-static const struct fs_parameter_spec nfs_param_specs[] = {
+enum {
+ Opt_local_lock_all,
+ Opt_local_lock_flock,
+ Opt_local_lock_none,
+ Opt_local_lock_posix,
+};
+
+static const struct constant_table nfs_param_enums_local_lock[] = {
+ { "all", Opt_local_lock_all },
+ { "flock", Opt_local_lock_flock },
+ { "none", Opt_local_lock_none },
+ {}
+};
+
+enum {
+ Opt_lookupcache_all,
+ Opt_lookupcache_none,
+ Opt_lookupcache_positive,
+};
+
+static const struct constant_table nfs_param_enums_lookupcache[] = {
+ { "all", Opt_lookupcache_all },
+ { "none", Opt_lookupcache_none },
+ { "pos", Opt_lookupcache_positive },
+ { "positive", Opt_lookupcache_positive },
+ {}
+};
+
+static const struct fs_parameter_spec nfs_fs_parameters[] = {
fsparam_flag_no("ac", Opt_ac),
fsparam_u32 ("acdirmax", Opt_acdirmax),
fsparam_u32 ("acdirmin", Opt_acdirmin),
@@ -97,14 +126,14 @@ static const struct fs_parameter_spec nfs_param_specs[] = {
fsparam_string("clientaddr", Opt_clientaddr),
fsparam_flag_no("cto", Opt_cto),
fsparam_flag ("fg", Opt_fg),
- __fsparam(fs_param_is_string, "fsc", Opt_fscache,
- fs_param_neg_with_no|fs_param_v_optional),
+ fsparam_flag_no("fsc", Opt_fscache_flag),
+ fsparam_string("fsc", Opt_fscache),
fsparam_flag ("hard", Opt_hard),
- __fsparam(fs_param_is_flag, "intr", Opt_intr,
- fs_param_neg_with_no|fs_param_deprecated),
- fsparam_enum ("local_lock", Opt_local_lock),
+ __fsparam(NULL, "intr", Opt_intr,
+ fs_param_neg_with_no|fs_param_deprecated, NULL),
+ fsparam_enum ("local_lock", Opt_local_lock, nfs_param_enums_local_lock),
fsparam_flag_no("lock", Opt_lock),
- fsparam_enum ("lookupcache", Opt_lookupcache),
+ fsparam_enum ("lookupcache", Opt_lookupcache, nfs_param_enums_lookupcache),
fsparam_flag_no("migration", Opt_migration),
fsparam_u32 ("minorversion", Opt_minorversion),
fsparam_string("mountaddr", Opt_mountaddr),
@@ -146,37 +175,6 @@ static const struct fs_parameter_spec nfs_param_specs[] = {
};
enum {
- Opt_local_lock_all,
- Opt_local_lock_flock,
- Opt_local_lock_none,
- Opt_local_lock_posix,
-};
-
-enum {
- Opt_lookupcache_all,
- Opt_lookupcache_none,
- Opt_lookupcache_positive,
-};
-
-static const struct fs_parameter_enum nfs_param_enums[] = {
- { Opt_local_lock, "all", Opt_local_lock_all },
- { Opt_local_lock, "flock", Opt_local_lock_flock },
- { Opt_local_lock, "none", Opt_local_lock_none },
- { Opt_local_lock, "posix", Opt_local_lock_posix },
- { Opt_lookupcache, "all", Opt_lookupcache_all },
- { Opt_lookupcache, "none", Opt_lookupcache_none },
- { Opt_lookupcache, "pos", Opt_lookupcache_positive },
- { Opt_lookupcache, "positive", Opt_lookupcache_positive },
- {}
-};
-
-static const struct fs_parameter_description nfs_fs_parameters = {
- .name = "nfs",
- .specs = nfs_param_specs,
- .enums = nfs_param_enums,
-};
-
-enum {
Opt_vers_2,
Opt_vers_3,
Opt_vers_4,
@@ -442,7 +440,7 @@ static int nfs_fs_context_parse_param(struct fs_context *fc,
dfprintk(MOUNT, "NFS: parsing nfs mount option '%s'\n", param->key);
- opt = fs_parse(fc, &nfs_fs_parameters, param, &result);
+ opt = fs_parse(fc, nfs_fs_parameters, param, &result);
if (opt < 0)
return ctx->sloppy ? 1 : opt;
@@ -540,14 +538,19 @@ static int nfs_fs_context_parse_param(struct fs_context *fc,
else
ctx->flags &= ~NFS_MOUNT_NORESVPORT;
break;
- case Opt_fscache:
- kfree(ctx->fscache_uniq);
- ctx->fscache_uniq = param->string;
- param->string = NULL;
+ case Opt_fscache_flag:
if (result.negated)
ctx->options &= ~NFS_OPTION_FSCACHE;
else
ctx->options |= NFS_OPTION_FSCACHE;
+ kfree(ctx->fscache_uniq);
+ ctx->fscache_uniq = NULL;
+ break;
+ case Opt_fscache:
+ ctx->options |= NFS_OPTION_FSCACHE;
+ kfree(ctx->fscache_uniq);
+ ctx->fscache_uniq = param->string;
+ param->string = NULL;
break;
case Opt_migration:
if (result.negated)
@@ -1415,7 +1418,7 @@ struct file_system_type nfs_fs_type = {
.owner = THIS_MODULE,
.name = "nfs",
.init_fs_context = nfs_init_fs_context,
- .parameters = &nfs_fs_parameters,
+ .parameters = nfs_fs_parameters,
.kill_sb = nfs_kill_super,
.fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA,
};
@@ -1427,7 +1430,7 @@ struct file_system_type nfs4_fs_type = {
.owner = THIS_MODULE,
.name = "nfs4",
.init_fs_context = nfs_init_fs_context,
- .parameters = &nfs_fs_parameters,
+ .parameters = nfs_fs_parameters,
.kill_sb = nfs_kill_super,
.fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA,
};