bcachefs: Fix incorrect use of bch2_extent_atomic_end()
authorKent Overstreet <kent.overstreet@gmail.com>
Mon, 7 Oct 2019 19:09:30 +0000 (15:09 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:28 +0000 (17:08 -0400)
bch2_extent_atomic_end counts the number of iterators requried for
marking overwrites - but journal replay never marks overwrites, so that
part was incorrect. And counting iterators for the key being inserted
should be unnecessary because we did that prior to the key being
inserted before it was first journalled.

This should fix an iterator overflow bug - the iterators for walking
overwrites were totally unneeded.

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

index 97c0d7d1fe772576162cfc1129f50e2748c4f5c1..095eef3828ceca486ee6020cc73cc7f793f4e8f5 100644 (file)
@@ -268,10 +268,12 @@ retry:
                                   BTREE_ITER_INTENT);
 
        do {
-               ret = bch2_extent_atomic_end(iter, k, &atomic_end);
+               ret = bch2_btree_iter_traverse(iter);
                if (ret)
                        goto err;
 
+               atomic_end = bpos_min(k->k.p, iter->l[0].b->key.k.p);
+
                split_iter = bch2_trans_copy_iter(&trans, iter);
                ret = PTR_ERR_OR_ZERO(split_iter);
                if (ret)