qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block/nvme: call blk_drain in NVMe reset code to avoid lockups
@ 2018-11-06 12:16 Igor Druzhinin
  2018-11-14 17:42 ` Igor Druzhinin
  2018-11-22 14:32 ` Kevin Wolf
  0 siblings, 2 replies; 5+ messages in thread
From: Igor Druzhinin @ 2018-11-06 12:16 UTC (permalink / raw)
  To: keith.busch, kwolf, mreitz; +Cc: qemu-devel, qemu-block, 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.

Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
---
 hw/block/nvme.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index fc7dacb..cdf836e 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);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] block/nvme: call blk_drain in NVMe reset code to avoid lockups
  2018-11-06 12:16 [Qemu-devel] [PATCH] block/nvme: call blk_drain in NVMe reset code to avoid lockups Igor Druzhinin
@ 2018-11-14 17:42 ` Igor Druzhinin
  2018-11-20 17:31   ` Igor Druzhinin
  2018-11-22 14:32 ` Kevin Wolf
  1 sibling, 1 reply; 5+ messages in thread
From: Igor Druzhinin @ 2018-11-14 17:42 UTC (permalink / raw)
  To: keith.busch, kwolf, mreitz; +Cc: qemu-devel, qemu-block

On 06/11/2018 12:16, Igor Druzhinin wrote:
> 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>
> ---
>  hw/block/nvme.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> index fc7dacb..cdf836e 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);
> 

ping?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] block/nvme: call blk_drain in NVMe reset code to avoid lockups
  2018-11-14 17:42 ` Igor Druzhinin
@ 2018-11-20 17:31   ` Igor Druzhinin
  2018-11-20 17:52     ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Igor Druzhinin @ 2018-11-20 17:31 UTC (permalink / raw)
  To: keith.busch, kwolf, mreitz; +Cc: qemu-devel, qemu-block, pbonzini

On 14/11/2018 17:42, Igor Druzhinin wrote:
> On 06/11/2018 12:16, Igor Druzhinin wrote:
>> 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>
>> ---
>>  hw/block/nvme.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
>> index fc7dacb..cdf836e 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);
>>
> 
> ping?
> 

CC: Paolo Bonzini <pbonzini@redhat.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] block/nvme: call blk_drain in NVMe reset code to avoid lockups
  2018-11-20 17:31   ` Igor Druzhinin
@ 2018-11-20 17:52     ` Paolo Bonzini
  0 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2018-11-20 17:52 UTC (permalink / raw)
  To: Igor Druzhinin, keith.busch, kwolf, mreitz; +Cc: qemu-devel, qemu-block

On 20/11/18 18:31, Igor Druzhinin wrote:
> On 14/11/2018 17:42, Igor Druzhinin wrote:
>> On 06/11/2018 12:16, Igor Druzhinin wrote:
>>> 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>
>>> ---
>>>  hw/block/nvme.c | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
>>> index fc7dacb..cdf836e 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);
>>>
>>
>> ping?
>>
> 
> CC: Paolo Bonzini <pbonzini@redhat.com>
> 

Looks good to me.  Kevin, Max?

Paolo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] block/nvme: call blk_drain in NVMe reset code to avoid lockups
  2018-11-06 12:16 [Qemu-devel] [PATCH] block/nvme: call blk_drain in NVMe reset code to avoid lockups Igor Druzhinin
  2018-11-14 17:42 ` Igor Druzhinin
@ 2018-11-22 14:32 ` Kevin Wolf
  1 sibling, 0 replies; 5+ messages in thread
From: Kevin Wolf @ 2018-11-22 14:32 UTC (permalink / raw)
  To: Igor Druzhinin; +Cc: keith.busch, mreitz, qemu-devel, qemu-block

Am 06.11.2018 um 13:16 hat Igor Druzhinin geschrieben:
> 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>

Thanks, applied to the block branch.

Kevin

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-11-22 14:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-06 12:16 [Qemu-devel] [PATCH] block/nvme: call blk_drain in NVMe reset code to avoid lockups Igor Druzhinin
2018-11-14 17:42 ` Igor Druzhinin
2018-11-20 17:31   ` Igor Druzhinin
2018-11-20 17:52     ` Paolo Bonzini
2018-11-22 14:32 ` Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).