From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRxAM-0005G8-Ut for qemu-devel@nongnu.org; Thu, 11 Sep 2014 01:43:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XRxAG-0006NR-Pj for qemu-devel@nongnu.org; Thu, 11 Sep 2014 01:43:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41920) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRxAG-0006NN-Hl for qemu-devel@nongnu.org; Thu, 11 Sep 2014 01:43:28 -0400 From: Fam Zheng Date: Thu, 11 Sep 2014 13:41:26 +0800 Message-Id: <1410414088-4419-21-git-send-email-famz@redhat.com> In-Reply-To: <1410414088-4419-1-git-send-email-famz@redhat.com> References: <1410414088-4419-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v6 20/22] ide: Convert trim_aiocb_info.cancel to .cancel_async List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Benoit Canet , Peter Lieven , Stefan Hajnoczi , Liu Yuan , Paolo Bonzini 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 --- hw/ide/core.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 2f2d3b4..ee30309 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -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) -- 1.9.3