From 2710c957a8ef4fb00f21acb306e3bd6bcf80c81f Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 6 Sep 2019 22:12:08 -0400 Subject: fs_parse: get rid of ->enums Don't do a single array; attach them to fsparam_enum() entry instead. And don't bother trying to embed the names into those - it actually loses memory, with no real speedup worth mentioning. Simplifies validation as well. Signed-off-by: Al Viro --- mm/shmem.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'mm') diff --git a/mm/shmem.c b/mm/shmem.c index 8793e8cc1a48..1c02c6c20f45 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -3381,9 +3381,19 @@ enum shmem_param { Opt_uid, }; +static const struct fs_parameter_enum shmem_param_enums_huge[] = { + {"never", SHMEM_HUGE_NEVER }, + {"always", SHMEM_HUGE_ALWAYS }, + {"within_size", SHMEM_HUGE_WITHIN_SIZE }, + {"advise", SHMEM_HUGE_ADVISE }, + {"deny", SHMEM_HUGE_DENY }, + {"force", SHMEM_HUGE_FORCE }, + {} +}; + static const struct fs_parameter_spec shmem_param_specs[] = { fsparam_u32 ("gid", Opt_gid), - fsparam_enum ("huge", Opt_huge), + fsparam_enum ("huge", Opt_huge, shmem_param_enums_huge), fsparam_u32oct("mode", Opt_mode), fsparam_string("mpol", Opt_mpol), fsparam_string("nr_blocks", Opt_nr_blocks), @@ -3393,18 +3403,9 @@ static const struct fs_parameter_spec shmem_param_specs[] = { {} }; -static const struct fs_parameter_enum shmem_param_enums[] = { - { Opt_huge, "never", SHMEM_HUGE_NEVER }, - { Opt_huge, "always", SHMEM_HUGE_ALWAYS }, - { Opt_huge, "within_size", SHMEM_HUGE_WITHIN_SIZE }, - { Opt_huge, "advise", SHMEM_HUGE_ADVISE }, - {} -}; - const struct fs_parameter_description shmem_fs_parameters = { .name = "tmpfs", .specs = shmem_param_specs, - .enums = shmem_param_enums, }; static int shmem_parse_one(struct fs_context *fc, struct fs_parameter *param) -- cgit From 5eede625297f4d21dc12ea7a7418fd21672f131d Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 16 Dec 2019 13:33:32 -0500 Subject: fold struct fs_parameter_enum into struct constant_table no real difference now Signed-off-by: Al Viro --- mm/shmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mm') diff --git a/mm/shmem.c b/mm/shmem.c index 1c02c6c20f45..90c7737bcce2 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -3381,7 +3381,7 @@ enum shmem_param { Opt_uid, }; -static const struct fs_parameter_enum shmem_param_enums_huge[] = { +static const struct constant_table shmem_param_enums_huge[] = { {"never", SHMEM_HUGE_NEVER }, {"always", SHMEM_HUGE_ALWAYS }, {"within_size", SHMEM_HUGE_WITHIN_SIZE }, -- cgit From 96cafb9ccb153f6a82ff2c9bde68916d9d65501e Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Fri, 6 Dec 2019 10:45:01 -0600 Subject: fs_parser: remove fs_parameter_description name field Unused now. Signed-off-by: Eric Sandeen Acked-by: David Howells Signed-off-by: Al Viro --- mm/shmem.c | 1 - 1 file changed, 1 deletion(-) (limited to 'mm') diff --git a/mm/shmem.c b/mm/shmem.c index 90c7737bcce2..445d038a54b9 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -3404,7 +3404,6 @@ static const struct fs_parameter_spec shmem_param_specs[] = { }; const struct fs_parameter_description shmem_fs_parameters = { - .name = "tmpfs", .specs = shmem_param_specs, }; -- cgit From d7167b149943e38ad610191ecbb0800c78bbced9 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 7 Sep 2019 07:23:15 -0400 Subject: fs_parse: fold fs_parameter_desc/fs_parameter_spec The former contains nothing but a pointer to an array of the latter... Signed-off-by: Al Viro --- mm/shmem.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'mm') diff --git a/mm/shmem.c b/mm/shmem.c index 445d038a54b9..efbbf2bc68fb 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -3391,7 +3391,7 @@ static const struct constant_table shmem_param_enums_huge[] = { {} }; -static const struct fs_parameter_spec shmem_param_specs[] = { +const struct fs_parameter_spec shmem_fs_parameters[] = { fsparam_u32 ("gid", Opt_gid), fsparam_enum ("huge", Opt_huge, shmem_param_enums_huge), fsparam_u32oct("mode", Opt_mode), @@ -3403,10 +3403,6 @@ static const struct fs_parameter_spec shmem_param_specs[] = { {} }; -const struct fs_parameter_description shmem_fs_parameters = { - .specs = shmem_param_specs, -}; - static int shmem_parse_one(struct fs_context *fc, struct fs_parameter *param) { struct shmem_options *ctx = fc->fs_private; @@ -3415,7 +3411,7 @@ static int shmem_parse_one(struct fs_context *fc, struct fs_parameter *param) char *rest; int opt; - opt = fs_parse(fc, &shmem_fs_parameters, param, &result); + opt = fs_parse(fc, shmem_fs_parameters, param, &result); if (opt < 0) return opt; @@ -3889,7 +3885,7 @@ static struct file_system_type shmem_fs_type = { .name = "tmpfs", .init_fs_context = shmem_init_fs_context, #ifdef CONFIG_TMPFS - .parameters = &shmem_fs_parameters, + .parameters = shmem_fs_parameters, #endif .kill_sb = kill_litter_super, .fs_flags = FS_USERNS_MOUNT, @@ -4035,7 +4031,7 @@ bool shmem_huge_enabled(struct vm_area_struct *vma) static struct file_system_type shmem_fs_type = { .name = "tmpfs", .init_fs_context = ramfs_init_fs_context, - .parameters = &ramfs_fs_parameters, + .parameters = ramfs_fs_parameters, .kill_sb = kill_litter_super, .fs_flags = FS_USERNS_MOUNT, }; -- cgit From f35aa2bc809eacc44c3cee41b52cef1c451d4a89 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 21 Dec 2019 21:35:55 -0500 Subject: tmpfs: switch to use of invalfc() Signed-off-by: Al Viro --- mm/shmem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mm') diff --git a/mm/shmem.c b/mm/shmem.c index efbbf2bc68fb..c8f7540ef048 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -3475,9 +3475,9 @@ static int shmem_parse_one(struct fs_context *fc, struct fs_parameter *param) return 0; unsupported_parameter: - return invalf(fc, "tmpfs: Unsupported parameter '%s'", param->key); + return invalfc(fc, "Unsupported parameter '%s'", param->key); bad_value: - return invalf(fc, "tmpfs: Bad value for '%s'", param->key); + return invalfc(fc, "Bad value for '%s'", param->key); } static int shmem_parse_options(struct fs_context *fc, void *data) @@ -3583,7 +3583,7 @@ static int shmem_reconfigure(struct fs_context *fc) return 0; out: spin_unlock(&sbinfo->stat_lock); - return invalf(fc, "tmpfs: %s", err); + return invalfc(fc, "%s", err); } static int shmem_show_options(struct seq_file *seq, struct dentry *root) -- cgit