From c16b5a2ca0b186de618654a576bdad9cdd2d1ab2 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 25 May 2009 12:37:32 +0200 Subject: fully split aio_pool from BlockDriver Now that we have a separate aio pool structure we can remove those aio pool details from BlockDriver. Every driver supporting AIO now needs to declare a static AIOPool with the aiocb size and the cancellation method. This cleans up the current code considerably and will make it cleaner and more obvious to support two different aio implementations behind a single BlockDriver. Signed-off-by: Christoph Hellwig Signed-off-by: Anthony Liguori --- dma-helpers.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'dma-helpers.c') diff --git a/dma-helpers.c b/dma-helpers.c index f9eb2240b2..712ed897f3 100644 --- a/dma-helpers.c +++ b/dma-helpers.c @@ -10,8 +10,6 @@ #include "dma.h" #include "block_int.h" -static AIOPool dma_aio_pool; - void qemu_sglist_init(QEMUSGList *qsg, int alloc_hint) { qsg->sg = qemu_malloc(alloc_hint * sizeof(ScatterGatherEntry)); @@ -132,12 +130,26 @@ static void dma_bdrv_cb(void *opaque, int ret) } } +static void dma_aio_cancel(BlockDriverAIOCB *acb) +{ + DMAAIOCB *dbs = container_of(acb, DMAAIOCB, common); + + if (dbs->acb) { + bdrv_aio_cancel(dbs->acb); + } +} + +static AIOPool dma_aio_pool = { + .aiocb_size = sizeof(DMAAIOCB), + .cancel = dma_aio_cancel, +}; + static BlockDriverAIOCB *dma_bdrv_io( BlockDriverState *bs, QEMUSGList *sg, uint64_t sector_num, BlockDriverCompletionFunc *cb, void *opaque, int is_write) { - DMAAIOCB *dbs = qemu_aio_get_pool(&dma_aio_pool, bs, cb, opaque); + DMAAIOCB *dbs = qemu_aio_get(&dma_aio_pool, bs, cb, opaque); dbs->acb = NULL; dbs->bs = bs; @@ -170,17 +182,3 @@ BlockDriverAIOCB *dma_bdrv_write(BlockDriverState *bs, { return dma_bdrv_io(bs, sg, sector, cb, opaque, 1); } - -static void dma_aio_cancel(BlockDriverAIOCB *acb) -{ - DMAAIOCB *dbs = container_of(acb, DMAAIOCB, common); - - if (dbs->acb) { - bdrv_aio_cancel(dbs->acb); - } -} - -void dma_helper_init(void) -{ - aio_pool_init(&dma_aio_pool, sizeof(DMAAIOCB), dma_aio_cancel); -} -- cgit v1.2.1