dma-helpers: dma_blk_io() cancel support
PATCH 1/1 dma-helpers: dma_blk_io() cancel support
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 anddma_aiocb_info.get_aio_context() is also NULL.
This patch trivially implements dma_aiocb_info.get_aio_context() by fetching the DMAAIOCB->ctx field.
--- dma-helpers.c | 7 +++++++ 1 file changed, 7 insertions(+)
dma-helpers.c +7 -0
@@ -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,
Signature · 1 line
2.5.5
Quoted 54 lines · 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->bsis NULL anddma_aiocb_info.get_aio_context()is also NULL.This patch trivially implements
dma_aiocb_info.get_aio_context()by fetching theDMAAIOCB->ctxfield.Signed-off-by Stefan Hajnoczi <[email protected]>--- dma-helpers.c | 7 +++++++ 1 file changed, 7 insertions(+)dma-helpers.c +7
-0@@ -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,Signature · 1 line
2.5.5
Stefan Hajnoczi
AppliedQuoted 20 lines · 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->bsis NULL anddma_aiocb_info.get_aio_context()is also NULL.
Quoted 7 lines
This patch trivially implements
dma_aiocb_info.get_aio_context()by fetching theDMAAIOCB->ctxfield.Signed-off-by Stefan Hajnoczi <[email protected]>--- 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