From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39655) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcDSx-00050J-8D for qemu-devel@nongnu.org; Mon, 31 Jul 2017 12:22:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcDSt-0005Y5-Sd for qemu-devel@nongnu.org; Mon, 31 Jul 2017 12:22:47 -0400 From: Anton Nefedov Date: Mon, 31 Jul 2017 19:22:04 +0300 Message-Id: <1501518125-29851-13-git-send-email-anton.nefedov@virtuozzo.com> In-Reply-To: <1501518125-29851-1-git-send-email-anton.nefedov@virtuozzo.com> References: <1501518125-29851-1-git-send-email-anton.nefedov@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH v3 12/13] iotest 190: test BDRV_REQ_ALLOCATE List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, kwolf@redhat.com, mreitz@redhat.com, eblake@redhat.com, Anton Nefedov Signed-off-by: Anton Nefedov --- tests/qemu-iotests/190 | 146 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/190.out | 50 ++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 197 insertions(+) create mode 100755 tests/qemu-iotests/190 create mode 100644 tests/qemu-iotests/190.out diff --git a/tests/qemu-iotests/190 b/tests/qemu-iotests/190 new file mode 100755 index 0000000..ad7162a --- /dev/null +++ b/tests/qemu-iotests/190 @@ -0,0 +1,146 @@ +#!/bin/env bash +# +# Test qcow2 BDRV_REQ_ALLOCATE requests +# +# Copyright (c) 2017 Parallels International GmbH +# +# 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 . +## + +seq=`basename $0` +echo "QA output created by $seq" + +status=1 # 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 + +function do_io() +{ + $QEMU_IO "$@" | _filter_qemu_io |\ + sed -e 's/bytes at offset [0-9]*/bytes at offset XXX/g' +} + +CLUSTER_SIZE=64k +size=128M + +_make_test_img 1G + +echo +echo "== Test discarded cluster reuse ==" + +# allocate first two clusters +do_io -c "writev -P 1 0x8000 0x10000" "$TEST_IMG" +len=$(stat -c "%s" $TEST_IMG) + +# discard the 1st cluster on qcow2 level only +do_io -c "open -o pass-discard-request=off $TEST_IMG" -c "discard 0 0x10000" + +# new write will reuse the dirty host cluster and has to overwrite that +# with zeroes +do_io -c "writev -P 2 0x24000 0x8000" "$TEST_IMG" +if [ $len -ne $(stat -c "%s" $TEST_IMG) ] ; then + >&2 echo "Failed to reuse cluster" + exit 1 +fi + +echo +echo "== Test preallocation ==" + +function io_commands() +{ + echo "open -o prealloc-size=$((1024*1024)) blkdebug::$TEST_IMG" + + # Verify that intersections of a running preallocation and new requests + # is handled properly. + # + # 1. send a write #1 which triggers preallocation, suspend it in action + # 2. send a write #2 which intersects with the area being preallocated + # 3. using break/wait_break/resume, wait until write #2 is at least + # at WRITE_AIO tracepoint. + # Then it is supposed to enter pwrite(bs->child) and start waiting + # for #1 to finish + # 4. resume #1 + +cat <