aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--block.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/block.c b/block.c
index ad16ee4935..fe83585582 100644
--- a/block.c
+++ b/block.c
@@ -47,6 +47,8 @@
#define SECTOR_BITS 9
#define SECTOR_SIZE (1 << SECTOR_BITS)
+static AIOPool vectored_aio_pool;
+
typedef struct BlockDriverAIOCBSync {
BlockDriverAIOCB common;
QEMUBH *bh;
@@ -1261,6 +1263,13 @@ typedef struct VectorTranslationState {
BlockDriverAIOCB *this_aiocb;
} VectorTranslationState;
+static void bdrv_aio_cancel_vector(BlockDriverAIOCB *acb)
+{
+ VectorTranslationState *s = acb->opaque;
+
+ bdrv_aio_cancel(s->aiocb);
+}
+
static void bdrv_aio_rw_vector_cb(void *opaque, int ret)
{
VectorTranslationState *s = opaque;
@@ -1283,7 +1292,8 @@ static BlockDriverAIOCB *bdrv_aio_rw_vector(BlockDriverState *bs,
{
VectorTranslationState *s = qemu_mallocz(sizeof(*s));
- BlockDriverAIOCB *aiocb = qemu_aio_get(bs, cb, opaque);
+ BlockDriverAIOCB *aiocb = qemu_aio_get_pool(&vectored_aio_pool, bs,
+ cb, opaque);
s->this_aiocb = aiocb;
s->iov = iov;
@@ -1372,11 +1382,6 @@ BlockDriverAIOCB *bdrv_aio_write(BlockDriverState *bs, int64_t sector_num,
void bdrv_aio_cancel(BlockDriverAIOCB *acb)
{
- if (acb->cb == bdrv_aio_rw_vector_cb) {
- VectorTranslationState *s = acb->opaque;
- acb = s->aiocb;
- }
-
acb->pool->cancel(acb);
}
@@ -1478,6 +1483,9 @@ static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num,
void bdrv_init(void)
{
+ aio_pool_init(&vectored_aio_pool, sizeof(BlockDriverAIOCB),
+ bdrv_aio_cancel_vector);
+
bdrv_register(&bdrv_raw);
bdrv_register(&bdrv_host_device);
#ifndef _WIN32