diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-03-21 00:15:38 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:28 -0400 |
commit | 63c4b25453828ee0670162d35f928ab43635e7fc (patch) | |
tree | f7a5d03fa18c92421a64c8cf65f3e1d992dd4b93 /fs/bcachefs/super-io.c | |
parent | 74b33393db54dd321c807c621fad966eb9ec54e5 (diff) | |
download | linux-stable-63c4b25453828ee0670162d35f928ab43635e7fc.tar.gz linux-stable-63c4b25453828ee0670162d35f928ab43635e7fc.tar.bz2 linux-stable-63c4b25453828ee0670162d35f928ab43635e7fc.zip |
bcachefs: Better superblock opt validation
This moves validation of superblock options to bch2_sb_validate(), so
they'll be checked in the write path as well.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/super-io.c')
-rw-r--r-- | fs/bcachefs/super-io.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c index eaa54167d6b3..224653f129f8 100644 --- a/fs/bcachefs/super-io.c +++ b/fs/bcachefs/super-io.c @@ -258,6 +258,7 @@ static int bch2_sb_validate(struct bch_sb_handle *disk_sb, struct printbuf *out) struct bch_sb *sb = disk_sb->sb; struct bch_sb_field *f; struct bch_sb_field_members *mi; + enum bch_opt_id opt_id; u32 version, version_min; u16 block_size; int ret; @@ -329,6 +330,21 @@ static int bch2_sb_validate(struct bch_sb_handle *disk_sb, struct printbuf *out) return -EINVAL; } + for (opt_id = 0; opt_id < bch2_opts_nr; opt_id++) { + const struct bch_option *opt = bch2_opt_table + opt_id; + + if (opt->get_sb != BCH2_NO_SB_OPT) { + u64 v = bch2_opt_from_sb(sb, opt_id); + + pr_buf(out, "Invalid option "); + ret = bch2_opt_validate(opt, v, out); + if (ret) + return ret; + + printbuf_reset(out); + } + } + /* validate layout */ ret = validate_sb_layout(&sb->layout, out); if (ret) |