bcachefs: bch2_btree_lost_data() now handles snapshots tree
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 24 Apr 2025 13:09:56 +0000 (09:09 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 22 May 2025 00:14:33 +0000 (20:14 -0400)
We have a consolidated places for "this btree lost data, run this
repair", so use it.

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

index 2a8bcb9b1dd2b721712158329b0391aaa63f7057..8f45d9e3a47e52481c05be329f6c498c1b732b5b 100644 (file)
@@ -95,6 +95,10 @@ int bch2_btree_lost_data(struct bch_fs *c, enum btree_id btree)
        case BTREE_ID_accounting:
                ret = bch2_run_explicit_recovery_pass_persistent_locked(c, BCH_RECOVERY_PASS_check_allocations) ?: ret;
                goto out;
+       case BTREE_ID_snapshots:
+               ret = bch2_run_explicit_recovery_pass_persistent_locked(c, BCH_RECOVERY_PASS_reconstruct_snapshots) ?: ret;
+               ret = bch2_run_explicit_recovery_pass_persistent_locked(c, BCH_RECOVERY_PASS_scan_for_btree_nodes) ?: ret;
+               goto out;
        default:
                ret = bch2_run_explicit_recovery_pass_persistent_locked(c, BCH_RECOVERY_PASS_scan_for_btree_nodes) ?: ret;
                goto out;
index 14ea09ccee37b1cb9070fbf2859c7561334aa0f4..94cf60f76b64260434b35983c1497e768eb51653 100644 (file)
@@ -1743,10 +1743,6 @@ int bch2_snapshots_read(struct bch_fs *c)
        BUG_ON(!test_bit(BCH_FS_new_fs, &c->flags) &&
               test_bit(BCH_FS_may_go_rw, &c->flags));
 
-       if (bch2_err_matches(ret, EIO) ||
-           (c->sb.btrees_lost_data & BIT_ULL(BTREE_ID_snapshots)))
-               ret = bch2_run_explicit_recovery_pass_persistent(c, BCH_RECOVERY_PASS_reconstruct_snapshots);
-
        return ret;
 }