block/nvme: call blk_drain in NVMe reset code to avoid lockups
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
@@ -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
Quoted 17 lines · Igor Druzhinin
When
blk_flushcalled 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. Callblk_drainbefore freeing the queues to avoid this nasty scenario.Signed-off-by Igor Druzhinin <[email protected]>--- hw/block/nvme.c | 2 ++ 1 file changed, 2 insertions(+)hw/block/nvme.c +0
-0
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?
Quoted 20 lines · Igor Druzhinin
Quoted 19 lines · Igor Druzhinin
When
blk_flushcalled 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. Callblk_drainbefore freeing the queues to avoid this nasty scenario.Signed-off-by Igor Druzhinin <[email protected]>--- hw/block/nvme.c | 2 ++ 1 file changed, 2 insertions(+)hw/block/nvme.c +0
-0@@ -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 31 lines · Igor Druzhinin
Quoted 20 lines · Igor Druzhinin
Quoted 19 lines · Igor Druzhinin
When
blk_flushcalled 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. Callblk_drainbefore freeing the queues to avoid this nasty scenario.Signed-off-by Igor Druzhinin <[email protected]>--- hw/block/nvme.c | 2 ++ 1 file changed, 2 insertions(+)hw/block/nvme.c +0
-0@@ -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
Kevin Wolf
AppliedAm 06.11.2018 um 13:16 hat Igor Druzhinin geschrieben:
Quoted 7 lines
When
blk_flushcalled 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. Callblk_drainbefore freeing the queues to avoid this nasty scenario.Signed-off-by Igor Druzhinin <[email protected]>
Thanks, applied to the block branch.
Kevin