diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2020-10-23 21:07:17 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:45 -0400 |
commit | a10e677a1555e070f1a7b3c1dc3e3189d462ab9e (patch) | |
tree | e3c10ea15e7706c079ced13f5c9de35c967f0466 /fs/bcachefs/fs.c | |
parent | 5b088c1dd005ec0fbddfa3664d3095caef6ae52e (diff) | |
download | lwn-a10e677a1555e070f1a7b3c1dc3e3189d462ab9e.tar.gz lwn-a10e677a1555e070f1a7b3c1dc3e3189d462ab9e.zip |
bcachefs: Fix for passing target= opts as mount opts
Some options can't be parsed until the filesystem initialized;
previously, passing these options to mount or remount would cause mount
to fail.
This changes the mount path so that we parse the options passed in
twice, and just ignore any options that can't be parsed the first time.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/fs.c')
-rw-r--r-- | fs/bcachefs/fs.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index a488dcebc11a..b214d58e94e9 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -1343,7 +1343,7 @@ static int bch2_remount(struct super_block *sb, int *flags, char *data) opt_set(opts, read_only, (*flags & SB_RDONLY) != 0); - ret = bch2_parse_mount_opts(&opts, data); + ret = bch2_parse_mount_opts(c, &opts, data); if (ret) return ret; @@ -1484,7 +1484,7 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type, opt_set(opts, read_only, (flags & SB_RDONLY) != 0); - ret = bch2_parse_mount_opts(&opts, data); + ret = bch2_parse_mount_opts(NULL, &opts, data); if (ret) return ERR_PTR(ret); @@ -1507,11 +1507,24 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type, goto got_sb; c = bch2_fs_open(devs, nr_devs, opts); - - if (!IS_ERR(c)) - sb = sget(fs_type, NULL, bch2_set_super, flags|SB_NOSEC, c); - else + if (IS_ERR(c)) { sb = ERR_CAST(c); + goto got_sb; + } + + /* Some options can't be parsed until after the fs is started: */ + ret = bch2_parse_mount_opts(c, &opts, data); + if (ret) { + bch2_fs_stop(c); + sb = ERR_PTR(ret); + goto got_sb; + } + + bch2_opts_apply(&c->opts, opts); + + sb = sget(fs_type, NULL, bch2_set_super, flags|SB_NOSEC, c); + if (IS_ERR(sb)) + bch2_fs_stop(c); got_sb: kfree(devs_to_fs); kfree(devs[0]); |