Commit f5d4481c authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: move "ptrs not changing" optimization to bch2_trigger_extent()

This is useful for btree ptrs as well, when we're just updating
sectors_written.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent e7999235
......@@ -1023,6 +1023,18 @@ int bch2_trigger_extent(struct btree_trans *trans,
struct bkey_s_c old, struct bkey_s new,
unsigned flags)
{
struct bkey_ptrs_c new_ptrs = bch2_bkey_ptrs_c(new.s_c);
struct bkey_ptrs_c old_ptrs = bch2_bkey_ptrs_c(old);
unsigned new_ptrs_bytes = (void *) new_ptrs.end - (void *) new_ptrs.start;
unsigned old_ptrs_bytes = (void *) old_ptrs.end - (void *) old_ptrs.start;
/* if pointers aren't changing - nothing to do: */
if (new_ptrs_bytes == old_ptrs_bytes &&
!memcmp(new_ptrs.start,
old_ptrs.start,
new_ptrs_bytes))
return 0;
if (flags & BTREE_TRIGGER_TRANSACTIONAL) {
struct bch_fs *c = trans->c;
int mod = (int) bch2_bkey_needs_rebalance(c, new.s_c) -
......
......@@ -301,14 +301,6 @@ int bch2_trans_mark_reflink_v(struct btree_trans *trans,
(flags & BTREE_TRIGGER_INSERT))
check_indirect_extent_deleting(new, &flags);
if (old.k->type == KEY_TYPE_reflink_v &&
new.k->type == KEY_TYPE_reflink_v &&
old.k->u64s == new.k->u64s &&
!memcmp(bkey_s_c_to_reflink_v(old).v->start,
bkey_s_to_reflink_v(new).v->start,
bkey_val_bytes(new.k) - 8))
return 0;
return bch2_trigger_extent(trans, btree_id, level, old, new, flags);
}
......
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