Skip to content

Commit c9d35ee

Browse files
committed
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() ...
2 parents 236f453 + f35aa2b commit c9d35ee

File tree

37 files changed

+562
-782
lines changed

37 files changed

+562
-782
lines changed

Documentation/filesystems/mount_api.txt

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@ returned.
427427
fs_value_is_string, Value is a string
428428
fs_value_is_blob, Value is a binary blob
429429
fs_value_is_filename, Value is a filename* + dirfd
430-
fs_value_is_filename_empty, Value is a filename* + dirfd + AT_EMPTY_PATH
431430
fs_value_is_file, Value is an open file (file*)
432431

433432
If there is a value, that value is stored in a union in the struct in one
@@ -519,7 +518,6 @@ Parameters are described using structures defined in linux/fs_parser.h.
519518
There's a core description struct that links everything together:
520519

521520
struct fs_parameter_description {
522-
const char name[16];
523521
const struct fs_parameter_spec *specs;
524522
const struct fs_parameter_enum *enums;
525523
};
@@ -535,19 +533,13 @@ For example:
535533
};
536534

537535
static const struct fs_parameter_description afs_fs_parameters = {
538-
.name = "kAFS",
539536
.specs = afs_param_specs,
540537
.enums = afs_param_enums,
541538
};
542539

543540
The members are as follows:
544541

545-
(1) const char name[16];
546-
547-
The name to be used in error messages generated by the parse helper
548-
functions.
549-
550-
(2) const struct fs_parameter_specification *specs;
542+
(1) const struct fs_parameter_specification *specs;
551543

552544
Table of parameter specifications, terminated with a null entry, where the
553545
entries are of type:
@@ -626,7 +618,7 @@ The members are as follows:
626618
of arguments to specify the type and the flags for anything that doesn't
627619
match one of the above macros.
628620

629-
(6) const struct fs_parameter_enum *enums;
621+
(2) const struct fs_parameter_enum *enums;
630622

631623
Table of enum value names to integer mappings, terminated with a null
632624
entry. This is of type:

arch/powerpc/platforms/cell/spufs/inode.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -583,19 +583,14 @@ enum {
583583
Opt_uid, Opt_gid, Opt_mode, Opt_debug,
584584
};
585585

586-
static const struct fs_parameter_spec spufs_param_specs[] = {
586+
static const struct fs_parameter_spec spufs_fs_parameters[] = {
587587
fsparam_u32 ("gid", Opt_gid),
588588
fsparam_u32oct ("mode", Opt_mode),
589589
fsparam_u32 ("uid", Opt_uid),
590590
fsparam_flag ("debug", Opt_debug),
591591
{}
592592
};
593593

594-
static const struct fs_parameter_description spufs_fs_parameters = {
595-
.name = "spufs",
596-
.specs = spufs_param_specs,
597-
};
598-
599594
static int spufs_show_options(struct seq_file *m, struct dentry *root)
600595
{
601596
struct spufs_sb_info *sbi = spufs_get_sb_info(root->d_sb);
@@ -623,7 +618,7 @@ static int spufs_parse_param(struct fs_context *fc, struct fs_parameter *param)
623618
kgid_t gid;
624619
int opt;
625620

626-
opt = fs_parse(fc, &spufs_fs_parameters, param, &result);
621+
opt = fs_parse(fc, spufs_fs_parameters, param, &result);
627622
if (opt < 0)
628623
return opt;
629624

@@ -774,7 +769,7 @@ static struct file_system_type spufs_type = {
774769
.owner = THIS_MODULE,
775770
.name = "spufs",
776771
.init_fs_context = spufs_init_fs_context,
777-
.parameters = &spufs_fs_parameters,
772+
.parameters = spufs_fs_parameters,
778773
.kill_sb = kill_litter_super,
779774
};
780775
MODULE_ALIAS_FS("spufs");

arch/s390/hypfs/inode.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,17 +209,12 @@ static int hypfs_release(struct inode *inode, struct file *filp)
209209

210210
enum { Opt_uid, Opt_gid, };
211211

212-
static const struct fs_parameter_spec hypfs_param_specs[] = {
212+
static const struct fs_parameter_spec hypfs_fs_parameters[] = {
213213
fsparam_u32("gid", Opt_gid),
214214
fsparam_u32("uid", Opt_uid),
215215
{}
216216
};
217217

218-
static const struct fs_parameter_description hypfs_fs_parameters = {
219-
.name = "hypfs",
220-
.specs = hypfs_param_specs,
221-
};
222-
223218
static int hypfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
224219
{
225220
struct hypfs_sb_info *hypfs_info = fc->s_fs_info;
@@ -228,7 +223,7 @@ static int hypfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
228223
kgid_t gid;
229224
int opt;
230225

231-
opt = fs_parse(fc, &hypfs_fs_parameters, param, &result);
226+
opt = fs_parse(fc, hypfs_fs_parameters, param, &result);
232227
if (opt < 0)
233228
return opt;
234229

@@ -455,7 +450,7 @@ static struct file_system_type hypfs_type = {
455450
.owner = THIS_MODULE,
456451
.name = "s390_hypfs",
457452
.init_fs_context = hypfs_init_fs_context,
458-
.parameters = &hypfs_fs_parameters,
453+
.parameters = hypfs_fs_parameters,
459454
.kill_sb = hypfs_kill_super
460455
};
461456

arch/x86/kernel/cpu/resctrl/rdtgroup.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2127,25 +2127,20 @@ enum rdt_param {
21272127
nr__rdt_params
21282128
};
21292129

2130-
static const struct fs_parameter_spec rdt_param_specs[] = {
2130+
static const struct fs_parameter_spec rdt_fs_parameters[] = {
21312131
fsparam_flag("cdp", Opt_cdp),
21322132
fsparam_flag("cdpl2", Opt_cdpl2),
21332133
fsparam_flag("mba_MBps", Opt_mba_mbps),
21342134
{}
21352135
};
21362136

2137-
static const struct fs_parameter_description rdt_fs_parameters = {
2138-
.name = "rdt",
2139-
.specs = rdt_param_specs,
2140-
};
2141-
21422137
static int rdt_parse_param(struct fs_context *fc, struct fs_parameter *param)
21432138
{
21442139
struct rdt_fs_context *ctx = rdt_fc2context(fc);
21452140
struct fs_parse_result result;
21462141
int opt;
21472142

2148-
opt = fs_parse(fc, &rdt_fs_parameters, param, &result);
2143+
opt = fs_parse(fc, rdt_fs_parameters, param, &result);
21492144
if (opt < 0)
21502145
return opt;
21512146

@@ -2378,7 +2373,7 @@ static void rdt_kill_sb(struct super_block *sb)
23782373
static struct file_system_type rdt_fs_type = {
23792374
.name = "resctrl",
23802375
.init_fs_context = rdt_init_fs_context,
2381-
.parameters = &rdt_fs_parameters,
2376+
.parameters = rdt_fs_parameters,
23822377
.kill_sb = rdt_kill_sb,
23832378
};
23842379

drivers/base/devtmpfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ static struct file_system_type internal_fs_type = {
6767
.name = "devtmpfs",
6868
#ifdef CONFIG_TMPFS
6969
.init_fs_context = shmem_init_fs_context,
70-
.parameters = &shmem_fs_parameters,
70+
.parameters = shmem_fs_parameters,
7171
#else
7272
.init_fs_context = ramfs_init_fs_context,
73-
.parameters = &ramfs_fs_parameters,
73+
.parameters = ramfs_fs_parameters,
7474
#endif
7575
.kill_sb = kill_litter_super,
7676
};

drivers/block/rbd.c

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ enum {
848848
Opt_notrim,
849849
};
850850

851-
static const struct fs_parameter_spec rbd_param_specs[] = {
851+
static const struct fs_parameter_spec rbd_parameters[] = {
852852
fsparam_u32 ("alloc_size", Opt_alloc_size),
853853
fsparam_flag ("exclusive", Opt_exclusive),
854854
fsparam_flag ("lock_on_read", Opt_lock_on_read),
@@ -863,11 +863,6 @@ static const struct fs_parameter_spec rbd_param_specs[] = {
863863
{}
864864
};
865865

866-
static const struct fs_parameter_description rbd_parameters = {
867-
.name = "rbd",
868-
.specs = rbd_param_specs,
869-
};
870-
871866
struct rbd_options {
872867
int queue_depth;
873868
int alloc_size;
@@ -6353,19 +6348,19 @@ static int rbd_parse_param(struct fs_parameter *param,
63536348
{
63546349
struct rbd_options *opt = pctx->opts;
63556350
struct fs_parse_result result;
6351+
struct p_log log = {.prefix = "rbd"};
63566352
int token, ret;
63576353

63586354
ret = ceph_parse_param(param, pctx->copts, NULL);
63596355
if (ret != -ENOPARAM)
63606356
return ret;
63616357

6362-
token = fs_parse(NULL, &rbd_parameters, param, &result);
6358+
token = __fs_parse(&log, rbd_parameters, param, &result);
63636359
dout("%s fs_parse '%s' token %d\n", __func__, param->key, token);
63646360
if (token < 0) {
6365-
if (token == -ENOPARAM) {
6366-
return invalf(NULL, "rbd: Unknown parameter '%s'",
6367-
param->key);
6368-
}
6361+
if (token == -ENOPARAM)
6362+
return inval_plog(&log, "Unknown parameter '%s'",
6363+
param->key);
63696364
return token;
63706365
}
63716366

@@ -6378,9 +6373,8 @@ static int rbd_parse_param(struct fs_parameter *param,
63786373
case Opt_alloc_size:
63796374
if (result.uint_32 < SECTOR_SIZE)
63806375
goto out_of_range;
6381-
if (!is_power_of_2(result.uint_32)) {
6382-
return invalf(NULL, "rbd: alloc_size must be a power of 2");
6383-
}
6376+
if (!is_power_of_2(result.uint_32))
6377+
return inval_plog(&log, "alloc_size must be a power of 2");
63846378
opt->alloc_size = result.uint_32;
63856379
break;
63866380
case Opt_lock_timeout:
@@ -6416,7 +6410,7 @@ static int rbd_parse_param(struct fs_parameter *param,
64166410
return 0;
64176411

64186412
out_of_range:
6419-
return invalf(NULL, "rbd: %s out of range", param->key);
6413+
return inval_plog(&log, "%s out of range", param->key);
64206414
}
64216415

64226416
/*
@@ -6433,7 +6427,7 @@ static int rbd_parse_options(char *options, struct rbd_parse_opts_ctx *pctx)
64336427
if (*key) {
64346428
struct fs_parameter param = {
64356429
.key = key,
6436-
.type = fs_value_is_string,
6430+
.type = fs_value_is_flag,
64376431
};
64386432
char *value = strchr(key, '=');
64396433
size_t v_len = 0;
@@ -6443,14 +6437,11 @@ static int rbd_parse_options(char *options, struct rbd_parse_opts_ctx *pctx)
64436437
continue;
64446438
*value++ = 0;
64456439
v_len = strlen(value);
6446-
}
6447-
6448-
6449-
if (v_len > 0) {
64506440
param.string = kmemdup_nul(value, v_len,
64516441
GFP_KERNEL);
64526442
if (!param.string)
64536443
return -ENOMEM;
6444+
param.type = fs_value_is_string;
64546445
}
64556446
param.size = v_len;
64566447

drivers/usb/gadget/function/f_fs.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,7 +1488,7 @@ enum {
14881488
Opt_gid,
14891489
};
14901490

1491-
static const struct fs_parameter_spec ffs_fs_param_specs[] = {
1491+
static const struct fs_parameter_spec ffs_fs_fs_parameters[] = {
14921492
fsparam_bool ("no_disconnect", Opt_no_disconnect),
14931493
fsparam_u32 ("rmode", Opt_rmode),
14941494
fsparam_u32 ("fmode", Opt_fmode),
@@ -1498,11 +1498,6 @@ static const struct fs_parameter_spec ffs_fs_param_specs[] = {
14981498
{}
14991499
};
15001500

1501-
static const struct fs_parameter_description ffs_fs_fs_parameters = {
1502-
.name = "kAFS",
1503-
.specs = ffs_fs_param_specs,
1504-
};
1505-
15061501
static int ffs_fs_parse_param(struct fs_context *fc, struct fs_parameter *param)
15071502
{
15081503
struct ffs_sb_fill_data *data = fc->fs_private;
@@ -1511,7 +1506,7 @@ static int ffs_fs_parse_param(struct fs_context *fc, struct fs_parameter *param)
15111506

15121507
ENTER();
15131508

1514-
opt = fs_parse(fc, &ffs_fs_fs_parameters, param, &result);
1509+
opt = fs_parse(fc, ffs_fs_fs_parameters, param, &result);
15151510
if (opt < 0)
15161511
return opt;
15171512

@@ -1643,7 +1638,7 @@ static struct file_system_type ffs_fs_type = {
16431638
.owner = THIS_MODULE,
16441639
.name = "functionfs",
16451640
.init_fs_context = ffs_fs_init_fs_context,
1646-
.parameters = &ffs_fs_fs_parameters,
1641+
.parameters = ffs_fs_fs_parameters,
16471642
.kill_sb = ffs_fs_kill_sb,
16481643
};
16491644
MODULE_ALIAS_FS("functionfs");

fs/afs/super.c

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ static int afs_statfs(struct dentry *dentry, struct kstatfs *buf);
3838
static int afs_show_devname(struct seq_file *m, struct dentry *root);
3939
static int afs_show_options(struct seq_file *m, struct dentry *root);
4040
static int afs_init_fs_context(struct fs_context *fc);
41-
static const struct fs_parameter_description afs_fs_parameters;
41+
static const struct fs_parameter_spec afs_fs_parameters[];
4242

4343
struct file_system_type afs_fs_type = {
4444
.owner = THIS_MODULE,
4545
.name = "afs",
4646
.init_fs_context = afs_init_fs_context,
47-
.parameters = &afs_fs_parameters,
47+
.parameters = afs_fs_parameters,
4848
.kill_sb = afs_kill_super,
4949
.fs_flags = FS_RENAME_DOES_D_MOVE,
5050
};
@@ -73,28 +73,22 @@ enum afs_param {
7373
Opt_source,
7474
};
7575

76-
static const struct fs_parameter_spec afs_param_specs[] = {
77-
fsparam_flag ("autocell", Opt_autocell),
78-
fsparam_flag ("dyn", Opt_dyn),
79-
fsparam_enum ("flock", Opt_flock),
80-
fsparam_string("source", Opt_source),
76+
static const struct constant_table afs_param_flock[] = {
77+
{"local", afs_flock_mode_local },
78+
{"openafs", afs_flock_mode_openafs },
79+
{"strict", afs_flock_mode_strict },
80+
{"write", afs_flock_mode_write },
8181
{}
8282
};
8383

84-
static const struct fs_parameter_enum afs_param_enums[] = {
85-
{ Opt_flock, "local", afs_flock_mode_local },
86-
{ Opt_flock, "openafs", afs_flock_mode_openafs },
87-
{ Opt_flock, "strict", afs_flock_mode_strict },
88-
{ Opt_flock, "write", afs_flock_mode_write },
84+
static const struct fs_parameter_spec afs_fs_parameters[] = {
85+
fsparam_flag ("autocell", Opt_autocell),
86+
fsparam_flag ("dyn", Opt_dyn),
87+
fsparam_enum ("flock", Opt_flock, afs_param_flock),
88+
fsparam_string("source", Opt_source),
8989
{}
9090
};
9191

92-
static const struct fs_parameter_description afs_fs_parameters = {
93-
.name = "kAFS",
94-
.specs = afs_param_specs,
95-
.enums = afs_param_enums,
96-
};
97-
9892
/*
9993
* initialise the filesystem
10094
*/
@@ -323,7 +317,7 @@ static int afs_parse_param(struct fs_context *fc, struct fs_parameter *param)
323317
struct afs_fs_context *ctx = fc->fs_private;
324318
int opt;
325319

326-
opt = fs_parse(fc, &afs_fs_parameters, param, &result);
320+
opt = fs_parse(fc, afs_fs_parameters, param, &result);
327321
if (opt < 0)
328322
return opt;
329323

fs/ceph/cache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ int ceph_fscache_register_fs(struct ceph_fs_client* fsc, struct fs_context *fc)
6767
if (uniq_len && memcmp(ent->uniquifier, fscache_uniq, uniq_len))
6868
continue;
6969

70-
errorf(fc, "ceph: fscache cookie already registered for fsid %pU, use fsc=<uniquifier> option",
70+
errorfc(fc, "fscache cookie already registered for fsid %pU, use fsc=<uniquifier> option",
7171
fsid);
7272
err = -EBUSY;
7373
goto out_unlock;
@@ -96,7 +96,7 @@ int ceph_fscache_register_fs(struct ceph_fs_client* fsc, struct fs_context *fc)
9696
list_add_tail(&ent->list, &ceph_fscache_list);
9797
} else {
9898
kfree(ent);
99-
errorf(fc, "ceph: unable to register fscache cookie for fsid %pU",
99+
errorfc(fc, "unable to register fscache cookie for fsid %pU",
100100
fsid);
101101
/* all other fs ignore this error */
102102
}

0 commit comments

Comments
 (0)