bcachefs: fix device remove error path

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2018-12-18 08:41:58 -05:00 committed by Kent Overstreet
parent 19b505a934
commit d3bb629d04

View 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;