]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/recovery.c
Update bcachefs sources to 95ff72a6c1 fixup! mm: Centralize & improve oom reporting...
[bcachefs-tools-debian] / libbcachefs / recovery.c
index 63e8c1c3d940db02f3a55720cd0977732e2e55b8..eea025a83b435c537ba622b2c80772fb715ae0ac 100644 (file)
@@ -919,6 +919,19 @@ fsck_err:
        return ERR_PTR(ret);
 }
 
+static bool btree_id_is_alloc(enum btree_id id)
+{
+       switch (id) {
+       case BTREE_ID_alloc:
+       case BTREE_ID_backpointers:
+       case BTREE_ID_need_discard:
+       case BTREE_ID_freespace:
+               return true;
+       default:
+               return false;
+       }
+}
+
 static int read_btree_roots(struct bch_fs *c)
 {
        unsigned i;
@@ -930,14 +943,14 @@ static int read_btree_roots(struct bch_fs *c)
                if (!r->alive)
                        continue;
 
-               if (i == BTREE_ID_alloc &&
+               if (btree_id_is_alloc(i) &&
                    c->opts.reconstruct_alloc) {
                        c->sb.compat &= ~(1ULL << BCH_COMPAT_alloc_info);
                        continue;
                }
 
                if (r->error) {
-                       __fsck_err(c, i == BTREE_ID_alloc
+                       __fsck_err(c, btree_id_is_alloc(i)
                                   ? FSCK_CAN_IGNORE : 0,
                                   "invalid btree root %s",
                                   bch2_btree_ids[i]);
@@ -947,7 +960,8 @@ static int read_btree_roots(struct bch_fs *c)
 
                ret = bch2_btree_root_read(c, i, &r->key, r->level);
                if (ret) {
-                       __fsck_err(c, i == BTREE_ID_alloc
+                       __fsck_err(c,
+                                  btree_id_is_alloc(i)
                                   ? FSCK_CAN_IGNORE : 0,
                                   "error reading btree root %s",
                                   bch2_btree_ids[i]);