bcachefs: Add an option for rebuilding the replicas section
authorKent Overstreet <kent.overstreet@gmail.com>
Mon, 20 Jul 2020 19:51:05 +0000 (15:51 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:42 +0000 (17:08 -0400)
There is a bug where we cnan end up clearing the data_has field in the
superblock members section, which causes us to skip reading the journal
and thus journal replay fails. This option tells the recovery path to
not trust those fields.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/opts.h
fs/bcachefs/recovery.c

index bc274918e18cee08c905a04c94513c4832e23f02..2f93238891b0dad114667644394912ac5536bbee 100644 (file)
@@ -260,6 +260,11 @@ enum opt_type {
          OPT_BOOL(),                                                   \
          NO_SB_OPT,                    false,                          \
          NULL,         "Don't replay the journal")                     \
+       x(rebuild_replicas,             u8,                             \
+         OPT_MOUNT,                                                    \
+         OPT_BOOL(),                                                   \
+         NO_SB_OPT,                    false,                          \
+         NULL,         "Rebuild the superblock replicas section")      \
        x(keep_journal,                 u8,                             \
          OPT_MOUNT,                                                    \
          OPT_BOOL(),                                                   \
index 1695a609ecd91a6308a66c8d03c61973aa67ed6b..28972f30e19866d1d0c57e4340e01959187761dd 100644 (file)
@@ -974,7 +974,8 @@ int bch2_fs_recovery(struct bch_fs *c)
                bch_info(c, "recovering from clean shutdown, journal seq %llu",
                         le64_to_cpu(clean->journal_seq));
 
-       if (!c->replicas.entries) {
+       if (!c->replicas.entries ||
+           c->opts.rebuild_replicas) {
                bch_info(c, "building replicas info");
                set_bit(BCH_FS_REBUILD_REPLICAS, &c->flags);
        }