From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53107) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMCwb-0005MD-5t for qemu-devel@nongnu.org; Tue, 26 Aug 2014 05:21:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMCwS-0007za-30 for qemu-devel@nongnu.org; Tue, 26 Aug 2014 05:21:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9981) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMCwR-0007zM-Qr for qemu-devel@nongnu.org; Tue, 26 Aug 2014 05:21:28 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s7Q9LQ4T011634 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 26 Aug 2014 05:21:27 -0400 Date: Tue, 26 Aug 2014 17:21:43 +0800 From: Fam Zheng Message-ID: <20140826092143.GA30816@T430.nay.redhat.com> References: <1409033298-5720-1-git-send-email-famz@redhat.com> <1409033298-5720-7-git-send-email-famz@redhat.com> <53FC496C.7020603@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <53FC496C.7020603@redhat.com> Subject: Re: [Qemu-devel] [RFC PATCH v2 6/8] dma: Implement .cancel_async List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi On Tue, 08/26 10:46, Paolo Bonzini wrote: > Il 26/08/2014 08:08, Fam Zheng ha scritto: > > + if (dbs->cancelled) { > > + ret = -ECANCELED; > > + } > > Why is dbs->cancelled necessary? Request may complete after bdrv_aio_cancel_async with other status, this flag is checked to fix the status to -ECANCELED. > > > dma_bdrv_unmap(dbs); > > if (dbs->common.cb) { > > dbs->common.cb(dbs->common.opaque, ret); > > @@ -141,6 +148,9 @@ static void dma_bdrv_cb(void *opaque, int ret) > > > > trace_dma_bdrv_cb(dbs, ret); > > > > + if (dbs->cancelled) { > > + ret = -ECANCELED; > > + } > > dbs->acb = NULL; > > dbs->sector_num += dbs->iov.size / 512; > > > > @@ -185,6 +195,7 @@ static void dma_aio_cancel(BlockDriverAIOCB *acb) > > > > trace_dma_aio_cancel(dbs); > > > > + dbs->cancelled = true; > > if (dbs->acb) { > > BlockDriverAIOCB *acb = dbs->acb; > > dbs->acb = NULL; > > @@ -196,9 +207,25 @@ static void dma_aio_cancel(BlockDriverAIOCB *acb) > > dma_complete(dbs, 0); > > } > > > > +static void dma_aio_cancel_async(BlockDriverAIOCB *acb) > > +{ > > + DMAAIOCB *dbs = container_of(acb, DMAAIOCB, common); > > + > > + trace_dma_aio_cancel(dbs); > > + > > + dbs->cancelled = true; > > + if (dbs->acb) { > > + acb = dbs->acb; > > + dbs->acb = NULL; > > Why do you need to set dbs->acb to NULL, since the callback is going to > be called? Just copied from dma_aio_cancel, but seems not particularly useful. It reminds me that the one in dma_aio_cancel also looks suspicious. Fam