From: Kent Overstreet Date: Tue, 18 Dec 2018 13:41:58 +0000 (-0500) Subject: bcachefs: fix device remove error path X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=d3bb629d04ec4ec49556fe3d974e0744a0dd0084;p=linux.git bcachefs: fix device remove error path Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index b2113c5426ca3..4e811ffdec8e1 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -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;