mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-17 13:58:46 +00:00
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: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
e7999235e6
commit
f5d4481c3e
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user