diff options
author | 2021-03-21 21:16:52 -0400 | |
---|---|---|
committer | 2023-10-22 17:08:57 -0400 | |
commit | bcad562259f7030a1f2e5e0a4e4f6f5b53371c74 (patch) | |
tree | ccd8ab0c1b359a14da3b3fc3d3766a27752131f1 | |
parent | bcachefs: Consolidate bch2_btree_iter_peek() and peek_with_updates() (diff) | |
download | linux-bcad562259f7030a1f2e5e0a4e4f6f5b53371c74.tar.gz linux-bcad562259f7030a1f2e5e0a4e4f6f5b53371c74.tar.bz2 linux-bcad562259f7030a1f2e5e0a4e4f6f5b53371c74.zip |
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>
-rw-r--r-- | fs/bcachefs/btree_iter.c | 9 | ||||
-rw-r--r-- | fs/bcachefs/btree_iter.h | 7 |
2 files changed, 7 insertions, 9 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 43885f907837..e9b580ee0026 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -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; } diff --git a/fs/bcachefs/btree_iter.h b/fs/bcachefs/btree_iter.h index 1276d8aaf652..3ae19e2900a6 100644 --- a/fs/bcachefs/btree_iter.h +++ b/fs/bcachefs/btree_iter.h @@ -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, |