]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bcachefs: Iterators are now always consistent with iter->real_pos
authorKent Overstreet <kent.overstreet@gmail.com>
Sun, 21 Mar 2021 21:09:55 +0000 (17:09 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:57 +0000 (17:08 -0400)
This means bch2_btree_iter_traverse_one() can be made more efficient.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_iter.c

index 572e553d55b185547314adfe76ad478daa9f84eb..c7fa80bf8b9c0f5141ed2e18f5b78eedd706f038 100644 (file)
@@ -1234,9 +1234,9 @@ static inline bool btree_iter_good_node(struct btree_iter *iter,
            !bch2_btree_node_relock(iter, l))
                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;
-       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 true;
 }
@@ -1287,24 +1287,8 @@ static int btree_iter_traverse_one(struct btree_iter *iter,
        if (unlikely(iter->level >= BTREE_MAX_DEPTH))
                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);
 
-       /*
-        * 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
         * would indicate to other code that we got to the end of the btree,