From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55107) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XP8gy-0006XI-JD for qemu-devel@nongnu.org; Wed, 03 Sep 2014 07:25:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XP8gs-00076W-77 for qemu-devel@nongnu.org; Wed, 03 Sep 2014 07:25:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1763) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XP8gr-00076M-ME for qemu-devel@nongnu.org; Wed, 03 Sep 2014 07:25:29 -0400 From: Fam Zheng Date: Wed, 3 Sep 2014 19:23:43 +0800 Message-Id: <1409743435-21155-9-git-send-email-famz@redhat.com> In-Reply-To: <1409743435-21155-1-git-send-email-famz@redhat.com> References: <1409743435-21155-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v4 08/20] dma: Convert dma_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 , Chrysostomos Nanakos , Stefan Hajnoczi , Liu Yuan , Peter Lieven , Ronnie Sahlberg , Josh Durgin , Paolo Bonzini , MORITA Kazutaka , Benoit Canet Just forward the request to bdrv_aio_cancel_async. Signed-off-by: Fam Zheng --- dma-helpers.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/dma-helpers.c b/dma-helpers.c index 3655d88..8163940 100644 --- a/dma-helpers.c +++ b/dma-helpers.c @@ -73,7 +73,6 @@ typedef struct { QEMUSGList *sg; uint64_t sector_num; DMADirection dir; - bool in_cancel; int sg_cur_index; dma_addr_t sg_cur_byte; QEMUIOVector iov; @@ -128,12 +127,7 @@ static void dma_complete(DMAAIOCB *dbs, int ret) qemu_bh_delete(dbs->bh); 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) @@ -189,19 +183,14 @@ static void dma_aio_cancel(BlockDriverAIOCB *acb) trace_dma_aio_cancel(dbs); if (dbs->acb) { - BlockDriverAIOCB *acb = dbs->acb; - dbs->acb = NULL; - dbs->in_cancel = true; - bdrv_aio_cancel(acb); - dbs->in_cancel = false; + bdrv_aio_cancel_async(dbs->acb); } - dbs->common.cb = NULL; - dma_complete(dbs, 0); } + static const AIOCBInfo dma_aiocb_info = { .aiocb_size = sizeof(DMAAIOCB), - .cancel = dma_aio_cancel, + .cancel_async = dma_aio_cancel, }; BlockDriverAIOCB *dma_bdrv_io( @@ -220,7 +209,6 @@ BlockDriverAIOCB *dma_bdrv_io( dbs->sg_cur_index = 0; dbs->sg_cur_byte = 0; dbs->dir = dir; - dbs->in_cancel = false; dbs->io_func = io_func; dbs->bh = NULL; qemu_iovec_init(&dbs->iov, sg->nsg); -- 2.1.0.27.g96db324