From 6bf7463615752934d7221e5be9820d9da45ab2de Mon Sep 17 00:00:00 2001 From: Igor Druzhinin Date: Tue, 6 Nov 2018 12:16:55 +0000 Subject: [PATCH] nvme: call blk_drain in NVMe reset code to avoid lockups When blk_flush called in NVMe reset path S/C queues are already freed which means that re-entering AIO handling loop having some IO requests unfinished will lockup or crash as their SG structures being potentially reused. Call blk_drain before freeing the queues to avoid this nasty scenario. Signed-off-by: Igor Druzhinin Acked-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- hw/block/nvme.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index d0226e7fdc..28d284346d 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -797,6 +797,8 @@ static void nvme_clear_ctrl(NvmeCtrl *n) { int i; + blk_drain(n->conf.blk); + for (i = 0; i < n->num_queues; i++) { if (n->sq[i] != NULL) { nvme_free_sq(n->sq[i], n);