xen-blkback: stop blkback thread of every queue in xen_blkif_disconnect
authorAnnie Li <annie.li@oracle.com>
Thu, 24 Aug 2017 21:25:59 +0000 (17:25 -0400)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Fri, 25 Aug 2017 19:59:34 +0000 (15:59 -0400)
commitdc52d783d68c07a68743d42ef2f9a6f9a6d80fb1
tree577efc33ae474312ea89cfe27fbb6ffca9d10666
parentb15bd8cb37598afb2963f7eb9e2de468d2d60a2f
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: Annie Li <annie.li@oracle.com>
Reviewed-by: Herbert van den Bergh <herbert.van.den.bergh@oracle.com>
Reviewed-by: Bhavesh Davda <bhavesh.davda@oracle.com>
Reviewed-by: Adnan Misherfi <adnan.misherfi@oracle.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
drivers/block/xen-blkback/xenbus.c