>> +# Set compress=on. That will align the written data >> +# by the cluster size and will write them compressed. >> +QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT \ >> +$QEMU_IO -c "write -P 0xbb 0 $data_size" --image-opts \ >> + driver=$IMGFMT,compress=on,file.filename=$TEST_IMG \ >> + 2>&1 | _filter_qemu_io | _filter_testdir >> + >> +let offset="4 * $cluster_size" >> +QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT \ >> +$QEMU_IO -c "write -P 0xcc $offset $data_size" "json:{\ >> + 'driver': '$IMGFMT', >> + 'file': { >> + 'driver': 'file', >> + 'filename': '$TEST_IMG' >> + }, >> + 'compress': true >> +}" | _filter_qemu_io | _filter_testdir >> + > > It would be good to add case with unaligned offset as well. And, maybe," > check that we don't rewrite existing data in partial clusters when writing > unaligned compressed data over it. >
The I/O error is raised in that case (see qcow2_alloc_compressed_cluster_offset()): "Compression can't overwrite anything. Fail if the cluster was already allocated." #0 qcow2_alloc_compressed_cluster_offset (bs=0x564669143390, offset=393216, compressed_size=79, host_offset=0x7f45289d9f00) at block/qcow2-cluster.c:767 #1 0x000056466703da7f in qcow2_co_pwritev_compressed_task (bs=0x564669143390, offset=393216, bytes=65536, qiov=0x7f4528dddec0, qiov_offset=196608) at block/qcow2.c:4198 #2 0x000056466703dc0c in qcow2_co_pwritev_compressed_task_entry (task=0x564669152ac0) at block/qcow2.c:4230 #3 0x00005646670a69d0 in aio_task_co (opaque=0x564669152ac0) at block/aio_task.c:45 #4 0x0000564667147a87 in coroutine_trampoline (i0=1762994976, i1=22086) at util/coroutine-ucontext.c:115 Andrey -- With the best regards, Andrey Shinkevich