ide: Convert trim_aiocb_info.cancel to .cancel_async

We know that either bh is scheduled or ide_issue_trim_cb will be called
again, so we just set i, j and ret to the right values. In both cases,
ide_trim_bh_cb will be called.

Also forward the cancellation to the iocb->aiocb which we get from
bdrv_aio_discard.

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:26 +08:00 committed by Stefan Hajnoczi
parent 5da91e4ef4
commit e551c999bc

View File

@ -372,23 +372,21 @@ static void trim_aio_cancel(BlockDriverAIOCB *acb)
{
TrimAIOCB *iocb = container_of(acb, TrimAIOCB, common);
/* Exit the loop in case bdrv_aio_cancel calls ide_issue_trim_cb again. */
/* Exit the loop so ide_issue_trim_cb will not continue */
iocb->j = iocb->qiov->niov - 1;
iocb->i = (iocb->qiov->iov[iocb->j].iov_len / 8) - 1;
/* Tell ide_issue_trim_cb not to trigger the completion, too. */
qemu_bh_delete(iocb->bh);
iocb->bh = NULL;
iocb->ret = -ECANCELED;
if (iocb->aiocb) {
bdrv_aio_cancel(iocb->aiocb);
bdrv_aio_cancel_async(iocb->aiocb);
iocb->aiocb = NULL;
}
qemu_aio_release(iocb);
}
static const AIOCBInfo trim_aiocb_info = {
.aiocb_size = sizeof(TrimAIOCB),
.cancel = trim_aio_cancel,
.cancel_async = trim_aio_cancel,
};
static void ide_trim_bh_cb(void *opaque)