On 05/05/2017 05:06 PM, Max Reitz wrote: > On 04.05.2017 05:07, Eric Blake wrote: >> We've already improved discards to operate efficiently on the tail >> of an unaligned qcow2 image; it's time to make a similar improvement >> to write zeroes. The special case is only valid at the tail >> cluster of a file, where we must recognize that any sectors beyond >> the image end would implicitly read as zero, and therefore should >> not penalize our logic for widening a partial cluster into writing >> the whole cluster as zero. >> >> $QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map >> >> +echo >> +echo == unaligned image tail cluster, no allocation needed == > > [...] > >> +# A preallocated cluster maintains its allocation, whether it stays as >> +# data due to a partial write: >> +# Convert 128m... | XX XX => ... | XX 00 >> +_make_test_img $((size + 1024)) >> +$QEMU_IO -c "write -P 1 $((size)) 1024" "$TEST_IMG" | _filter_qemu_io >> +$QEMU_IO -c "write -z $((size + 512)) 512" "$TEST_IMG.base" | _filter_qemu_io > > s/\.base//, I suppose? D'oh. Serves me right for renaming which file I was working on. > > (You should read your reference output. "Pattern verification failed" is > never good. ;-)) Looks like I get to spin a v13 then. > > With that (and the reference output) fixed: > > Reviewed-by: Max Reitz > -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org