Commit dc52d783 authored by Annie Li's avatar Annie Li Committed by Konrad Rzeszutek Wilk

xen-blkback: stop blkback thread of every queue in xen_blkif_disconnect

In xen_blkif_disconnect, before checking inflight I/O, following code
stops the blkback thread,
if (ring->xenblkd) {
	kthread_stop(ring->xenblkd);
	wake_up(&ring->shutdown_wq);
}
If there is inflight I/O in any non-last queue, blkback returns -EBUSY
directly, and above code would not be called to stop thread of remaining
queue and processs them. When removing vbd device with lots of disk I/O
load, some queues with inflight I/O still have blkback thread running even
though the corresponding vbd device or guest is gone.
And this could cause some problems, for example, if the backend device type
is file, some loop devices and blkback thread always lingers there forever
after guest is destroyed, and this causes failure of umounting repositories
unless rebooting the dom0.
This patch allows thread of every queue has the chance to get stopped.
Otherwise, only thread of queue previous to(including) first busy one get
stopped, blkthread of remaining queue will still run.  So stop all threads
properly and return -EBUSY if any queue has inflight I/O.
Signed-off-by: default avatarAnnie Li <annie.li@oracle.com>
Reviewed-by: default avatarHerbert van den Bergh <herbert.van.den.bergh@oracle.com>
Reviewed-by: default avatarBhavesh Davda <bhavesh.davda@oracle.com>
Reviewed-by: default avatarAdnan Misherfi <adnan.misherfi@oracle.com>
Acked-by: default avatarRoger Pau Monné <roger.pau@citrix.com>
Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
parent b15bd8cb
...@@ -244,6 +244,7 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif) ...@@ -244,6 +244,7 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif)
{ {
struct pending_req *req, *n; struct pending_req *req, *n;
unsigned int j, r; unsigned int j, r;
bool busy = false;
for (r = 0; r < blkif->nr_rings; r++) { for (r = 0; r < blkif->nr_rings; r++) {
struct xen_blkif_ring *ring = &blkif->rings[r]; struct xen_blkif_ring *ring = &blkif->rings[r];
...@@ -261,8 +262,10 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif) ...@@ -261,8 +262,10 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif)
* don't have any discard_io or other_io requests. So, checking * don't have any discard_io or other_io requests. So, checking
* for inflight IO is enough. * for inflight IO is enough.
*/ */
if (atomic_read(&ring->inflight) > 0) if (atomic_read(&ring->inflight) > 0) {
return -EBUSY; busy = true;
continue;
}
if (ring->irq) { if (ring->irq) {
unbind_from_irqhandler(ring->irq, ring); unbind_from_irqhandler(ring->irq, ring);
...@@ -300,6 +303,9 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif) ...@@ -300,6 +303,9 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif)
WARN_ON(i != (XEN_BLKIF_REQS_PER_PAGE * blkif->nr_ring_pages)); WARN_ON(i != (XEN_BLKIF_REQS_PER_PAGE * blkif->nr_ring_pages));
ring->active = false; ring->active = false;
} }
if (busy)
return -EBUSY;
blkif->nr_ring_pages = 0; blkif->nr_ring_pages = 0;
/* /*
* blkif->rings was allocated in connect_ring, so we should free it in * blkif->rings was allocated in connect_ring, so we should free it in
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment