From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34655) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tvrl5-000483-8m for qemu-devel@nongnu.org; Thu, 17 Jan 2013 10:52:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tvrkz-0005uU-23 for qemu-devel@nongnu.org; Thu, 17 Jan 2013 10:52:02 -0500 Received: from nodalink.pck.nerim.net ([62.212.105.220]:44094 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tvrky-0005uA-PY for qemu-devel@nongnu.org; Thu, 17 Jan 2013 10:51:56 -0500 From: =?UTF-8?q?Beno=C3=AEt=20Canet?= Date: Thu, 17 Jan 2013 16:51:34 +0100 Message-Id: <1358437897-24251-9-git-send-email-benoit@irqsave.net> In-Reply-To: <1358437897-24251-1-git-send-email-benoit@irqsave.net> References: <1358437897-24251-1-git-send-email-benoit@irqsave.net> Subject: [Qemu-devel] [RFC V6 08/11] 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, pbonzini@redhat.com, =?UTF-8?q?Beno=C3=AEt=20Canet?= , stefanha@redhat.com Check that every bs file return the same length. If not return -EIO to disable the quorum and avoid length discrepancy. Signed-off-by: Benoit Canet --- block/quorum.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/block/quorum.c b/block/quorum.c index 2bffff4..261e9b6 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -593,12 +593,32 @@ static BlockDriverAIOCB *quorum_aio_writev(BlockDriverState *bs, return &acb->common; } +static int64_t quorum_getlength(BlockDriverState *bs) +{ + BDRVQuorumState *s = bs->opaque; + int64_t result; + int i; + + /* check that every file have the same length */ + result = bdrv_getlength(s->bs[0]); + for (i = 1; i < s->total; i++) { + int64_t value = bdrv_getlength(s->bs[i]); + if (value != result) { + return -EIO; + } + } + + return result; +} + static BlockDriver bdrv_quorum = { .format_name = "quorum", .protocol_name = "quorum", .instance_size = sizeof(BDRVQuorumState), + .bdrv_getlength = quorum_getlength, + .bdrv_file_open = quorum_open, .bdrv_close = quorum_close, -- 1.7.10.4