From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGyMA-0003Bj-F2 for qemu-devel@nongnu.org; Fri, 21 Feb 2014 17:14:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WGyM5-0000i3-4P for qemu-devel@nongnu.org; Fri, 21 Feb 2014 17:14:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3980) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGyM4-0000ho-Qu for qemu-devel@nongnu.org; Fri, 21 Feb 2014 17:14:01 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1LMDxQ7028438 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 21 Feb 2014 17:13:59 -0500 From: Kevin Wolf Date: Fri, 21 Feb 2014 23:12:44 +0100 Message-Id: <1393020771-32712-48-git-send-email-kwolf@redhat.com> In-Reply-To: <1393020771-32712-1-git-send-email-kwolf@redhat.com> References: <1393020771-32712-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 47/54] 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 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 Signed-off-by: Kevin Wolf --- block/quorum.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/block/quorum.c b/block/quorum.c index 4beee96..c6ea862 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -595,12 +595,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->num_children; 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.1.4