bcachefs: Inline fast path of check_pos_snapshot_overwritten()

This moves the slowpath of check_pos_snapshot_overwritten() to a
separate function, and inlines the fast path - helping performance on
btrees that don't use snapshot and for users that aren't using
snapshots.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2022-09-26 18:13:29 -04:00
parent c23a9e0882
commit 25b4b3308e

View File

@ -1113,7 +1113,7 @@ err:
goto retry;
}
static int check_pos_snapshot_overwritten(struct btree_trans *trans,
static noinline int __check_pos_snapshot_overwritten(struct btree_trans *trans,
enum btree_id id,
struct bpos pos)
{
@ -1122,12 +1122,6 @@ static int check_pos_snapshot_overwritten(struct btree_trans *trans,
struct bkey_s_c k;
int ret;
if (!btree_type_has_snapshots(id))
return 0;
if (!snapshot_t(c, pos.snapshot)->children[0])
return 0;
bch2_trans_iter_init(trans, &iter, id, pos,
BTREE_ITER_NOT_EXTENTS|
BTREE_ITER_ALL_SNAPSHOTS);
@ -1153,6 +1147,18 @@ static int check_pos_snapshot_overwritten(struct btree_trans *trans,
return ret;
}
static inline int check_pos_snapshot_overwritten(struct btree_trans *trans,
enum btree_id id,
struct bpos pos)
{
if (!btree_type_has_snapshots(id) ||
pos.snapshot == U32_MAX ||
!snapshot_t(trans->c, pos.snapshot)->children[0])
return 0;
return __check_pos_snapshot_overwritten(trans, id, pos);
}
static noinline int extent_front_merge(struct btree_trans *trans,
struct btree_iter *iter,
struct bkey_s_c k,