From nobody Mon Feb 9 19:55:37 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1604684735; cv=none; d=zohomail.com; s=zohoarc; b=VZfncUQsML0TS23+6+3AdFtDpPwhhTBOPKRGNRduowl61EMDI1rIhT1jgHXsQwFPAveBbw+HIg5QQf14EA7cB4+wRknbBy9hsfKxx8UxZrBfJv4FZ9caR27Y7HgzVkup9hKigfwEE+7MRV96Re0R+70gVLBROfEtRZltScBWrxE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604684735; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FWPbYEvQ4sDniQZs/tN0Fc7C4jx2iT5Y1IcrYLecynY=; b=aoYzDdFh4GEr5sR7mTGQ3NIHukyioePtENI+A28LkWcN6RnwnCfY0W3Dnr5HEkSlXr8Lhm/ERTO7o2i/ONDlYnG7Ww8p0yseQoZE4aVED5qr++2+NXlBaGaY+7HL2ZsGqr5Jo9W7AXEjZ/C8qMOkYcjTLQ2e/TprwjGsLgItlSs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160468473480387.27087024093692; Fri, 6 Nov 2020 09:45:34 -0800 (PST) Received: from localhost ([::1]:44986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kb5np-0003By-Nh for importer@patchew.org; Fri, 06 Nov 2020 12:45:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kb5mj-000285-3E; Fri, 06 Nov 2020 12:44:25 -0500 Received: from fanzine.igalia.com ([178.60.130.6]:56597) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kb5mf-0007ha-IQ; Fri, 06 Nov 2020 12:44:24 -0500 Received: from [81.0.39.238] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1kb5mb-0003zk-8b; Fri, 06 Nov 2020 18:44:17 +0100 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1kb5mO-0007fS-CT; Fri, 06 Nov 2020 18:44:04 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=FWPbYEvQ4sDniQZs/tN0Fc7C4jx2iT5Y1IcrYLecynY=; b=bpUD30ZDfZF+PC6xk2XNfKY3xzu4OfaMhNuQzD4tn3z6xaMhEYrTFCLupluZXeoezEnoQ82bIqtR3AXC04ULRuvG8wtNcRVKURRh/pYGz4lBmTUPxeacnhxxC0cMpm1HrOTLWeJ0jVrD7z3tm08+pEossZ04pDXC09adVHRfUBLg0cf7JE4v0DJo/MtdcUnS40TDQtZRTBQA7Ur6vuvmyHGZYsRN6svCayhMAdsRqRyWC1TfWskWFtDRbOxHKUrtDhMGz5hjuXC7giFgLBWDDHnHXifcOeB2JJ4Gag4DG+RP46zWpS1CEFk/9SD8MpoyxIAYn+NcQZKcL9CSODQZGQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [PATCH v2 2/2] quorum: Implement bdrv_co_pwrite_zeroes() Date: Fri, 6 Nov 2020 18:43:48 +0100 Message-Id: <9bb1362c14a065c15f6e367217ed9096aadb1f26.1604684432.git.berto@igalia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=178.60.130.6; envelope-from=berto@igalia.com; helo=fanzine.igalia.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/06 12:44:18 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Tao Xu , Alberto Garcia , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This simply calls bdrv_co_pwrite_zeroes() in all children Signed-off-by: Alberto Garcia --- block/quorum.c | 18 ++++++++++++++++-- tests/qemu-iotests/312 | 7 +++++++ tests/qemu-iotests/312.out | 4 ++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/block/quorum.c b/block/quorum.c index 29cee42705..70b39a7226 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -692,8 +692,13 @@ static void write_quorum_entry(void *opaque) QuorumChildRequest *sacb =3D &acb->qcrs[i]; =20 sacb->bs =3D s->children[i]->bs; - sacb->ret =3D bdrv_co_pwritev(s->children[i], acb->offset, acb->bytes, - acb->qiov, acb->flags); + if (acb->flags & BDRV_REQ_ZERO_WRITE) { + sacb->ret =3D bdrv_co_pwrite_zeroes(s->children[i], acb->offset, + acb->bytes, acb->flags); + } else { + sacb->ret =3D bdrv_co_pwritev(s->children[i], acb->offset, acb->by= tes, + acb->qiov, acb->flags); + } if (sacb->ret =3D=3D 0) { acb->success_count++; } else { @@ -739,6 +744,14 @@ static int quorum_co_pwritev(BlockDriverState *bs, uin= t64_t offset, return ret; } =20 +static int quorum_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, + int bytes, BdrvRequestFlags flags) + +{ + return quorum_co_pwritev(bs, offset, bytes, NULL, + flags | BDRV_REQ_ZERO_WRITE); +} + static int64_t quorum_getlength(BlockDriverState *bs) { BDRVQuorumState *s =3D bs->opaque; @@ -1248,6 +1261,7 @@ static BlockDriver bdrv_quorum =3D { =20 .bdrv_co_preadv =3D quorum_co_preadv, .bdrv_co_pwritev =3D quorum_co_pwritev, + .bdrv_co_pwrite_zeroes =3D quorum_co_pwrite_zeroes, =20 .bdrv_add_child =3D quorum_add_child, .bdrv_del_child =3D quorum_del_child, diff --git a/tests/qemu-iotests/312 b/tests/qemu-iotests/312 index 1b08f1552f..93046393e7 100755 --- a/tests/qemu-iotests/312 +++ b/tests/qemu-iotests/312 @@ -114,6 +114,13 @@ $QEMU_IO -c "write -P 0 $((0x200000)) $((0x10000))" "$= TEST_IMG.0" | _filter_qemu $QEMU_IO -c "write -z $((0x200000)) $((0x30000))" "$TEST_IMG.1" | _filte= r_qemu_io $QEMU_IO -c "write -P 0 $((0x200000)) $((0x20000))" "$TEST_IMG.2" | _filte= r_qemu_io =20 +# Test 5: write data to a region and then zeroize it, doing it +# directly on the quorum device instead of the individual images. +# This has no effect on the end result but proves that the quorum driver +# supports 'write -z'. +$QEMU_IO -c "open -o $quorum" -c "write $((0x250000)) $((0x10000))" | _fil= ter_qemu_io +$QEMU_IO -c "open -o $quorum" -c "write -z $((0x250000)) $((0x10000))" | _= filter_qemu_io + echo echo '### Launch the drive-mirror job' echo diff --git a/tests/qemu-iotests/312.out b/tests/qemu-iotests/312.out index 4ae749175b..778dda95c7 100644 --- a/tests/qemu-iotests/312.out +++ b/tests/qemu-iotests/312.out @@ -39,6 +39,10 @@ wrote 196608/196608 bytes at offset 2097152 192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 131072/131072 bytes at offset 2097152 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 2424832 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 2424832 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 ### Launch the drive-mirror job =20 --=20 2.20.1