bcachefs: Avoid deadlocking on the allocator
authorKent Overstreet <kent.overstreet@gmail.com>
Wed, 18 Sep 2019 23:33:12 +0000 (19:33 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:27 +0000 (17:08 -0400)
The allocator needs to make sure there's buckets available on the
RESERVE_NONE freelist if at all possible - otherwise foreground IO will
get stuck.

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

index 54051161eba7624998b3bc0c1e1643984e62aaf2..85795b580892de0c0a6904f0d443ef54ff74e368 100644 (file)
@@ -1164,7 +1164,7 @@ static int bch2_allocator_thread(void *arg)
                         */
                        if (!nr ||
                            (nr < ALLOC_SCAN_BATCH(ca) &&
-                            !fifo_full(&ca->free[RESERVE_MOVINGGC]))) {
+                            !fifo_empty(&ca->free[RESERVE_NONE]))) {
                                ret = wait_buckets_available(c, ca);
                                if (ret) {
                                        up_read(&c->gc_lock);