|
|
b38b0f |
From b4841fd40fefcffc99c4b52c8a06720edb4ef9ef Mon Sep 17 00:00:00 2001
|
|
|
b38b0f |
From: Thomas Huth <thuth@redhat.com>
|
|
|
b38b0f |
Date: Fri, 30 Aug 2019 12:56:28 +0100
|
|
|
b38b0f |
Subject: [PATCH 10/10] iotests: Test allocate_first_block() with O_DIRECT
|
|
|
b38b0f |
|
|
|
b38b0f |
RH-Author: Thomas Huth <thuth@redhat.com>
|
|
|
b38b0f |
Message-id: <20190830125628.23668-6-thuth@redhat.com>
|
|
|
b38b0f |
Patchwork-id: 90212
|
|
|
b38b0f |
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH v2 5/5] iotests: Test allocate_first_block() with O_DIRECT
|
|
|
b38b0f |
Bugzilla: 1738839
|
|
|
b38b0f |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
b38b0f |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
b38b0f |
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
|
|
b38b0f |
|
|
|
b38b0f |
From: Nir Soffer <nirsof@gmail.com>
|
|
|
b38b0f |
|
|
|
b38b0f |
Using block_resize we can test allocate_first_block() with file
|
|
|
b38b0f |
descriptor opened with O_DIRECT, ensuring that it works for any size
|
|
|
b38b0f |
larger than 4096 bytes.
|
|
|
b38b0f |
|
|
|
b38b0f |
Testing smaller sizes is tricky as the result depends on the filesystem
|
|
|
b38b0f |
used for testing. For example on NFS any size will work since O_DIRECT
|
|
|
b38b0f |
does not require any alignment.
|
|
|
b38b0f |
|
|
|
b38b0f |
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
|
|
|
b38b0f |
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
|
b38b0f |
Message-id: 20190827010528.8818-3-nsoffer@redhat.com
|
|
|
b38b0f |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
b38b0f |
(cherry picked from commit 4656fb5ebbece8c7bbca0bef56bea882c94b9132)
|
|
|
b38b0f |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
b38b0f |
---
|
|
|
b38b0f |
tests/qemu-iotests/175 | 28 ++++++++++++++++++++++++++++
|
|
|
b38b0f |
tests/qemu-iotests/175.out | 8 ++++++++
|
|
|
b38b0f |
2 files changed, 36 insertions(+)
|
|
|
b38b0f |
|
|
|
b38b0f |
diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175
|
|
|
b38b0f |
index b3b7712..74ca49d 100755
|
|
|
b38b0f |
--- a/tests/qemu-iotests/175
|
|
|
b38b0f |
+++ b/tests/qemu-iotests/175
|
|
|
b38b0f |
@@ -50,6 +50,23 @@ _filter_blocks()
|
|
|
b38b0f |
-e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/"
|
|
|
b38b0f |
}
|
|
|
b38b0f |
|
|
|
b38b0f |
+# Resize image using block_resize.
|
|
|
b38b0f |
+# Parameter 1: image path
|
|
|
b38b0f |
+# Parameter 2: new size
|
|
|
b38b0f |
+_block_resize()
|
|
|
b38b0f |
+{
|
|
|
b38b0f |
+ local path=$1
|
|
|
b38b0f |
+ local size=$2
|
|
|
b38b0f |
+
|
|
|
b38b0f |
+ $QEMU -qmp stdio -nographic -nodefaults \
|
|
|
b38b0f |
+ -blockdev file,node-name=file,filename=$path,cache.direct=on \
|
|
|
b38b0f |
+ <
|
|
|
b38b0f |
+{'execute': 'qmp_capabilities'}
|
|
|
b38b0f |
+{'execute': 'block_resize', 'arguments': {'node-name': 'file', 'size': $size}}
|
|
|
b38b0f |
+{'execute': 'quit'}
|
|
|
b38b0f |
+EOF
|
|
|
b38b0f |
+}
|
|
|
b38b0f |
+
|
|
|
b38b0f |
# get standard environment, filters and checks
|
|
|
b38b0f |
. ./common.rc
|
|
|
b38b0f |
. ./common.filter
|
|
|
b38b0f |
@@ -58,6 +75,9 @@ _supported_fmt raw
|
|
|
b38b0f |
_supported_proto file
|
|
|
b38b0f |
_supported_os Linux
|
|
|
b38b0f |
|
|
|
b38b0f |
+_default_cache_mode none
|
|
|
b38b0f |
+_supported_cache_modes none directsync
|
|
|
b38b0f |
+
|
|
|
b38b0f |
size=$((1 * 1024 * 1024))
|
|
|
b38b0f |
|
|
|
b38b0f |
touch "$TEST_DIR/empty"
|
|
|
b38b0f |
@@ -80,6 +100,14 @@ for mode in off full falloc; do
|
|
|
b38b0f |
stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size
|
|
|
b38b0f |
done
|
|
|
b38b0f |
|
|
|
b38b0f |
+for new_size in 4096 1048576; do
|
|
|
b38b0f |
+ echo
|
|
|
b38b0f |
+ echo "== resize empty image with block_resize =="
|
|
|
b38b0f |
+ _make_test_img 0 | _filter_imgfmt
|
|
|
b38b0f |
+ _block_resize $TEST_IMG $new_size >/dev/null
|
|
|
b38b0f |
+ stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $new_size
|
|
|
b38b0f |
+done
|
|
|
b38b0f |
+
|
|
|
b38b0f |
# success, all done
|
|
|
b38b0f |
echo "*** done"
|
|
|
b38b0f |
rm -f $seq.full
|
|
|
b38b0f |
diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out
|
|
|
b38b0f |
index 263e521..39c2ee0 100644
|
|
|
b38b0f |
--- a/tests/qemu-iotests/175.out
|
|
|
b38b0f |
+++ b/tests/qemu-iotests/175.out
|
|
|
b38b0f |
@@ -15,4 +15,12 @@ size=1048576, max allocation
|
|
|
b38b0f |
== creating image with preallocation falloc ==
|
|
|
b38b0f |
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc
|
|
|
b38b0f |
size=1048576, max allocation
|
|
|
b38b0f |
+
|
|
|
b38b0f |
+== resize empty image with block_resize ==
|
|
|
b38b0f |
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0
|
|
|
b38b0f |
+size=4096, min allocation
|
|
|
b38b0f |
+
|
|
|
b38b0f |
+== resize empty image with block_resize ==
|
|
|
b38b0f |
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0
|
|
|
b38b0f |
+size=1048576, min allocation
|
|
|
b38b0f |
*** done
|
|
|
b38b0f |
--
|
|
|
b38b0f |
1.8.3.1
|
|
|
b38b0f |
|