From: Igor Druzhinin Date: Tue, 6 Nov 2018 12:16:55 +0000 (+0000) Subject: nvme: call blk_drain in NVMe reset code to avoid lockups X-Git-Tag: v3.1.0-rc3~13^2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6bf7463615752934d7221e5be9820d9da45ab2de;p=thirdparty%2Fqemu.git 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 --- diff --git a/hw/block/nvme.c b/hw/block/nvme.c index d0226e7fdcd..28d284346dd 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);