qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] dma-helpers: dma_blk_io() cancel support
@ 2016-06-20 19:36 Stefan Hajnoczi
  2016-06-21  1:25 ` Fam Zheng
  2016-06-22 12:17 ` Stefan Hajnoczi
  0 siblings, 2 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2016-06-20 19:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Paolo Bonzini, John Snow, Stefan Hajnoczi

Attempting to cancel a dma_blk_io() request causes an abort(3):

  void bdrv_aio_cancel(BlockAIOCB *acb)
  {
      ...
      while (acb->refcnt > 1) {
          if (acb->aiocb_info->get_aio_context) {
              aio_poll(acb->aiocb_info->get_aio_context(acb), true);
          } else if (acb->bs) {
              aio_poll(bdrv_get_aio_context(acb->bs), true);
          } else {
              abort();
          }
      }
      ...
  }

This happens because DMAAIOCB->bs is NULL and
dma_aiocb_info.get_aio_context() is also NULL.

This patch trivially implements dma_aiocb_info.get_aio_context() by
fetching the DMAAIOCB->ctx field.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 dma-helpers.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/dma-helpers.c b/dma-helpers.c
index b521d84..9defc10 100644
--- a/dma-helpers.c
+++ b/dma-helpers.c
@@ -185,10 +185,17 @@ static void dma_aio_cancel(BlockAIOCB *acb)
     }
 }
 
+static AioContext *dma_get_aio_context(BlockAIOCB *acb)
+{
+    DMAAIOCB *dbs = container_of(acb, DMAAIOCB, common);
+
+    return dbs->ctx;
+}
 
 static const AIOCBInfo dma_aiocb_info = {
     .aiocb_size         = sizeof(DMAAIOCB),
     .cancel_async       = dma_aio_cancel,
+    .get_aio_context    = dma_get_aio_context,
 };
 
 BlockAIOCB *dma_blk_io(AioContext *ctx,
-- 
2.5.5

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

* Re: [Qemu-devel] [PATCH] dma-helpers: dma_blk_io() cancel support
  2016-06-20 19:36 [Qemu-devel] [PATCH] dma-helpers: dma_blk_io() cancel support Stefan Hajnoczi
@ 2016-06-21  1:25 ` Fam Zheng
  2016-06-22 12:17 ` Stefan Hajnoczi
  1 sibling, 0 replies; 3+ messages in thread
From: Fam Zheng @ 2016-06-21  1:25 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: qemu-devel, Kevin Wolf, Paolo Bonzini, John Snow

On Mon, 06/20 20:36, Stefan Hajnoczi wrote:
> Attempting to cancel a dma_blk_io() request causes an abort(3):
> 
>   void bdrv_aio_cancel(BlockAIOCB *acb)
>   {
>       ...
>       while (acb->refcnt > 1) {
>           if (acb->aiocb_info->get_aio_context) {
>               aio_poll(acb->aiocb_info->get_aio_context(acb), true);
>           } else if (acb->bs) {
>               aio_poll(bdrv_get_aio_context(acb->bs), true);
>           } else {
>               abort();
>           }
>       }
>       ...
>   }
> 
> This happens because DMAAIOCB->bs is NULL and
> dma_aiocb_info.get_aio_context() is also NULL.
> 
> This patch trivially implements dma_aiocb_info.get_aio_context() by
> fetching the DMAAIOCB->ctx field.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  dma-helpers.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/dma-helpers.c b/dma-helpers.c
> index b521d84..9defc10 100644
> --- a/dma-helpers.c
> +++ b/dma-helpers.c
> @@ -185,10 +185,17 @@ static void dma_aio_cancel(BlockAIOCB *acb)
>      }
>  }
>  
> +static AioContext *dma_get_aio_context(BlockAIOCB *acb)
> +{
> +    DMAAIOCB *dbs = container_of(acb, DMAAIOCB, common);
> +
> +    return dbs->ctx;
> +}
>  
>  static const AIOCBInfo dma_aiocb_info = {
>      .aiocb_size         = sizeof(DMAAIOCB),
>      .cancel_async       = dma_aio_cancel,
> +    .get_aio_context    = dma_get_aio_context,
>  };
>  
>  BlockAIOCB *dma_blk_io(AioContext *ctx,
> -- 
> 2.5.5
> 
> 

Reviewed-by: Fam Zheng <famz@redhat.com>

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

* Re: [Qemu-devel] [PATCH] dma-helpers: dma_blk_io() cancel support
  2016-06-20 19:36 [Qemu-devel] [PATCH] dma-helpers: dma_blk_io() cancel support Stefan Hajnoczi
  2016-06-21  1:25 ` Fam Zheng
@ 2016-06-22 12:17 ` Stefan Hajnoczi
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2016-06-22 12:17 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: qemu-devel, Kevin Wolf, Paolo Bonzini, John Snow

[-- Attachment #1: Type: text/plain, Size: 1064 bytes --]

On Mon, Jun 20, 2016 at 08:36:57PM +0100, Stefan Hajnoczi wrote:
> Attempting to cancel a dma_blk_io() request causes an abort(3):
> 
>   void bdrv_aio_cancel(BlockAIOCB *acb)
>   {
>       ...
>       while (acb->refcnt > 1) {
>           if (acb->aiocb_info->get_aio_context) {
>               aio_poll(acb->aiocb_info->get_aio_context(acb), true);
>           } else if (acb->bs) {
>               aio_poll(bdrv_get_aio_context(acb->bs), true);
>           } else {
>               abort();
>           }
>       }
>       ...
>   }
> 
> This happens because DMAAIOCB->bs is NULL and
> dma_aiocb_info.get_aio_context() is also NULL.
> 
> This patch trivially implements dma_aiocb_info.get_aio_context() by
> fetching the DMAAIOCB->ctx field.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  dma-helpers.c | 7 +++++++
>  1 file changed, 7 insertions(+)

dma-helpers.c has no maintainer, I'll take this through my tree.

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

end of thread, other threads:[~2016-06-22 12:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-20 19:36 [Qemu-devel] [PATCH] dma-helpers: dma_blk_io() cancel support Stefan Hajnoczi
2016-06-21  1:25 ` Fam Zheng
2016-06-22 12:17 ` Stefan Hajnoczi

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