Skip to contentSkip to conversation

block/nvme: call blk_drain in NVMe reset code to avoid lockups

PATCH Applied Igor Druzhinin 3 participants 5 messages Nov 6, 2018 – Nov 22, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block/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.

---
 hw/block/nvme.c | 2 ++
 1 file changed, 2 insertions(+)
hw/block/nvme.c +2 -0
index fc7dacb..cdf836e 100644
@@ -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);
Signature · 1 line
2.7.4
#1 lore raw
Quoted 17 lines · Igor Druzhinin

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.

---
 hw/block/nvme.c | 2 ++
 1 file changed, 2 insertions(+)
hw/block/nvme.c +0 -0
index fc7dacb..cdf836e 100644

hw/block/nvme.c static void nvme_clear_ctrl(NvmeCtrl *n) · line 804

Quoted 8 lines
hw/block/nvme.c +2 -0
@@ -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);

ping?

#2 lore raw
Quoted 20 lines · Igor Druzhinin
Quoted 19 lines · Igor Druzhinin

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.

---
 hw/block/nvme.c | 2 ++
 1 file changed, 2 insertions(+)
hw/block/nvme.c +0 -0
index fc7dacb..cdf836e 100644
@@ -797,6 +797,8 @@ static void nvme_clear_ctrl(NvmeCtrl *n)
 {
     int i;
 
Quoted 9 lines

hw/block/nvme.c static void nvme_clear_ctrl(NvmeCtrl *n) · line 804

Quoted 6 lines
hw/block/nvme.c +2 -0
+    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);

ping?

CC Paolo Bonzini <[email protected]>
#3 lore raw
Quoted 31 lines · Igor Druzhinin
Quoted 20 lines · Igor Druzhinin
Quoted 19 lines · Igor Druzhinin

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.

---
 hw/block/nvme.c | 2 ++
 1 file changed, 2 insertions(+)
hw/block/nvme.c +0 -0
index fc7dacb..cdf836e 100644
@@ -797,6 +797,8 @@ static void nvme_clear_ctrl(NvmeCtrl *n)
 {
     int i;
 
Quoted 9 lines

hw/block/nvme.c static void nvme_clear_ctrl(NvmeCtrl *n) · line 804

Quoted 6 lines
hw/block/nvme.c +2 -0
+    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);

ping?

Quoted 2 lines
CC Paolo Bonzini <[email protected]>

Looks good to me. Kevin, Max?

Paolo

Applied
#4 lore raw
In reply to Igor Druzhinin

Am 06.11.2018 um 13:16 hat Igor Druzhinin geschrieben:

Quoted 7 lines

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.

Thanks, applied to the block branch.

Kevin