mirror of https://github.com/xqemu/xqemu.git
qemu-iotests: align test requests according to cluster size
Change the io_test and io_test2 functions to take the cluster size of the image and the number of test requests to issue. Tests are changed to specify a cluster size (usually 4k), but expected test results stay the same for now (apart from qemu-img printing the cluster size now). Based on a patch written by Christoph Hellwig. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
3b5fe6e60c
commit
8fc1024cee
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# qcow2 pattern test, empty and compressed image
|
# qcow2 pattern test, empty and compressed image - 4k cluster patterns
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Red Hat, Inc.
|
# Copyright (C) 2009 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
|
@ -45,6 +45,7 @@ _supported_os Linux
|
||||||
|
|
||||||
TEST_OFFSETS="0 4294967296"
|
TEST_OFFSETS="0 4294967296"
|
||||||
TEST_OPS="writev read write readv"
|
TEST_OPS="writev read write readv"
|
||||||
|
CLUSTER_SIZE=4096
|
||||||
|
|
||||||
_make_test_img 6G
|
_make_test_img 6G
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ echo
|
||||||
for offset in $TEST_OFFSETS; do
|
for offset in $TEST_OFFSETS; do
|
||||||
echo "At offset $offset:"
|
echo "At offset $offset:"
|
||||||
for op in $TEST_OPS; do
|
for op in $TEST_OPS; do
|
||||||
io_test $op $offset
|
io_test $op $offset $CLUSTER_SIZE 8
|
||||||
done
|
done
|
||||||
_check_test_img
|
_check_test_img
|
||||||
done
|
done
|
||||||
|
@ -72,7 +73,7 @@ echo
|
||||||
for offset in $TEST_OFFSETS; do
|
for offset in $TEST_OFFSETS; do
|
||||||
echo "With offset $offset:"
|
echo "With offset $offset:"
|
||||||
for op in read readv; do
|
for op in read readv; do
|
||||||
io_test $op $offset
|
io_test $op $offset $CLUSTER_SIZE 8
|
||||||
done
|
done
|
||||||
_check_test_img
|
_check_test_img
|
||||||
done
|
done
|
||||||
|
@ -85,7 +86,7 @@ for offset in $TEST_OFFSETS; do
|
||||||
offset=$((offset + 512))
|
offset=$((offset + 512))
|
||||||
echo "With offset $offset:"
|
echo "With offset $offset:"
|
||||||
for op in $TEST_OPS; do
|
for op in $TEST_OPS; do
|
||||||
io_test $op $offset
|
io_test $op $offset $CLUSTER_SIZE 8
|
||||||
done
|
done
|
||||||
_check_test_img
|
_check_test_img
|
||||||
done
|
done
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
QA output created by 013
|
QA output created by 013
|
||||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=6442450944
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=6442450944 cluster_size=4096
|
||||||
Testing empty image
|
Testing empty image
|
||||||
|
|
||||||
At offset 0:
|
At offset 0:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# qcow2 pattern test, complex patterns including compression and snapshots
|
# qcow2 pattern test, complex patterns including compression and snapshots
|
||||||
|
# Using patterns for 4k cluster size.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Red Hat, Inc.
|
# Copyright (C) 2009 Red Hat, Inc.
|
||||||
|
@ -46,13 +47,14 @@ _supported_os Linux
|
||||||
|
|
||||||
TEST_OFFSETS="0 4294967296"
|
TEST_OFFSETS="0 4294967296"
|
||||||
TEST_OPS="writev read write readv"
|
TEST_OPS="writev read write readv"
|
||||||
|
CLUSTER_SIZE=4096
|
||||||
|
|
||||||
_make_test_img 6G
|
_make_test_img 6G
|
||||||
|
|
||||||
echo "Testing empty image:"
|
echo "Testing empty image:"
|
||||||
for offset in $TEST_OFFSETS; do
|
for offset in $TEST_OFFSETS; do
|
||||||
echo test2: With offset $offset
|
echo test2: With offset $offset
|
||||||
io_test2 $offset
|
io_test2 $offset $CLUSTER_SIZE 256
|
||||||
_check_test_img
|
_check_test_img
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -62,7 +64,7 @@ for i in `seq 1 3`; do
|
||||||
for offset in $TEST_OFFSETS; do
|
for offset in $TEST_OFFSETS; do
|
||||||
echo With snapshot test$i, offset $offset
|
echo With snapshot test$i, offset $offset
|
||||||
for op in $TEST_OPS; do
|
for op in $TEST_OPS; do
|
||||||
io_test $op $offset
|
io_test $op $offset $CLUSTER_SIZE 8
|
||||||
done
|
done
|
||||||
_check_test_img
|
_check_test_img
|
||||||
done
|
done
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
QA output created by 014
|
QA output created by 014
|
||||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=6442450944
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=6442450944 cluster_size=4096
|
||||||
Testing empty image:
|
Testing empty image:
|
||||||
test2: With offset 0
|
test2: With offset 0
|
||||||
=== Clusters to be compressed [1]
|
=== Clusters to be compressed [1]
|
||||||
|
|
|
@ -48,6 +48,7 @@ _supported_fmt qcow qcow2 vmdk
|
||||||
_supported_os Linux
|
_supported_os Linux
|
||||||
|
|
||||||
TEST_OFFSETS="0 4294967296"
|
TEST_OFFSETS="0 4294967296"
|
||||||
|
CLUSTER_SIZE=65536
|
||||||
|
|
||||||
_make_test_img 6G
|
_make_test_img 6G
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
QA output created by 019
|
QA output created by 019
|
||||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=6442450944
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=6442450944 cluster_size=65536
|
||||||
Filling base image
|
Filling base image
|
||||||
|
|
||||||
=== IO: pattern 0
|
=== IO: pattern 0
|
||||||
|
@ -269,7 +269,7 @@ qemu-io> wrote 65536/65536 bytes at offset 4296081408
|
||||||
qemu-io> No errors were found on the image.
|
qemu-io> No errors were found on the image.
|
||||||
Creating test image with backing file
|
Creating test image with backing file
|
||||||
|
|
||||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=6442450944 backing_file='TEST_DIR/t.IMGFMT.base'
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=6442450944 backing_file='TEST_DIR/t.IMGFMT.base' cluster_size=65536
|
||||||
Filling test image
|
Filling test image
|
||||||
|
|
||||||
=== IO: pattern 1
|
=== IO: pattern 1
|
||||||
|
|
|
@ -46,6 +46,7 @@ _supported_fmt qcow2
|
||||||
_supported_os Linux
|
_supported_os Linux
|
||||||
|
|
||||||
TEST_OFFSETS="10485760 4294967296"
|
TEST_OFFSETS="10485760 4294967296"
|
||||||
|
CLUSTER_SIZE="4096"
|
||||||
|
|
||||||
_make_test_img 6G
|
_make_test_img 6G
|
||||||
|
|
||||||
|
@ -54,8 +55,8 @@ echo
|
||||||
|
|
||||||
for offset in $TEST_OFFSETS; do
|
for offset in $TEST_OFFSETS; do
|
||||||
echo "At offset $offset:"
|
echo "At offset $offset:"
|
||||||
io_test "write -b" $offset
|
io_test "write -b" $offset $CLUSTER_SIZE 8
|
||||||
io_test "read -b" $offset
|
io_test "read -b" $offset $CLUSTER_SIZE 8
|
||||||
_check_test_img
|
_check_test_img
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
QA output created by 022
|
QA output created by 022
|
||||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=6442450944
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=6442450944 cluster_size=4096
|
||||||
Testing empty image
|
Testing empty image
|
||||||
|
|
||||||
At offset 10485760:
|
At offset 10485760:
|
||||||
|
|
|
@ -63,69 +63,77 @@ function io_zero() {
|
||||||
function io_test() {
|
function io_test() {
|
||||||
local op=$1
|
local op=$1
|
||||||
local offset=$2
|
local offset=$2
|
||||||
|
local cluster_size=$3
|
||||||
|
|
||||||
# Complete clusters (size = 4k)
|
local num_large=$4
|
||||||
io "$op" $offset 4096 4096 256
|
local num_medium=$((num_large * num_large))
|
||||||
offset=$((offset + 256 * 4096))
|
local num_small=$((4 * num_medium))
|
||||||
|
|
||||||
|
local half_cluster=$((cluster_size / 2))
|
||||||
|
local quarter_cluster=$((cluster_size / 4))
|
||||||
|
local l2_size=$((cluster_size * cluster_size / 8))
|
||||||
|
|
||||||
|
# Complete clusters
|
||||||
|
io "$op" $offset $cluster_size $cluster_size $num_small
|
||||||
|
offset=$((offset + num_small * $cluster_size))
|
||||||
|
|
||||||
# From somewhere in the middle to the end of a cluster
|
# From somewhere in the middle to the end of a cluster
|
||||||
io "$op" $((offset + 2048)) 2048 4096 256
|
io "$op" $((offset + $half_cluster)) $half_cluster $cluster_size $num_small
|
||||||
offset=$((offset + 256 * 4096))
|
offset=$((offset + num_small * $cluster_size))
|
||||||
|
|
||||||
# From the start to somewhere in the middle of a cluster
|
# From the start to somewhere in the middle of a cluster
|
||||||
io "$op" $offset 2048 4096 256
|
io "$op" $offset $half_cluster $cluster_size $num_small
|
||||||
offset=$((offset + 256 * 4096))
|
offset=$((offset + num_small * $cluster_size))
|
||||||
|
|
||||||
# Completely misaligned (and small)
|
# Completely misaligned (and small)
|
||||||
io "$op" $((offset + 1024)) 2048 4096 256
|
io "$op" $((offset + $quarter_cluster)) $half_cluster $cluster_size $num_small
|
||||||
offset=$((offset + 256 * 4096))
|
offset=$((offset + num_small * $cluster_size))
|
||||||
|
|
||||||
# Spanning multiple clusters
|
# Spanning multiple clusters
|
||||||
io "$op" $((offset + 2048)) 8192 12288 64
|
io "$op" $((offset + $half_cluster)) $((cluster_size * 2)) $((cluster_size * 3)) $num_medium
|
||||||
offset=$((offset + 64 * 12288))
|
offset=$((offset + num_medium * 3 * $cluster_size))
|
||||||
|
|
||||||
# Spanning multiple L2 tables
|
# Spanning multiple L2 tables
|
||||||
# L2 table size: 512 clusters of 4k = 2M
|
# L2 table size: 512 clusters of 4k = 2M
|
||||||
io "$op" $((offset + 2048)) 4194304 4999680 8
|
io "$op" $((offset + $half_cluster)) $((2 * l2_size)) 4999680 $num_large
|
||||||
offset=$((offset + 8 * 4999680))
|
offset=$((offset + num_large * (2 * l2_size + 512 * 1573)))
|
||||||
|
|
||||||
if false; then
|
|
||||||
true
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function io_test2() {
|
function io_test2() {
|
||||||
local orig_offset=$1
|
local orig_offset=$1
|
||||||
|
local cluster_size=$2
|
||||||
|
local num=$3
|
||||||
|
|
||||||
# Pattern (repeat after 9 clusters):
|
# Pattern (repeat after 9 clusters):
|
||||||
# used - used - free - used - compressed - compressed - free - free - compressed
|
# used - used - free - used - compressed - compressed -
|
||||||
|
# free - free - compressed
|
||||||
|
|
||||||
# Write the clusters to be compressed
|
# Write the clusters to be compressed
|
||||||
echo === Clusters to be compressed [1]
|
echo === Clusters to be compressed [1]
|
||||||
io_pattern writev $((offset + 4 * 4096)) 4096 $((9 * 4096)) 256 165
|
io_pattern writev $((offset + 4 * $cluster_size)) $cluster_size $((9 * $cluster_size)) $num 165
|
||||||
echo === Clusters to be compressed [2]
|
echo === Clusters to be compressed [2]
|
||||||
io_pattern writev $((offset + 5 * 4096)) 4096 $((9 * 4096)) 256 165
|
io_pattern writev $((offset + 5 * $cluster_size)) $cluster_size $((9 * $cluster_size)) $num 165
|
||||||
echo === Clusters to be compressed [3]
|
echo === Clusters to be compressed [3]
|
||||||
io_pattern writev $((offset + 8 * 4096)) 4096 $((9 * 4096)) 256 165
|
io_pattern writev $((offset + 8 * $cluster_size)) $cluster_size $((9 * $cluster_size)) $num 165
|
||||||
|
|
||||||
mv $TEST_IMG $TEST_IMG.orig
|
mv $TEST_IMG $TEST_IMG.orig
|
||||||
$QEMU_IMG convert -f $IMGFMT -O $IMGFMT -c $TEST_IMG.orig $TEST_IMG
|
$QEMU_IMG convert -f $IMGFMT -O $IMGFMT -c $TEST_IMG.orig $TEST_IMG
|
||||||
|
|
||||||
# Write the used clusters
|
# Write the used clusters
|
||||||
echo === Used clusters [1]
|
echo === Used clusters [1]
|
||||||
io_pattern writev $((offset + 0 * 4096)) 4096 $((9 * 4096)) 256 165
|
io_pattern writev $((offset + 0 * $cluster_size)) $cluster_size $((9 * $cluster_size)) $num 165
|
||||||
echo === Used clusters [2]
|
echo === Used clusters [2]
|
||||||
io_pattern writev $((offset + 1 * 4096)) 4096 $((9 * 4096)) 256 165
|
io_pattern writev $((offset + 1 * $cluster_size)) $cluster_size $((9 * $cluster_size)) $num 165
|
||||||
echo === Used clusters [3]
|
echo === Used clusters [3]
|
||||||
io_pattern writev $((offset + 3 * 4096)) 4096 $((9 * 4096)) 256 165
|
io_pattern writev $((offset + 3 * $cluster_size)) $cluster_size $((9 * $cluster_size)) $num 165
|
||||||
|
|
||||||
# Read them
|
# Read them
|
||||||
echo === Read used/compressed clusters
|
echo === Read used/compressed clusters
|
||||||
io_pattern readv $((offset + 0 * 4096)) $((2 * 4096)) $((9 * 4096)) 256 165
|
io_pattern readv $((offset + 0 * $cluster_size)) $((2 * $cluster_size)) $((9 * $cluster_size)) $num 165
|
||||||
io_pattern readv $((offset + 3 * 4096)) $((3 * 4096)) $((9 * 4096)) 256 165
|
io_pattern readv $((offset + 3 * $cluster_size)) $((3 * $cluster_size)) $((9 * $cluster_size)) $num 165
|
||||||
io_pattern readv $((offset + 8 * 4096)) $((1 * 4096)) $((9 * 4096)) 256 165
|
io_pattern readv $((offset + 8 * $cluster_size)) $((1 * $cluster_size)) $((9 * $cluster_size)) $num 165
|
||||||
|
|
||||||
echo === Read zeros
|
echo === Read zeros
|
||||||
io_zero readv $((offset + 2 * 4096)) $((1 * 4096)) $((9 * 4096)) 256
|
io_zero readv $((offset + 2 * $cluster_size)) $((1 * $cluster_size)) $((9 * $cluster_size)) $num
|
||||||
io_zero readv $((offset + 6 * 4096)) $((2 * 4096)) $((9 * 4096)) 256
|
io_zero readv $((offset + 6 * $cluster_size)) $((2 * $cluster_size)) $((9 * $cluster_size)) $num
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,10 @@ _make_test_img()
|
||||||
# at least one argument (the image size) needs to be added
|
# at least one argument (the image size) needs to be added
|
||||||
local extra_img_options=$*
|
local extra_img_options=$*
|
||||||
|
|
||||||
|
if [ "$IMGFMT" = "qcow2" -a -n "$CLUSTER_SIZE" ]; then
|
||||||
|
extra_img_options="-o cluster_size=$CLUSTER_SIZE $extra_img_options"
|
||||||
|
fi
|
||||||
|
|
||||||
# XXX(hch): have global image options?
|
# XXX(hch): have global image options?
|
||||||
$QEMU_IMG create -f $IMGFMT $TEST_IMG $extra_img_options | \
|
$QEMU_IMG create -f $IMGFMT $TEST_IMG $extra_img_options | \
|
||||||
sed -e "s#$TEST_DIR#TEST_DIR#g" | \
|
sed -e "s#$TEST_DIR#TEST_DIR#g" | \
|
||||||
|
|
Loading…
Reference in New Issue