diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-09-26 18:13:29 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2022-10-03 23:55:38 -0400 |
commit | d203c9538c5f42cda814e8a9f01355613fb8c7cc (patch) | |
tree | 195ad3839372f4db3cc6432716e8d722bcbd5e99 | |
parent | 2eaede1e57add15c0590046786b056b42fb36e1e (diff) |
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>
-rw-r--r-- | fs/bcachefs/btree_update_leaf.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index 07ca146baee0..dec0bde7b539 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -1100,7 +1100,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) { @@ -1109,12 +1109,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); @@ -1140,6 +1134,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); +} + int bch2_trans_update_extent(struct btree_trans *trans, struct btree_iter *orig_iter, struct bkey_i *insert, |