Skip to content

Commit

Permalink
util/hbitmap: update orig_size on truncate
Browse files Browse the repository at this point in the history
Without this, hbitmap_next_zero and hbitmap_next_dirty_area are broken
after truncate. So, orig_size is broken since it's introduction in
76d570d.

Fixes: 76d570d
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-id: 20190805120120.23585-1-vsementsov@virtuozzo.com
Reviewed-by: Max Reitz <mreitz@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Max Reitz <mreitz@redhat.com>
(cherry picked from commit 4e4de22)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
  • Loading branch information
Vladimir Sementsov-Ogievskiy authored and mdroth committed Oct 1, 2019
1 parent c430d76 commit fc5c701
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion util/hbitmap.c
Expand Up @@ -53,7 +53,9 @@
*/

struct HBitmap {
/* Size of the bitmap, as requested in hbitmap_alloc. */
/*
* Size of the bitmap, as requested in hbitmap_alloc or in hbitmap_truncate.
*/
uint64_t orig_size;

/* Number of total bits in the bottom level. */
Expand Down Expand Up @@ -732,6 +734,8 @@ void hbitmap_truncate(HBitmap *hb, uint64_t size)
uint64_t num_elements = size;
uint64_t old;

hb->orig_size = size;

/* Size comes in as logical elements, adjust for granularity. */
size = (size + (1ULL << hb->granularity) - 1) >> hb->granularity;
assert(size <= ((uint64_t)1 << HBITMAP_LOG_MAX_SIZE));
Expand Down

0 comments on commit fc5c701

Please sign in to comment.