diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-03-13 00:30:16 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-03-13 11:34:22 -0400 |
commit | 60fe2c74e08d972292e165d7a4627fe13a02abcf (patch) | |
tree | 5cb79a05ca2ab9128a1a1f6e8ef5fa3ee3afc030 | |
parent | 67141c2adf5b4d6ff58140692f85ecf941fa7d9b (diff) |
bcachefs: Fix BTREE_TRIGGER_WANTS_OLD_AND_NEW
BTREE_TRIGGER_WANTS_OLD_AND_NEW didn't work correctly when the old and
new key were both alloc keys, but different versions - it required old
and new key type to be identical, and this bug is a problem for the new
allocator rewrite.
This patch fixes it by checking if the old and new key have the same
trigger functions - the different versions of alloc (and inode) keys
have the same trigger functions.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r-- | fs/bcachefs/btree_update_leaf.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index db9e3b172e05..58db541e6f85 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -442,7 +442,8 @@ static int run_one_mem_trigger(struct btree_trans *trans, if (!btree_node_type_needs_gc(i->btree_id)) return 0; - if (old.k->type == new->k.type && + if (bch2_bkey_ops[old.k->type].atomic_trigger == + bch2_bkey_ops[i->k->k.type].atomic_trigger && ((1U << old.k->type) & BTREE_TRIGGER_WANTS_OLD_AND_NEW)) { ret = bch2_mark_key(trans, old, bkey_i_to_s_c(new), BTREE_TRIGGER_INSERT|BTREE_TRIGGER_OVERWRITE|flags); @@ -493,7 +494,8 @@ static int run_one_trans_trigger(struct btree_trans *trans, struct btree_insert_ if (overwrite) { ret = bch2_trans_mark_old(trans, old, i->flags); - } else if (old.k->type == i->k->k.type && + } else if (bch2_bkey_ops[old.k->type].trans_trigger == + bch2_bkey_ops[i->k->k.type].trans_trigger && ((1U << old.k->type) & BTREE_TRIGGER_WANTS_OLD_AND_NEW)) { i->overwrite_trigger_run = true; ret = bch2_trans_mark_key(trans, old, i->k, |