From d3bb629d04ec4ec49556fe3d974e0744a0dd0084 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Tue, 18 Dec 2018 08:41:58 -0500 Subject: [PATCH] bcachefs: fix device remove error path Signed-off-by: Kent Overstreet --- fs/bcachefs/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; -- 2.30.2