summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-12-08 09:51:04 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2024-01-01 19:47:43 +0300
commit5ce8b92da0b04faa4864845f43ed7357034e700d (patch)
treebcfae35ecbe7ee14fba52a4a31434766f46a56f8 /fs
parent4753bdeb26d55eebb415254f795b8be66cb80452 (diff)
downloadlinux-5ce8b92da0b04faa4864845f43ed7357034e700d.tar.xz
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.c4
-rw-r--r--fs/bcachefs/btree_iter.h8
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;
}