From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPYeP-00039D-Bg for qemu-devel@nongnu.org; Thu, 04 Sep 2014 11:08:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XPYeJ-0008WV-53 for qemu-devel@nongnu.org; Thu, 04 Sep 2014 11:08:41 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:46857 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPYeI-0008WH-Ub for qemu-devel@nongnu.org; Thu, 04 Sep 2014 11:08:35 -0400 Date: Thu, 4 Sep 2014 17:07:48 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140904150748.GB8094@irqsave.net> References: <1409743435-21155-1-git-send-email-famz@redhat.com> <1409743435-21155-2-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1409743435-21155-2-git-send-email-famz@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v4 01/20] block: Add refcnt in BlockDriverAIOCB List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: Kevin Wolf , Chrysostomos Nanakos , Stefan Hajnoczi , Liu Yuan , Peter Lieven , qemu-devel@nongnu.org, Ronnie Sahlberg , Josh Durgin , Paolo Bonzini , MORITA Kazutaka The Wednesday 03 Sep 2014 =E0 19:23:36 (+0800), Fam Zheng wrote : > This will be useful in synchronous cancel emulation with > bdrv_aio_cancel_async. >=20 > Signed-off-by: Fam Zheng > --- > block.c | 12 +++++++++++- > include/block/aio.h | 2 ++ > 2 files changed, 13 insertions(+), 1 deletion(-) >=20 > diff --git a/block.c b/block.c > index cb670fd..78d68cb 100644 > --- a/block.c > +++ b/block.c > @@ -4885,13 +4885,23 @@ void *qemu_aio_get(const AIOCBInfo *aiocb_info,= BlockDriverState *bs, > acb->bs =3D bs; > acb->cb =3D cb; > acb->opaque =3D opaque; > + acb->refcnt =3D 1; > return acb; > } > =20 > +void qemu_aio_ref(void *p) > +{ > + BlockDriverAIOCB *acb =3D p; > + acb->refcnt++; > +} > + > void qemu_aio_release(void *p) I would expect _release to change to _unref for symetry. > { > BlockDriverAIOCB *acb =3D p; > - g_slice_free1(acb->aiocb_info->aiocb_size, acb); > + assert(acb->refcnt > 0); > + if (--acb->refcnt =3D=3D 0) { > + g_slice_free1(acb->aiocb_info->aiocb_size, acb); > + } > } > =20 > /**************************************************************/ > diff --git a/include/block/aio.h b/include/block/aio.h > index 4603c0f..2626fc7 100644 > --- a/include/block/aio.h > +++ b/include/block/aio.h > @@ -35,11 +35,13 @@ struct BlockDriverAIOCB { > BlockDriverState *bs; > BlockDriverCompletionFunc *cb; > void *opaque; > + int refcnt; > }; > =20 > void *qemu_aio_get(const AIOCBInfo *aiocb_info, BlockDriverState *bs, > BlockDriverCompletionFunc *cb, void *opaque); > void qemu_aio_release(void *p); > +void qemu_aio_ref(void *p); > =20 > typedef struct AioHandler AioHandler; > typedef void QEMUBHFunc(void *opaque); > --=20 > 2.1.0.27.g96db324 >=20