Commit c07a9008ac6985cd5a15909c2b9977d982defc12

Authored by aliguori
1 parent 6bbff9a0

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
Showing 1 changed file with 14 additions and 6 deletions
... ... @@ -47,6 +47,8 @@
47 47 #define SECTOR_BITS 9
48 48 #define SECTOR_SIZE (1 << SECTOR_BITS)
49 49  
  50 +static AIOPool vectored_aio_pool;
  51 +
50 52 typedef struct BlockDriverAIOCBSync {
51 53 BlockDriverAIOCB common;
52 54 QEMUBH *bh;
... ... @@ -1261,6 +1263,13 @@ typedef struct VectorTranslationState {
1261 1263 BlockDriverAIOCB *this_aiocb;
1262 1264 } VectorTranslationState;
1263 1265  
  1266 +static void bdrv_aio_cancel_vector(BlockDriverAIOCB *acb)
  1267 +{
  1268 + VectorTranslationState *s = acb->opaque;
  1269 +
  1270 + bdrv_aio_cancel(s->aiocb);
  1271 +}
  1272 +
1264 1273 static void bdrv_aio_rw_vector_cb(void *opaque, int ret)
1265 1274 {
1266 1275 VectorTranslationState *s = opaque;
... ... @@ -1283,7 +1292,8 @@ static BlockDriverAIOCB *bdrv_aio_rw_vector(BlockDriverState *bs,
1283 1292  
1284 1293 {
1285 1294 VectorTranslationState *s = qemu_mallocz(sizeof(*s));
1286   - BlockDriverAIOCB *aiocb = qemu_aio_get(bs, cb, opaque);
  1295 + BlockDriverAIOCB *aiocb = qemu_aio_get_pool(&vectored_aio_pool, bs,
  1296 + cb, opaque);
1287 1297  
1288 1298 s->this_aiocb = aiocb;
1289 1299 s->iov = iov;
... ... @@ -1372,11 +1382,6 @@ BlockDriverAIOCB *bdrv_aio_write(BlockDriverState *bs, int64_t sector_num,
1372 1382  
1373 1383 void bdrv_aio_cancel(BlockDriverAIOCB *acb)
1374 1384 {
1375   - if (acb->cb == bdrv_aio_rw_vector_cb) {
1376   - VectorTranslationState *s = acb->opaque;
1377   - acb = s->aiocb;
1378   - }
1379   -
1380 1385 acb->pool->cancel(acb);
1381 1386 }
1382 1387  
... ... @@ -1478,6 +1483,9 @@ static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num,
1478 1483  
1479 1484 void bdrv_init(void)
1480 1485 {
  1486 + aio_pool_init(&vectored_aio_pool, sizeof(BlockDriverAIOCB),
  1487 + bdrv_aio_cancel_vector);
  1488 +
1481 1489 bdrv_register(&bdrv_raw);
1482 1490 bdrv_register(&bdrv_host_device);
1483 1491 #ifndef _WIN32
... ...