Commit 25ee25e6 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Kill bch2_mount()

Fold into bch2_fs_get_tree()
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent b9efa967
...@@ -1888,25 +1888,24 @@ static int bch2_test_super(struct super_block *s, void *data) ...@@ -1888,25 +1888,24 @@ static int bch2_test_super(struct super_block *s, void *data)
return true; return true;
} }
static struct dentry *bch2_mount(struct file_system_type *fs_type, static int bch2_fs_get_tree(struct fs_context *fc)
int flags, const char *dev_name,
struct bch2_opts_parse opts_parse)
{ {
struct bch_fs *c; struct bch_fs *c;
struct super_block *sb; struct super_block *sb;
struct inode *vinode; struct inode *vinode;
struct bch_opts opts = opts_parse.opts; struct bch2_opts_parse *opts_parse = fc->fs_private;
struct bch_opts opts = opts_parse->opts;
int ret; int ret;
opt_set(opts, read_only, (flags & SB_RDONLY) != 0); opt_set(opts, read_only, (fc->sb_flags & SB_RDONLY) != 0);
if (!dev_name || strlen(dev_name) == 0) if (!fc->source || strlen(fc->source) == 0)
return ERR_PTR(-EINVAL); return -EINVAL;
darray_str devs; darray_str devs;
ret = bch2_split_devs(dev_name, &devs); ret = bch2_split_devs(fc->source, &devs);
if (ret) if (ret)
return ERR_PTR(ret); return ret;
darray_fs devs_to_fs = {}; darray_fs devs_to_fs = {};
darray_for_each(devs, i) { darray_for_each(devs, i) {
...@@ -1917,7 +1916,7 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type, ...@@ -1917,7 +1916,7 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type,
} }
} }
sb = sget(fs_type, bch2_test_super, bch2_noset_super, flags|SB_NOSEC, &devs_to_fs); sb = sget(fc->fs_type, bch2_test_super, bch2_noset_super, fc->sb_flags|SB_NOSEC, &devs_to_fs);
if (!IS_ERR(sb)) if (!IS_ERR(sb))
goto got_sb; goto got_sb;
...@@ -1928,7 +1927,7 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type, ...@@ -1928,7 +1927,7 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type,
} }
/* Some options can't be parsed until after the fs is started: */ /* Some options can't be parsed until after the fs is started: */
ret = bch2_parse_mount_opts(c, &opts, NULL, opts_parse.parse_later.buf); ret = bch2_parse_mount_opts(c, &opts, NULL, opts_parse->parse_later.buf);
if (ret) { if (ret) {
bch2_fs_stop(c); bch2_fs_stop(c);
sb = ERR_PTR(ret); sb = ERR_PTR(ret);
...@@ -1937,7 +1936,7 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type, ...@@ -1937,7 +1936,7 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type,
bch2_opts_apply(&c->opts, opts); bch2_opts_apply(&c->opts, opts);
sb = sget(fs_type, NULL, bch2_set_super, flags|SB_NOSEC, c); sb = sget(fc->fs_type, NULL, bch2_set_super, fc->sb_flags|SB_NOSEC, c);
if (IS_ERR(sb)) if (IS_ERR(sb))
bch2_fs_stop(c); bch2_fs_stop(c);
got_sb: got_sb:
...@@ -1952,7 +1951,7 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type, ...@@ -1952,7 +1951,7 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type,
c = sb->s_fs_info; c = sb->s_fs_info;
if (sb->s_root) { if (sb->s_root) {
if ((flags ^ sb->s_flags) & SB_RDONLY) { if ((fc->sb_flags ^ sb->s_flags) & SB_RDONLY) {
ret = -EBUSY; ret = -EBUSY;
goto err_put_super; goto err_put_super;
} }
...@@ -2018,7 +2017,8 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type, ...@@ -2018,7 +2017,8 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type,
sb->s_flags |= SB_ACTIVE; sb->s_flags |= SB_ACTIVE;
out: out:
return dget(sb->s_root); fc->root = dget(sb->s_root);
return 0;
err_put_super: err_put_super:
__bch2_fs_stop(c); __bch2_fs_stop(c);
...@@ -2034,7 +2034,7 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type, ...@@ -2034,7 +2034,7 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type,
*/ */
if (bch2_err_matches(ret, EROFS) && ret != -EROFS) if (bch2_err_matches(ret, EROFS) && ret != -EROFS)
ret = -EIO; ret = -EIO;
return ERR_PTR(bch2_err_class(ret)); return bch2_err_class(ret);
} }
static void bch2_kill_sb(struct super_block *sb) static void bch2_kill_sb(struct super_block *sb)
...@@ -2079,22 +2079,6 @@ static int bch2_fs_parse_param(struct fs_context *fc, ...@@ -2079,22 +2079,6 @@ static int bch2_fs_parse_param(struct fs_context *fc,
return bch2_err_class(ret); return bch2_err_class(ret);
} }
static int bch2_fs_get_tree(struct fs_context *fc)
{
struct bch2_opts_parse *opts = fc->fs_private;
const char *dev_name = fc->source;
struct dentry *root;
root = bch2_mount(fc->fs_type, fc->sb_flags, dev_name, *opts);
if (IS_ERR(root))
return PTR_ERR(root);
fc->root = root;
return 0;
}
static int bch2_fs_reconfigure(struct fs_context *fc) static int bch2_fs_reconfigure(struct fs_context *fc)
{ {
struct super_block *sb = fc->root->d_sb; struct super_block *sb = fc->root->d_sb;
......
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