dma: Convert dma_aiocb_info.cancel to .cancel_async

Just forward the request to bdrv_aio_cancel_async.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Fam Zheng 2014-09-11 13:41:14 +08:00 committed by Stefan Hajnoczi
parent 771b64daf9
commit 9bb9da46d6

View File

@ -73,7 +73,6 @@ typedef struct {
QEMUSGList *sg; QEMUSGList *sg;
uint64_t sector_num; uint64_t sector_num;
DMADirection dir; DMADirection dir;
bool in_cancel;
int sg_cur_index; int sg_cur_index;
dma_addr_t sg_cur_byte; dma_addr_t sg_cur_byte;
QEMUIOVector iov; QEMUIOVector iov;
@ -125,12 +124,7 @@ static void dma_complete(DMAAIOCB *dbs, int ret)
qemu_bh_delete(dbs->bh); qemu_bh_delete(dbs->bh);
dbs->bh = NULL; dbs->bh = NULL;
} }
if (!dbs->in_cancel) {
/* Requests may complete while dma_aio_cancel is in progress. In
* this case, the AIOCB should not be released because it is still
* referenced by dma_aio_cancel. */
qemu_aio_release(dbs); qemu_aio_release(dbs);
}
} }
static void dma_bdrv_cb(void *opaque, int ret) static void dma_bdrv_cb(void *opaque, int ret)
@ -186,19 +180,14 @@ static void dma_aio_cancel(BlockDriverAIOCB *acb)
trace_dma_aio_cancel(dbs); trace_dma_aio_cancel(dbs);
if (dbs->acb) { if (dbs->acb) {
BlockDriverAIOCB *acb = dbs->acb; bdrv_aio_cancel_async(dbs->acb);
dbs->acb = NULL;
dbs->in_cancel = true;
bdrv_aio_cancel(acb);
dbs->in_cancel = false;
} }
dbs->common.cb = NULL;
dma_complete(dbs, 0);
} }
static const AIOCBInfo dma_aiocb_info = { static const AIOCBInfo dma_aiocb_info = {
.aiocb_size = sizeof(DMAAIOCB), .aiocb_size = sizeof(DMAAIOCB),
.cancel = dma_aio_cancel, .cancel_async = dma_aio_cancel,
}; };
BlockDriverAIOCB *dma_bdrv_io( BlockDriverAIOCB *dma_bdrv_io(
@ -217,7 +206,6 @@ BlockDriverAIOCB *dma_bdrv_io(
dbs->sg_cur_index = 0; dbs->sg_cur_index = 0;
dbs->sg_cur_byte = 0; dbs->sg_cur_byte = 0;
dbs->dir = dir; dbs->dir = dir;
dbs->in_cancel = false;
dbs->io_func = io_func; dbs->io_func = io_func;
dbs->bh = NULL; dbs->bh = NULL;
qemu_iovec_init(&dbs->iov, sg->nsg); qemu_iovec_init(&dbs->iov, sg->nsg);