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: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2018-07-24 19:45:22 -04:00 committed by Kent Overstreet
parent 277c981c63
commit 94c1f4adec

View File

@ -964,16 +964,21 @@ static int bch2_allocator_thread(void *arg)
if (ret)
goto stop;
ret = bch2_invalidate_buckets(c, ca);
if (ret)
goto stop;
down_read(&c->gc_lock);
if (!fifo_empty(&ca->free_inc))
ret = bch2_invalidate_buckets(c, ca);
if (ret) {
up_read(&c->gc_lock);
goto stop;
}
if (!fifo_empty(&ca->free_inc)) {
up_read(&c->gc_lock);
continue;
}
pr_debug("free_inc now empty");
down_read(&c->gc_lock);
do {
if (test_bit(BCH_FS_GC_FAILURE, &c->flags)) {
up_read(&c->gc_lock);