diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-11-25 23:01:36 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:09:48 +0300 |
commit | 321bdc73f3aaba5acb9ed7082cf222444541eb74 (patch) | |
tree | 8d67b0f1b51e3ca46c0d48247c8e40c4ee5ad042 | |
parent | 78c0b75c34209c471616566b3978eac4c1c53e99 (diff) | |
download | linux-321bdc73f3aaba5acb9ed7082cf222444541eb74.tar.xz |
bcachefs: bkey_min(), bkey_max()
Parallel to bpos_min(), bpos_max() - trivial refactoring.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/bkey.h | 18 | ||||
-rw-r--r-- | fs/bcachefs/btree_iter.c | 4 |
2 files changed, 15 insertions, 7 deletions
diff --git a/fs/bcachefs/bkey.h b/fs/bcachefs/bkey.h index dc2b91bc67f3..28a70ad5a25d 100644 --- a/fs/bcachefs/bkey.h +++ b/fs/bcachefs/bkey.h @@ -182,6 +182,16 @@ static __always_inline int bpos_cmp(struct bpos l, struct bpos r) cmp_int(l.snapshot, r.snapshot); } +static inline struct bpos bpos_min(struct bpos l, struct bpos r) +{ + return bpos_lt(l, r) ? l : r; +} + +static inline struct bpos bpos_max(struct bpos l, struct bpos r) +{ + return bpos_gt(l, r) ? l : r; +} + static __always_inline bool bkey_eq(struct bpos l, struct bpos r) { return !((l.inode ^ r.inode) | @@ -218,14 +228,14 @@ static __always_inline int bkey_cmp(struct bpos l, struct bpos r) cmp_int(l.offset, r.offset); } -static inline struct bpos bpos_min(struct bpos l, struct bpos r) +static inline struct bpos bkey_min(struct bpos l, struct bpos r) { - return bpos_lt(l, r) ? l : r; + return bkey_lt(l, r) ? l : r; } -static inline struct bpos bpos_max(struct bpos l, struct bpos r) +static inline struct bpos bkey_max(struct bpos l, struct bpos r) { - return bpos_gt(l, r) ? l : r; + return bkey_gt(l, r) ? l : r; } void bch2_bpos_swab(struct bpos *); diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 04051e45f4e0..8c951cfa74ae 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2022,10 +2022,8 @@ struct bkey_s_c bch2_btree_iter_peek_upto(struct btree_iter *iter, struct bpos e */ if (!(iter->flags & BTREE_ITER_IS_EXTENTS)) iter_pos = k.k->p; - else if (bkey_gt(bkey_start_pos(k.k), iter->pos)) - iter_pos = bkey_start_pos(k.k); else - iter_pos = iter->pos; + iter_pos = bkey_max(iter->pos, bkey_start_pos(k.k)); if (bkey_gt(iter_pos, end)) { bch2_btree_iter_set_pos(iter, end); |