summaryrefslogtreecommitdiff
path: root/fs/bcachefs/recovery.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-02-13 03:24:34 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:52 +0300
commit806c8a6aa83410cf78dc13fc63bb5df6352670f2 (patch)
tree579b838a17253ef1aeb92098c9be7c2d11ae12ec /fs/bcachefs/recovery.c
parent3277081522d8620f7410b173881d4b0267ce58f9 (diff)
downloadlinux-806c8a6aa83410cf78dc13fc63bb5df6352670f2.tar.xz
bcachefs: Fix failure to read btree roots
If failed to read a btree root - or if we're not using a btree root, because of the reconstruct_alloc option - make sure we update the corresponding info for the key/level for the root on disk. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/recovery.c')
-rw-r--r--fs/bcachefs/recovery.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c
index 8a78377bf9c5..178f06424460 100644
--- a/fs/bcachefs/recovery.c
+++ b/fs/bcachefs/recovery.c
@@ -974,9 +974,15 @@ static int read_btree_roots(struct bch_fs *c)
}
}
- for (i = 0; i < BTREE_ID_NR; i++)
- if (!c->btree_roots[i].b)
+ for (i = 0; i < BTREE_ID_NR; i++) {
+ struct btree_root *r = &c->btree_roots[i];
+
+ if (!r->b) {
+ r->alive = false;
+ r->level = 0;
bch2_btree_root_alloc(c, i);
+ }
+ }
fsck_err:
return ret;
}