bcachefs: Fix journal deadlock
After we get a journal reservation, we need to use it - if we erorr out of a transaction commit, we'll be eating into space in the journal and if our transaction needs to make forward progress in order to reclaim space in the journal, we'll deadlock. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
b753d4b338
commit
6167f7c8ff
@ -426,6 +426,14 @@ bch2_trans_commit_write_locked(struct btree_trans *trans,
|
||||
fs_usage = bch2_fs_usage_scratch_get(c);
|
||||
}
|
||||
|
||||
/* Must be called under mark_lock: */
|
||||
if (marking && trans->fs_usage_deltas &&
|
||||
bch2_replicas_delta_list_apply(c, &fs_usage->u,
|
||||
trans->fs_usage_deltas)) {
|
||||
ret = BTREE_INSERT_NEED_MARK_REPLICAS;
|
||||
goto err;
|
||||
}
|
||||
|
||||
/*
|
||||
* Don't get journal reservation until after we know insert will
|
||||
* succeed:
|
||||
@ -462,14 +470,6 @@ bch2_trans_commit_write_locked(struct btree_trans *trans,
|
||||
i->k->k.version = MAX_VERSION;
|
||||
}
|
||||
|
||||
/* Must be called under mark_lock: */
|
||||
if (marking && trans->fs_usage_deltas &&
|
||||
bch2_replicas_delta_list_apply(c, &fs_usage->u,
|
||||
trans->fs_usage_deltas)) {
|
||||
ret = BTREE_INSERT_NEED_MARK_REPLICAS;
|
||||
goto err;
|
||||
}
|
||||
|
||||
trans_for_each_update(trans, i)
|
||||
if (BTREE_NODE_TYPE_HAS_MEM_TRIGGERS & (1U << i->bkey_type))
|
||||
bch2_mark_update(trans, i->iter, i->k,
|
||||
|
Loading…
x
Reference in New Issue
Block a user