]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
iotests: Filter out ZFS in several tests
authorEric Blake <eblake@redhat.com>
Fri, 23 May 2025 16:27:23 +0000 (11:27 -0500)
committerEric Blake <eblake@redhat.com>
Thu, 29 May 2025 21:40:00 +0000 (16:40 -0500)
Fiona reported that ZFS makes sparse file testing awkward, since:
- it has asynchronous allocation (not even 'fsync $file' makes du see
  the desired size; it takes the slower 'fsync -f $file' which is not
  appropriate for the tests)
- for tests of fully allocated files, ZFS with compression enabled
  still reports smaller disk usage

Add a new _require_disk_usage that quickly probes whether an attempt
to create a sparse 5M file shows as less than 1M usage, while the same
file with -o preallocation=full shows as more than 4M usage without
sync, which should filter out ZFS behavior.  Then use it in various
affected tests.

This does not add the new filter on all tests that Fiona is seeing ZFS
failures on, but only those where I could quickly spot that there is
at least one place where the test depends on the output of 'du -b' or
'stat -c %b'.

Reported-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-ID: <20250523163041.2548675-8-eblake@redhat.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Tested-by: Fiona Ebner <f.ebner@proxmox.com>
tests/qemu-iotests/106
tests/qemu-iotests/175
tests/qemu-iotests/221
tests/qemu-iotests/253
tests/qemu-iotests/308
tests/qemu-iotests/common.rc
tests/qemu-iotests/tests/mirror-sparse
tests/qemu-iotests/tests/write-zeroes-unmap

index ae0fc466910d6e38ba43fa4e8d6c7d2ba62d326d..55548439aad107843b0d8fe37225cdc7400bcfc4 100755 (executable)
@@ -40,6 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 _supported_fmt raw
 _supported_proto file fuse
 _supported_os Linux
+_require_disk_usage
 
 # in kB
 CREATION_SIZE=128
index f74f053b719cbdc31856793810ca8b28a3ff6748..bbbf550a5af96a1c1cc03c324bc8bd8c0a3f2b68 100755 (executable)
@@ -77,6 +77,7 @@ _supported_os Linux
 
 _default_cache_mode none
 _supported_cache_modes none directsync
+_require_disk_usage
 
 size=$((1 * 1024 * 1024))
 
index c463fd4b113e7af6b99a659cdd1c0873d0a6561a..eba00b80adb3f7ac3e38ece592223c0ab2eaf8ad 100755 (executable)
@@ -41,6 +41,7 @@ _supported_os Linux
 
 _default_cache_mode writeback
 _supported_cache_modes writeback writethrough unsafe
+_require_disk_usage
 
 echo
 echo "=== Check mapping of unaligned raw image ==="
index 35039d20a8936e380b786500e77b4e7ef94b1184..6da85e6a1133991cf258869bbd26342f1c565441 100755 (executable)
@@ -41,6 +41,7 @@ _supported_os Linux
 
 _default_cache_mode none
 _supported_cache_modes none directsync
+_require_disk_usage
 
 echo
 echo "=== Check mapping of unaligned raw image ==="
index 437a9014da504c5c2a75bd77f31093f900324af9..6eced3aefb9797a451d668de5aed340f656ea1cd 100755 (executable)
@@ -51,6 +51,7 @@ _unsupported_fmt vpc
 
 _supported_proto file # We create the FUSE export manually
 _supported_os Linux # We need /dev/urandom
+_require_disk_usage
 
 # $1: Export ID
 # $2: Options (beyond the node-name and ID)
index 237f746af88f9e178f5d47739c989a3e45c3e36c..e977cb4eb61d622a9802b072b06db3649ff15bf4 100644 (file)
@@ -996,6 +996,36 @@ _require_large_file()
     rm "$FILENAME"
 }
 
+# Check whether disk_usage can be reliably used.
+_require_disk_usage()
+{
+    local unusable=false
+    # ZFS triggers known failures on this front; it does not immediately
+    # allocate files, and then aggressively compresses writes even when full
+    # allocation was requested.
+    if [ -z "$TEST_IMG_FILE" ]; then
+        FILENAME="$TEST_IMG"
+    else
+        FILENAME="$TEST_IMG_FILE"
+    fi
+    if [ -e "FILENAME" ]; then
+        echo "unwilling to overwrite existing file"
+        exit 1
+    fi
+    $QEMU_IMG create -f raw "$FILENAME" 5M > /dev/null
+    if [ $(disk_usage "$FILENAME") -gt $((1024*1024)) ]; then
+        unusable=true
+    fi
+    $QEMU_IMG create -f raw -o preallocation=full "$FILENAME" 5M > /dev/null
+    if [ $(disk_usage "$FILENAME") -lt $((4*1024*1024)) ]; then
+        unusable=true
+    fi
+    rm -f "$FILENAME"
+    if $unusable; then
+        _notrun "file system on $TEST_DIR does not handle sparse files nicely"
+    fi
+}
+
 # Check that a set of devices is available in the QEMU binary
 #
 _require_devices()
index 11418c08713c619aa7b2e77013e128b6ebdba2bd..cfcaa600ab4fb78c9ede444c075e873078f04291 100755 (executable)
@@ -40,6 +40,7 @@ cd ..
 _supported_fmt qcow2 raw  # Format of the source. dst is always raw file
 _supported_proto file
 _supported_os Linux
+_require_disk_usage
 
 echo
 echo "=== Initial image setup ==="
index 7cfeeaf8391c918c90e60712cccf5b59d10add7a..f90fb8e8d2706c9e2ecc703a6cf226e5d4dcf1b5 100755 (executable)
@@ -32,6 +32,7 @@ cd ..
 _supported_fmt raw
 _supported_proto file
 _supported_os Linux
+_require_disk_usage
 
 create_test_image() {
     _make_test_img -f $IMGFMT 1m