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 --- block/qcow2.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'block/qcow2.c') diff --git a/block/qcow2.c b/block/qcow2.c index 619b923..d1611d1 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1246,6 +1246,19 @@ typedef struct QCowAIOCB { QCowL2Meta l2meta; } QCowAIOCB; +static void qcow_aio_cancel(BlockDriverAIOCB *blockacb) +{ + QCowAIOCB *acb = (QCowAIOCB *)blockacb; + if (acb->hd_aiocb) + bdrv_aio_cancel(acb->hd_aiocb); + qemu_aio_release(acb); +} + +static AIOPool qcow_aio_pool = { + .aiocb_size = sizeof(QCowAIOCB), + .cancel = qcow_aio_cancel, +}; + static void qcow_aio_read_cb(void *opaque, int ret); static void qcow_aio_read_bh(void *opaque) { @@ -1375,7 +1388,7 @@ static QCowAIOCB *qcow_aio_setup(BlockDriverState *bs, { QCowAIOCB *acb; - acb = qemu_aio_get(bs, cb, opaque); + acb = qemu_aio_get(&qcow_aio_pool, bs, cb, opaque); if (!acb) return NULL; acb->hd_aiocb = NULL; @@ -1498,14 +1511,6 @@ static BlockDriverAIOCB *qcow_aio_writev(BlockDriverState *bs, return &acb->common; } -static void qcow_aio_cancel(BlockDriverAIOCB *blockacb) -{ - QCowAIOCB *acb = (QCowAIOCB *)blockacb; - if (acb->hd_aiocb) - bdrv_aio_cancel(acb->hd_aiocb); - qemu_aio_release(acb); -} - static void qcow_close(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; @@ -2998,8 +3003,6 @@ static BlockDriver bdrv_qcow2 = { .bdrv_aio_readv = qcow_aio_readv, .bdrv_aio_writev = qcow_aio_writev, - .bdrv_aio_cancel = qcow_aio_cancel, - .aiocb_size = sizeof(QCowAIOCB), .bdrv_write_compressed = qcow_write_compressed, .bdrv_snapshot_create = qcow_snapshot_create, -- cgit v1.1