bcachefs: Fix allocate -> self healing path
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 23 May 2025 22:30:10 +0000 (18:30 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Fri, 23 May 2025 23:52:31 +0000 (19:52 -0400)
When we go to allocate and find taht a bucket in the freespace btree is
actually allocated, we're supposed to return nonzero to tell the
allocator to skip it.

This fixes an emergency read only due to a bucket/ptr gen mismatch - we
also don't return the correct bucket gen when this happens.

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

index a38b9c6c891e7240562f4f5e1da95ea659ed4fbf..173e81c2bbcbc227516b5d9cbf9375c93f3c7702 100644 (file)
@@ -1475,6 +1475,8 @@ delete:
                w->c = c;
                w->pos = BBPOS(iter->btree_id, iter->pos);
                queue_work(c->write_ref_wq, &w->work);
+
+               ret = 1; /* don't allocate from this bucket */
                goto out;
        }
 }