From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:33887) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzOzM-0003JH-Hd for qemu-devel@nongnu.org; Thu, 09 Aug 2012 05:25:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SzOzI-0001Xu-EV for qemu-devel@nongnu.org; Thu, 09 Aug 2012 05:25:08 -0400 Received: from paradis.irqsave.net ([109.190.18.76]:37860) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzOzI-0001VQ-6u for qemu-devel@nongnu.org; Thu, 09 Aug 2012 05:25:04 -0400 Date: Thu, 9 Aug 2012 11:24:54 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20120809092454.GB2928@irqsave.net> References: <1344347073-7773-1-git-send-email-benoit@irqsave.net> <1344347073-7773-7-git-send-email-benoit@irqsave.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC V2 06/10] quorum: Add quorum_aio_writev and its dependencies. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: kwolf@redhat.com, =?iso-8859-1?Q?Beno=EEt?= Canet , stefanha@linux.vnet.ibm.com, qemu-devel@nongnu.org, blauwirbel@gmail.com, anthony@codemonkey.ws, pbonzini@redhat.com, eblake@redhat.com, afaerber@suse.de Le Wednesday 08 Aug 2012 =E0 16:37:13 (+0100), Stefan Hajnoczi a =E9crit = : > On Tue, Aug 7, 2012 at 2:44 PM, Beno=EEt Canet = wrote: > > +static int quorum_check_ret(QuorumAIOCB *acb) > > +{ > > + int i, j; > > + > > + for (i =3D 0, j =3D 0; i <=3D 2; i++) { > > + if (acb->aios[0].ret) { > > + j++; > > + } > > + } > > + > > + if (j > 1) { > > + return -EIO; > > + } > > + > > + return 0; > > +} >=20 > Simpler version just scans the return values (also I think > acb->aios[0].ret should be acb->aios[i].ret): >=20 > static int quorum_check_ret(QuorumAIOCB *acb) > { > int i; > for (i =3D 0; i <=3D 2; i++) { > if (acb->aios[i].ret) { > return -EIO; /* or acb->aios[i].ret */ > } > } > return 0; > } I am wondering what is the best code to return. There is some potential case like a filer containing a particular image (or a image on the network) going down where the user probably don't want to get an -EIO. The=20 if (j > 1) { return -EIO; } part was about detecting an error count greater dans the threshold (2). >=20 > > + > > +static void quorum_aio_bh(void *opaque) > > +{ > > + QuorumAIOCB *acb =3D opaque; > > + > > + qemu_bh_delete(acb->bh); > > + acb->common.cb(acb->common.opaque, quorum_check_ret(acb)); > > + if (acb->finished) { > > + *acb->finished =3D true; > > + } > > + qemu_aio_release(acb); > > +} > > + > > +static QuorumAIOCB *quorum_aio_get(BlockDriverState *bs, > > + QEMUIOVector *qiov, > > + int64_t sector_num, > > + int nb_sectors, > > + BlockDriverCompletionFunc *cb, > > + void *opaque) > > +{ > > + QuorumAIOCB *acb =3D qemu_aio_get(&quorum_aio_pool, bs, cb, opaq= ue); > > + int i; > > + > > + acb->qiov =3D qiov; > > + acb->bh =3D NULL; > > + acb->count =3D 0; > > + acb->sector_num =3D sector_num; > > + acb->nb_sectors =3D nb_sectors; > > + acb->vote =3D NULL; > > + acb->vote_ret =3D 0; >=20 > acb->finished =3D NULL; >=20