From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34961) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRd91-0004aV-NR for qemu-devel@nongnu.org; Wed, 10 Sep 2014 04:21:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XRd8r-00078u-QR for qemu-devel@nongnu.org; Wed, 10 Sep 2014 04:20:51 -0400 Received: from mail-wi0-x229.google.com ([2a00:1450:400c:c05::229]:46264) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRd8r-00078n-JT for qemu-devel@nongnu.org; Wed, 10 Sep 2014 04:20:41 -0400 Received: by mail-wi0-f169.google.com with SMTP id cc10so565247wib.4 for ; Wed, 10 Sep 2014 01:20:40 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <541009D3.3070301@redhat.com> Date: Wed, 10 Sep 2014 10:20:35 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1410328814-12560-1-git-send-email-famz@redhat.com> <1410328814-12560-6-git-send-email-famz@redhat.com> In-Reply-To: <1410328814-12560-6-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v5 05/22] block: Convert bdrv_em_aiocb_info.cancel to .cancel_async List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , Liu Yuan , Peter Lieven , Benoit Canet , Stefan Hajnoczi Il 10/09/2014 07:59, Fam Zheng ha scritto: > @@ -4679,6 +4679,9 @@ static void bdrv_aio_cancel_em(BlockDriverAIOCB *blockacb) > { > BlockDriverAIOCBSync *acb = > container_of(blockacb, BlockDriverAIOCBSync, common); > + > + acb->ret = -ECANCELED; > + acb->common.cb(acb->common.opaque, acb->ret); > qemu_bh_delete(acb->bh); > acb->bh = NULL; > qemu_aio_release(acb); This could call the callback before I/O is finished. I/O can then complete and write to disk stuff that was not meant to be written. I think there is a pre-existing bug, which should be fixed with a "bool *done" member similar to BlockDriverAIOCBCoroutine's. But for the sake of conversion to async cancellation, you can just empty bdrv_aio_cancel_em. Paolo