From 47ab0c5f6a1e6ac1e9387181585fb39393fec4ea Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sun, 26 Jun 2022 20:34:34 -0400 Subject: [PATCH] bcachefs: Fix bch2_check_alloc_key() 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 --- fs/bcachefs/alloc_background.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index 9ede98a3dc646..f4457d62d75e1 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -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; -- 2.30.2