111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 2*9dd003a9SVladimir Sementsov-Ogievskiy# group: rw auto quick 340812d93SEric Blake# 440812d93SEric Blake# Test corner cases with unusual block geometries 540812d93SEric Blake# 6d6ac6e93SEric Blake# Copyright (C) 2016-2018 Red Hat, Inc. 740812d93SEric Blake# 840812d93SEric Blake# This program is free software; you can redistribute it and/or modify 940812d93SEric Blake# it under the terms of the GNU General Public License as published by 1040812d93SEric Blake# the Free Software Foundation; either version 2 of the License, or 1140812d93SEric Blake# (at your option) any later version. 1240812d93SEric Blake# 1340812d93SEric Blake# This program is distributed in the hope that it will be useful, 1440812d93SEric Blake# but WITHOUT ANY WARRANTY; without even the implied warranty of 1540812d93SEric Blake# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1640812d93SEric Blake# GNU General Public License for more details. 1740812d93SEric Blake# 1840812d93SEric Blake# You should have received a copy of the GNU General Public License 1940812d93SEric Blake# along with this program. If not, see <http://www.gnu.org/licenses/>. 2040812d93SEric Blake# 2140812d93SEric Blake 2240812d93SEric Blake# creator 2340812d93SEric Blakeowner=eblake@redhat.com 2440812d93SEric Blake 2540812d93SEric Blakeseq=`basename $0` 2640812d93SEric Blakeecho "QA output created by $seq" 2740812d93SEric Blake 2840812d93SEric Blakestatus=1 # failure is the default! 2940812d93SEric Blake 3040812d93SEric Blake_cleanup() 3140812d93SEric Blake{ 3240812d93SEric Blake _cleanup_test_img 3340812d93SEric Blake} 3440812d93SEric Blaketrap "_cleanup; exit \$status" 0 1 2 3 15 3540812d93SEric Blake 3640812d93SEric Blake# get standard environment, filters and checks 3740812d93SEric Blake. ./common.rc 3840812d93SEric Blake. ./common.filter 3940812d93SEric Blake 40d6ac6e93SEric Blake# This test is runnable under compat=0.10; see test 204 for additional 41d6ac6e93SEric Blake# tests specific to compat=1.1. 42d6ac6e93SEric Blake 4340812d93SEric Blake_supported_fmt qcow2 4457284d2aSMax Reitz_supported_proto file fuse 4540812d93SEric Blake 4640812d93SEric BlakeCLUSTER_SIZE=1M 4740812d93SEric Blakesize=128M 4840812d93SEric Blakeoptions=driver=blkdebug,image.driver=qcow2 4940812d93SEric Blake 5040812d93SEric Blakeecho 5140812d93SEric Blakeecho "== setting up files ==" 5240812d93SEric Blake 5340812d93SEric BlakeTEST_IMG="$TEST_IMG.base" _make_test_img $size 5440812d93SEric Blake$QEMU_IO -c "write -P 11 0 $size" "$TEST_IMG.base" | _filter_qemu_io 55b66ff2c2SEric Blake_make_test_img -b "$TEST_IMG.base" -F $IMGFMT 56d6ac6e93SEric Blake$QEMU_IO -c "write -P 22 0 $size" "$TEST_IMG" | _filter_qemu_io 5740812d93SEric Blake 5840812d93SEric Blake# Limited to 64k max-transfer 5940812d93SEric Blakeecho 6040812d93SEric Blakeecho "== constrained alignment and max-transfer ==" 6140812d93SEric Blakelimits=align=4k,max-transfer=64k 6240812d93SEric Blake$QEMU_IO -c "open -o $options,$limits blkdebug::$TEST_IMG" \ 6340812d93SEric Blake -c "write -P 33 1000 128k" -c "read -P 33 1000 128k" | _filter_qemu_io 6440812d93SEric Blake 6540812d93SEric Blakeecho 6640812d93SEric Blakeecho "== write zero with constrained max-transfer ==" 6740812d93SEric Blakelimits=align=512,max-transfer=64k,opt-write-zero=$CLUSTER_SIZE 6840812d93SEric Blake$QEMU_IO -c "open -o $options,$limits blkdebug::$TEST_IMG" \ 6940812d93SEric Blake -c "write -z 8003584 2093056" | _filter_qemu_io 7040812d93SEric Blake 7140812d93SEric Blake# non-power-of-2 write-zero/discard alignments 7240812d93SEric Blakeecho 7340812d93SEric Blakeecho "== non-power-of-2 write zeroes limits ==" 7440812d93SEric Blake 7540812d93SEric Blakelimits=align=512,opt-write-zero=15M,max-write-zero=15M,opt-discard=15M,max-discard=15M 7640812d93SEric Blake$QEMU_IO -c "open -o $options,$limits blkdebug::$TEST_IMG" \ 7740812d93SEric Blake -c "write -z 32M 32M" | _filter_qemu_io 7840812d93SEric Blake 7940812d93SEric Blakeecho 8040812d93SEric Blakeecho "== non-power-of-2 discard limits ==" 8140812d93SEric Blake 8240812d93SEric Blakelimits=align=512,opt-write-zero=15M,max-write-zero=15M,opt-discard=15M,max-discard=15M 8340812d93SEric Blake$QEMU_IO -c "open -o $options,$limits blkdebug::$TEST_IMG" \ 8440812d93SEric Blake -c "discard 80000001 30M" | _filter_qemu_io 8540812d93SEric Blake 8640812d93SEric Blakeecho 8740812d93SEric Blakeecho "== verify image content ==" 8840812d93SEric Blake 898cedcffdSEric Blakeverify_io() 9040812d93SEric Blake{ 9140812d93SEric Blake if ($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | 9240812d93SEric Blake grep "compat: 0.10" > /dev/null); then 9380f5c011SAlberto Garcia # In v2 images clusters are not discarded when there is a backing file 9480f5c011SAlberto Garcia # so the previous value is read 9580f5c011SAlberto Garcia discarded=22 9640812d93SEric Blake else 9740812d93SEric Blake # Discarded clusters are zeroed for v3 or later 9840812d93SEric Blake discarded=0 9940812d93SEric Blake fi 10040812d93SEric Blake 10140812d93SEric Blake echo read -P 22 0 1000 10240812d93SEric Blake echo read -P 33 1000 128k 10340812d93SEric Blake echo read -P 22 132072 7871512 10440812d93SEric Blake echo read -P 0 8003584 2093056 10540812d93SEric Blake echo read -P 22 10096640 23457792 10640812d93SEric Blake echo read -P 0 32M 32M 10740812d93SEric Blake echo read -P 22 64M 13M 10840812d93SEric Blake echo read -P $discarded 77M 29M 109d6ac6e93SEric Blake echo read -P 22 106M 22M 11040812d93SEric Blake} 11140812d93SEric Blake 11240812d93SEric Blakeverify_io | $QEMU_IO -r "$TEST_IMG" | _filter_qemu_io 11340812d93SEric Blake 11440812d93SEric Blake_check_test_img 11540812d93SEric Blake 11640812d93SEric Blake# success, all done 11740812d93SEric Blakeecho "*** done" 11840812d93SEric Blakestatus=0 119