|
|
ae23c9 |
From 6749a16ae2e3d5aa51012bed0d9a910be8de004e Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: John Snow <jsnow@redhat.com>
|
|
|
ae23c9 |
Date: Tue, 20 Nov 2018 18:18:22 +0000
|
|
|
ae23c9 |
Subject: [PATCH 28/35] bitmap: Update count after a merge
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
ae23c9 |
Message-id: <20181120181828.15132-19-jsnow@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 83073
|
|
|
ae23c9 |
O-Subject: [RHEL8/rhel qemu-kvm PATCH 18/24] bitmap: Update count after a merge
|
|
|
ae23c9 |
Bugzilla: 1518989
|
|
|
ae23c9 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
From: Eric Blake <eblake@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
We need an accurate count of the number of bits set in a bitmap
|
|
|
ae23c9 |
after a merge. In particular, since the merge operation short-circuits
|
|
|
ae23c9 |
a merge from an empty source, if you have bitmaps A, B, and C where
|
|
|
ae23c9 |
B started empty, then merge C into B, and B into A, an inaccurate
|
|
|
ae23c9 |
count meant that A did not get the contents of C.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
In the worst case, we may falsely regard the bitmap as empty when
|
|
|
ae23c9 |
it has had new writes merged into it.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Fixes: be58721db
|
|
|
ae23c9 |
CC: qemu-stable@nongnu.org
|
|
|
ae23c9 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
ae23c9 |
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
ae23c9 |
Message-id: 20181002233314.30159-1-jsnow@redhat.com
|
|
|
ae23c9 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit d1dde7149e376d72b422a529ec4bf3ed47f3ba30)
|
|
|
ae23c9 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
util/hbitmap.c | 3 +++
|
|
|
ae23c9 |
1 file changed, 3 insertions(+)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/util/hbitmap.c b/util/hbitmap.c
|
|
|
ae23c9 |
index d5aca51..8d402c5 100644
|
|
|
ae23c9 |
--- a/util/hbitmap.c
|
|
|
ae23c9 |
+++ b/util/hbitmap.c
|
|
|
ae23c9 |
@@ -759,6 +759,9 @@ bool hbitmap_merge(const HBitmap *a, const HBitmap *b, HBitmap *result)
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+ /* Recompute the dirty count */
|
|
|
ae23c9 |
+ result->count = hb_count_between(result, 0, result->size - 1);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
return true;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|