Commit 94c1f4ad authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix locking in allocator thread

gc lock must be held while invalidating buckets - fixes
"1f7a95698e bcachefs: Invalidate buckets when writing to alloc btree"
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 277c981c
...@@ -964,16 +964,21 @@ static int bch2_allocator_thread(void *arg) ...@@ -964,16 +964,21 @@ static int bch2_allocator_thread(void *arg)
if (ret) if (ret)
goto stop; goto stop;
down_read(&c->gc_lock);
ret = bch2_invalidate_buckets(c, ca); ret = bch2_invalidate_buckets(c, ca);
if (ret) if (ret) {
up_read(&c->gc_lock);
goto stop; goto stop;
}
if (!fifo_empty(&ca->free_inc)) if (!fifo_empty(&ca->free_inc)) {
up_read(&c->gc_lock);
continue; continue;
}
pr_debug("free_inc now empty"); pr_debug("free_inc now empty");
down_read(&c->gc_lock);
do { do {
if (test_bit(BCH_FS_GC_FAILURE, &c->flags)) { if (test_bit(BCH_FS_GC_FAILURE, &c->flags)) {
up_read(&c->gc_lock); up_read(&c->gc_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment