From ed1c336119c084159575ae9d4fd9171bd500f7e4 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Fri, 23 May 2025 11:27:22 -0500 Subject: [PATCH] iotests: Improve mirror-sparse on ext4 and xfs Fiona reported that an ext4 filesystem on top of LVM can sometimes report over-allocation to du (based on the heuristics the filesystem is making while observing the contents being mirrored); even though the contents and actual size matched, about 50% of the time the size reported by disk_usage was too large by 4k, failing the test. In auditing other iotests, this is a common problem we've had to deal with. Meanwhile, Markus reported that an xfs filesystem reports disk usage at a default granularity of 1M (so the sparse file occupies 3M, since it has just over 2M data). Reported-by: Fiona Ebner Reported-by: Markus Armbruster Fixes: c0ddcb2c ("tests: Add iotest mirror-sparse for recent patches") Signed-off-by: Eric Blake Reviewed-by: Fiona Ebner Tested-by: Fiona Ebner Message-ID: <20250523163041.2548675-7-eblake@redhat.com> [eblake: Also fix xfs issue] Signed-off-by: Eric Blake --- tests/qemu-iotests/tests/mirror-sparse | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/tests/mirror-sparse b/tests/qemu-iotests/tests/mirror-sparse index 8c52a4e244..11418c0871 100755 --- a/tests/qemu-iotests/tests/mirror-sparse +++ b/tests/qemu-iotests/tests/mirror-sparse @@ -96,13 +96,15 @@ _send_qemu_cmd $h1 '{"execute": "blockdev-del", "arguments": {"node-name": "dst"}}' 'return' \ | _filter_block_job_offset | _filter_block_job_len $QEMU_IMG compare -U -f $IMGFMT -F raw $TEST_IMG.base $TEST_IMG +# Some filesystems can fudge allocations for various reasons; rather +# than expecting precise 2M and 20M images, it is better to allow for slop. result=$(disk_usage $TEST_IMG) -if test $result -lt $((3*1024*1024)); then +if test $result -lt $((4*1024*1024)); then actual=sparse -elif test $result = $((20*1024*1024)); then +elif test $result -gt $((19*1024*1024)); then actual=full else - actual=unknown + actual="unexpected size ($result)" fi echo "Destination is $actual; expected $expected" } -- 2.39.5