From patchwork Mon Feb 3 15:02:15 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: 316211 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 5075A2C0084 for ; Tue, 4 Feb 2014 02:59:06 +1100 (EST) Received: from localhost ([::1]:47807 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAL5Q-00009a-V8 for incoming@patchwork.ozlabs.org; Mon, 03 Feb 2014 10:05:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54941) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAL32-0005ff-F7 for qemu-devel@nongnu.org; Mon, 03 Feb 2014 10:03:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WAL2u-0000sI-2d for qemu-devel@nongnu.org; Mon, 03 Feb 2014 10:02:56 -0500 Received: from paradis.irqsave.net ([62.212.105.220]:48943) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAL2t-0000rk-JR for qemu-devel@nongnu.org; Mon, 03 Feb 2014 10:02:48 -0500 Received: from localhost.localdomain (laure.irqsave.net [192.168.77.2]) by paradis.irqsave.net (Postfix) with ESMTP id 328EF5EABA; Mon, 3 Feb 2014 16:36:11 +0100 (CET) From: =?UTF-8?q?Beno=C3=AEt=20Canet?= To: qemu-devel@nongnu.org Date: Mon, 3 Feb 2014 16:02:15 +0100 Message-Id: <1391439741-29078-8-git-send-email-benoit.canet@irqsave.net> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1391439741-29078-1-git-send-email-benoit.canet@irqsave.net> References: <1391439741-29078-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, =?UTF-8?q?Beno=C3=AEt=20Canet?= , stefanha@redhat.com, mreitz@redhat.com Subject: [Qemu-devel] [PATCH V11 07/13] 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 d779074..442da2e 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -553,12 +553,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->total; 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, };