From patchwork Fri Sep 19 14:41:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 391286 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C465C14019D for ; Sat, 20 Sep 2014 00:48:13 +1000 (EST) Received: from localhost ([::1]:58594 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUzTn-0006zF-A5 for incoming@patchwork.ozlabs.org; Fri, 19 Sep 2014 10:48:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43811) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUzOt-0006s3-C2 for qemu-devel@nongnu.org; Fri, 19 Sep 2014 10:43:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XUzOn-00077m-8W for qemu-devel@nongnu.org; Fri, 19 Sep 2014 10:43:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12548) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUzOm-000769-W6 for qemu-devel@nongnu.org; Fri, 19 Sep 2014 10:43:01 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8JEgrZ3021002 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 19 Sep 2014 10:42:54 -0400 Received: from localhost (ovpn-112-56.ams2.redhat.com [10.36.112.56]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8JEgqow019319; Fri, 19 Sep 2014 10:42:53 -0400 From: Stefan Hajnoczi To: Date: Fri, 19 Sep 2014 15:41:30 +0100 Message-Id: <1411137738-31280-12-git-send-email-stefanha@redhat.com> In-Reply-To: <1411137738-31280-1-git-send-email-stefanha@redhat.com> References: <1411137738-31280-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , Fam Zheng , Stefan Hajnoczi Subject: [Qemu-devel] [PULL 11/59] dma: Convert dma_aiocb_info.cancel to .cancel_async X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Fam Zheng Just forward the request to bdrv_aio_cancel_async. Signed-off-by: Fam Zheng Signed-off-by: Stefan Hajnoczi --- dma-helpers.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/dma-helpers.c b/dma-helpers.c index f6811fa..207b21e 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; @@ -125,12 +124,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) @@ -186,19 +180,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( @@ -217,7 +206,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);