Commit 321bdc73 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: bkey_min(), bkey_max()

Parallel to bpos_min(), bpos_max() - trivial refactoring.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 78c0b75c
......@@ -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 *);
......
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment