[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 03/27] qemu-img: rebase: use backing files' BlockBackend for buffe
From: |
Kevin Wolf |
Subject: |
[PULL 03/27] qemu-img: rebase: use backing files' BlockBackend for buffer alignment |
Date: |
Tue, 31 Oct 2023 19:58:54 +0100 |
From: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Since commit bb1c05973cf ("qemu-img: Use qemu_blockalign"), buffers for
the data read from the old and new backing files are aligned using
BlockDriverState (or BlockBackend later on) referring to the target image.
However, this isn't quite right, because buf_new is only being used for
reading from the new backing, while buf_old is being used for both reading
from the old backing and writing to the target. Let's take that into account
and use more appropriate values as alignments.
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Message-ID: <20230919165804.439110-4-andrey.drobyshev@virtuozzo.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
qemu-img.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index 2b2a3a86ca..e61d996e0f 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -3759,8 +3759,13 @@ static int img_rebase(int argc, char **argv)
int64_t n;
float local_progress = 0;
- buf_old = blk_blockalign(blk, IO_BUF_SIZE);
- buf_new = blk_blockalign(blk, IO_BUF_SIZE);
+ if (blk_old_backing && bdrv_opt_mem_align(blk_bs(blk_old_backing)) >
+ bdrv_opt_mem_align(blk_bs(blk))) {
+ buf_old = blk_blockalign(blk_old_backing, IO_BUF_SIZE);
+ } else {
+ buf_old = blk_blockalign(blk, IO_BUF_SIZE);
+ }
+ buf_new = blk_blockalign(blk_new_backing, IO_BUF_SIZE);
size = blk_getlength(blk);
if (size < 0) {
--
2.41.0
- [PULL 00/27] Block layer patches, Kevin Wolf, 2023/10/31
- [PULL 01/27] qemu-img: rebase: stop when reaching EOF of old backing file, Kevin Wolf, 2023/10/31
- [PULL 02/27] qemu-iotests: 024: add rebasing test case for overlay_size > backing_size, Kevin Wolf, 2023/10/31
- [PULL 03/27] qemu-img: rebase: use backing files' BlockBackend for buffer alignment,
Kevin Wolf <=
- [PULL 04/27] qemu-img: add chunk size parameter to compare_buffers(), Kevin Wolf, 2023/10/31
- [PULL 07/27] qemu-img: add compression option to rebase subcommand, Kevin Wolf, 2023/10/31
- [PULL 05/27] qemu-img: rebase: avoid unnecessary COW operations, Kevin Wolf, 2023/10/31
- [PULL 06/27] iotests/{024, 271}: add testcases for qemu-img rebase, Kevin Wolf, 2023/10/31
- [PULL 16/27] virtio: use defer_call() in virtio_irqfd_notify(), Kevin Wolf, 2023/10/31
- [PULL 15/27] util/defer-call: move defer_call() to util/, Kevin Wolf, 2023/10/31
- [PULL 21/27] block/mirror: determine copy_to_target only once, Kevin Wolf, 2023/10/31
- [PULL 19/27] block/mirror: set actively_synced even after the job is ready, Kevin Wolf, 2023/10/31
- [PULL 20/27] block/mirror: move dirty bitmap to filter, Kevin Wolf, 2023/10/31
- [PULL 17/27] virtio-blk: remove batch notification BH, Kevin Wolf, 2023/10/31