bcachefs: Kill bch2_mount()
PATCH 1/2 bcachefs: Kill bch2_mount()
Fold into bch2_fs_get_tree()
Signed-off-by Kent Overstreet <[email protected]>
--- fs/bcachefs/fs.c | 46 +++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 31 deletions(-)
fs/bcachefs/fs.c +15 -31
@@ -1872,25 +1872,24 @@ static int bch2_test_super(struct super_block *s, void *data)return true; } -static struct dentry *bch2_mount (struct file_system_type *fs_type, -int flags,const char *dev_name, -struct bch2_opts_parse opts_parse) +static int bch2_fs_get_tree (struct fs_context *fc) {struct bch_fs *c;struct super_block *sb;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; -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 ) -return ERR_PTR (-EINVAL ); +if (!fc->source ||strlen (fc->source) ==0 ) +return -EINVAL ;darray_str devs; - ret =bch2_split_devs (dev_name, &devs); + ret =bch2_split_devs (fc->source, &devs);if (ret) -return ERR_PTR (ret); +return ret;darray_fs devs_to_fs = {};darray_for_each (devs, i) {
@@ -1901,7 +1900,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)) goto got_sb;
@@ -1912,7 +1911,7 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type, }/* 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) {bch2_fs_stop (c); sb =ERR_PTR (ret);
@@ -1921,7 +1920,7 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type,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))bch2_fs_stop (c); got_sb:
@@ -1936,7 +1935,7 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type, c = sb->s_fs_info;if (sb->s_root) { -if ((flags ^ sb->s_flags) &SB_RDONLY ) { +if ((fc->sb_flags ^ sb->s_flags) &SB_RDONLY ) { ret = -EBUSY ; goto err_put_super; }
@@ -2001,7 +2000,8 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type, sb->s_flags |=SB_ACTIVE ; out: -return dget (sb->s_root); + fc->root =dget (sb->s_root); +return 0 ; err_put_super:__bch2_fs_stop (c);
@@ -2015,7 +2015,7 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type,*/ if (bch2_err_matches (ret,EROFS ) && ret != -EROFS ) ret = -EIO ; -return ERR_PTR (bch2_err_class (ret)); +return bch2_err_class (ret); }static void bch2_kill_sb (struct super_block *sb)
@@ -2060,22 +2060,6 @@ static int bch2_fs_parse_param(struct fs_context *fc,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) {struct super_block *sb = fc->root->d_sb;
Signature · 1 line
2.45.1
PATCH 2/2 bcachefs: bch2_fs_get_tree() cleanup
- improve error paths
- call bch2_fs_start() separately, after applying late-parsed options
Signed-off-by Kent Overstreet <[email protected]>
--- fs/bcachefs/fs.c | 59 ++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 30 deletions(-)
fs/bcachefs/fs.c +29 -30
@@ -1879,25 +1879,24 @@ static int bch2_fs_get_tree(struct fs_context *fc)struct inode *vinode;struct bch2_opts_parse *opts_parse = fc->fs_private;struct bch_opts opts = opts_parse->opts; +darray_str devs; +darray_fs devs_to_fs = {};int ret;opt_set (opts, read_only, (fc->sb_flags &SB_RDONLY ) !=0 ); +opt_set (opts, nostart, true);if (!fc->source ||strlen (fc->source) ==0 )return -EINVAL ; -darray_str devs; ret =bch2_split_devs (fc->source, &devs);if (ret)return ret; -darray_fs devs_to_fs = {};darray_for_each (devs, i) { ret =darray_push (&devs_to_fs,bch2_path_to_fs (*i)); -if (ret) { - sb =ERR_PTR (ret); - goto got_sb; - } +if (ret) + goto err; } sb =sget (fc->fs_type, bch2_test_super, bch2_noset_super, fc->sb_flags|SB_NOSEC , &devs_to_fs);
@@ -1905,33 +1904,27 @@ static int bch2_fs_get_tree(struct fs_context *fc) goto got_sb; c =bch2_fs_open (devs.data, devs.nr, opts); -if (IS_ERR (c)) { - sb =ERR_CAST (c); - goto got_sb; - } + ret =PTR_ERR_OR_ZERO (c); +if (ret) + goto err;/* Some options can't be parsed until after the fs is started: */ + opts =bch2_opts_empty (); ret =bch2_parse_mount_opts (c, &opts,NULL , opts_parse->parse_later.buf); -if (ret) { -bch2_fs_stop (c); - sb =ERR_PTR (ret); - goto got_sb; - } +if (ret) + goto err_stop_fs;bch2_opts_apply (&c->opts, opts); + ret =bch2_fs_start (c); +if (ret) + goto err_stop_fs; + sb =sget (fc->fs_type,NULL , bch2_set_super, fc->sb_flags|SB_NOSEC , c); -if (IS_ERR (sb)) -bch2_fs_stop (c); + ret =PTR_ERR_OR_ZERO (sb); +if (ret) + goto err_stop_fs; got_sb: -darray_exit (&devs_to_fs); -bch2_darray_str_exit (&devs); - -if (IS_ERR (sb)) { - ret =PTR_ERR (sb); - goto err; - } - c = sb->s_fs_info;if (sb->s_root) {
@@ -2001,12 +1994,9 @@ static int bch2_fs_get_tree(struct fs_context *fc) sb->s_flags |=SB_ACTIVE ; out: fc->root =dget (sb->s_root); -return 0 ; - -err_put_super: -__bch2_fs_stop (c); -deactivate_locked_super (sb); err: +darray_exit (&devs_to_fs); +bch2_darray_str_exit (&devs);/* * On an inconsistency error in recovery we might see an -EROFS derived * errorcode (from the journal), but we don't want to return that to
@@ -2016,6 +2006,15 @@ static int bch2_fs_get_tree(struct fs_context *fc)if (bch2_err_matches (ret,EROFS ) && ret != -EROFS ) ret = -EIO ;return bch2_err_class (ret); + +err_stop_fs: +bch2_fs_stop (c); + goto err; + +err_put_super: +__bch2_fs_stop (c); +deactivate_locked_super (sb); + goto err; }static void bch2_kill_sb (struct super_block *sb)
Signature · 1 line
2.45.1