From patchwork Wed Oct 17 14:33:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 10645715 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DD9D43B73 for ; Wed, 17 Oct 2018 14:36:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA6D720415 for ; Wed, 17 Oct 2018 14:36:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BABB02239C; Wed, 17 Oct 2018 14:36:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EB43420415 for ; Wed, 17 Oct 2018 14:36:22 +0000 (UTC) Received: from localhost ([::1]:37033 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gCmvt-0001Sj-MT for patchwork-qemu-devel@patchwork.kernel.org; Wed, 17 Oct 2018 10:36:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gCmuJ-0000DB-6F for qemu-devel@nongnu.org; Wed, 17 Oct 2018 10:34:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gCmuF-0006FJ-3R for qemu-devel@nongnu.org; Wed, 17 Oct 2018 10:34:43 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:48028) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gCmuE-0005ou-BB; Wed, 17 Oct 2018 10:34:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=LLoD6/cUM3YQA9qalTv0FsNk3cEb7CQSqfhELh7PCig=; b=K3nOJZeWi95qKifCMYCgd3z937Q/hFf/hrbPtsgUy0jluR6P2awGhN6r20BrmbrUfaL8dyCfyI0FGqt7d6qu4tA5TFdoM8PjZ4Kpp8hdHYcrp5Q0Uzd1mLHUWd2QcYLZbp0pj6bdGS5smQ1JKlvKYNUX6KeqntmRBPQs03/JioaDNNbMzlkRVY5vbEqsoMxb47p6ndRvhsp5PAwxvCOtKY+6x1LDHZ3D3BgaWNzqiagIl4xo4nphTw0S0p/WKQrAnL5sqxM04EnKUF8bkqR0jUO3QSUcFrEFuCoK3TLpREjBcGytaY61s07Xw1GS/YbsZwHwma7LywD7BnoDaIgUXA==; Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1gCmtt-0004Gn-9p; Wed, 17 Oct 2018 16:34:17 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1gCmtb-0003iZ-9r; Wed, 17 Oct 2018 17:33:59 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 17:33:49 +0300 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH 1/3] quorum: Remove quorum_err() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , Markus Armbruster , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This is a static function with only one caller, so there's no need to keep it. Inlining the code in quorum_compare() makes it much simpler. Signed-off-by: Alberto Garcia Reported-by: Markus Armbruster --- block/quorum.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/block/quorum.c b/block/quorum.c index eb526cc0f1..b1b777baef 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -437,23 +437,7 @@ static bool quorum_iovec_compare(QEMUIOVector *a, QEMUIOVector *b) return true; } -static void GCC_FMT_ATTR(2, 3) quorum_err(QuorumAIOCB *acb, - const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - fprintf(stderr, "quorum: offset=%" PRIu64 " bytes=%" PRIu64 " ", - acb->offset, acb->bytes); - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); - va_end(ap); - exit(1); -} - -static bool quorum_compare(QuorumAIOCB *acb, - QEMUIOVector *a, - QEMUIOVector *b) +static bool quorum_compare(QuorumAIOCB *acb, QEMUIOVector *a, QEMUIOVector *b) { BDRVQuorumState *s = acb->bs->opaque; ssize_t offset; @@ -462,8 +446,10 @@ static bool quorum_compare(QuorumAIOCB *acb, if (s->is_blkverify) { offset = qemu_iovec_compare(a, b); if (offset != -1) { - quorum_err(acb, "contents mismatch at offset %" PRIu64, - acb->offset + offset); + fprintf(stderr, "quorum: offset=%" PRIu64 " bytes=%" PRIu64 + " contents mismatch at offset %" PRIu64 "\n", + acb->offset, acb->bytes, acb->offset + offset); + exit(1); } return true; } From patchwork Wed Oct 17 14:33:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 10645717 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F2C113B0 for ; Wed, 17 Oct 2018 14:36:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F406120415 for ; Wed, 17 Oct 2018 14:36:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7A0821E5A; Wed, 17 Oct 2018 14:36:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9A94C212E8 for ; Wed, 17 Oct 2018 14:36:23 +0000 (UTC) Received: from localhost ([::1]:37030 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gCmvu-0001SH-TS for patchwork-qemu-devel@patchwork.kernel.org; Wed, 17 Oct 2018 10:36:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52844) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gCmuJ-0000DA-6B for qemu-devel@nongnu.org; Wed, 17 Oct 2018 10:34:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gCmuG-0006HU-QW for qemu-devel@nongnu.org; Wed, 17 Oct 2018 10:34:43 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:48027) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gCmuG-0005ot-8W; Wed, 17 Oct 2018 10:34:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=eEG8rSmGvJF+bWufq/aBbY6dyeXCQnXdefWMrgNKHyM=; b=lIEuHvgTxH7tiLanZRS7Tjexj+61Jk6lPYngsy07R0IXiSkFKC3RSoxJDhKbzUzX4mCQNkxzukqkQVcjLUcv/2NcpCW8u76IuG9lPr/xvXwvWsgjkQvDG4YOpdJCBRs51zn2/NgCZr8jdKP2kSCPeL6JCrFhE/kn2T1eMB8k34QcjNh6Up71mlJvZHSjWyT2hjSPM5wwYLDUe+Tcp9SMsBrr5w61znlhl8qAQPQW2zv/cck0TC273i0baFuqijkttQZMBP/OBn9oHTE7yJuY7uBOBEkMKAvzApoIzmSxYM3bVW+PSEFh0ebabZ7xPb3aiiQo842dl5xRWXnro/Lsbg==; Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1gCmtt-0004Gp-AQ; Wed, 17 Oct 2018 16:34:17 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1gCmtb-0003ib-Au; Wed, 17 Oct 2018 17:33:59 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 17:33:50 +0300 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH 2/3] quorum: Return an error if the blkverify mode has invalid settings X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , Markus Armbruster , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The blkverify mode of Quorum can only be enabled if the number of children is exactly two and the value of vote-threshold is also two. If the user tries to enable it but the other settings are incorrect then QEMU simply prints an error message to stderr and carries on disabling the blkverify setting. This patch makes quorum_open() fail and return an error in this case. Signed-off-by: Alberto Garcia Reported-by: Markus Armbruster --- block/quorum.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/block/quorum.c b/block/quorum.c index b1b777baef..6188ff6666 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -912,13 +912,12 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags, s->read_pattern = ret; if (s->read_pattern == QUORUM_READ_PATTERN_QUORUM) { - /* is the driver in blkverify mode */ - if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false) && - s->num_children == 2 && s->threshold == 2) { - s->is_blkverify = true; - } else if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false)) { - fprintf(stderr, "blkverify mode is set by setting blkverify=on " - "and using two files with vote_threshold=2\n"); + s->is_blkverify = qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false); + if (s->is_blkverify && (s->num_children != 2 || s->threshold != 2)) { + error_setg(&local_err, "blkverify=on can only be set if there are " + "exactly two files and vote-threshold is 2"); + ret = -EINVAL; + goto exit; } s->rewrite_corrupted = qemu_opt_get_bool(opts, QUORUM_OPT_REWRITE, From patchwork Wed Oct 17 14:33:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 10645719 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19B8013A4 for ; Wed, 17 Oct 2018 14:36:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A06D20415 for ; Wed, 17 Oct 2018 14:36:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFEDC21E5A; Wed, 17 Oct 2018 14:36:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 870AC20415 for ; Wed, 17 Oct 2018 14:36:38 +0000 (UTC) Received: from localhost ([::1]:37036 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gCmw9-0001gf-S4 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 17 Oct 2018 10:36:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gCmuJ-0000D8-5M for qemu-devel@nongnu.org; Wed, 17 Oct 2018 10:34:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gCmuG-0006Gd-7g for qemu-devel@nongnu.org; Wed, 17 Oct 2018 10:34:43 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:48025) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gCmuE-0005or-F3; Wed, 17 Oct 2018 10:34:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=jPmBiybIYQlNkYQMVI+70/FvaaYTdPTfPByJcNwaI1M=; b=VC3eQ9r4rQ57VuX5UrEIhlHT2bP48BLiDDk0HEgDzCxjMM8p95Kg7Hc/5GjNVczdRa0mFqGlgKxkcx62AoIplHCMq2M1pJh8kOM1mGwXs7Vh+T1gmAkNJo1JAMCO6eR1y9kn6V32T3qDrQ62K0wBC8vRJ40HlAybtNPPblMYb704V/a8bE+xGbb4qkXVrFEoldGmoGo8W/58POvd581S4zRnyYhyaZVyHw664V8eLGsyRuYP6+dkU2n8Q/lUERBWVDG8V+YhHJ2JDhW8xF8+fZSA81e/WU48EhFPNKBDMVT/03ldblB1CuyhjoudE0xp6uYpYc6nzioDc+2PSdoCrg==; Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1gCmtt-0004Gq-9f; Wed, 17 Oct 2018 16:34:17 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1gCmtb-0003id-Bz; Wed, 17 Oct 2018 17:33:59 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 17:33:51 +0300 Message-Id: <3e64535f5e375a67890d3f912bc4618471d8e0ff.1539786605.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH 3/3] iotest: Test the blkverify mode of the Quorum driver X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , Markus Armbruster , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alberto Garcia --- tests/qemu-iotests/081 | 30 ++++++++++++++++++++++++++++++ tests/qemu-iotests/081.out | 16 ++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081 index da3fb0984b..0ea010afbf 100755 --- a/tests/qemu-iotests/081 +++ b/tests/qemu-iotests/081 @@ -168,6 +168,36 @@ echo "== checking that quorum is broken ==" $QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io +echo +echo "== checking the blkverify mode with broken content ==" + +quorum="driver=raw,file.driver=quorum,file.vote-threshold=2,file.blkverify=on" +quorum="$quorum,file.children.0.file.filename=$TEST_DIR/1.raw" +quorum="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw" +quorum="$quorum,file.children.0.driver=raw" +quorum="$quorum,file.children.1.driver=raw" + +$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io + +echo +echo "== writing the same data to both files ==" + +$QEMU_IO -c "write -P 0x32 0 $size" "$TEST_DIR/1.raw" | _filter_qemu_io +$QEMU_IO -c "write -P 0x32 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io + +echo +echo "== checking the blkverify mode with valid content ==" + +$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io + +echo +echo "== checking the blkverify mode with invalid settings ==" + +quorum="$quorum,file.children.2.file.filename=$TEST_DIR/3.raw" +quorum="$quorum,file.children.2.driver=raw" + +$QEMU_IO -c "open -o $quorum" | _filter_qemu_io + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/081.out b/tests/qemu-iotests/081.out index 2533c31c78..2f12c890e9 100644 --- a/tests/qemu-iotests/081.out +++ b/tests/qemu-iotests/081.out @@ -55,4 +55,20 @@ wrote 10485760/10485760 bytes at offset 0 == checking that quorum is broken == read failed: Input/output error + +== checking the blkverify mode with broken content == +quorum: offset=0 bytes=10485760 contents mismatch at offset 0 + +== writing the same data to both files == +wrote 10485760/10485760 bytes at offset 0 +10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 10485760/10485760 bytes at offset 0 +10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== checking the blkverify mode with valid content == +read 10485760/10485760 bytes at offset 0 +10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== checking the blkverify mode with invalid settings == +can't open: blkverify=on can only be set if there are exactly two files and vote-threshold is 2 *** done