From patchwork Tue Feb 11 14:45:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Beno=C3=AEt_Canet?= X-Patchwork-Id: 319309 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6AF802C00BC for ; Wed, 12 Feb 2014 01:46:18 +1100 (EST) Received: from localhost ([::1]:33959 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDEbI-0001b8-1n for incoming@patchwork.ozlabs.org; Tue, 11 Feb 2014 09:46:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDEab-0001ZQ-Q7 for qemu-devel@nongnu.org; Tue, 11 Feb 2014 09:45:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDEaT-000553-5p for qemu-devel@nongnu.org; Tue, 11 Feb 2014 09:45:33 -0500 Received: from paradis.irqsave.net ([62.212.105.220]:49697) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDEaS-00054N-LB for qemu-devel@nongnu.org; Tue, 11 Feb 2014 09:45:25 -0500 Received: from localhost.localdomain (laure.irqsave.net [192.168.77.2]) by paradis.irqsave.net (Postfix) with ESMTP id A9FD9618FB; Tue, 11 Feb 2014 16:22:36 +0100 (CET) From: =?UTF-8?q?Beno=C3=AEt=20Canet?= To: qemu-devel@nongnu.org Date: Tue, 11 Feb 2014 15:45:14 +0100 Message-Id: <1392129919-7764-8-git-send-email-benoit.canet@irqsave.net> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1392129919-7764-1-git-send-email-benoit.canet@irqsave.net> References: <1392129919-7764-1-git-send-email-benoit.canet@irqsave.net> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 62.212.105.220 Cc: kwolf@redhat.com, famz@redhat.com, =?UTF-8?q?Beno=C3=AEt=20Canet?= , jcody@redhat.com, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com Subject: [Qemu-devel] [PATCH V16 07/12] quorum: Add quorum_getlength(). X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: BenoƮt 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 a862714..c066f08 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -600,12 +600,38 @@ 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 all file have the same length */ + result = bdrv_getlength(s->bs[0]); + if (result < 0) { + return result; + } + for (i = 1; i < s->num_children; i++) { + int64_t value = bdrv_getlength(s->bs[i]); + if (value < 0) { + return value; + } + 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_aio_readv = quorum_aio_readv, .bdrv_aio_writev = quorum_aio_writev, };