diff options
author | 2022-03-21 03:03:03 -0400 | |
---|---|---|
committer | 2023-10-22 17:09:28 -0400 | |
commit | b8559f1a212a7035b430b83e0a01e94a872adc23 (patch) | |
tree | 3c9287001560b6c210a491d27c5cefb6b2b556f5 /fs/bcachefs/super-io.c | |
parent | bcachefs: Change journal_io.c assertion to error message (diff) | |
download | linux-b8559f1a212a7035b430b83e0a01e94a872adc23.tar.gz linux-b8559f1a212a7035b430b83e0a01e94a872adc23.tar.bz2 linux-b8559f1a212a7035b430b83e0a01e94a872adc23.zip |
bcachefs: Reset journal flush delay to default value if zeroed
We've been seeing a very strange bug where journal flush & reclaim delay
end up getting inexplicably zeroed, in the superblock. We're now
validating all the options in bch2_validate_super(), and 0 is no longer
a valid value for those options, but we need to be careful not to
prevent people's filesystems from mounting because of the new
validation.
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 | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c index 224653f129f8..6d54319a95e6 100644 --- a/fs/bcachefs/super-io.c +++ b/fs/bcachefs/super-io.c @@ -253,7 +253,8 @@ static int validate_sb_layout(struct bch_sb_layout *layout, struct printbuf *out return 0; } -static int bch2_sb_validate(struct bch_sb_handle *disk_sb, struct printbuf *out) +static int bch2_sb_validate(struct bch_sb_handle *disk_sb, struct printbuf *out, + int rw) { struct bch_sb *sb = disk_sb->sb; struct bch_sb_field *f; @@ -330,6 +331,18 @@ static int bch2_sb_validate(struct bch_sb_handle *disk_sb, struct printbuf *out) return -EINVAL; } + if (rw == READ) { + /* + * Been seeing a bug where these are getting inexplicably + * zeroed, so we'r now validating them, but we have to be + * careful not to preven people's filesystems from mounting: + */ + if (!BCH_SB_JOURNAL_FLUSH_DELAY(sb)) + SET_BCH_SB_JOURNAL_FLUSH_DELAY(sb, 1000); + if (!BCH_SB_JOURNAL_RECLAIM_DELAY(sb)) + SET_BCH_SB_JOURNAL_RECLAIM_DELAY(sb, 1000); + } + for (opt_id = 0; opt_id < bch2_opts_nr; opt_id++) { const struct bch_option *opt = bch2_opt_table + opt_id; @@ -696,7 +709,7 @@ got_super: ret = 0; sb->have_layout = true; - ret = bch2_sb_validate(sb, &err); + ret = bch2_sb_validate(sb, &err, READ); if (ret) { printk(KERN_ERR "bcachefs (%s): error validating superblock: %s", path, err.buf); @@ -808,7 +821,7 @@ int bch2_write_super(struct bch_fs *c) for_each_online_member(ca, c, i) { printbuf_reset(&err); - ret = bch2_sb_validate(&ca->disk_sb, &err); + ret = bch2_sb_validate(&ca->disk_sb, &err, WRITE); if (ret) { bch2_fs_inconsistent(c, "sb invalid before write: %s", err.buf); percpu_ref_put(&ca->io_ref); |