From 6d61724b2ba1836e4e1f5f8755cb2278d4eae1a0 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 18 Mar 2020 11:46:46 -0400 Subject: [PATCH] bcachefs: Shut down quicker Internal writes (i.e. copygc/rebalance operations) shouldn't be blocking on the allocator when we're going RO. Signed-off-by: Kent Overstreet Signed-off-by: Kent Overstreet --- fs/bcachefs/io.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c index 2ec7203e58248..3dcb166afa231 100644 --- a/fs/bcachefs/io.c +++ b/fs/bcachefs/io.c @@ -1070,6 +1070,12 @@ again: BKEY_EXTENT_U64s_MAX)) goto flush_io; + if ((op->flags & BCH_WRITE_FROM_INTERNAL) && + percpu_ref_is_dying(&c->writes)) { + ret = -EROFS; + goto err; + } + wp = bch2_alloc_sectors_start(c, op->target, op->opts.erasure_code, -- 2.30.2