[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 54/76] hbitmap: cache array lengths
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 54/76] hbitmap: cache array lengths |
Date: |
Tue, 28 Apr 2015 17:00:36 +0200 |
From: John Snow <address@hidden>
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.
Reviewed-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: John Snow <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Kevin Wolf <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.8.3.1
- [Qemu-block] [PULL 44/76] block/iscsi: optimize WRITE10/16 if cache.writeback is not set, (continued)
- [Qemu-block] [PULL 44/76] block/iscsi: optimize WRITE10/16 if cache.writeback is not set, Kevin Wolf, 2015/04/28
- [Qemu-block] [PULL 45/76] block/iscsi: increase retry count, Kevin Wolf, 2015/04/28
- [Qemu-block] [PULL 46/76] block/iscsi: handle SCSI_STATUS_TASK_SET_FULL, Kevin Wolf, 2015/04/28
- [Qemu-block] [PULL 47/76] block/iscsi: bump year in copyright notice, Kevin Wolf, 2015/04/28
- [Qemu-block] [PULL 48/76] block/iscsi: use the allocationmap also if cache.direct=on, Kevin Wolf, 2015/04/28
- [Qemu-block] [PULL 49/76] docs: incremental backup documentation, Kevin Wolf, 2015/04/28
- [Qemu-block] [PULL 50/76] qapi: Add optional field "name" to block dirty bitmap, Kevin Wolf, 2015/04/28
- [Qemu-block] [PULL 51/76] qmp: Ensure consistent granularity type, Kevin Wolf, 2015/04/28
- [Qemu-block] [PULL 52/76] qmp: Add block-dirty-bitmap-add and block-dirty-bitmap-remove, Kevin Wolf, 2015/04/28
- [Qemu-block] [PULL 53/76] block: Introduce bdrv_dirty_bitmap_granularity(), Kevin Wolf, 2015/04/28
- [Qemu-block] [PULL 54/76] hbitmap: cache array lengths,
Kevin Wolf <=
- [Qemu-block] [PULL 55/76] hbitmap: add hbitmap_merge, Kevin Wolf, 2015/04/28
- [Qemu-block] [PULL 56/76] block: Add bitmap disabled status, Kevin Wolf, 2015/04/28
- [Qemu-block] [PULL 57/76] block: Add bitmap successors, Kevin Wolf, 2015/04/28
- [Qemu-block] [PULL 58/76] qmp: Add support of "dirty-bitmap" sync mode for drive-backup, Kevin Wolf, 2015/04/28
- [Qemu-block] [PULL 59/76] qmp: add block-dirty-bitmap-clear, Kevin Wolf, 2015/04/28
- [Qemu-block] [PULL 60/76] qmp: Add dirty bitmap status field in query-block, Kevin Wolf, 2015/04/28
- [Qemu-block] [PULL 61/76] block: add BdrvDirtyBitmap documentation, Kevin Wolf, 2015/04/28
- [Qemu-block] [PULL 62/76] block: Ensure consistent bitmap function prototypes, Kevin Wolf, 2015/04/28
- [Qemu-block] [PULL 64/76] hbitmap: truncate tests, Kevin Wolf, 2015/04/28
- [Qemu-block] [PULL 63/76] block: Resize bitmaps on bdrv_truncate, Kevin Wolf, 2015/04/28