Skip to content
  • Andrey Drobyshev's avatar
    fc6b211f
    block/io: align requests to subcluster_size · fc6b211f
    Andrey Drobyshev authored
    
    
    When target image is using subclusters, and we align the request during
    copy-on-read, it makes sense to align to subcluster_size rather than
    cluster_size.  Otherwise we end up with unnecessary allocations.
    
    This commit renames bdrv_round_to_clusters() to bdrv_round_to_subclusters()
    and utilizes subcluster_size field of BlockDriverInfo to make necessary
    alignments.  It affects copy-on-read as well as mirror job (which is
    using bdrv_round_to_clusters()).
    
    This change also fixes the following bug with failing assert (covered by
    the test in the subsequent commit):
    
    qemu-img create -f qcow2 base.qcow2 64K
    qemu-img create -f qcow2 -o extended_l2=on,backing_file=base.qcow2,backing_fmt=qcow2 img.qcow2 64K
    qemu-io -c "write -P 0xaa 0 2K" img.qcow2
    qemu-io -C -c "read -P 0x00 2K 62K" img.qcow2
    
    qemu-io: ../block/io.c:1236: bdrv_co_do_copy_on_readv: Assertion `skip_bytes < pnum' failed.
    
    Reviewed-by: default avatarEric Blake <eblake@redhat.com>
    Reviewed-by: default avatarDenis V. Lunev <den@openvz.org>
    Signed-off-by: default avatarAndrey Drobyshev <andrey.drobyshev@virtuozzo.com>
    Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
    Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Message-ID: <20230711172553.234055-3-andrey.drobyshev@virtuozzo.com>
    fc6b211f
    block/io: align requests to subcluster_size
    Andrey Drobyshev authored
    
    
    When target image is using subclusters, and we align the request during
    copy-on-read, it makes sense to align to subcluster_size rather than
    cluster_size.  Otherwise we end up with unnecessary allocations.
    
    This commit renames bdrv_round_to_clusters() to bdrv_round_to_subclusters()
    and utilizes subcluster_size field of BlockDriverInfo to make necessary
    alignments.  It affects copy-on-read as well as mirror job (which is
    using bdrv_round_to_clusters()).
    
    This change also fixes the following bug with failing assert (covered by
    the test in the subsequent commit):
    
    qemu-img create -f qcow2 base.qcow2 64K
    qemu-img create -f qcow2 -o extended_l2=on,backing_file=base.qcow2,backing_fmt=qcow2 img.qcow2 64K
    qemu-io -c "write -P 0xaa 0 2K" img.qcow2
    qemu-io -C -c "read -P 0x00 2K 62K" img.qcow2
    
    qemu-io: ../block/io.c:1236: bdrv_co_do_copy_on_readv: Assertion `skip_bytes < pnum' failed.
    
    Reviewed-by: default avatarEric Blake <eblake@redhat.com>
    Reviewed-by: default avatarDenis V. Lunev <den@openvz.org>
    Signed-off-by: default avatarAndrey Drobyshev <andrey.drobyshev@virtuozzo.com>
    Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
    Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Message-ID: <20230711172553.234055-3-andrey.drobyshev@virtuozzo.com>
Loading