bcachefs: fix device remove error path
authorKent Overstreet <kent.overstreet@gmail.com>
Tue, 18 Dec 2018 13:41:58 +0000 (08:41 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:13 +0000 (17:08 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/super.c

index b2113c5426ca360fe2f158c9c42e5207c3533652..4e811ffdec8e1eb327f29666ee2e39c190bb648c 100644 (file)
@@ -1306,7 +1306,8 @@ int bch2_dev_remove(struct bch_fs *c, struct bch_dev *ca, int flags)
        mutex_unlock(&c->state_lock);
        return 0;
 err:
-       if (ca->mi.state == BCH_MEMBER_STATE_RW)
+       if (ca->mi.state == BCH_MEMBER_STATE_RW &&
+           !percpu_ref_is_zero(&ca->io_ref))
                __bch2_dev_read_write(c, ca);
        mutex_unlock(&c->state_lock);
        return ret;