From patchwork Mon Jan 28 17:07:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Beno=C3=AEt_Canet?= X-Patchwork-Id: 216267 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B47882C0094 for ; Tue, 29 Jan 2013 04:32:44 +1100 (EST) Received: from localhost ([::1]:43277 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TzsZW-00078i-Rg for incoming@patchwork.ozlabs.org; Mon, 28 Jan 2013 12:32:42 -0500 Received: from eggs.gnu.org ([208.118.235.92]:45724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TzsBA-0007dH-Fb for qemu-devel@nongnu.org; Mon, 28 Jan 2013 12:07:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TzsB3-0000Du-5Y for qemu-devel@nongnu.org; Mon, 28 Jan 2013 12:07:32 -0500 Received: from nodalink.pck.nerim.net ([62.212.105.220]:48519 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TzsB2-0000Dh-Ub for qemu-devel@nongnu.org; Mon, 28 Jan 2013 12:07:25 -0500 Received: by paradis.irqsave.net (Postfix, from userid 1002) id 6B10887431B; Mon, 28 Jan 2013 18:07:24 +0100 (CET) Received: from localhost.localdomain (unknown [192.168.77.1]) by paradis.irqsave.net (Postfix) with ESMTP id 66588874325; Mon, 28 Jan 2013 18:06:43 +0100 (CET) From: =?UTF-8?q?Beno=C3=AEt=20Canet?= To: qemu-devel@nongnu.org Date: Mon, 28 Jan 2013 18:07:19 +0100 Message-Id: <1359392845-15905-8-git-send-email-benoit@irqsave.net> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1359392845-15905-1-git-send-email-benoit@irqsave.net> References: <1359392845-15905-1-git-send-email-benoit@irqsave.net> 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 Subject: [Qemu-devel] [RFC V8 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 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 4c552e4..fe920e7 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -497,12 +497,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_aio_readv = quorum_aio_readv, .bdrv_aio_writev = quorum_aio_writev, };