From: Eric Blake Date: Mon, 29 Oct 2018 20:23:17 +0000 (-0400) Subject: bitmap: Update count after a merge X-Git-Tag: v3.0.1~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5d64550dc5886bbce8763bbfd5aa2f822ee89db1;p=thirdparty%2Fqemu.git bitmap: Update count after a merge We need an accurate count of the number of bits set in a bitmap after a merge. In particular, since the merge operation short-circuits a merge from an empty source, if you have bitmaps A, B, and C where B started empty, then merge C into B, and B into A, an inaccurate count meant that A did not get the contents of C. In the worst case, we may falsely regard the bitmap as empty when it has had new writes merged into it. Fixes: be58721db CC: qemu-stable@nongnu.org Signed-off-by: Eric Blake Signed-off-by: John Snow Reviewed-by: Vladimir Sementsov-Ogievskiy Message-id: 20181002233314.30159-1-jsnow@redhat.com Signed-off-by: John Snow (cherry picked from commit d1dde7149e376d72b422a529ec4bf3ed47f3ba30) *drop functional dep. on fa000f2f Signed-off-by: Michael Roth --- diff --git a/util/hbitmap.c b/util/hbitmap.c index bcd304041aa..f686e8015f8 100644 --- a/util/hbitmap.c +++ b/util/hbitmap.c @@ -754,6 +754,9 @@ bool hbitmap_merge(HBitmap *a, const HBitmap *b) } } + /* Recompute the dirty count */ + a->count = hb_count_between(a, 0, a->size - 1); + return true; }