Skip to content

Commit b47a82f

Browse files
author
Kent Overstreet
committed
bcachefs: Only run 'increase_depth' for keys from btree node csan
bch2_btree_increase_depth() was originally for disaster recovery, to get some data back from the journal when a btree root was bad. We don't need it for that purpose anymore; on bad btree root we'll launch btree node scan and reconstruct all the interior nodes. If there's a key in the journal for a depth that doesn't exists, and it's not from check_topology/btree node scan, we should just ignore it. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 7b0e6b1 commit b47a82f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

fs/bcachefs/recovery.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,24 @@ static int bch2_journal_replay_key(struct btree_trans *trans,
271271
goto out;
272272

273273
struct btree_path *path = btree_iter_path(trans, &iter);
274-
if (unlikely(!btree_path_node(path, k->level))) {
274+
if (unlikely(!btree_path_node(path, k->level) &&
275+
!k->allocated)) {
276+
struct bch_fs *c = trans->c;
277+
278+
if (!(c->recovery.passes_complete & (BIT_ULL(BCH_RECOVERY_PASS_scan_for_btree_nodes)|
279+
BIT_ULL(BCH_RECOVERY_PASS_check_topology)))) {
280+
bch_err(c, "have key in journal replay for btree depth that does not exist, confused");
281+
ret = -EINVAL;
282+
}
283+
#if 0
275284
bch2_trans_iter_exit(trans, &iter);
276285
bch2_trans_node_iter_init(trans, &iter, k->btree_id, k->k->k.p,
277286
BTREE_MAX_DEPTH, 0, iter_flags);
278287
ret = bch2_btree_iter_traverse(trans, &iter) ?:
279288
bch2_btree_increase_depth(trans, iter.path, 0) ?:
280289
-BCH_ERR_transaction_restart_nested;
290+
#endif
291+
k->overwritten = true;
281292
goto out;
282293
}
283294

0 commit comments

Comments
 (0)