Commit 3fb94d56c6adc96ffc4a81b58c752cc4ccfae39c
1 parent
6512a2a7
Use vectored aiocb storage to store vector translation state (Avi Kivity)
Now that we have a dedicated acb pool for vector translation acbs, we can store the vector translation state in the acbs instead of in an external structure. 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@6873 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
14 additions
and
15 deletions
block.c
| ... | ... | @@ -1255,31 +1255,32 @@ char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn) |
| 1255 | 1255 | /**************************************************************/ |
| 1256 | 1256 | /* async I/Os */ |
| 1257 | 1257 | |
| 1258 | -typedef struct VectorTranslationState { | |
| 1258 | +typedef struct VectorTranslationAIOCB { | |
| 1259 | + BlockDriverAIOCB common; | |
| 1259 | 1260 | QEMUIOVector *iov; |
| 1260 | 1261 | uint8_t *bounce; |
| 1261 | 1262 | int is_write; |
| 1262 | 1263 | BlockDriverAIOCB *aiocb; |
| 1263 | - BlockDriverAIOCB *this_aiocb; | |
| 1264 | -} VectorTranslationState; | |
| 1264 | +} VectorTranslationAIOCB; | |
| 1265 | 1265 | |
| 1266 | -static void bdrv_aio_cancel_vector(BlockDriverAIOCB *acb) | |
| 1266 | +static void bdrv_aio_cancel_vector(BlockDriverAIOCB *_acb) | |
| 1267 | 1267 | { |
| 1268 | - VectorTranslationState *s = acb->opaque; | |
| 1268 | + VectorTranslationAIOCB *acb | |
| 1269 | + = container_of(_acb, VectorTranslationAIOCB, common); | |
| 1269 | 1270 | |
| 1270 | - bdrv_aio_cancel(s->aiocb); | |
| 1271 | + bdrv_aio_cancel(acb->aiocb); | |
| 1271 | 1272 | } |
| 1272 | 1273 | |
| 1273 | 1274 | static void bdrv_aio_rw_vector_cb(void *opaque, int ret) |
| 1274 | 1275 | { |
| 1275 | - VectorTranslationState *s = opaque; | |
| 1276 | + VectorTranslationAIOCB *s = (VectorTranslationAIOCB *)opaque; | |
| 1276 | 1277 | |
| 1277 | 1278 | if (!s->is_write) { |
| 1278 | 1279 | qemu_iovec_from_buffer(s->iov, s->bounce, s->iov->size); |
| 1279 | 1280 | } |
| 1280 | 1281 | qemu_vfree(s->bounce); |
| 1281 | - s->this_aiocb->cb(s->this_aiocb->opaque, ret); | |
| 1282 | - qemu_aio_release(s->this_aiocb); | |
| 1282 | + s->common.cb(s->common.opaque, ret); | |
| 1283 | + qemu_aio_release(s); | |
| 1283 | 1284 | } |
| 1284 | 1285 | |
| 1285 | 1286 | static BlockDriverAIOCB *bdrv_aio_rw_vector(BlockDriverState *bs, |
| ... | ... | @@ -1291,11 +1292,9 @@ static BlockDriverAIOCB *bdrv_aio_rw_vector(BlockDriverState *bs, |
| 1291 | 1292 | int is_write) |
| 1292 | 1293 | |
| 1293 | 1294 | { |
| 1294 | - VectorTranslationState *s = qemu_mallocz(sizeof(*s)); | |
| 1295 | - BlockDriverAIOCB *aiocb = qemu_aio_get_pool(&vectored_aio_pool, bs, | |
| 1296 | - cb, opaque); | |
| 1295 | + VectorTranslationAIOCB *s = qemu_aio_get_pool(&vectored_aio_pool, bs, | |
| 1296 | + cb, opaque); | |
| 1297 | 1297 | |
| 1298 | - s->this_aiocb = aiocb; | |
| 1299 | 1298 | s->iov = iov; |
| 1300 | 1299 | s->bounce = qemu_memalign(512, nb_sectors * 512); |
| 1301 | 1300 | s->is_write = is_write; |
| ... | ... | @@ -1307,7 +1306,7 @@ static BlockDriverAIOCB *bdrv_aio_rw_vector(BlockDriverState *bs, |
| 1307 | 1306 | s->aiocb = bdrv_aio_read(bs, sector_num, s->bounce, nb_sectors, |
| 1308 | 1307 | bdrv_aio_rw_vector_cb, s); |
| 1309 | 1308 | } |
| 1310 | - return aiocb; | |
| 1309 | + return &s->common; | |
| 1311 | 1310 | } |
| 1312 | 1311 | |
| 1313 | 1312 | BlockDriverAIOCB *bdrv_aio_readv(BlockDriverState *bs, int64_t sector_num, |
| ... | ... | @@ -1483,7 +1482,7 @@ static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num, |
| 1483 | 1482 | |
| 1484 | 1483 | void bdrv_init(void) |
| 1485 | 1484 | { |
| 1486 | - aio_pool_init(&vectored_aio_pool, sizeof(BlockDriverAIOCB), | |
| 1485 | + aio_pool_init(&vectored_aio_pool, sizeof(VectorTranslationAIOCB), | |
| 1487 | 1486 | bdrv_aio_cancel_vector); |
| 1488 | 1487 | |
| 1489 | 1488 | bdrv_register(&bdrv_raw); | ... | ... |