]> git.proxmox.com Git - mirror_qemu.git/commit
block/io: align requests to subcluster_size
authorAndrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Tue, 11 Jul 2023 17:25:52 +0000 (20:25 +0300)
committerStefan Hajnoczi <stefanha@redhat.com>
Wed, 30 Aug 2023 11:39:10 +0000 (07:39 -0400)
commitfc6b211f920a68f4c9c8db91ccc35ca95fe6683a
tree6a7fb31cd09918d1580f3638614846dca146e182
parentc54483b6f45a0c84e230728a1a9e7adf90345e15
block/io: align requests to subcluster_size

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: Eric Blake <eblake@redhat.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20230711172553.234055-3-andrey.drobyshev@virtuozzo.com>
block/io.c
block/mirror.c
include/block/block-io.h