diff mbox series

[for-7.2,v2,2/6] hw/nvme: fix cancellation of format operations

Message ID 20221110070523.36290-3-its@irrelevant.dk (mailing list archive)
State New, archived
Headers show
Series hw/nvme: misc fixes | expand

Commit Message

Klaus Jensen Nov. 10, 2022, 7:05 a.m. UTC
From: Klaus Jensen <k.jensen@samsung.com>

Cancelling a format operation neglects to set iocb->ret as well as
clearing the iocb->aiocb after cancelling the underlying aiocb.

Fix this.

Fixes: 3bcf26d3d619 ("hw/nvme: reimplement format nvm to allow cancellation")
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
 hw/nvme/ctrl.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Philippe Mathieu-Daudé Nov. 10, 2022, 9:53 a.m. UTC | #1
On 10/11/22 08:05, Klaus Jensen wrote:
> From: Klaus Jensen <k.jensen@samsung.com>
> 
> Cancelling a format operation neglects to set iocb->ret as well as
> clearing the iocb->aiocb after cancelling the underlying aiocb.
> 
> Fix this.
> 
> Fixes: 3bcf26d3d619 ("hw/nvme: reimplement format nvm to allow cancellation")
> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
> ---
>   hw/nvme/ctrl.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
> index 918af03d32be..819c02067191 100644
> --- a/hw/nvme/ctrl.c
> +++ b/hw/nvme/ctrl.c
> @@ -5762,8 +5762,11 @@ static void nvme_format_cancel(BlockAIOCB *aiocb)
>   {
>       NvmeFormatAIOCB *iocb = container_of(aiocb, NvmeFormatAIOCB, common);
>   
> +    iocb->ret = -ECANCELED;
> +
>       if (iocb->aiocb) {
>           blk_aio_cancel_async(iocb->aiocb);
> +        iocb->aiocb = NULL;
>       }
>   }
>   

What about nvme_flush_cancel()?
Philippe Mathieu-Daudé Nov. 10, 2022, 9:54 a.m. UTC | #2
On 10/11/22 10:53, Philippe Mathieu-Daudé wrote:
> On 10/11/22 08:05, Klaus Jensen wrote:
>> From: Klaus Jensen <k.jensen@samsung.com>
>>
>> Cancelling a format operation neglects to set iocb->ret as well as
>> clearing the iocb->aiocb after cancelling the underlying aiocb.
>>
>> Fix this.
>>
>> Fixes: 3bcf26d3d619 ("hw/nvme: reimplement format nvm to allow 
>> cancellation")
>> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
>> ---
>>   hw/nvme/ctrl.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
>> index 918af03d32be..819c02067191 100644
>> --- a/hw/nvme/ctrl.c
>> +++ b/hw/nvme/ctrl.c
>> @@ -5762,8 +5762,11 @@ static void nvme_format_cancel(BlockAIOCB *aiocb)
>>   {
>>       NvmeFormatAIOCB *iocb = container_of(aiocb, NvmeFormatAIOCB, 
>> common);
>> +    iocb->ret = -ECANCELED;
>> +
>>       if (iocb->aiocb) {
>>           blk_aio_cancel_async(iocb->aiocb);
>> +        iocb->aiocb = NULL;
>>       }
>>   }
> 
> What about nvme_flush_cancel()?

Ah, this is what the next patch fixes...
diff mbox series

Patch

diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index 918af03d32be..819c02067191 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -5762,8 +5762,11 @@  static void nvme_format_cancel(BlockAIOCB *aiocb)
 {
     NvmeFormatAIOCB *iocb = container_of(aiocb, NvmeFormatAIOCB, common);
 
+    iocb->ret = -ECANCELED;
+
     if (iocb->aiocb) {
         blk_aio_cancel_async(iocb->aiocb);
+        iocb->aiocb = NULL;
     }
 }