Commit 35d4aeea authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'zonefs-6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/zonefs

Pull zonefs update from Damien Le Moal:

 - A single change for this cycle to convert zonefs to use the new
   mount API

* tag 'zonefs-6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/zonefs:
  zonefs: convert zonefs to use the new mount api
parents 65d287c7 567e629f
...@@ -15,12 +15,13 @@ ...@@ -15,12 +15,13 @@
#include <linux/writeback.h> #include <linux/writeback.h>
#include <linux/quotaops.h> #include <linux/quotaops.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/parser.h>
#include <linux/uio.h> #include <linux/uio.h>
#include <linux/mman.h> #include <linux/mman.h>
#include <linux/sched/mm.h> #include <linux/sched/mm.h>
#include <linux/crc32.h> #include <linux/crc32.h>
#include <linux/task_io_accounting_ops.h> #include <linux/task_io_accounting_ops.h>
#include <linux/fs_parser.h>
#include <linux/fs_context.h>
#include "zonefs.h" #include "zonefs.h"
...@@ -470,58 +471,47 @@ static int zonefs_statfs(struct dentry *dentry, struct kstatfs *buf) ...@@ -470,58 +471,47 @@ static int zonefs_statfs(struct dentry *dentry, struct kstatfs *buf)
} }
enum { enum {
Opt_errors_ro, Opt_errors_zro, Opt_errors_zol, Opt_errors_repair, Opt_errors, Opt_explicit_open,
Opt_explicit_open, Opt_err,
}; };
static const match_table_t tokens = { struct zonefs_context {
{ Opt_errors_ro, "errors=remount-ro"}, unsigned long s_mount_opts;
{ Opt_errors_zro, "errors=zone-ro"},
{ Opt_errors_zol, "errors=zone-offline"},
{ Opt_errors_repair, "errors=repair"},
{ Opt_explicit_open, "explicit-open" },
{ Opt_err, NULL}
}; };
static int zonefs_parse_options(struct super_block *sb, char *options) static const struct constant_table zonefs_param_errors[] = {
{ {"remount-ro", ZONEFS_MNTOPT_ERRORS_RO},
struct zonefs_sb_info *sbi = ZONEFS_SB(sb); {"zone-ro", ZONEFS_MNTOPT_ERRORS_ZRO},
substring_t args[MAX_OPT_ARGS]; {"zone-offline", ZONEFS_MNTOPT_ERRORS_ZOL},
char *p; {"repair", ZONEFS_MNTOPT_ERRORS_REPAIR},
{}
if (!options) };
return 0;
while ((p = strsep(&options, ",")) != NULL) {
int token;
if (!*p) static const struct fs_parameter_spec zonefs_param_spec[] = {
continue; fsparam_enum ("errors", Opt_errors, zonefs_param_errors),
fsparam_flag ("explicit-open", Opt_explicit_open),
{}
};
token = match_token(p, tokens, args); static int zonefs_parse_param(struct fs_context *fc, struct fs_parameter *param)
switch (token) { {
case Opt_errors_ro: struct zonefs_context *ctx = fc->fs_private;
sbi->s_mount_opts &= ~ZONEFS_MNTOPT_ERRORS_MASK; struct fs_parse_result result;
sbi->s_mount_opts |= ZONEFS_MNTOPT_ERRORS_RO; int opt;
break;
case Opt_errors_zro: opt = fs_parse(fc, zonefs_param_spec, param, &result);
sbi->s_mount_opts &= ~ZONEFS_MNTOPT_ERRORS_MASK; if (opt < 0)
sbi->s_mount_opts |= ZONEFS_MNTOPT_ERRORS_ZRO; return opt;
break;
case Opt_errors_zol: switch (opt) {
sbi->s_mount_opts &= ~ZONEFS_MNTOPT_ERRORS_MASK; case Opt_errors:
sbi->s_mount_opts |= ZONEFS_MNTOPT_ERRORS_ZOL; ctx->s_mount_opts &= ~ZONEFS_MNTOPT_ERRORS_MASK;
break; ctx->s_mount_opts |= result.uint_32;
case Opt_errors_repair: break;
sbi->s_mount_opts &= ~ZONEFS_MNTOPT_ERRORS_MASK; case Opt_explicit_open:
sbi->s_mount_opts |= ZONEFS_MNTOPT_ERRORS_REPAIR; ctx->s_mount_opts |= ZONEFS_MNTOPT_EXPLICIT_OPEN;
break; break;
case Opt_explicit_open: default:
sbi->s_mount_opts |= ZONEFS_MNTOPT_EXPLICIT_OPEN; return -EINVAL;
break;
default:
return -EINVAL;
}
} }
return 0; return 0;
...@@ -543,13 +533,6 @@ static int zonefs_show_options(struct seq_file *seq, struct dentry *root) ...@@ -543,13 +533,6 @@ static int zonefs_show_options(struct seq_file *seq, struct dentry *root)
return 0; return 0;
} }
static int zonefs_remount(struct super_block *sb, int *flags, char *data)
{
sync_filesystem(sb);
return zonefs_parse_options(sb, data);
}
static int zonefs_inode_setattr(struct mnt_idmap *idmap, static int zonefs_inode_setattr(struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *iattr) struct dentry *dentry, struct iattr *iattr)
{ {
...@@ -1205,7 +1188,6 @@ static const struct super_operations zonefs_sops = { ...@@ -1205,7 +1188,6 @@ static const struct super_operations zonefs_sops = {
.alloc_inode = zonefs_alloc_inode, .alloc_inode = zonefs_alloc_inode,
.free_inode = zonefs_free_inode, .free_inode = zonefs_free_inode,
.statfs = zonefs_statfs, .statfs = zonefs_statfs,
.remount_fs = zonefs_remount,
.show_options = zonefs_show_options, .show_options = zonefs_show_options,
}; };
...@@ -1250,9 +1232,10 @@ static void zonefs_release_zgroup_inodes(struct super_block *sb) ...@@ -1250,9 +1232,10 @@ static void zonefs_release_zgroup_inodes(struct super_block *sb)
* sub-directories and files according to the device zone configuration and * sub-directories and files according to the device zone configuration and
* format options. * format options.
*/ */
static int zonefs_fill_super(struct super_block *sb, void *data, int silent) static int zonefs_fill_super(struct super_block *sb, struct fs_context *fc)
{ {
struct zonefs_sb_info *sbi; struct zonefs_sb_info *sbi;
struct zonefs_context *ctx = fc->fs_private;
struct inode *inode; struct inode *inode;
enum zonefs_ztype ztype; enum zonefs_ztype ztype;
int ret; int ret;
...@@ -1289,7 +1272,7 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -1289,7 +1272,7 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
sbi->s_uid = GLOBAL_ROOT_UID; sbi->s_uid = GLOBAL_ROOT_UID;
sbi->s_gid = GLOBAL_ROOT_GID; sbi->s_gid = GLOBAL_ROOT_GID;
sbi->s_perm = 0640; sbi->s_perm = 0640;
sbi->s_mount_opts = ZONEFS_MNTOPT_ERRORS_RO; sbi->s_mount_opts = ctx->s_mount_opts;
atomic_set(&sbi->s_wro_seq_files, 0); atomic_set(&sbi->s_wro_seq_files, 0);
sbi->s_max_wro_seq_files = bdev_max_open_zones(sb->s_bdev); sbi->s_max_wro_seq_files = bdev_max_open_zones(sb->s_bdev);
...@@ -1300,10 +1283,6 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -1300,10 +1283,6 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
if (ret) if (ret)
return ret; return ret;
ret = zonefs_parse_options(sb, data);
if (ret)
return ret;
zonefs_info(sb, "Mounting %u zones", bdev_nr_zones(sb->s_bdev)); zonefs_info(sb, "Mounting %u zones", bdev_nr_zones(sb->s_bdev));
if (!sbi->s_max_wro_seq_files && if (!sbi->s_max_wro_seq_files &&
...@@ -1364,12 +1343,6 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -1364,12 +1343,6 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
return ret; return ret;
} }
static struct dentry *zonefs_mount(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data)
{
return mount_bdev(fs_type, flags, dev_name, data, zonefs_fill_super);
}
static void zonefs_kill_super(struct super_block *sb) static void zonefs_kill_super(struct super_block *sb)
{ {
struct zonefs_sb_info *sbi = ZONEFS_SB(sb); struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
...@@ -1384,15 +1357,65 @@ static void zonefs_kill_super(struct super_block *sb) ...@@ -1384,15 +1357,65 @@ static void zonefs_kill_super(struct super_block *sb)
kfree(sbi); kfree(sbi);
} }
static void zonefs_free_fc(struct fs_context *fc)
{
struct zonefs_context *ctx = fc->fs_private;
kfree(ctx);
}
static int zonefs_get_tree(struct fs_context *fc)
{
return get_tree_bdev(fc, zonefs_fill_super);
}
static int zonefs_reconfigure(struct fs_context *fc)
{
struct zonefs_context *ctx = fc->fs_private;
struct super_block *sb = fc->root->d_sb;
struct zonefs_sb_info *sbi = sb->s_fs_info;
sync_filesystem(fc->root->d_sb);
/* Copy new options from ctx into sbi. */
sbi->s_mount_opts = ctx->s_mount_opts;
return 0;
}
static const struct fs_context_operations zonefs_context_ops = {
.parse_param = zonefs_parse_param,
.get_tree = zonefs_get_tree,
.reconfigure = zonefs_reconfigure,
.free = zonefs_free_fc,
};
/*
* Set up the filesystem mount context.
*/
static int zonefs_init_fs_context(struct fs_context *fc)
{
struct zonefs_context *ctx;
ctx = kzalloc(sizeof(struct zonefs_context), GFP_KERNEL);
if (!ctx)
return -ENOMEM;
ctx->s_mount_opts = ZONEFS_MNTOPT_ERRORS_RO;
fc->ops = &zonefs_context_ops;
fc->fs_private = ctx;
return 0;
}
/* /*
* File system definition and registration. * File system definition and registration.
*/ */
static struct file_system_type zonefs_type = { static struct file_system_type zonefs_type = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "zonefs", .name = "zonefs",
.mount = zonefs_mount, .kill_sb = zonefs_kill_super,
.kill_sb = zonefs_kill_super, .fs_flags = FS_REQUIRES_DEV,
.fs_flags = FS_REQUIRES_DEV, .init_fs_context = zonefs_init_fs_context,
.parameters = zonefs_param_spec,
}; };
static int __init zonefs_init_inodecache(void) static int __init zonefs_init_inodecache(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment