From nobody Sun Feb 8 13:45:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491873608665118.05924338918499; Mon, 10 Apr 2017 18:20:08 -0700 (PDT) Received: from localhost ([::1]:36690 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxkTX-0006y3-Dr for importer@patchew.org; Mon, 10 Apr 2017 21:20:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxkR6-0005HI-AI for qemu-devel@nongnu.org; Mon, 10 Apr 2017 21:17:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxkR4-0005px-E9 for qemu-devel@nongnu.org; Mon, 10 Apr 2017 21:17:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36620) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cxkQy-0005n9-P5; Mon, 10 Apr 2017 21:17:28 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C482C80461; Tue, 11 Apr 2017 01:17:27 +0000 (UTC) Received: from red.redhat.com (ovpn-122-58.rdu2.redhat.com [10.10.122.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id E355C78DF2; Tue, 11 Apr 2017 01:17:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C482C80461 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=eblake@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C482C80461 From: Eric Blake To: qemu-devel@nongnu.org Date: Mon, 10 Apr 2017 20:17:07 -0500 Message-Id: <20170411011718.9152-3-eblake@redhat.com> In-Reply-To: <20170411011718.9152-1-eblake@redhat.com> References: <20170411011718.9152-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 11 Apr 2017 01:17:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v9 02/13] iotests: Add test 179 to cover write zeroes with unmap 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: kwolf@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" No tests were covering write zeroes with unmap. Additionally, I wanted to prove that my patch to optimize write zeroes for compat=3D0.10 images actually had an impact; for that, run: ./check -qcow2 -o compat=3D0.10 179 Writing the test to work correctly for both old and new qcow2 images is a bit tricky: 'qemu-img map' works for showing whether a cluster is assigned an offset (in the preallocation sense), but older images have to write literal zeroes where newer images can set the zero flag. Thankfully, 'qemu-io alloc' hides the difference, by instead reporting whether a cluster's content comes from the current layer (regardless of whether it was due to a cluster allocation or a flag). Signed-off-by: Eric Blake --- tests/qemu-iotests/179 | 78 ++++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/179.out | 22 +++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 101 insertions(+) create mode 100755 tests/qemu-iotests/179 create mode 100644 tests/qemu-iotests/179.out diff --git a/tests/qemu-iotests/179 b/tests/qemu-iotests/179 new file mode 100755 index 0000000..338a45d --- /dev/null +++ b/tests/qemu-iotests/179 @@ -0,0 +1,78 @@ +#!/bin/bash +# +# Test case for write zeroes with unmap +# +# Copyright (C) 2017 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=3Deblake@redhat.com + +seq=3D"$(basename $0)" +echo "QA output created by $seq" + +here=3D"$PWD" +status=3D1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux + +echo +echo '=3D=3D=3D Testing write zeroes with unmap =3D=3D=3D' +echo + +TEST_IMG=3D"$TEST_IMG.base" _make_test_img 16M +_make_test_img -b "$TEST_IMG.base" + +# Aligned writes should not allocate clusters, if unmap is requested +# and there is no backing file. +$QEMU_IO -c "write -z -u 1M 1M" "$TEST_IMG.base" | _filter_qemu_io + +# Unmap can even clear previously-allocated clusters. +$QEMU_IO -c "write 3M 1M" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "write -z -u 3M 1M" "$TEST_IMG.base" | _filter_qemu_io + +# Up to now, the entire image should still be unallocated. +$QEMU_IMG map --output=3Djson "$TEST_IMG" | _filter_qemu_img_map + +# But not requesting unmap must result in allocation (whether a cluster +# allocation in compat=3D0.10 or a flag allocation in compat=3D1.1). +$QEMU_IO -c "write -z 5M 1M" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "alloc 5M $((1024*1024 / 512))" "$TEST_IMG.base" | _filter_qem= u_io + +# Presence of a backing file overrides permission to unmap. Again, +# compat=3D0.10 images allocate, while compat=3D1.1 images set zero flag. +$QEMU_IO -c "write -z -u 7M 1M" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "alloc 7M $((1024 * 1024 / 512))" "$TEST_IMG" | _filter_qemu_io + +# Final check that images are still sane. +TEST_IMG=3D"$TEST_IMG.base" _check_test_img +_check_test_img + +# success, all done +echo '*** done' +status=3D0 diff --git a/tests/qemu-iotests/179.out b/tests/qemu-iotests/179.out new file mode 100644 index 0000000..fc97b19 --- /dev/null +++ b/tests/qemu-iotests/179.out @@ -0,0 +1,22 @@ +QA output created by 179 + +=3D=3D=3D Testing write zeroes with unmap =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D16777216 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D16777216 backing_file= =3DTEST_DIR/t.IMGFMT.base +wrote 1048576/1048576 bytes at offset 1048576 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1048576/1048576 bytes at offset 3145728 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1048576/1048576 bytes at offset 3145728 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +[{ "start": 0, "length": 16777216, "depth": 1, "zero": true, "data": false= }] +wrote 1048576/1048576 bytes at offset 5242880 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +2048/2048 sectors allocated at offset 5 MiB +wrote 1048576/1048576 bytes at offset 7340032 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +2048/2048 sectors allocated at offset 7 MiB +No errors were found on the image. +No errors were found on the image. +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 43142dd..cfc8823 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -169,3 +169,4 @@ 174 auto 175 auto quick 176 rw auto backing +179 rw auto quick --=20 2.9.3