From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38022) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPDSC-0008L3-NK for qemu-devel@nongnu.org; Thu, 26 Sep 2013 11:26:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VPDS7-0004al-Ie for qemu-devel@nongnu.org; Thu, 26 Sep 2013 11:26:08 -0400 Received: from nodalink.pck.nerim.net ([62.212.105.220]:39666 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPDS7-0004aA-1O for qemu-devel@nongnu.org; Thu, 26 Sep 2013 11:26:03 -0400 Date: Thu, 26 Sep 2013 17:25:55 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20130926152555.GC3338@irqsave.net> References: <1359392845-15905-1-git-send-email-benoit@irqsave.net> <1359392845-15905-4-git-send-email-benoit@irqsave.net> <5114D5AE.6070901@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <5114D5AE.6070901@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC V8 03/13] quorum: Add quorum_aio_writev and its dependencies. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org, stefanha@redhat.com Le Friday 08 Feb 2013 =E0 11:38:38 (+0100), Kevin Wolf a =E9crit : > Am 28.01.2013 18:07, schrieb Beno=EEt Canet: > > Signed-off-by: Benoit Canet > > --- > > block/quorum.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++= ++++++++++ > > 1 file changed, 111 insertions(+) > >=20 > > diff --git a/block/quorum.c b/block/quorum.c > > index d8fffbe..5d8470b 100644 > > --- a/block/quorum.c > > +++ b/block/quorum.c > > @@ -52,11 +52,122 @@ struct QuorumAIOCB { > > int vote_ret; > > }; > > =20 > > +static void quorum_aio_cancel(BlockDriverAIOCB *blockacb) > > +{ > > + QuorumAIOCB *acb =3D container_of(blockacb, QuorumAIOCB, common)= ; > > + bool finished =3D false; > > + > > + /* Wait for the request to finish */ > > + acb->finished =3D &finished; > > + while (!finished) { > > + qemu_aio_wait(); > > + } > > +} > > + > > +static AIOCBInfo quorum_aiocb_info =3D { > > + .aiocb_size =3D sizeof(QuorumAIOCB), > > + .cancel =3D quorum_aio_cancel, > > +}; > > + > > +static void quorum_aio_bh(void *opaque) > > +{ > > + QuorumAIOCB *acb =3D opaque; > > + BDRVQuorumState *s =3D acb->bqs; > > + int ret; > > + > > + ret =3D s->threshold <=3D acb->success_count ? 0 : -EIO; >=20 > It would be very much preferable if you stored the actual error code > instead of turning everything into -EIO. >=20 > > + > > + qemu_bh_delete(acb->bh); > > + acb->common.cb(acb->common.opaque, ret); > > + if (acb->finished) { > > + *acb->finished =3D true; > > + } > > + g_free(acb->aios); > > + qemu_aio_release(acb); > > +} >=20 > Move this down so that it's next to the function using the bottom half. >=20 > > + > > +static QuorumAIOCB *quorum_aio_get(BDRVQuorumState *s, > > + BlockDriverState *bs, > > + QEMUIOVector *qiov, > > + uint64_t sector_num, > > + int nb_sectors, > > + BlockDriverCompletionFunc *cb, > > + void *opaque) > > +{ > > + QuorumAIOCB *acb =3D qemu_aio_get(&quorum_aiocb_info, bs, cb, op= aque); > > + int i; > > + > > + acb->aios =3D g_new0(QuorumSingleAIOCB, s->total); > > + > > + acb->bqs =3D s; > > + acb->qiov =3D qiov; > > + acb->bh =3D NULL; > > + acb->count =3D 0; > > + acb->success_count =3D 0; > > + acb->sector_num =3D sector_num; > > + acb->nb_sectors =3D nb_sectors; > > + acb->vote =3D NULL; > > + acb->vote_ret =3D 0; > > + acb->finished =3D NULL; > > + > > + for (i =3D 0; i < s->total; i++) { > > + acb->aios[i].buf =3D NULL; > > + acb->aios[i].ret =3D 0; > > + acb->aios[i].parent =3D acb; > > + } >=20 > Would you mind to reorder the initialisation of the fields according to > the order that is used in the struct definition? >=20 > > + > > + return acb; > > +} > > + > > +static void quorum_aio_cb(void *opaque, int ret) > > +{ > > + QuorumSingleAIOCB *sacb =3D opaque; > > + QuorumAIOCB *acb =3D sacb->parent; > > + BDRVQuorumState *s =3D acb->bqs; > > + > > + sacb->ret =3D ret; > > + acb->count++; > > + if (ret =3D=3D 0) { > > + acb->success_count++; > > + } > > + assert(acb->count <=3D s->total); > > + assert(acb->success_count <=3D s->total); > > + if (acb->count < s->total) { > > + return; > > + } > > + > > + acb->bh =3D qemu_bh_new(quorum_aio_bh, acb); > > + qemu_bh_schedule(acb->bh); >=20 > What's the reason for using a bottom half here? Worth a comment? >=20 > multiwrite_cb() in block.c doesn't use one to achieve something similar= . > Is it buggy when you need one here? It think I get the bottom half by largely taking inspiration reading Marc= ello blkmirror code. Best regards Beno=EEt >=20 > Kevin >=20