mirror of
https://github.com/torvalds/linux.git
synced 2026-05-05 23:05:25 -04:00
bcachefs: bkey_min(), bkey_max()
Parallel to bpos_min(), bpos_max() - trivial refactoring. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user