In case the virtqueue is flagged as broken, IO errors are triggered for current request queue entries. Signed-off-by: Heinz Graalfs <graalfs@xxxxxxxxxxxxxxxxxx> --- drivers/block/virtio_blk.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 01b5d3a..8eb91be 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -875,6 +875,20 @@ out: return err; } +static void virtblk_flush_request_queue(struct request_queue *q) +{ + spinlock_t *lock = q->queue_lock; + struct request *req; + + if (!q) + return; + + spin_lock_irq(lock); + while ((req = blk_fetch_request(q))) + __blk_end_request_all(req, -EIO); + spin_unlock_irq(lock); +} + static void virtblk_remove(struct virtio_device *vdev) { struct virtio_blk *vblk = vdev->priv; @@ -890,6 +904,7 @@ static void virtblk_remove(struct virtio_device *vdev) virtqueue_notify(vblk->vq); if (virtqueue_is_broken(vblk->vq)) { queue_broken = true; + virtblk_flush_request_queue(vblk->disk->queue); blk_cleanup_queue(vblk->disk->queue); del_gendisk(vblk->disk); } else { -- 1.8.3.1 _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/virtualization