From 01254036a326e0663eaeabb2eb3359c04caed2a0 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Mon, 31 May 2021 20:52:39 -0400 Subject: [PATCH] bcachefs; Check for allocator thread shutdown We were missing a kthread_should_stop() check in the loop in bch2_invalidate_buckets(), very occasionally leading to us getting stuck while shutting down. Signed-off-by: Kent Overstreet --- fs/bcachefs/alloc_background.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index 791066b6b39b..b6bfba7aea0a 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -836,6 +836,11 @@ static int bch2_invalidate_buckets(struct bch_fs *c, struct bch_dev *ca) while (!ret && !fifo_full(&ca->free_inc) && ca->alloc_heap.used) { + if (kthread_should_stop()) { + ret = 1; + break; + } + ret = bch2_invalidate_one_bucket(c, ca, &journal_seq, (!fifo_empty(&ca->free_inc) ? BTREE_INSERT_NOWAIT : 0));