From: Kent Overstreet Date: Tue, 24 Jul 2018 23:45:22 +0000 (-0400) Subject: bcachefs: Fix locking in allocator thread X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=94c1f4adec42c03c8fb1b7dc41f2fc07481a5395;p=linux.git 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 --- diff --git a/fs/bcachefs/alloc.c b/fs/bcachefs/alloc.c index ea1dc52e5ff6e..192ab655ca238 100644 --- a/fs/bcachefs/alloc.c +++ b/fs/bcachefs/alloc.c @@ -964,16 +964,21 @@ static int bch2_allocator_thread(void *arg) if (ret) goto stop; + down_read(&c->gc_lock); + ret = bch2_invalidate_buckets(c, ca); - if (ret) + if (ret) { + up_read(&c->gc_lock); goto stop; + } - if (!fifo_empty(&ca->free_inc)) + 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);