[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [2.4 PATCH v3 06/19] hbitmap: cache array lengths
From: |
John Snow |
Subject: |
[Qemu-block] [2.4 PATCH v3 06/19] hbitmap: cache array lengths |
Date: |
Fri, 13 Mar 2015 14:30:06 -0400 |
As a convenience: between incremental backups, bitmap migrations
and bitmap persistence we seem to need to recalculate these a lot.
Because the lengths are a little bit-twiddly, let's just solidly
cache them and be done with it.
Signed-off-by: John Snow <address@hidden>
---
util/hbitmap.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/util/hbitmap.c b/util/hbitmap.c
index ab13971..5b78613 100644
--- a/util/hbitmap.c
+++ b/util/hbitmap.c
@@ -90,6 +90,9 @@ struct HBitmap {
* bitmap will still allocate HBITMAP_LEVELS arrays.
*/
unsigned long *levels[HBITMAP_LEVELS];
+
+ /* The length of each levels[] array. */
+ uint64_t sizes[HBITMAP_LEVELS];
};
/* Advance hbi to the next nonzero word and return it. hbi->pos
@@ -384,6 +387,7 @@ HBitmap *hbitmap_alloc(uint64_t size, int granularity)
hb->granularity = granularity;
for (i = HBITMAP_LEVELS; i-- > 0; ) {
size = MAX((size + BITS_PER_LONG - 1) >> BITS_PER_LEVEL, 1);
+ hb->sizes[i] = size;
hb->levels[i] = g_new0(unsigned long, size);
}
--
1.9.3
- [Qemu-block] [2.4 PATCH v3 19/19] iotests: add incremental backup failure recovery test, (continued)
- [Qemu-block] [2.4 PATCH v3 19/19] iotests: add incremental backup failure recovery test, John Snow, 2015/03/13
- [Qemu-block] [2.4 PATCH v3 18/19] iotests: add simple incremental backup case, John Snow, 2015/03/13
- [Qemu-block] [2.4 PATCH v3 14/19] block: Ensure consistent bitmap function prototypes, John Snow, 2015/03/13
- [Qemu-block] [2.4 PATCH v3 10/19] qmp: Add support of "dirty-bitmap" sync mode for drive-backup, John Snow, 2015/03/13
- [Qemu-block] [2.4 PATCH v3 11/19] qmp: add block-dirty-bitmap-clear, John Snow, 2015/03/13
- [Qemu-block] [2.4 PATCH v3 09/19] block: Add bitmap successors, John Snow, 2015/03/13
- [Qemu-block] [2.4 PATCH v3 08/19] block: Add bitmap disabled status, John Snow, 2015/03/13
- [Qemu-block] [2.4 PATCH v3 06/19] hbitmap: cache array lengths,
John Snow <=
- [Qemu-block] [2.4 PATCH v3 13/19] block: add BdrvDirtyBitmap documentation, John Snow, 2015/03/13
- [Qemu-block] [2.4 PATCH v3 05/19] block: Introduce bdrv_dirty_bitmap_granularity(), John Snow, 2015/03/13
- [Qemu-block] [2.4 PATCH v3 07/19] hbitmap: add hbitmap_merge, John Snow, 2015/03/13
- [Qemu-block] [2.4 PATCH v3 04/19] qmp: Add block-dirty-bitmap-add and block-dirty-bitmap-remove, John Snow, 2015/03/13
[Qemu-block] [2.4 PATCH v3 12/19] qmp: Add dirty bitmap status field in query-block, John Snow, 2015/03/13