bcachefs: Add a kthread_should_stop() check to allocator thread
authorKent Overstreet <kent.overstreet@gmail.com>
Wed, 17 Jun 2020 22:20:26 +0000 (18:20 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:41 +0000 (17:08 -0400)
Turns out it's possible during shutdown for the allocator to get stuck
spinning on bch2_invalidate_buckets() without hitting any of the other
checks.

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

index 93ee5cdfbe354571928b66344bd43d98e06b904e..98dd4995e528adab912029ad1c10838c987c017a 100644 (file)
@@ -1104,6 +1104,8 @@ static int bch2_allocator_thread(void *arg)
 
        while (1) {
                cond_resched();
+               if (kthread_should_stop())
+                       break;
 
                pr_debug("discarding %zu invalidated buckets",
                         fifo_used(&ca->free_inc));