cryptospore / rpms / qemu-kvm

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