diff mbox series

[PULL,09/13] nvme: call blk_drain in NVMe reset code to avoid lockups

Message ID 20181122165417.23894-10-kwolf@redhat.com
State New
Headers show
Series [PULL,01/13] iotests: Replace time.clock() with Timeout | expand

Commit Message

Kevin Wolf Nov. 22, 2018, 4:54 p.m. UTC
From: Igor Druzhinin <igor.druzhinin@citrix.com>

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 <igor.druzhinin@citrix.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 hw/block/nvme.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

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);