xen/blkfront: correctly detach a disk with active users

Call disk_gone when the backend switches to the "Closing" state and blkfront
still has pending users. This allows the disk to be detached, and will call
into xbd_closing by itself when the geom layout cleanup has finished.

Reported by:		bapt
Tested by:		manu
Reviewed by:		bapt
Sponsored by:		Citrix Systems R&D
MFC after:		1 week
Differential revision:	https://reviews.freebsd.org/D10772
This commit is contained in:
Roger Pau Monné 2017-05-19 08:11:15 +00:00
parent da31cbbca0
commit e5d27b37e3

View file

@ -1578,11 +1578,14 @@ xbd_backend_changed(device_t dev, XenbusState backend_state)
break;
case XenbusStateClosing:
if (sc->xbd_users > 0)
xenbus_dev_error(dev, -EBUSY,
"Device in use; refusing to close");
else
if (sc->xbd_users > 0) {
device_printf(dev, "detaching with pending users\n");
KASSERT(sc->xbd_disk != NULL,
("NULL disk with pending users\n"));
disk_gone(sc->xbd_disk);
} else {
xbd_closing(dev);
}
break;
}
}