2010-04-26 11:44:05 +02:00
|
|
|
#!/bin/bash
|
2010-01-17 12:23:15 +01:00
|
|
|
#
|
|
|
|
# Rebasing COW images
|
|
|
|
#
|
|
|
|
# Copyright (C) 2009 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 <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
# creator
|
|
|
|
owner=kwolf@redhat.com
|
|
|
|
|
|
|
|
seq=`basename $0`
|
|
|
|
echo "QA output created by $seq"
|
|
|
|
|
|
|
|
here=`pwd`
|
|
|
|
tmp=/tmp/$$
|
|
|
|
status=1 # failure is the default!
|
|
|
|
|
|
|
|
_cleanup()
|
|
|
|
{
|
|
|
|
_cleanup_test_img
|
2013-09-25 14:12:22 +02:00
|
|
|
rm -f "$TEST_DIR/t.$IMGFMT.base_old"
|
|
|
|
rm -f "$TEST_DIR/t.$IMGFMT.base_new"
|
2010-01-17 12:23:15 +01:00
|
|
|
}
|
|
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
|
|
|
. ./common.rc
|
|
|
|
. ./common.filter
|
|
|
|
. ./common.pattern
|
|
|
|
|
2010-10-31 21:10:20 +01:00
|
|
|
# Currently only qcow2 and qed support rebasing
|
|
|
|
_supported_fmt qcow2 qed
|
2011-01-17 18:01:17 +01:00
|
|
|
_supported_proto generic
|
2010-01-17 12:23:15 +01:00
|
|
|
_supported_os Linux
|
|
|
|
|
|
|
|
CLUSTER_SIZE=65536
|
|
|
|
|
|
|
|
# Cluster allocations to be tested:
|
|
|
|
#
|
|
|
|
# Backing (old) 11 -- 11 -- 11 -- 11 --
|
|
|
|
# Backing (new) 22 22 -- -- 22 22 -- --
|
|
|
|
# COW image 33 33 33 33 -- -- -- --
|
2010-05-04 18:59:26 +02:00
|
|
|
#
|
|
|
|
# The pattern is written twice to have both an alloc -> non-alloc and a
|
|
|
|
# non-alloc -> alloc transition in the COW image.
|
2010-01-17 12:23:15 +01:00
|
|
|
|
|
|
|
echo "Creating backing file"
|
|
|
|
echo
|
|
|
|
|
|
|
|
_make_test_img 1G
|
qemu-iotests: Use zero-based offsets for IO patterns
The io_pattern style functions have the following loop:
for i in `seq 1 $count`; do
echo ... $(( start + i * step )) ...
done
Offsets are 1-based so start=1024, step=512, count=4 yields:
1536, 2048, 2560, 3072
Normally we expect:
1024, 1536, 2048, 2560
Most tests ignore this detail, which means that they perform I/O to a
slightly different range than expected by the test author.
Later on things got less innocent and tests started trying to compensate
for the 1-based indexing. This included negative start values in test
024 and my own attempt with count-1 in test 028!
The end result is that tests that use io_pattern are hard to reason
about and don't work the way you'd expect. It's time to clean this mess
up.
This patch switches io_pattern to 0-based offsets. This requires
adjusting the golden outputs since I/O ranges are now shifted and output
differs.
Verifying these output diffs is easy, however. Each diff hunk moves one
I/O from beyond the end of the pattern range to the beginning.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2011-02-04 13:55:02 +01:00
|
|
|
io_pattern writev 0 $CLUSTER_SIZE $((2 * CLUSTER_SIZE)) 8 0x11
|
2013-09-25 14:12:22 +02:00
|
|
|
mv "$TEST_IMG" "$TEST_IMG.base_old"
|
2010-01-17 12:23:15 +01:00
|
|
|
|
|
|
|
echo "Creating new backing file"
|
|
|
|
echo
|
|
|
|
|
|
|
|
_make_test_img 1G
|
qemu-iotests: Use zero-based offsets for IO patterns
The io_pattern style functions have the following loop:
for i in `seq 1 $count`; do
echo ... $(( start + i * step )) ...
done
Offsets are 1-based so start=1024, step=512, count=4 yields:
1536, 2048, 2560, 3072
Normally we expect:
1024, 1536, 2048, 2560
Most tests ignore this detail, which means that they perform I/O to a
slightly different range than expected by the test author.
Later on things got less innocent and tests started trying to compensate
for the 1-based indexing. This included negative start values in test
024 and my own attempt with count-1 in test 028!
The end result is that tests that use io_pattern are hard to reason
about and don't work the way you'd expect. It's time to clean this mess
up.
This patch switches io_pattern to 0-based offsets. This requires
adjusting the golden outputs since I/O ranges are now shifted and output
differs.
Verifying these output diffs is easy, however. Each diff hunk moves one
I/O from beyond the end of the pattern range to the beginning.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2011-02-04 13:55:02 +01:00
|
|
|
io_pattern writev 0 $((2 * CLUSTER_SIZE)) $((4 * CLUSTER_SIZE)) 4 0x22
|
2013-09-25 14:12:22 +02:00
|
|
|
mv "$TEST_IMG" "$TEST_IMG.base_new"
|
2010-01-17 12:23:15 +01:00
|
|
|
|
|
|
|
echo "Creating COW image"
|
|
|
|
echo
|
|
|
|
|
2013-09-25 14:12:22 +02:00
|
|
|
_make_test_img -b "$TEST_IMG.base_old" 1G
|
2010-01-17 12:23:15 +01:00
|
|
|
io_pattern writev 0 $((4 * CLUSTER_SIZE)) 0 1 0x33
|
2010-05-04 18:59:26 +02:00
|
|
|
io_pattern writev $((8 * CLUSTER_SIZE)) $((4 * CLUSTER_SIZE)) 0 1 0x33
|
2010-01-17 12:23:15 +01:00
|
|
|
|
|
|
|
echo "Read before the rebase to make sure everything is set up correctly"
|
|
|
|
echo
|
|
|
|
io_pattern readv $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((1 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((3 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((4 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
|
|
|
|
io_pattern readv $((5 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
|
|
|
|
io_pattern readv $((6 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
|
|
|
|
io_pattern readv $((7 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
|
2010-05-04 18:59:26 +02:00
|
|
|
io_pattern readv $((8 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((9 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((10 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((11 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((12 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
|
|
|
|
io_pattern readv $((13 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
|
|
|
|
io_pattern readv $((14 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
|
|
|
|
io_pattern readv $((15 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
|
2010-01-17 12:23:15 +01:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo Rebase and test again
|
|
|
|
echo
|
2013-09-25 14:12:22 +02:00
|
|
|
$QEMU_IMG rebase -b "$TEST_IMG.base_new" "$TEST_IMG"
|
2010-01-17 12:23:15 +01:00
|
|
|
io_pattern readv $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((1 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((3 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((4 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
|
|
|
|
io_pattern readv $((5 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
|
|
|
|
io_pattern readv $((6 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
|
|
|
|
io_pattern readv $((7 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
|
2010-05-04 18:59:26 +02:00
|
|
|
io_pattern readv $((8 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((9 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((10 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((11 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x33
|
|
|
|
io_pattern readv $((12 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
|
|
|
|
io_pattern readv $((13 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
|
|
|
|
io_pattern readv $((14 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
|
|
|
|
io_pattern readv $((15 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
|
2010-01-17 12:23:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
# success, all done
|
|
|
|
echo "*** done"
|
|
|
|
rm -f $seq.full
|
|
|
|
status=0
|