Skip to content

Commit c72d628

Browse files
author
Kent Overstreet
committed
bcachefs: Fix btree for nonexistent tree depth
The fix for when we should increase tree depth in journal replay was entirely bogus. We should only increase the tree depth in journal replay when recovery from btree node scan, and then only for keys found by btree node scan. This needs additional work - we should be shooting down existing interior node pointers when recovery from scan, they shouldn't be showing up here. Fixes: b47a82f ("bcachefs: Only run 'increase_depth' for keys from btree node csan") Cc: Alan Huang <[email protected]> Reported-by: [email protected] Signed-off-by: Kent Overstreet <[email protected]>
1 parent ddb9680 commit c72d628

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

fs/bcachefs/recovery.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,24 +273,35 @@ static int bch2_journal_replay_key(struct btree_trans *trans,
273273
goto out;
274274

275275
struct btree_path *path = btree_iter_path(trans, &iter);
276-
if (unlikely(!btree_path_node(path, k->level) &&
277-
!k->allocated)) {
276+
if (unlikely(!btree_path_node(path, k->level))) {
278277
struct bch_fs *c = trans->c;
279278

279+
CLASS(printbuf, buf)();
280+
prt_str(&buf, "btree=");
281+
bch2_btree_id_to_text(&buf, k->btree_id);
282+
prt_printf(&buf, " level=%u ", k->level);
283+
bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(k->k));
284+
280285
if (!(c->recovery.passes_complete & (BIT_ULL(BCH_RECOVERY_PASS_scan_for_btree_nodes)|
281286
BIT_ULL(BCH_RECOVERY_PASS_check_topology)))) {
282-
bch_err(c, "have key in journal replay for btree depth that does not exist, confused");
287+
bch_err(c, "have key in journal replay for btree depth that does not exist, confused\n%s",
288+
buf.buf);
283289
ret = -EINVAL;
284290
}
285-
#if 0
291+
292+
if (!k->allocated) {
293+
bch_notice(c, "dropping key in journal replay for depth that does not exist because we're recovering from scan\n%s",
294+
buf.buf);
295+
k->overwritten = true;
296+
goto out;
297+
}
298+
286299
bch2_trans_iter_exit(trans, &iter);
287300
bch2_trans_node_iter_init(trans, &iter, k->btree_id, k->k->k.p,
288301
BTREE_MAX_DEPTH, 0, iter_flags);
289302
ret = bch2_btree_iter_traverse(trans, &iter) ?:
290303
bch2_btree_increase_depth(trans, iter.path, 0) ?:
291304
-BCH_ERR_transaction_restart_nested;
292-
#endif
293-
k->overwritten = true;
294305
goto out;
295306
}
296307

0 commit comments

Comments
 (0)