From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAOw6-0000LQ-5O for qemu-devel@nongnu.org; Mon, 03 Feb 2014 14:12:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WAOw0-0002J2-JA for qemu-devel@nongnu.org; Mon, 03 Feb 2014 14:12:02 -0500 Received: from paradis.irqsave.net ([62.212.105.220]:49054) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAOvz-0002I7-Uj for qemu-devel@nongnu.org; Mon, 03 Feb 2014 14:11:56 -0500 From: =?UTF-8?q?Beno=C3=AEt=20Canet?= Date: Mon, 3 Feb 2014 20:11:46 +0100 Message-Id: <1391454712-14353-8-git-send-email-benoit.canet@irqsave.net> In-Reply-To: <1391454712-14353-1-git-send-email-benoit.canet@irqsave.net> References: <1391454712-14353-1-git-send-email-benoit.canet@irqsave.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH V14 07/13] quorum: Add quorum_getlength(). List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, =?UTF-8?q?Beno=C3=AEt=20Canet?= , stefanha@redhat.com, mreitz@redhat.com From: Beno=C3=AEt Canet Check that every bs file returns the same length. Otherwise, return -EIO to disable the quorum and avoid length discrepancy. Signed-off-by: Benoit Canet Reviewed-by: Max Reitz --- block/quorum.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/block/quorum.c b/block/quorum.c index 56ad6a0..a3920d8 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -587,12 +587,38 @@ static BlockDriverAIOCB *quorum_aio_writev(BlockDri= verState *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, }; --=20 1.8.3.2