[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 04/12] hbitmap: Fix merge when b is empty, and resul
From: |
John Snow |
Subject: |
[Qemu-block] [PATCH 04/12] hbitmap: Fix merge when b is empty, and result is not an alias of a |
Date: |
Wed, 19 Jun 2019 21:03:48 -0400 |
Nobody calls the function like this currently, but we neither prohibit
or cope with this behavior. I decided to make the function cope with it.
Signed-off-by: John Snow <address@hidden>
---
util/hbitmap.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/util/hbitmap.c b/util/hbitmap.c
index 7905212a8b..45d1725daf 100644
--- a/util/hbitmap.c
+++ b/util/hbitmap.c
@@ -781,8 +781,9 @@ bool hbitmap_can_merge(const HBitmap *a, const HBitmap *b)
}
/**
- * Given HBitmaps A and B, let A := A (BITOR) B.
- * Bitmap B will not be modified.
+ * Given HBitmaps A and B, let R := A (BITOR) B.
+ * Bitmaps A and B will not be modified,
+ * except when bitmap R is an alias of A or B.
*
* @return true if the merge was successful,
* false if it was not attempted.
@@ -797,7 +798,9 @@ bool hbitmap_merge(const HBitmap *a, const HBitmap *b,
HBitmap *result)
}
assert(hbitmap_can_merge(b, result));
- if (hbitmap_count(b) == 0) {
+ if ((!hbitmap_count(a) && result == b) ||
+ (!hbitmap_count(b) && result == a) ||
+ (!hbitmap_count(a) && !hbitmap_count(b))) {
return true;
}
--
2.21.0
- Re: [Qemu-block] [Qemu-devel] [PATCH 07/12] block/backup: add 'always' bitmap sync policy, (continued)
[Qemu-block] [PATCH 10/12] iotests: teach FilePath to produce multiple paths, John Snow, 2019/06/19
[Qemu-block] [PATCH 06/12] block/dirty-bitmap: add bdrv_dirty_bitmap_claim, John Snow, 2019/06/19
[Qemu-block] [PATCH 04/12] hbitmap: Fix merge when b is empty, and result is not an alias of a,
John Snow <=
[Qemu-block] [PATCH 01/12] qapi: add BitmapSyncMode enum, John Snow, 2019/06/19
[Qemu-block] [PATCH 02/12] block/backup: Add mirror sync mode 'bitmap', John Snow, 2019/06/19
Re: [Qemu-block] [PATCH 02/12] block/backup: Add mirror sync mode 'bitmap', Vladimir Sementsov-Ogievskiy, 2019/06/21