diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-12-08 01:51:04 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-01-01 11:47:43 -0500 |
commit | 5ce8b92da0b04faa4864845f43ed7357034e700d (patch) | |
tree | bcfae35ecbe7ee14fba52a4a31434766f46a56f8 /fs | |
parent | 4753bdeb26d55eebb415254f795b8be66cb80452 (diff) | |
download | lwn-5ce8b92da0b04faa4864845f43ed7357034e700d.tar.gz lwn-5ce8b92da0b04faa4864845f43ed7357034e700d.zip |
bcachefs: minor bch2_btree_path_set_pos() optimization
bpos_eq() is cheaper than bpos_cmp()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/bcachefs/btree_iter.c | 4 | ||||
-rw-r--r-- | fs/bcachefs/btree_iter.h | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 79e6ec7b9a52..f16fefbb6497 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1221,8 +1221,10 @@ struct btree_path *__bch2_btree_path_make_mut(struct btree_trans *trans, struct btree_path * __must_check __bch2_btree_path_set_pos(struct btree_trans *trans, struct btree_path *path, struct bpos new_pos, - bool intent, unsigned long ip, int cmp) + bool intent, unsigned long ip) { + int cmp = bpos_cmp(new_pos, path->pos); + bch2_trans_verify_not_in_restart(trans); EBUG_ON(!path->ref); diff --git a/fs/bcachefs/btree_iter.h b/fs/bcachefs/btree_iter.h index 29f02335642e..3b981144e472 100644 --- a/fs/bcachefs/btree_iter.h +++ b/fs/bcachefs/btree_iter.h @@ -176,17 +176,15 @@ bch2_btree_path_make_mut(struct btree_trans *trans, struct btree_path * __must_check __bch2_btree_path_set_pos(struct btree_trans *, struct btree_path *, - struct bpos, bool, unsigned long, int); + struct bpos, bool, unsigned long); static inline struct btree_path * __must_check bch2_btree_path_set_pos(struct btree_trans *trans, struct btree_path *path, struct bpos new_pos, bool intent, unsigned long ip) { - int cmp = bpos_cmp(new_pos, path->pos); - - return cmp - ? __bch2_btree_path_set_pos(trans, path, new_pos, intent, ip, cmp) + return !bpos_eq(new_pos, path->pos) + ? __bch2_btree_path_set_pos(trans, path, new_pos, intent, ip) : path; } |