aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-03-20 18:26:03 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-03-20 18:26:03 +0000
commitc07a9008ac6985cd5a15909c2b9977d982defc12 (patch)
tree78ee87d63fa8d81092cc0de36d27dee90f6de913 /block.c
parent6bbff9a0b495918309074ac60375be5f9dc868b3 (diff)
Convert vectored aio emulation to use a dedicated pool (Avi Kivity)
This allows us to remove a hack in the vectored aio cancellation code. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6871 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'block.c')
-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