From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59999) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMDVb-0004F9-P9 for qemu-devel@nongnu.org; Tue, 26 Aug 2014 05:57:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMDVO-0003mb-OF for qemu-devel@nongnu.org; Tue, 26 Aug 2014 05:57:47 -0400 Received: from mail-wi0-x229.google.com ([2a00:1450:400c:c05::229]:40688) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMDVO-0003mP-Gc for qemu-devel@nongnu.org; Tue, 26 Aug 2014 05:57:34 -0400 Received: by mail-wi0-f169.google.com with SMTP id n3so4910207wiv.2 for ; Tue, 26 Aug 2014 02:57:33 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <53FC5A09.7070807@redhat.com> Date: Tue, 26 Aug 2014 11:57:29 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1409033298-5720-1-git-send-email-famz@redhat.com> <1409033298-5720-7-git-send-email-famz@redhat.com> <53FC496C.7020603@redhat.com> <20140826092143.GA30816@T430.nay.redhat.com> In-Reply-To: <20140826092143.GA30816@T430.nay.redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit 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: Fam Zheng Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi Il 26/08/2014 11:21, Fam Zheng ha scritto: > 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. Ah, that's because the operation could be partly incomplete? I think it would be better to call dma_complete with -ECANCELED, instead of doing the same dbs->cancelled check twice. For example, in dma_bdrv_cb: if (dbs->sg_cur_index == dbs->sg->nsg || ret < 0) { dma_complete(dbs, ret); return; } if (dbs->cancelled) { dma_complete(dbs, -ECANCELED); return; } >>> +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. Yeah, that one looks useless too... Paolo