Commit 5cde51cd authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Iterators are now always consistent with iter->real_pos

This means bch2_btree_iter_traverse_one() can be made more efficient.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 345ca825
...@@ -1234,9 +1234,9 @@ static inline bool btree_iter_good_node(struct btree_iter *iter, ...@@ -1234,9 +1234,9 @@ static inline bool btree_iter_good_node(struct btree_iter *iter,
!bch2_btree_node_relock(iter, l)) !bch2_btree_node_relock(iter, l))
return false; return false;
if (check_pos <= 0 && btree_iter_pos_before_node(iter, iter->l[l].b)) if (check_pos < 0 && btree_iter_pos_before_node(iter, iter->l[l].b))
return false; return false;
if (check_pos >= 0 && btree_iter_pos_after_node(iter, iter->l[l].b)) if (check_pos > 0 && btree_iter_pos_after_node(iter, iter->l[l].b))
return false; return false;
return true; return true;
} }
...@@ -1287,24 +1287,8 @@ static int btree_iter_traverse_one(struct btree_iter *iter, ...@@ -1287,24 +1287,8 @@ static int btree_iter_traverse_one(struct btree_iter *iter,
if (unlikely(iter->level >= BTREE_MAX_DEPTH)) if (unlikely(iter->level >= BTREE_MAX_DEPTH))
return 0; return 0;
/*
* XXX: correctly using BTREE_ITER_UPTODATE should make using check_pos
* here unnecessary
*/
iter->level = btree_iter_up_until_good_node(iter, 0); iter->level = btree_iter_up_until_good_node(iter, 0);
/*
* If we've got a btree node locked (i.e. we aren't about to relock the
* root) - advance its node iterator if necessary:
*
* XXX correctly using BTREE_ITER_UPTODATE should make this unnecessary
*/
if (is_btree_node(iter, iter->level)) {
BUG_ON(!btree_iter_pos_in_node(iter, iter->l[iter->level].b));
btree_iter_advance_to_pos(iter, &iter->l[iter->level], -1);
}
/* /*
* Note: iter->nodes[iter->level] may be temporarily NULL here - that * Note: iter->nodes[iter->level] may be temporarily NULL here - that
* would indicate to other code that we got to the end of the btree, * would indicate to other code that we got to the end of the btree,
......
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