Commit 9054ef2e authored by Kent Overstreet's avatar Kent Overstreet

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: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 9e203c43
......@@ -1926,6 +1926,8 @@ int __bch2_foreground_maybe_merge(struct btree_trans *trans,
BUG_ON(!trans->paths[path].should_be_locked);
BUG_ON(!btree_node_locked(&trans->paths[path], level));
flags &= ~BCH_WATERMARK_MASK;
b = trans->paths[path].l[level].b;
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,
bch2_path_put(trans, new_path, true);
bch2_path_put(trans, sib_path, true);
bch2_trans_verify_locks(trans);
if (ret == -BCH_ERR_journal_reclaim_would_deadlock)
ret = 0;
if (!ret)
ret = bch2_trans_relock(trans);
return ret;
err_free_update:
bch2_btree_node_free_never_used(as, trans, n);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment