Blame SOURCES/kvm-bitmap-Update-count-after-a-merge.patch

383d26
From 56152f8d7cb931e6172a9e44bec7fe274716a240 Mon Sep 17 00:00:00 2001
383d26
From: John Snow <jsnow@redhat.com>
383d26
Date: Wed, 6 Feb 2019 22:12:37 +0100
383d26
Subject: [PATCH 27/33] bitmap: Update count after a merge
383d26
383d26
RH-Author: John Snow <jsnow@redhat.com>
383d26
Message-id: <20190206221243.7407-18-jsnow@redhat.com>
383d26
Patchwork-id: 84282
383d26
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH v2 17/23] bitmap: Update count after a merge
383d26
Bugzilla: 1658343
383d26
RH-Acked-by: Thomas Huth <thuth@redhat.com>
383d26
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
383d26
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
383d26
383d26
From: Eric Blake <eblake@redhat.com>
383d26
383d26
We need an accurate count of the number of bits set in a bitmap
383d26
after a merge. In particular, since the merge operation short-circuits
383d26
a merge from an empty source, if you have bitmaps A, B, and C where
383d26
B started empty, then merge C into B, and B into A, an inaccurate
383d26
count meant that A did not get the contents of C.
383d26
383d26
In the worst case, we may falsely regard the bitmap as empty when
383d26
it has had new writes merged into it.
383d26
383d26
Fixes: be58721db
383d26
CC: qemu-stable@nongnu.org
383d26
Signed-off-by: Eric Blake <eblake@redhat.com>
383d26
Signed-off-by: John Snow <jsnow@redhat.com>
383d26
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
383d26
Message-id: 20181002233314.30159-1-jsnow@redhat.com
383d26
Signed-off-by: John Snow <jsnow@redhat.com>
383d26
(cherry picked from commit d1dde7149e376d72b422a529ec4bf3ed47f3ba30)
383d26
Signed-off-by: John Snow <jsnow@redhat.com>
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 util/hbitmap.c | 3 +++
383d26
 1 file changed, 3 insertions(+)
383d26
383d26
diff --git a/util/hbitmap.c b/util/hbitmap.c
383d26
index d5aca51..8d402c5 100644
383d26
--- a/util/hbitmap.c
383d26
+++ b/util/hbitmap.c
383d26
@@ -759,6 +759,9 @@ bool hbitmap_merge(const HBitmap *a, const HBitmap *b, HBitmap *result)
383d26
         }
383d26
     }
383d26
 
383d26
+    /* Recompute the dirty count */
383d26
+    result->count = hb_count_between(result, 0, result->size - 1);
383d26
+
383d26
     return true;
383d26
 }
383d26
 
383d26
-- 
383d26
1.8.3.1
383d26