There's no reason to treat them as errors: just ignore them, and go with
a previous btree root if we had one.

Reported-by: [email protected]
Signed-off-by: Kent Overstreet <[email protected]>
---
 fs/bcachefs/recovery.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c
index 547c78a323f7..727e894762f5 100644
--- a/fs/bcachefs/recovery.c
+++ b/fs/bcachefs/recovery.c
@@ -442,7 +442,9 @@ static int journal_replay_entry_early(struct bch_fs *c,
 
        switch (entry->type) {
        case BCH_JSET_ENTRY_btree_root: {
-               struct btree_root *r;
+
+               if (unlikely(!entry->u64s))
+                       return 0;
 
                if (fsck_err_on(entry->btree_id >= BTREE_ID_NR_MAX,
                                c, invalid_btree_id,
@@ -456,15 +458,11 @@ static int journal_replay_entry_early(struct bch_fs *c,
                                return ret;
                }
 
-               r = bch2_btree_id_root(c, entry->btree_id);
+               struct btree_root *r = bch2_btree_id_root(c, entry->btree_id);
 
-               if (entry->u64s) {
-                       r->level = entry->level;
-                       bkey_copy(&r->key, (struct bkey_i *) entry->start);
-                       r->error = 0;
-               } else {
-                       r->error = -BCH_ERR_btree_node_read_error;
-               }
+               r->level = entry->level;
+               bkey_copy(&r->key, (struct bkey_i *) entry->start);
+               r->error = 0;
                r->alive = true;
                break;
        }
-- 
2.45.2


Reply via email to