Commit 3745efd6 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Improve btree_iter_pos_in_node()

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent a9d1f910
...@@ -742,18 +742,29 @@ static void btree_iter_verify_new_node(struct btree_iter *iter, struct btree *b) ...@@ -742,18 +742,29 @@ static void btree_iter_verify_new_node(struct btree_iter *iter, struct btree *b)
btree_node_unlock(iter, b->c.level + 1); btree_node_unlock(iter, b->c.level + 1);
} }
static inline bool btree_iter_pos_before_node(struct btree_iter *iter,
struct btree *b)
{
return bkey_cmp(iter->pos, b->data->min_key) < 0;
}
static inline bool btree_iter_pos_after_node(struct btree_iter *iter, static inline bool btree_iter_pos_after_node(struct btree_iter *iter,
struct btree *b) struct btree *b)
{ {
return __btree_iter_pos_cmp(iter, NULL, int cmp = bkey_cmp(b->key.k.p, iter->pos);
bkey_to_packed(&b->key), true) < 0;
if (!cmp &&
(iter->flags & BTREE_ITER_IS_EXTENTS) &&
bkey_cmp(b->key.k.p, POS_MAX))
cmp = -1;
return cmp < 0;
} }
static inline bool btree_iter_pos_in_node(struct btree_iter *iter, static inline bool btree_iter_pos_in_node(struct btree_iter *iter,
struct btree *b) struct btree *b)
{ {
return iter->btree_id == b->c.btree_id && return iter->btree_id == b->c.btree_id &&
bkey_cmp(iter->pos, b->data->min_key) >= 0 && !btree_iter_pos_before_node(iter, b) &&
!btree_iter_pos_after_node(iter, b); !btree_iter_pos_after_node(iter, b);
} }
......
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