bcachefs: Fix journal_iters_fix()
authorKent Overstreet <kent.overstreet@gmail.com>
Thu, 21 Apr 2022 04:34:58 +0000 (00:34 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:32 +0000 (17:09 -0400)
journal_iters_fix() was incorrectly rewinding iterators past keys they
had already returned, leading to those keys being double counted in the
bch2_gc() path - oops.

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

index 5831ab53a98237434eb0d36f659021c24dbc1336..f54859b49416101b1b236a99ba0d80825adeecb6 100644 (file)
@@ -147,7 +147,7 @@ static void journal_iters_fix(struct bch_fs *c)
 
        /*
         * If an iterator points one after the key we just inserted,
-        * and the key we just inserted compares >= the iterator's position,
+        * and the key we just inserted compares > the iterator's position,
         * decrement the iterator so it points at the key we just inserted:
         */
        list_for_each_entry(iter, &c->journal_iters, journal.list)
@@ -155,7 +155,7 @@ static void journal_iters_fix(struct bch_fs *c)
                    iter->last &&
                    iter->b->c.btree_id == n->btree_id &&
                    iter->b->c.level    == n->level &&
-                   bpos_cmp(n->k->k.p, iter->unpacked.p) >= 0)
+                   bpos_cmp(n->k->k.p, iter->unpacked.p) > 0)
                        iter->journal.idx = keys->gap - 1;
 }