Commit 0c10cf85 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Run alloc triggers last

Triggers can generate additional btree updates - we need to run alloc
triggers after all other triggers have run, because they generate
updates for the alloc btree.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 96d3a0af
...@@ -507,6 +507,9 @@ static int run_btree_triggers(struct btree_trans *trans, enum btree_id btree_id, ...@@ -507,6 +507,9 @@ static int run_btree_triggers(struct btree_trans *trans, enum btree_id btree_id,
for (i = btree_id_start; for (i = btree_id_start;
i < trans->updates + trans->nr_updates && i->btree_id <= btree_id; i < trans->updates + trans->nr_updates && i->btree_id <= btree_id;
i++) { i++) {
if (i->btree_id != btree_id)
continue;
ret = run_one_trans_trigger(trans, i, overwrite); ret = run_one_trans_trigger(trans, i, overwrite);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -533,6 +536,9 @@ static int bch2_trans_commit_run_triggers(struct btree_trans *trans) ...@@ -533,6 +536,9 @@ static int bch2_trans_commit_run_triggers(struct btree_trans *trans)
* they are re-added. * they are re-added.
*/ */
for (btree_id = 0; btree_id < BTREE_ID_NR; btree_id++) { for (btree_id = 0; btree_id < BTREE_ID_NR; btree_id++) {
if (btree_id == BTREE_ID_alloc)
continue;
while (btree_id_start < trans->updates + trans->nr_updates && while (btree_id_start < trans->updates + trans->nr_updates &&
btree_id_start->btree_id < btree_id) btree_id_start->btree_id < btree_id)
btree_id_start++; btree_id_start++;
...@@ -542,6 +548,17 @@ static int bch2_trans_commit_run_triggers(struct btree_trans *trans) ...@@ -542,6 +548,17 @@ static int bch2_trans_commit_run_triggers(struct btree_trans *trans)
return ret; return ret;
} }
trans_for_each_update(trans, i) {
if (i->btree_id > BTREE_ID_alloc)
break;
if (i->btree_id == BTREE_ID_alloc) {
ret = run_btree_triggers(trans, BTREE_ID_alloc, i);
if (ret)
return ret;
break;
}
}
trans_for_each_update(trans, i) trans_for_each_update(trans, i)
BUG_ON(!(i->flags & BTREE_TRIGGER_NORUN) && BUG_ON(!(i->flags & BTREE_TRIGGER_NORUN) &&
(BTREE_NODE_TYPE_HAS_TRANS_TRIGGERS & (1U << i->bkey_type)) && (BTREE_NODE_TYPE_HAS_TRANS_TRIGGERS & (1U << i->bkey_type)) &&
......
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