Skip to content

Commit

Permalink
Merge branch 'merge.nfs-fs_parse.1' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/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()
  ...
  • Loading branch information
torvalds committed Feb 8, 2020
2 parents 236f453 + f35aa2b commit c9d35ee
Show file tree
Hide file tree
Showing 37 changed files with 562 additions and 782 deletions.
12 changes: 2 additions & 10 deletions Documentation/filesystems/mount_api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ returned.
fs_value_is_string, Value is a string
fs_value_is_blob, Value is a binary blob
fs_value_is_filename, Value is a filename* + dirfd
fs_value_is_filename_empty, Value is a filename* + dirfd + AT_EMPTY_PATH
fs_value_is_file, Value is an open file (file*)

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

struct fs_parameter_description {
const char name[16];
const struct fs_parameter_spec *specs;
const struct fs_parameter_enum *enums;
};
Expand All @@ -535,19 +533,13 @@ For example:
};

static const struct fs_parameter_description afs_fs_parameters = {
.name = "kAFS",
.specs = afs_param_specs,
.enums = afs_param_enums,
};

The members are as follows:

(1) const char name[16];

The name to be used in error messages generated by the parse helper
functions.

(2) const struct fs_parameter_specification *specs;
(1) const struct fs_parameter_specification *specs;

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

(6) const struct fs_parameter_enum *enums;
(2) const struct fs_parameter_enum *enums;

Table of enum value names to integer mappings, terminated with a null
entry. This is of type:
Expand Down
11 changes: 3 additions & 8 deletions arch/powerpc/platforms/cell/spufs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,19 +583,14 @@ enum {
Opt_uid, Opt_gid, Opt_mode, Opt_debug,
};

static const struct fs_parameter_spec spufs_param_specs[] = {
static const struct fs_parameter_spec spufs_fs_parameters[] = {
fsparam_u32 ("gid", Opt_gid),
fsparam_u32oct ("mode", Opt_mode),
fsparam_u32 ("uid", Opt_uid),
fsparam_flag ("debug", Opt_debug),
{}
};

static const struct fs_parameter_description spufs_fs_parameters = {
.name = "spufs",
.specs = spufs_param_specs,
};

static int spufs_show_options(struct seq_file *m, struct dentry *root)
{
struct spufs_sb_info *sbi = spufs_get_sb_info(root->d_sb);
Expand Down Expand Up @@ -623,7 +618,7 @@ static int spufs_parse_param(struct fs_context *fc, struct fs_parameter *param)
kgid_t gid;
int opt;

opt = fs_parse(fc, &spufs_fs_parameters, param, &result);
opt = fs_parse(fc, spufs_fs_parameters, param, &result);
if (opt < 0)
return opt;

Expand Down Expand Up @@ -774,7 +769,7 @@ static struct file_system_type spufs_type = {
.owner = THIS_MODULE,
.name = "spufs",
.init_fs_context = spufs_init_fs_context,
.parameters = &spufs_fs_parameters,
.parameters = spufs_fs_parameters,
.kill_sb = kill_litter_super,
};
MODULE_ALIAS_FS("spufs");
Expand Down
11 changes: 3 additions & 8 deletions arch/s390/hypfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,12 @@ static int hypfs_release(struct inode *inode, struct file *filp)

enum { Opt_uid, Opt_gid, };

static const struct fs_parameter_spec hypfs_param_specs[] = {
static const struct fs_parameter_spec hypfs_fs_parameters[] = {
fsparam_u32("gid", Opt_gid),
fsparam_u32("uid", Opt_uid),
{}
};

static const struct fs_parameter_description hypfs_fs_parameters = {
.name = "hypfs",
.specs = hypfs_param_specs,
};

static int hypfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
{
struct hypfs_sb_info *hypfs_info = fc->s_fs_info;
Expand All @@ -228,7 +223,7 @@ static int hypfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
kgid_t gid;
int opt;

opt = fs_parse(fc, &hypfs_fs_parameters, param, &result);
opt = fs_parse(fc, hypfs_fs_parameters, param, &result);
if (opt < 0)
return opt;

Expand Down Expand Up @@ -455,7 +450,7 @@ static struct file_system_type hypfs_type = {
.owner = THIS_MODULE,
.name = "s390_hypfs",
.init_fs_context = hypfs_init_fs_context,
.parameters = &hypfs_fs_parameters,
.parameters = hypfs_fs_parameters,
.kill_sb = hypfs_kill_super
};

Expand Down
11 changes: 3 additions & 8 deletions arch/x86/kernel/cpu/resctrl/rdtgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -2127,25 +2127,20 @@ enum rdt_param {
nr__rdt_params
};

static const struct fs_parameter_spec rdt_param_specs[] = {
static const struct fs_parameter_spec rdt_fs_parameters[] = {
fsparam_flag("cdp", Opt_cdp),
fsparam_flag("cdpl2", Opt_cdpl2),
fsparam_flag("mba_MBps", Opt_mba_mbps),
{}
};

static const struct fs_parameter_description rdt_fs_parameters = {
.name = "rdt",
.specs = rdt_param_specs,
};

static int rdt_parse_param(struct fs_context *fc, struct fs_parameter *param)
{
struct rdt_fs_context *ctx = rdt_fc2context(fc);
struct fs_parse_result result;
int opt;

opt = fs_parse(fc, &rdt_fs_parameters, param, &result);
opt = fs_parse(fc, rdt_fs_parameters, param, &result);
if (opt < 0)
return opt;

Expand Down Expand Up @@ -2378,7 +2373,7 @@ static void rdt_kill_sb(struct super_block *sb)
static struct file_system_type rdt_fs_type = {
.name = "resctrl",
.init_fs_context = rdt_init_fs_context,
.parameters = &rdt_fs_parameters,
.parameters = rdt_fs_parameters,
.kill_sb = rdt_kill_sb,
};

Expand Down
4 changes: 2 additions & 2 deletions drivers/base/devtmpfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ static struct file_system_type internal_fs_type = {
.name = "devtmpfs",
#ifdef CONFIG_TMPFS
.init_fs_context = shmem_init_fs_context,
.parameters = &shmem_fs_parameters,
.parameters = shmem_fs_parameters,
#else
.init_fs_context = ramfs_init_fs_context,
.parameters = &ramfs_fs_parameters,
.parameters = ramfs_fs_parameters,
#endif
.kill_sb = kill_litter_super,
};
Expand Down
31 changes: 11 additions & 20 deletions drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ enum {
Opt_notrim,
};

static const struct fs_parameter_spec rbd_param_specs[] = {
static const struct fs_parameter_spec rbd_parameters[] = {
fsparam_u32 ("alloc_size", Opt_alloc_size),
fsparam_flag ("exclusive", Opt_exclusive),
fsparam_flag ("lock_on_read", Opt_lock_on_read),
Expand All @@ -863,11 +863,6 @@ static const struct fs_parameter_spec rbd_param_specs[] = {
{}
};

static const struct fs_parameter_description rbd_parameters = {
.name = "rbd",
.specs = rbd_param_specs,
};

struct rbd_options {
int queue_depth;
int alloc_size;
Expand Down Expand Up @@ -6353,19 +6348,19 @@ static int rbd_parse_param(struct fs_parameter *param,
{
struct rbd_options *opt = pctx->opts;
struct fs_parse_result result;
struct p_log log = {.prefix = "rbd"};
int token, ret;

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

token = fs_parse(NULL, &rbd_parameters, param, &result);
token = __fs_parse(&log, rbd_parameters, param, &result);
dout("%s fs_parse '%s' token %d\n", __func__, param->key, token);
if (token < 0) {
if (token == -ENOPARAM) {
return invalf(NULL, "rbd: Unknown parameter '%s'",
param->key);
}
if (token == -ENOPARAM)
return inval_plog(&log, "Unknown parameter '%s'",
param->key);
return token;
}

Expand All @@ -6378,9 +6373,8 @@ static int rbd_parse_param(struct fs_parameter *param,
case Opt_alloc_size:
if (result.uint_32 < SECTOR_SIZE)
goto out_of_range;
if (!is_power_of_2(result.uint_32)) {
return invalf(NULL, "rbd: alloc_size must be a power of 2");
}
if (!is_power_of_2(result.uint_32))
return inval_plog(&log, "alloc_size must be a power of 2");
opt->alloc_size = result.uint_32;
break;
case Opt_lock_timeout:
Expand Down Expand Up @@ -6416,7 +6410,7 @@ static int rbd_parse_param(struct fs_parameter *param,
return 0;

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

/*
Expand All @@ -6433,7 +6427,7 @@ static int rbd_parse_options(char *options, struct rbd_parse_opts_ctx *pctx)
if (*key) {
struct fs_parameter param = {
.key = key,
.type = fs_value_is_string,
.type = fs_value_is_flag,
};
char *value = strchr(key, '=');
size_t v_len = 0;
Expand All @@ -6443,14 +6437,11 @@ static int rbd_parse_options(char *options, struct rbd_parse_opts_ctx *pctx)
continue;
*value++ = 0;
v_len = strlen(value);
}


if (v_len > 0) {
param.string = kmemdup_nul(value, v_len,
GFP_KERNEL);
if (!param.string)
return -ENOMEM;
param.type = fs_value_is_string;
}
param.size = v_len;

Expand Down
11 changes: 3 additions & 8 deletions drivers/usb/gadget/function/f_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ enum {
Opt_gid,
};

static const struct fs_parameter_spec ffs_fs_param_specs[] = {
static const struct fs_parameter_spec ffs_fs_fs_parameters[] = {
fsparam_bool ("no_disconnect", Opt_no_disconnect),
fsparam_u32 ("rmode", Opt_rmode),
fsparam_u32 ("fmode", Opt_fmode),
Expand All @@ -1498,11 +1498,6 @@ static const struct fs_parameter_spec ffs_fs_param_specs[] = {
{}
};

static const struct fs_parameter_description ffs_fs_fs_parameters = {
.name = "kAFS",
.specs = ffs_fs_param_specs,
};

static int ffs_fs_parse_param(struct fs_context *fc, struct fs_parameter *param)
{
struct ffs_sb_fill_data *data = fc->fs_private;
Expand All @@ -1511,7 +1506,7 @@ static int ffs_fs_parse_param(struct fs_context *fc, struct fs_parameter *param)

ENTER();

opt = fs_parse(fc, &ffs_fs_fs_parameters, param, &result);
opt = fs_parse(fc, ffs_fs_fs_parameters, param, &result);
if (opt < 0)
return opt;

Expand Down Expand Up @@ -1643,7 +1638,7 @@ static struct file_system_type ffs_fs_type = {
.owner = THIS_MODULE,
.name = "functionfs",
.init_fs_context = ffs_fs_init_fs_context,
.parameters = &ffs_fs_fs_parameters,
.parameters = ffs_fs_fs_parameters,
.kill_sb = ffs_fs_kill_sb,
};
MODULE_ALIAS_FS("functionfs");
Expand Down
32 changes: 13 additions & 19 deletions fs/afs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ static int afs_statfs(struct dentry *dentry, struct kstatfs *buf);
static int afs_show_devname(struct seq_file *m, struct dentry *root);
static int afs_show_options(struct seq_file *m, struct dentry *root);
static int afs_init_fs_context(struct fs_context *fc);
static const struct fs_parameter_description afs_fs_parameters;
static const struct fs_parameter_spec afs_fs_parameters[];

struct file_system_type afs_fs_type = {
.owner = THIS_MODULE,
.name = "afs",
.init_fs_context = afs_init_fs_context,
.parameters = &afs_fs_parameters,
.parameters = afs_fs_parameters,
.kill_sb = afs_kill_super,
.fs_flags = FS_RENAME_DOES_D_MOVE,
};
Expand Down Expand Up @@ -73,28 +73,22 @@ enum afs_param {
Opt_source,
};

static const struct fs_parameter_spec afs_param_specs[] = {
fsparam_flag ("autocell", Opt_autocell),
fsparam_flag ("dyn", Opt_dyn),
fsparam_enum ("flock", Opt_flock),
fsparam_string("source", Opt_source),
static const struct constant_table afs_param_flock[] = {
{"local", afs_flock_mode_local },
{"openafs", afs_flock_mode_openafs },
{"strict", afs_flock_mode_strict },
{"write", afs_flock_mode_write },
{}
};

static const struct fs_parameter_enum afs_param_enums[] = {
{ Opt_flock, "local", afs_flock_mode_local },
{ Opt_flock, "openafs", afs_flock_mode_openafs },
{ Opt_flock, "strict", afs_flock_mode_strict },
{ Opt_flock, "write", afs_flock_mode_write },
static const struct fs_parameter_spec afs_fs_parameters[] = {
fsparam_flag ("autocell", Opt_autocell),
fsparam_flag ("dyn", Opt_dyn),
fsparam_enum ("flock", Opt_flock, afs_param_flock),
fsparam_string("source", Opt_source),
{}
};

static const struct fs_parameter_description afs_fs_parameters = {
.name = "kAFS",
.specs = afs_param_specs,
.enums = afs_param_enums,
};

/*
* initialise the filesystem
*/
Expand Down Expand Up @@ -323,7 +317,7 @@ static int afs_parse_param(struct fs_context *fc, struct fs_parameter *param)
struct afs_fs_context *ctx = fc->fs_private;
int opt;

opt = fs_parse(fc, &afs_fs_parameters, param, &result);
opt = fs_parse(fc, afs_fs_parameters, param, &result);
if (opt < 0)
return opt;

Expand Down
4 changes: 2 additions & 2 deletions fs/ceph/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int ceph_fscache_register_fs(struct ceph_fs_client* fsc, struct fs_context *fc)
if (uniq_len && memcmp(ent->uniquifier, fscache_uniq, uniq_len))
continue;

errorf(fc, "ceph: fscache cookie already registered for fsid %pU, use fsc=<uniquifier> option",
errorfc(fc, "fscache cookie already registered for fsid %pU, use fsc=<uniquifier> option",
fsid);
err = -EBUSY;
goto out_unlock;
Expand Down Expand Up @@ -96,7 +96,7 @@ int ceph_fscache_register_fs(struct ceph_fs_client* fsc, struct fs_context *fc)
list_add_tail(&ent->list, &ceph_fscache_list);
} else {
kfree(ent);
errorf(fc, "ceph: unable to register fscache cookie for fsid %pU",
errorfc(fc, "unable to register fscache cookie for fsid %pU",
fsid);
/* all other fs ignore this error */
}
Expand Down
Loading

0 comments on commit c9d35ee

Please sign in to comment.