]>
Commit | Line | Data |
---|---|---|
d95ad93e TL |
1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
2 | From: Stefan Reiter <s.reiter@proxmox.com> | |
3 | Date: Thu, 22 Oct 2020 17:34:17 +0200 | |
4 | Subject: [PATCH] migration/block-dirty-bitmap: fix larger granularity bitmaps | |
5 | ||
6 | sectors_per_chunk is a 64 bit integer, but the calculation would be done | |
7 | in 32 bits, leading to an overflow for coarse bitmap granularities. | |
8 | ||
9 | If that results in the value 0, it leads to a hang where no progress is | |
10 | made but send_bitmap_bits is constantly called with nr_sectors being 0. | |
11 | ||
12 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | |
13 | Reviewed-by: Eric Blake <eblake@redhat.com> | |
14 | Signed-off-by: Stefan Reiter <s.reiter@proxmox.com> | |
15 | --- | |
16 | migration/block-dirty-bitmap.c | 3 ++- | |
17 | 1 file changed, 2 insertions(+), 1 deletion(-) | |
18 | ||
19 | diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c | |
20 | index 784330ebe1..5bf0d9fbc6 100644 | |
21 | --- a/migration/block-dirty-bitmap.c | |
22 | +++ b/migration/block-dirty-bitmap.c | |
23 | @@ -334,8 +334,9 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs, | |
24 | dbms->node_name = bs_name; | |
25 | dbms->bitmap = bitmap; | |
26 | dbms->total_sectors = bdrv_nb_sectors(bs); | |
27 | - dbms->sectors_per_chunk = CHUNK_SIZE * 8 * | |
28 | + dbms->sectors_per_chunk = CHUNK_SIZE * 8LLU * | |
29 | bdrv_dirty_bitmap_granularity(bitmap) >> BDRV_SECTOR_BITS; | |
30 | + assert(dbms->sectors_per_chunk != 0); | |
31 | if (bdrv_dirty_bitmap_enabled(bitmap)) { | |
32 | dbms->flags |= DIRTY_BITMAP_MIG_START_FLAG_ENABLED; | |
33 | } |