diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026 index a4aa74764f8c21da65085bf278eb81a7152fd22a..0c1273c3398bd30bc8399772507ef6ff1bcb7a80 100755 --- a/tests/qemu-iotests/026 +++ b/tests/qemu-iotests/026 @@ -218,6 +218,27 @@ _make_test_img 64M $QEMU_IO -c "write 0 1M" -c "write 0 1M" "$BLKDBG_TEST_IMG" | _filter_qemu_io _check_test_img +echo +echo === Avoid freeing preallocated zero clusters on failure === +echo + +cat > "$TEST_DIR/blkdebug.conf" <<EOF +[inject-error] +event = "write_aio" +errno = "5" +once = "on" +EOF + +_make_test_img $CLUSTER_SIZE +# Create a preallocated zero cluster +$QEMU_IO -c "write 0 $CLUSTER_SIZE" -c "write -z 0 $CLUSTER_SIZE" "$TEST_IMG" \ + | _filter_qemu_io +# Try to overwrite it (prompting an I/O error from blkdebug), thus +# triggering the alloc abort code +$QEMU_IO -c "write 0 $CLUSTER_SIZE" "$BLKDBG_TEST_IMG" | _filter_qemu_io + +_check_test_img + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/026.out b/tests/qemu-iotests/026.out index ff0817b6f282e566ae8fc8d2d376a611f5074e42..83989996ff624f17f746dc78835110f5f76ace28 100644 --- a/tests/qemu-iotests/026.out +++ b/tests/qemu-iotests/026.out @@ -643,4 +643,14 @@ write failed: Input/output error wrote 1048576/1048576 bytes at offset 0 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) No errors were found on the image. + +=== Avoid freeing preallocated zero clusters on failure === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1024 +wrote 1024/1024 bytes at offset 0 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1024/1024 bytes at offset 0 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +write failed: Input/output error +No errors were found on the image. *** done diff --git a/tests/qemu-iotests/026.out.nocache b/tests/qemu-iotests/026.out.nocache index 495d013007cd3c4e11ed88e61b22efb53adb865f..9359d26d7e2078472395a01b4755f63204488422 100644 --- a/tests/qemu-iotests/026.out.nocache +++ b/tests/qemu-iotests/026.out.nocache @@ -651,4 +651,14 @@ write failed: Input/output error wrote 1048576/1048576 bytes at offset 0 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) No errors were found on the image. + +=== Avoid freeing preallocated zero clusters on failure === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1024 +wrote 1024/1024 bytes at offset 0 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1024/1024 bytes at offset 0 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +write failed: Input/output error +No errors were found on the image. *** done