Commit bcad5622 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Update iter->real_pos lazily

peek() has to update iter->real_pos - there's no need for
bch2_btree_iter_set_pos() to update it as well.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 818664f5
......@@ -1470,14 +1470,6 @@ static void btree_iter_set_search_pos(struct btree_iter *iter, struct bpos new_p
bch2_btree_iter_verify(iter);
}
void bch2_btree_iter_set_pos(struct btree_iter *iter, struct bpos new_pos)
{
bkey_init(&iter->k);
iter->k.p = iter->pos = new_pos;
btree_iter_set_search_pos(iter, btree_iter_search_key(iter));
}
inline bool bch2_btree_iter_advance(struct btree_iter *iter)
{
struct bpos pos = iter->k.p;
......@@ -1994,6 +1986,7 @@ struct btree_iter *__bch2_trans_get_iter(struct btree_trans *trans,
__bch2_btree_iter_upgrade_nounlock(iter, 1);
bch2_btree_iter_set_pos(iter, pos);
btree_iter_set_search_pos(iter, btree_iter_search_key(iter));
return iter;
}
......
......@@ -177,7 +177,12 @@ struct bkey_s_c bch2_btree_iter_peek_cached(struct btree_iter *);
bool bch2_btree_iter_advance(struct btree_iter *);
bool bch2_btree_iter_rewind(struct btree_iter *);
void bch2_btree_iter_set_pos(struct btree_iter *, struct bpos);
static inline void bch2_btree_iter_set_pos(struct btree_iter *iter, struct bpos new_pos)
{
bkey_init(&iter->k);
iter->k.p = iter->pos = new_pos;
}
/* Sort order for locking btree iterators: */
static inline int btree_iter_lock_cmp(const struct btree_iter *l,
......
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