From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VS6hZ-00081L-6T for qemu-devel@nongnu.org; Fri, 04 Oct 2013 10:50:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VS6hT-0001x6-PV for qemu-devel@nongnu.org; Fri, 04 Oct 2013 10:49:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16383) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VS6hT-0001x0-GP for qemu-devel@nongnu.org; Fri, 04 Oct 2013 10:49:51 -0400 Message-ID: <524ED58A.7070005@redhat.com> Date: Fri, 04 Oct 2013 16:49:46 +0200 From: Max Reitz MIME-Version: 1.0 References: <1380717564-11098-1-git-send-email-benoit@irqsave.net> <1380717564-11098-8-git-send-email-benoit@irqsave.net> In-Reply-To: <1380717564-11098-8-git-send-email-benoit@irqsave.net> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH V9 07/11] quorum: Add quorum_getlength(). List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?ISO-8859-15?Q?Beno=EEt_Canet?= Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com On 2013-10-02 14:39, Beno=EEt Canet wrote: > Check that every bs file return the same length. *returns > If not return -EIO to disable the quorum and I'd prefer "If not," (mind the comma) or "Otherwise," (comma optional). Max > avoid length discrepancy. > > Signed-off-by: Benoit Canet > --- > block/quorum.c | 26 ++++++++++++++++++++++++++ > 1 file changed, 26 insertions(+) > > diff --git a/block/quorum.c b/block/quorum.c > index e235ac1..b3649a4 100644 > --- a/block/quorum.c > +++ b/block/quorum.c > @@ -541,12 +541,38 @@ static BlockDriverAIOCB *quorum_aio_writev(BlockD= riverState *bs, > return &acb->common; > } > =20 > +static int64_t quorum_getlength(BlockDriverState *bs) > +{ > + BDRVQuorumState *s =3D bs->opaque; > + int64_t result; > + int i; > + > + /* check that all file have the same length */ > + result =3D bdrv_getlength(&s->bs[0]); > + if (result < 0) { > + return result; > + } > + for (i =3D 1; i < s->total; i++) { > + int64_t value =3D bdrv_getlength(&s->bs[i]); > + if (value < 0) { > + return value; > + } > + if (value !=3D result) { > + return -EIO; > + } > + } > + > + return result; > +} > + > static BlockDriver bdrv_quorum =3D { > .format_name =3D "quorum", > .protocol_name =3D "quorum", > =20 > .instance_size =3D sizeof(BDRVQuorumState), > =20 > + .bdrv_getlength =3D quorum_getlength, > + > .bdrv_aio_readv =3D quorum_aio_readv, > .bdrv_aio_writev =3D quorum_aio_writev, > };