|
|
4ec855 |
From b897ede11c7b47cc9db8334ca44dd960d3001309 Mon Sep 17 00:00:00 2001
|
|
|
4ec855 |
From: Thomas Huth <thuth@redhat.com>
|
|
|
4ec855 |
Date: Fri, 30 Aug 2019 12:56:26 +0100
|
|
|
4ec855 |
Subject: [PATCH 08/10] iotests: Filter 175's allocation information
|
|
|
4ec855 |
|
|
|
4ec855 |
RH-Author: Thomas Huth <thuth@redhat.com>
|
|
|
4ec855 |
Message-id: <20190830125628.23668-4-thuth@redhat.com>
|
|
|
4ec855 |
Patchwork-id: 90211
|
|
|
4ec855 |
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH v2 3/5] iotests: Filter 175's allocation information
|
|
|
4ec855 |
Bugzilla: 1738839
|
|
|
4ec855 |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
4ec855 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
4ec855 |
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
|
|
4ec855 |
|
|
|
4ec855 |
From: Max Reitz <mreitz@redhat.com>
|
|
|
4ec855 |
|
|
|
4ec855 |
It is possible for an empty file to take up blocks on a filesystem, for
|
|
|
4ec855 |
example:
|
|
|
4ec855 |
|
|
|
4ec855 |
$ qemu-img create -f raw test.img 1G
|
|
|
4ec855 |
Formatting 'test.img', fmt=raw size=1073741824
|
|
|
4ec855 |
$ mkfs.ext4 -I 128 -q test.img
|
|
|
4ec855 |
$ mkdir test-mount
|
|
|
4ec855 |
$ sudo mount -o loop test.img test-mount
|
|
|
4ec855 |
$ sudo touch test-mount/test-file
|
|
|
4ec855 |
$ stat -c 'blocks=%b' test-mount/test-file
|
|
|
4ec855 |
blocks=8
|
|
|
4ec855 |
|
|
|
4ec855 |
These extra blocks (one cluster) are apparently used for metadata,
|
|
|
4ec855 |
because they are always there, on top of blocks used for data:
|
|
|
4ec855 |
|
|
|
4ec855 |
$ sudo dd if=/dev/zero of=test-mount/test-file bs=1M count=1
|
|
|
4ec855 |
1+0 records in
|
|
|
4ec855 |
1+0 records out
|
|
|
4ec855 |
1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.00135339 s, 775 MB/s
|
|
|
4ec855 |
$ stat -c 'blocks=%b' test-mount/test-file
|
|
|
4ec855 |
blocks=2056
|
|
|
4ec855 |
|
|
|
4ec855 |
Make iotest 175 take this into account.
|
|
|
4ec855 |
|
|
|
4ec855 |
Reported-by: Thomas Huth <thuth@redhat.com>
|
|
|
4ec855 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
4ec855 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
4ec855 |
Reviewed-by: Nir Soffer <nsoffer@redhat.com>
|
|
|
4ec855 |
Message-id: 20190516144319.12570-1-mreitz@redhat.com
|
|
|
4ec855 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
4ec855 |
(cherry picked from commit a3bd71b5773a3664692601e6e181f108e1e4aa41)
|
|
|
4ec855 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
4ec855 |
---
|
|
|
4ec855 |
tests/qemu-iotests/175 | 26 ++++++++++++++++++++++----
|
|
|
4ec855 |
tests/qemu-iotests/175.out | 8 ++++----
|
|
|
4ec855 |
2 files changed, 26 insertions(+), 8 deletions(-)
|
|
|
4ec855 |
|
|
|
4ec855 |
diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175
|
|
|
4ec855 |
index ca56e82..2e37c9a 100755
|
|
|
4ec855 |
--- a/tests/qemu-iotests/175
|
|
|
4ec855 |
+++ b/tests/qemu-iotests/175
|
|
|
4ec855 |
@@ -29,10 +29,25 @@ status=1 # failure is the default!
|
|
|
4ec855 |
|
|
|
4ec855 |
_cleanup()
|
|
|
4ec855 |
{
|
|
|
4ec855 |
- _cleanup_test_img
|
|
|
4ec855 |
+ _cleanup_test_img
|
|
|
4ec855 |
+ rm -f "$TEST_DIR/empty"
|
|
|
4ec855 |
}
|
|
|
4ec855 |
trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
4ec855 |
|
|
|
4ec855 |
+# Some file systems sometimes allocate extra blocks independently of
|
|
|
4ec855 |
+# the file size. This function hides the resulting difference in the
|
|
|
4ec855 |
+# stat -c '%b' output.
|
|
|
4ec855 |
+# Parameter 1: Number of blocks an empty file occupies
|
|
|
4ec855 |
+# Parameter 2: Image size in bytes
|
|
|
4ec855 |
+_filter_blocks()
|
|
|
4ec855 |
+{
|
|
|
4ec855 |
+ extra_blocks=$1
|
|
|
4ec855 |
+ img_size=$2
|
|
|
4ec855 |
+
|
|
|
4ec855 |
+ sed -e "s/blocks=$extra_blocks\\(\$\\|[^0-9]\\)/nothing allocated/" \
|
|
|
4ec855 |
+ -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/everything allocated/"
|
|
|
4ec855 |
+}
|
|
|
4ec855 |
+
|
|
|
4ec855 |
# get standard environment, filters and checks
|
|
|
4ec855 |
. ./common.rc
|
|
|
4ec855 |
. ./common.filter
|
|
|
4ec855 |
@@ -41,18 +56,21 @@ _supported_fmt raw
|
|
|
4ec855 |
_supported_proto file
|
|
|
4ec855 |
_supported_os Linux
|
|
|
4ec855 |
|
|
|
4ec855 |
-size=1m
|
|
|
4ec855 |
+size=$((1 * 1024 * 1024))
|
|
|
4ec855 |
+
|
|
|
4ec855 |
+touch "$TEST_DIR/empty"
|
|
|
4ec855 |
+extra_blocks=$(stat -c '%b' "$TEST_DIR/empty")
|
|
|
4ec855 |
|
|
|
4ec855 |
echo
|
|
|
4ec855 |
echo "== creating image with default preallocation =="
|
|
|
4ec855 |
_make_test_img $size | _filter_imgfmt
|
|
|
4ec855 |
-stat -c "size=%s, blocks=%b" $TEST_IMG
|
|
|
4ec855 |
+stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $size
|
|
|
4ec855 |
|
|
|
4ec855 |
for mode in off full falloc; do
|
|
|
4ec855 |
echo
|
|
|
4ec855 |
echo "== creating image with preallocation $mode =="
|
|
|
4ec855 |
IMGOPTS=preallocation=$mode _make_test_img $size | _filter_imgfmt
|
|
|
4ec855 |
- stat -c "size=%s, blocks=%b" $TEST_IMG
|
|
|
4ec855 |
+ stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $size
|
|
|
4ec855 |
done
|
|
|
4ec855 |
|
|
|
4ec855 |
# success, all done
|
|
|
4ec855 |
diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out
|
|
|
4ec855 |
index 76c02c6..6d9a5ed 100644
|
|
|
4ec855 |
--- a/tests/qemu-iotests/175.out
|
|
|
4ec855 |
+++ b/tests/qemu-iotests/175.out
|
|
|
4ec855 |
@@ -2,17 +2,17 @@ QA output created by 175
|
|
|
4ec855 |
|
|
|
4ec855 |
== creating image with default preallocation ==
|
|
|
4ec855 |
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
|
|
|
4ec855 |
-size=1048576, blocks=0
|
|
|
4ec855 |
+size=1048576, nothing allocated
|
|
|
4ec855 |
|
|
|
4ec855 |
== creating image with preallocation off ==
|
|
|
4ec855 |
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=off
|
|
|
4ec855 |
-size=1048576, blocks=0
|
|
|
4ec855 |
+size=1048576, nothing allocated
|
|
|
4ec855 |
|
|
|
4ec855 |
== creating image with preallocation full ==
|
|
|
4ec855 |
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=full
|
|
|
4ec855 |
-size=1048576, blocks=2048
|
|
|
4ec855 |
+size=1048576, everything allocated
|
|
|
4ec855 |
|
|
|
4ec855 |
== creating image with preallocation falloc ==
|
|
|
4ec855 |
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc
|
|
|
4ec855 |
-size=1048576, blocks=2048
|
|
|
4ec855 |
+size=1048576, everything allocated
|
|
|
4ec855 |
*** done
|
|
|
4ec855 |
--
|
|
|
4ec855 |
1.8.3.1
|
|
|
4ec855 |
|