Received: from eggs.gnu.org ([2001:4830:134:3::10]:52247) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOlkX-00080D-0v for qemu-devel@nongnu.org; Tue, 02 Sep 2014 06:55:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XOlkQ-0008Ia-Pv for qemu-devel@nongnu.org; Tue, 02 Sep 2014 06:55:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38169) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOlkQ-0008IT-DF for qemu-devel@nongnu.org; Tue, 02 Sep 2014 06:55:38 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s82AtXO3004015 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 2 Sep 2014 06:55:35 -0400 Date: Tue, 2 Sep 2014 11:55:29 +0100 From: Stefan Hajnoczi Message-ID: <20140902105529.GJ29067@stefanha-thinkpad.redhat.com> References: <1409107756-5967-1-git-send-email-famz@redhat.com> <1409107756-5967-3-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="UlxN1C6awaFNesUv" Content-Disposition: inline In-Reply-To: <1409107756-5967-3-git-send-email-famz@redhat.com> Subject: Re: [Qemu-devel] [PATCH v3 2/8] block: Add bdrv_aio_cancel_async List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: Kevin Wolf , Paolo Bonzini , qemu-devel@nongnu.org --UlxN1C6awaFNesUv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Aug 27, 2014 at 10:49:10AM +0800, Fam Zheng wrote: > +/* Async version of aio cancel. The caller is not blocked if the acb implements > + * cancel_async, otherwise fall back to bdrv_aio_cancel. In both cases, acb->cb > + * is guarenteed to be called, before or after function returns. */ > +void bdrv_aio_cancel_async(BlockDriverAIOCB *acb) > +{ > + if (acb->aiocb_info->cancel_async) { > + acb->aiocb_info->cancel_async(acb); > + } else { > + /* Mask the cb and cancel, we'll call it manually once the synchronous > + * cancel is done. */ > + BlockDriverCompletionFunc *cb = acb->cb; > + void *opaque = acb->opaque; > + acb->cb = bdrv_aio_cancel_cb_nop; > + acb->opaque = NULL; > + qemu_aio_ref(acb); > + acb->aiocb_info->cancel(acb); > + cb(opaque, -ECANCELED); > + qemu_aio_release(acb); > + } > +} It is not totally obvious why we hijack the callback. If you respin, please rephrase the comment along the lines of: /* bdrv_aio_cancel() does not guarantee to invoke cb() so mask it during * bdrv_aio_cancel() and always invoke it ourselves. */ Stefan --UlxN1C6awaFNesUv Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUBaIhAAoJEJykq7OBq3PIvCsH/312Q0SzHEHCk8wtAv+xrjnT 5TGnl9Hm3t/d0mWU3xA4Ph+Shz4trcUE4K5dac9HsY96lPurhNzixE9TZxUYsH7A IhmQHYK8bOHmLau75ElqEBABUIiSkS2HM0tzxJUtwvrIPTj6w3dV84Z4509qW172 mWnNBdlqYU4EMrETqV1bJkkug3aSGRq8fazdttE0KZqVDbzvrQg77JC7HsSveHvL 7U63Oj+f3L3hCkHr/A8rlwbiq+3c5j2tv1j70BkdBPMXCY3ad/NwQeb23yagH+Ir WCqTg7bNIVJp549W28fRAaabI1tmA20J4GrnToEsM6lQM28VW9IYPfC5qD93xIo= =LQSr -----END PGP SIGNATURE----- --UlxN1C6awaFNesUv--