This is a regression test for the bug fixed in the previous commit where discard and write_zeroes operations wouldn't consider their dependencies in s->cluster_allocs. Without the fix, this results in a corrupted image.
Signed-off-by: Kevin Wolf <[email protected]> Message-ID: <[email protected]> Reviewed-by: Denis V. Lunev <[email protected]> Tested-by: Denis V. Lunev <[email protected]> Signed-off-by: Kevin Wolf <[email protected]> --- tests/qemu-iotests/046 | 46 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/046.out | 36 +++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/tests/qemu-iotests/046 b/tests/qemu-iotests/046 index 4c9ed4d26e1..e03dd401479 100755 --- a/tests/qemu-iotests/046 +++ b/tests/qemu-iotests/046 @@ -184,6 +184,48 @@ aio_write -P 160 0x104000 0x18000 resume A aio_flush EOF + +# Create a pre-allocated zero cluster, then start a write on it and discard it +# before the L2 update is made +cat <<EOF +write -P 181 0x120000 0x10000 +write -z 0x120000 0x10000 + +break write_aio A +aio_write -P 180 0x120000 0x10000 +wait_break A +aio_discard 0x120000 0x10000 +resume A +aio_flush +EOF + +# Create a pre-allocated zero cluster, then start a write on it and a +# concurrent zero write with MAY_UNMAP before the L2 update is made +cat <<EOF +write -P 181 0x130000 0x10000 +write -z 0x130000 0x10000 + +break write_aio A +aio_write -P 180 0x130000 0x10000 +wait_break A +aio_write -z -u 0x130000 0x10000 +resume A +aio_flush +EOF + +# Create a pre-allocated zero cluster, then start a write on it and a +# concurrent zero write without MAY_UNMAP before the L2 update is made +cat <<EOF +write -P 181 0x140000 0x10000 +write -z 0x140000 0x10000 + +break write_aio A +aio_write -P 180 0x140000 0x10000 +wait_break A +aio_write -z 0x140000 0x10000 +resume A +aio_flush +EOF } overlay_io | $QEMU_IO blkdebug::"$TEST_IMG" | _filter_qemu_io |\ @@ -264,6 +306,10 @@ verify_io() # Undefined content for 0x10c000 0x8000 echo read -P 160 0x114000 0x8000 echo read -P 17 0x11c000 0x4000 + + echo read -P 0 0x120000 0x10000 + echo read -P 0 0x130000 0x10000 + echo read -P 0 0x140000 0x10000 } verify_io | $QEMU_IO "$TEST_IMG" | _filter_qemu_io diff --git a/tests/qemu-iotests/046.out b/tests/qemu-iotests/046.out index b1a03f40414..6341df335c9 100644 --- a/tests/qemu-iotests/046.out +++ b/tests/qemu-iotests/046.out @@ -139,6 +139,36 @@ wrote XXX/XXX bytes at offset XXX XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote XXX/XXX bytes at offset XXX XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote XXX/XXX bytes at offset XXX +XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote XXX/XXX bytes at offset XXX +XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +blkdebug: Suspended request 'A' +blkdebug: Resuming request 'A' +wrote XXX/XXX bytes at offset XXX +XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +discarded XXX/XXX bytes at offset XXX +XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote XXX/XXX bytes at offset XXX +XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote XXX/XXX bytes at offset XXX +XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +blkdebug: Suspended request 'A' +blkdebug: Resuming request 'A' +wrote XXX/XXX bytes at offset XXX +XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote XXX/XXX bytes at offset XXX +XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote XXX/XXX bytes at offset XXX +XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote XXX/XXX bytes at offset XXX +XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +blkdebug: Suspended request 'A' +blkdebug: Resuming request 'A' +wrote XXX/XXX bytes at offset XXX +XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote XXX/XXX bytes at offset XXX +XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) == Verify image content == read 65536/65536 bytes at offset 0 @@ -239,5 +269,11 @@ read 32768/32768 bytes at offset 1130496 32 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 16384/16384 bytes at offset 1163264 16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 1179648 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 1245184 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 1310720 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) No errors were found on the image. *** done -- 2.54.0
