On Fri, May 09, 2025 at 03:40:27PM -0500, Eric Blake wrote: > When doing a sync=full mirroring, we can skip pre-zeroing the > destination if it already reads as zeroes and we are not also trying > to punch holes due to detect-zeroes. With this patch, there are fewer > scenarios that have to pass in an explicit target-is-zero, while still > resulting in a sparse destination remaining sparse. > > A later patch will then further improve things to skip writing to the > destination for parts of the image where the source is zero; but even > with just this patch, it is possible to see a difference for any > source that does not report itself as fully allocated, coupled with a > destination BDS that can quickly report that it already reads as zero. > (For a source that reports as fully allocated, such as a file, the > rest of mirror_dirty_init() still sets the entire dirty bitmap to > true, so even though we avoided the pre-zeroing, we are not yet > avoiding all redundant I/O). > > Iotest 194 detects the difference made by this patch: for a file > source (where block status reports the entire image as allocated, and > therefore we end up writing zeroes everywhere in the destination > anyways), the job length remains the same. But for a qcow2 source and > a destination that reads as all zeroes, the dirty bitmap changes to > just tracking the allocated portions of the source, which results in > faster completion and smaller job statistics. For the test to pass > with both ./check -file and -qcow2, a new python filter is needed to > mask out the now-varying job amounts (this matches the shell filters > _filter_block_job_{offset,len} in common.filter). A later test will > also be added which further validates expected sparseness, so it does > not matter that 194 is no longer explicitly looking at how many bytes > were copied. > > Signed-off-by: Eric Blake <ebl...@redhat.com> > > --- > > v3: add exemption for "detect-zeroes":"unmap" on destination > v4: Rebase later in series, revise logic for pre-zeroing [Sunny], add > in python filter > --- > block/mirror.c | 24 ++++++++++++++++-------- > tests/qemu-iotests/194 | 6 ++++-- > tests/qemu-iotests/194.out | 4 ++-- > tests/qemu-iotests/iotests.py | 12 +++++++++++- > 4 files changed, 33 insertions(+), 13 deletions(-)
Reviewed-by: Stefan Hajnoczi <stefa...@redhat.com>
signature.asc
Description: PGP signature