On 7/13/18 6:14 AM, Max Reitz wrote: > Past the end of the source backing file, we memset() buf_old to zero, so > it is clearly easy to use blk_pwrite_zeroes() instead of blk_pwrite() > then. > > Signed-off-by: Max Reitz <[email protected]> > --- > qemu-img.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) >
> @@ -3458,8 +3461,12 @@ static int img_rebase(int argc, char **argv)
> if (compare_buffers(buf_old + written, buf_new + written,
> n - written, &pnum))
> {
> - ret = blk_pwrite(blk, offset + written,
> - buf_old + written, pnum, 0);
> + if (buf_old_is_zero) {
> + ret = blk_pwrite_zeroes(blk, offset + written, pnum,
> 0);
Should we allow BDRV_REQ_MAY_UNMAP here, either unconditionally, or
based on a command line knob that told us whether the user is more
interested in a sparse result (that still reads as zero) vs. a
fully-allocated result?
Reviewed-by: Eric Blake <[email protected]>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
