Skip to content
  • Kevin Wolf's avatar
    edafc70c
    qemu-img convert: Don't pre-zero images · edafc70c
    Kevin Wolf authored
    
    
    Since commit 5a37b60a, qemu-img create will pre-zero the target image
    if it isn't already zero-initialised (most importantly, for host block
    devices, but also iscsi etc.), so that writing explicit zeros wouldn't
    be necessary later.
    
    This could speed up the operation significantly, in particular when the
    source image file was only sparsely populated. However, it also means
    that some block are written twice: Once when pre-zeroing them, and then
    when they are overwritten with actual data. On a full image, the
    pre-zeroing is wasted work because everything will be overwritten.
    
    In practice, write_zeroes typically turns out faster than writing
    explicit zero buffers, but slow enough that first zeroing everything and
    then overwriting parts can be a significant net loss.
    
    Meanwhile, qemu-img convert was rewritten in 690c7301 and zero blocks
    are now written to the target using bdrv_co_pwrite_zeroes() if the
    target could be pre-zeroed. This way we already make use of the faster
    write_zeroes operation, but avoid writing any blocks twice.
    
    Remove the pre-zeroing because these days this former optimisation has
    actually turned into a pessimisation in the common case.
    
    Reported-by: default avatarNir Soffer <nsoffer@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    Message-Id: <20200622151203.35624-1-kwolf@redhat.com>
    Tested-by: default avatarNir Soffer <nsoffer@redhat.com>
    Reviewed-by: default avatarEric Blake <eblake@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    edafc70c
    qemu-img convert: Don't pre-zero images
    Kevin Wolf authored
    
    
    Since commit 5a37b60a, qemu-img create will pre-zero the target image
    if it isn't already zero-initialised (most importantly, for host block
    devices, but also iscsi etc.), so that writing explicit zeros wouldn't
    be necessary later.
    
    This could speed up the operation significantly, in particular when the
    source image file was only sparsely populated. However, it also means
    that some block are written twice: Once when pre-zeroing them, and then
    when they are overwritten with actual data. On a full image, the
    pre-zeroing is wasted work because everything will be overwritten.
    
    In practice, write_zeroes typically turns out faster than writing
    explicit zero buffers, but slow enough that first zeroing everything and
    then overwriting parts can be a significant net loss.
    
    Meanwhile, qemu-img convert was rewritten in 690c7301 and zero blocks
    are now written to the target using bdrv_co_pwrite_zeroes() if the
    target could be pre-zeroed. This way we already make use of the faster
    write_zeroes operation, but avoid writing any blocks twice.
    
    Remove the pre-zeroing because these days this former optimisation has
    actually turned into a pessimisation in the common case.
    
    Reported-by: default avatarNir Soffer <nsoffer@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    Message-Id: <20200622151203.35624-1-kwolf@redhat.com>
    Tested-by: default avatarNir Soffer <nsoffer@redhat.com>
    Reviewed-by: default avatarEric Blake <eblake@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
Loading