summaryrefslogtreecommitdiff
path: root/fs/bcachefs/recovery.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-12-28 04:05:07 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:20 +0300
commitd93cf6858fe67a84e90af76994a2fe4b390c0a0b (patch)
treeb4362259505f94e91589d64c931743c3b4bac904 /fs/bcachefs/recovery.c
parent862bfd5062a0a512369ae647b94310ee873f95f3 (diff)
downloadlinux-d93cf6858fe67a84e90af76994a2fe4b390c0a0b.tar.xz
bcachefs: Run scan_old_btree_nodes after version upgrade
In the recovery path, we scan for old btree nodes if we don't have certain compat bits set. If we do this, we should be doing it after we upgraded to the newest on disk format. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/recovery.c')
-rw-r--r--fs/bcachefs/recovery.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c
index ffa8ab933a11..f6dc557b7439 100644
--- a/fs/bcachefs/recovery.c
+++ b/fs/bcachefs/recovery.c
@@ -1298,33 +1298,14 @@ use_clean:
bch_verbose(c, "quotas done");
}
- if (!(c->sb.compat & (1ULL << BCH_COMPAT_extents_above_btree_updates_done)) ||
- !(c->sb.compat & (1ULL << BCH_COMPAT_bformat_overflow_done)) ||
- le16_to_cpu(c->sb.version_min) < bcachefs_metadata_version_btree_ptr_sectors_written) {
- struct bch_move_stats stats;
-
- bch_move_stats_init(&stats, "recovery");
-
- bch_info(c, "scanning for old btree nodes");
- ret = bch2_fs_read_write(c);
- if (ret)
- goto err;
-
- ret = bch2_scan_old_btree_nodes(c, &stats);
- if (ret)
- goto err;
- bch_info(c, "scanning for old btree nodes done");
- }
-
mutex_lock(&c->sb_lock);
/*
* With journal replay done, we can clear the journal seq blacklist
* table:
*/
BUG_ON(!test_bit(JOURNAL_REPLAY_DONE, &c->journal.flags));
- BUG_ON(le16_to_cpu(c->sb.version_min) < bcachefs_metadata_version_btree_ptr_sectors_written);
-
- bch2_sb_resize_journal_seq_blacklist(&c->disk_sb, 0);
+ if (le16_to_cpu(c->sb.version_min) >= bcachefs_metadata_version_btree_ptr_sectors_written)
+ bch2_sb_resize_journal_seq_blacklist(&c->disk_sb, 0);
if (c->opts.version_upgrade) {
c->disk_sb.sb->version = cpu_to_le16(bcachefs_metadata_version_current);
@@ -1349,6 +1330,24 @@ use_clean:
bch2_write_super(c);
mutex_unlock(&c->sb_lock);
+ if (!(c->sb.compat & (1ULL << BCH_COMPAT_extents_above_btree_updates_done)) ||
+ !(c->sb.compat & (1ULL << BCH_COMPAT_bformat_overflow_done)) ||
+ le16_to_cpu(c->sb.version_min) < bcachefs_metadata_version_btree_ptr_sectors_written) {
+ struct bch_move_stats stats;
+
+ bch_move_stats_init(&stats, "recovery");
+
+ bch_info(c, "scanning for old btree nodes");
+ ret = bch2_fs_read_write(c);
+ if (ret)
+ goto err;
+
+ ret = bch2_scan_old_btree_nodes(c, &stats);
+ if (ret)
+ goto err;
+ bch_info(c, "scanning for old btree nodes done");
+ }
+
ret = 0;
out:
set_bit(BCH_FS_FSCK_DONE, &c->flags);