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

bcachefs: Replace bch2_btree_iter_next() calls with bch2_btree_iter_advance

The way btree iterators work internally has been changing, particularly
with the iter->real_pos changes, and bch2_btree_iter_next() is no longer
hyper optimized - it's just advance followed by peek, so it's more
efficient to just call advance where we're not using the return value of
bch2_btree_iter_next().
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent cb16bfaa
......@@ -1208,7 +1208,7 @@ static int bch2_gc_btree_gens(struct bch_fs *c, enum btree_id btree_id)
}
}
bch2_btree_iter_next(iter);
bch2_btree_iter_advance(iter);
}
bch2_trans_iter_put(&trans, iter);
......
......@@ -1501,7 +1501,7 @@ void bch2_btree_iter_set_pos(struct btree_iter *iter, struct bpos new_pos)
btree_iter_set_search_pos(iter, btree_iter_search_key(iter));
}
inline bool bch2_btree_iter_advance_pos(struct btree_iter *iter)
inline bool bch2_btree_iter_advance(struct btree_iter *iter)
{
struct bpos pos = iter->k.p;
bool ret = bkey_cmp(pos, POS_MAX) != 0;
......@@ -1512,7 +1512,7 @@ inline bool bch2_btree_iter_advance_pos(struct btree_iter *iter)
return ret;
}
inline bool bch2_btree_iter_rewind_pos(struct btree_iter *iter)
inline bool bch2_btree_iter_rewind(struct btree_iter *iter)
{
struct bpos pos = bkey_start_pos(&iter->k);
bool ret = bkey_cmp(pos, POS_MIN) != 0;
......@@ -1637,7 +1637,7 @@ struct bkey_s_c bch2_btree_iter_peek(struct btree_iter *iter)
*/
struct bkey_s_c bch2_btree_iter_next(struct btree_iter *iter)
{
if (!bch2_btree_iter_advance_pos(iter))
if (!bch2_btree_iter_advance(iter))
return bkey_s_c_null;
return bch2_btree_iter_peek(iter);
......@@ -1691,7 +1691,7 @@ struct bkey_s_c bch2_btree_iter_peek_with_updates(struct btree_iter *iter)
k = __bch2_btree_iter_peek_with_updates(iter);
if (k.k && bkey_deleted(k.k)) {
if (!bch2_btree_iter_advance_pos(iter))
if (!bch2_btree_iter_advance(iter))
return bkey_s_c_null;
continue;
}
......@@ -1716,7 +1716,7 @@ struct bkey_s_c bch2_btree_iter_peek_with_updates(struct btree_iter *iter)
struct bkey_s_c bch2_btree_iter_next_with_updates(struct btree_iter *iter)
{
if (!bch2_btree_iter_advance_pos(iter))
if (!bch2_btree_iter_advance(iter))
return bkey_s_c_null;
return bch2_btree_iter_peek_with_updates(iter);
......@@ -1793,7 +1793,7 @@ struct bkey_s_c bch2_btree_iter_peek_prev(struct btree_iter *iter)
*/
struct bkey_s_c bch2_btree_iter_prev(struct btree_iter *iter)
{
if (!bch2_btree_iter_rewind_pos(iter))
if (!bch2_btree_iter_rewind(iter))
return bkey_s_c_null;
return bch2_btree_iter_peek_prev(iter);
......@@ -1885,7 +1885,7 @@ struct bkey_s_c bch2_btree_iter_peek_slot(struct btree_iter *iter)
struct bkey_s_c bch2_btree_iter_next_slot(struct btree_iter *iter)
{
if (!bch2_btree_iter_advance_pos(iter))
if (!bch2_btree_iter_advance(iter))
return bkey_s_c_null;
return bch2_btree_iter_peek_slot(iter);
......@@ -1893,7 +1893,7 @@ struct bkey_s_c bch2_btree_iter_next_slot(struct btree_iter *iter)
struct bkey_s_c bch2_btree_iter_prev_slot(struct btree_iter *iter)
{
if (!bch2_btree_iter_rewind_pos(iter))
if (!bch2_btree_iter_rewind(iter))
return bkey_s_c_null;
return bch2_btree_iter_peek_slot(iter);
......
......@@ -175,8 +175,8 @@ struct bkey_s_c bch2_btree_iter_prev_slot(struct btree_iter *);
struct bkey_s_c bch2_btree_iter_peek_cached(struct btree_iter *);
bool bch2_btree_iter_advance_pos(struct btree_iter *);
bool bch2_btree_iter_rewind_pos(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);
/* Sort order for locking btree iterators: */
......
......@@ -356,7 +356,7 @@ static ssize_t bch2_read_bfloat_failed(struct file *file, char __user *buf,
if (err)
break;
bch2_btree_iter_next(iter);
bch2_btree_iter_advance(iter);
i->from = iter->pos;
err = flush_buf(i);
......
......@@ -842,13 +842,13 @@ static int ec_stripe_update_ptrs(struct bch_fs *c,
struct bch_extent_ptr *ptr, *ec_ptr = NULL;
if (extent_has_stripe_ptr(k, s->key.k.p.offset)) {
bch2_btree_iter_next(iter);
bch2_btree_iter_advance(iter);
continue;
}
block = bkey_matches_stripe(&s->key.v, k);
if (block < 0) {
bch2_btree_iter_next(iter);
bch2_btree_iter_advance(iter);
continue;
}
......
......@@ -914,7 +914,7 @@ static int bch2_fiemap(struct inode *vinode, struct fiemap_extent_info *info,
if (!bkey_extent_is_data(k.k) &&
k.k->type != KEY_TYPE_reservation) {
bch2_btree_iter_next(iter);
bch2_btree_iter_advance(iter);
continue;
}
......
......@@ -547,7 +547,7 @@ static int check_extents(struct bch_fs *c)
i_sectors += k.k->size;
bch2_bkey_buf_reassemble(&prev, c, k);
bch2_btree_iter_advance_pos(iter);
bch2_btree_iter_advance(iter);
}
fsck_err:
if (ret == -EINTR)
......@@ -703,7 +703,7 @@ static int check_dirents(struct bch_fs *c)
}
bch2_btree_iter_advance_pos(iter);
bch2_btree_iter_advance(iter);
}
hash_stop_chain(&trans, &h);
......@@ -762,7 +762,7 @@ static int check_xattrs(struct bch_fs *c)
if (ret)
break;
bch2_btree_iter_advance_pos(iter);
bch2_btree_iter_advance(iter);
}
fsck_err:
if (ret == -EINTR)
......@@ -1389,7 +1389,7 @@ peek_nlinks: link = genradix_iter_peek(&nlinks_iter, links);
if (nlinks_pos == iter->pos.offset)
genradix_iter_advance(&nlinks_iter, links);
bch2_btree_iter_advance_pos(iter);
bch2_btree_iter_advance(iter);
bch2_trans_cond_resched(&trans);
}
fsck_err:
......
......@@ -53,7 +53,7 @@ static int __bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags
while ((k = bch2_btree_iter_peek(iter)).k &&
!(ret = bkey_err(k))) {
if (!bch2_bkey_has_device(k, dev_idx)) {
bch2_btree_iter_next(iter);
bch2_btree_iter_advance(iter);
continue;
}
......
......@@ -638,7 +638,7 @@ static int __bch2_move_data(struct bch_fs *c,
atomic64_add(k.k->size * bch2_bkey_nr_ptrs_allocated(k),
&stats->sectors_seen);
next_nondata:
bch2_btree_iter_next(iter);
bch2_btree_iter_advance(iter);
bch2_trans_cond_resched(&trans);
}
out:
......
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