qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-5.1 v2 1/2] block/block-copy: always align copied region to cluster size
@ 2020-08-10  9:55 Stefan Reiter
  2020-08-10  9:55 ` [PATCH for-5.1 v2 2/2] iotests: add test for unaligned granularity bitmap backup Stefan Reiter
  2020-08-10 15:15 ` [PATCH for-5.1 v2 1/2] block/block-copy: always align copied region to cluster size Max Reitz
  0 siblings, 2 replies; 5+ messages in thread
From: Stefan Reiter @ 2020-08-10  9:55 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, vsementsov, qemu-devel, mreitz

Since commit 42ac214406e0 (block/block-copy: refactor task creation)
block_copy_task_create calculates the area to be copied via
bdrv_dirty_bitmap_next_dirty_area, but that can return an unaligned byte
count if the image's last cluster end is not aligned to the bitmap's
granularity.

Always ALIGN_UP the resulting bytes value to satisfy block_copy_do_copy,
which requires the 'bytes' parameter to be aligned to cluster size.

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
---

I've now marked it for-5.1 since it is just a fix, but it's probably okay if
done later as well.

v2:
* add assert on offset alignment
* remove 'backing image' wording from commit
* collect R-b

 block/block-copy.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/block/block-copy.c b/block/block-copy.c
index f7428a7c08..a30b9097ef 100644
--- a/block/block-copy.c
+++ b/block/block-copy.c
@@ -142,6 +142,9 @@ static BlockCopyTask *block_copy_task_create(BlockCopyState *s,
         return NULL;
     }
 
+    assert(QEMU_IS_ALIGNED(offset, s->cluster_size));
+    bytes = QEMU_ALIGN_UP(bytes, s->cluster_size);
+
     /* region is dirty, so no existent tasks possible in it */
     assert(!find_conflicting_task(s, offset, bytes));
 
-- 
2.20.1




^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-08-10 15:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-10  9:55 [PATCH for-5.1 v2 1/2] block/block-copy: always align copied region to cluster size Stefan Reiter
2020-08-10  9:55 ` [PATCH for-5.1 v2 2/2] iotests: add test for unaligned granularity bitmap backup Stefan Reiter
2020-08-10 15:11   ` Max Reitz
2020-08-10 15:35     ` Stefan Reiter
2020-08-10 15:15 ` [PATCH for-5.1 v2 1/2] block/block-copy: always align copied region to cluster size Max Reitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).