mirror of
https://github.com/qemu/qemu.git
synced 2024-11-23 19:03:38 +08:00
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
This commit is contained in:
parent
6bbff9a0b4
commit
c07a9008ac
20
block.c
20
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
|
||||
|
Loading…
Reference in New Issue
Block a user