]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bcachefs: Update iter->real_pos lazily
authorKent Overstreet <kent.overstreet@gmail.com>
Mon, 22 Mar 2021 01:16:52 +0000 (21:16 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:57 +0000 (17:08 -0400)
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>
fs/bcachefs/btree_iter.c
fs/bcachefs/btree_iter.h

index 43885f9078375a87dd6551ee276e32440213c6ab..e9b580ee0026b0a399fe0958ac2a3fb5535663e6 100644 (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;
 }
index 1276d8aaf65203ef7609e4be22569315c9646343..3ae19e2900a6294614eb9ac898a3c60b97c46c91 100644 (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,