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: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2021-03-21 21:16:52 -04:00 committed by Kent Overstreet
parent 818664f505
commit bcad562259
2 changed files with 7 additions and 9 deletions

View File

@ -1470,14 +1470,6 @@ out:
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 @@ alloc_iter:
__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;
}

View File

@ -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,