bcachefs: Fix bch2_check_alloc_key()
authorKent Overstreet <kent.overstreet@gmail.com>
Mon, 27 Jun 2022 00:34:34 +0000 (20:34 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:34 +0000 (17:09 -0400)
bch2_check_alloc_key() was failing to check buckets that didn't have
alloc keys yet (because they'd never been used) - they still need to be
added to the freespace btree.

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

index 9ede98a3dc6465d9db24a02c371aac70522211ba..f4457d62d75e1f7ab5c57c8393b399ab55a63372 100644 (file)
@@ -618,7 +618,9 @@ static int bch2_check_alloc_key(struct btree_trans *trans,
        struct printbuf buf = PRINTBUF;
        int ret;
 
-       alloc_k = bch2_btree_iter_peek(alloc_iter);
+       alloc_k = bch2_dev_bucket_exists(c, alloc_iter->pos)
+               ? bch2_btree_iter_peek_slot(alloc_iter)
+               : bch2_btree_iter_peek(alloc_iter);
        if (!alloc_k.k)
                return 1;