bcachefs: Shut down quicker
authorKent Overstreet <kent.overstreet@gmail.com>
Wed, 18 Mar 2020 15:46:46 +0000 (11:46 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:37 +0000 (17:08 -0400)
Internal writes (i.e. copygc/rebalance operations) shouldn't be blocking
on the allocator when we're going RO.

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

index 2ec7203e582487d1ea9291878cee6773267dd6d6..3dcb166afa231c72af2e27ae3573ee5ebcabd482 100644 (file)
@@ -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,