From patchwork Mon Feb 3 21:51: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: 316351 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 3C7552C0089 for ; Tue, 4 Feb 2014 09:43:46 +1100 (EST) Received: from localhost ([::1]:49720 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WARR5-0008RJ-Ie for incoming@patchwork.ozlabs.org; Mon, 03 Feb 2014 16:52:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WARQP-0008M2-OL for qemu-devel@nongnu.org; Mon, 03 Feb 2014 16:51:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WARQJ-0008JJ-Ig for qemu-devel@nongnu.org; Mon, 03 Feb 2014 16:51:29 -0500 Received: from paradis.irqsave.net ([62.212.105.220]:49092) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WARQI-0008IZ-Lg for qemu-devel@nongnu.org; Mon, 03 Feb 2014 16:51:23 -0500 Received: from localhost.localdomain (laure.irqsave.net [192.168.77.2]) by paradis.irqsave.net (Postfix) with ESMTP id 63E775EE64; Mon, 3 Feb 2014 23:24:55 +0100 (CET) From: =?UTF-8?q?Beno=C3=AEt=20Canet?= To: qemu-devel@nongnu.org Date: Mon, 3 Feb 2014 22:51:14 +0100 Message-Id: <1391464280-25627-8-git-send-email-benoit.canet@irqsave.net> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1391464280-25627-1-git-send-email-benoit.canet@irqsave.net> References: <1391464280-25627-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 V15 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 837d261..2f302b4 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -585,12 +585,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, };