Skip to content

Commit 9054ef2

Browse files
author
Kent Overstreet
committed
bcachefs: Run merges at BCH_WATERMARK_btree
This fixes a deadlock where the interior update path during journal replay ends up doing a ton of merges on the backpointers btree, and deadlocking. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 9e203c4 commit 9054ef2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fs/bcachefs/btree_update_interior.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,6 +1926,8 @@ int __bch2_foreground_maybe_merge(struct btree_trans *trans,
19261926
BUG_ON(!trans->paths[path].should_be_locked);
19271927
BUG_ON(!btree_node_locked(&trans->paths[path], level));
19281928

1929+
flags &= ~BCH_WATERMARK_MASK;
1930+
19291931
b = trans->paths[path].l[level].b;
19301932

19311933
if ((sib == btree_prev_sib && bpos_eq(b->data->min_key, POS_MIN)) ||
@@ -2071,6 +2073,10 @@ int __bch2_foreground_maybe_merge(struct btree_trans *trans,
20712073
bch2_path_put(trans, new_path, true);
20722074
bch2_path_put(trans, sib_path, true);
20732075
bch2_trans_verify_locks(trans);
2076+
if (ret == -BCH_ERR_journal_reclaim_would_deadlock)
2077+
ret = 0;
2078+
if (!ret)
2079+
ret = bch2_trans_relock(trans);
20742080
return ret;
20752081
err_free_update:
20762082
bch2_btree_node_free_never_used(as, trans, n);

0 commit comments

Comments
 (0)