[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 28/85] block/dirty-bitmap: add deserialize_ones func
From: |
Max Reitz |
Subject: |
[Qemu-block] [PULL 28/85] block/dirty-bitmap: add deserialize_ones func |
Date: |
Tue, 11 Jul 2017 18:07:17 +0200 |
From: Vladimir Sementsov-Ogievskiy <address@hidden>
Add bdrv_dirty_bitmap_deserialize_ones() function, which is needed for
qcow2 bitmap loading, to handle unallocated bitmap parts, marked as
all-ones.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Reviewed-by: John Snow <address@hidden>
Message-id: address@hidden
Signed-off-by: Max Reitz <address@hidden>
---
include/block/dirty-bitmap.h | 3 +++
include/qemu/hbitmap.h | 15 +++++++++++++++
block/dirty-bitmap.c | 7 +++++++
util/hbitmap.c | 17 +++++++++++++++++
4 files changed, 42 insertions(+)
diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h
index ab89f08..05451c7 100644
--- a/include/block/dirty-bitmap.h
+++ b/include/block/dirty-bitmap.h
@@ -66,6 +66,9 @@ void bdrv_dirty_bitmap_deserialize_part(BdrvDirtyBitmap
*bitmap,
void bdrv_dirty_bitmap_deserialize_zeroes(BdrvDirtyBitmap *bitmap,
uint64_t start, uint64_t count,
bool finish);
+void bdrv_dirty_bitmap_deserialize_ones(BdrvDirtyBitmap *bitmap,
+ uint64_t start, uint64_t count,
+ bool finish);
void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap *bitmap);
/* Functions that require manual locking. */
diff --git a/include/qemu/hbitmap.h b/include/qemu/hbitmap.h
index 6b04391..b52304a 100644
--- a/include/qemu/hbitmap.h
+++ b/include/qemu/hbitmap.h
@@ -229,6 +229,21 @@ void hbitmap_deserialize_zeroes(HBitmap *hb, uint64_t
start, uint64_t count,
bool finish);
/**
+ * hbitmap_deserialize_ones
+ * @hb: HBitmap to operate on.
+ * @start: First bit to restore.
+ * @count: Number of bits to restore.
+ * @finish: Whether to call hbitmap_deserialize_finish automatically.
+ *
+ * Fills the bitmap with ones.
+ *
+ * If @finish is false, caller must call hbitmap_serialize_finish before using
+ * the bitmap.
+ */
+void hbitmap_deserialize_ones(HBitmap *hb, uint64_t start, uint64_t count,
+ bool finish);
+
+/**
* hbitmap_deserialize_finish
* @hb: HBitmap to operate on.
*
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index df0110c..f502c45 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -586,6 +586,13 @@ void bdrv_dirty_bitmap_deserialize_zeroes(BdrvDirtyBitmap
*bitmap,
hbitmap_deserialize_zeroes(bitmap->bitmap, start, count, finish);
}
+void bdrv_dirty_bitmap_deserialize_ones(BdrvDirtyBitmap *bitmap,
+ uint64_t start, uint64_t count,
+ bool finish)
+{
+ hbitmap_deserialize_ones(bitmap->bitmap, start, count, finish);
+}
+
void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap *bitmap)
{
hbitmap_deserialize_finish(bitmap->bitmap);
diff --git a/util/hbitmap.c b/util/hbitmap.c
index 0b38817..0c1591a 100644
--- a/util/hbitmap.c
+++ b/util/hbitmap.c
@@ -551,6 +551,23 @@ void hbitmap_deserialize_zeroes(HBitmap *hb, uint64_t
start, uint64_t count,
}
}
+void hbitmap_deserialize_ones(HBitmap *hb, uint64_t start, uint64_t count,
+ bool finish)
+{
+ uint64_t el_count;
+ unsigned long *first;
+
+ if (!count) {
+ return;
+ }
+ serialization_chunk(hb, start, count, &first, &el_count);
+
+ memset(first, 0xff, el_count * sizeof(unsigned long));
+ if (finish) {
+ hbitmap_deserialize_finish(hb);
+ }
+}
+
void hbitmap_deserialize_finish(HBitmap *bitmap)
{
int64_t i, size, prev_size;
--
2.9.4
- [Qemu-block] [PULL 19/85] qcow2: report encryption specific image information, (continued)
- [Qemu-block] [PULL 19/85] qcow2: report encryption specific image information, Max Reitz, 2017/07/11
- [Qemu-block] [PULL 20/85] docs: document encryption options for qcow, qcow2 and luks, Max Reitz, 2017/07/11
- [Qemu-block] [PULL 21/85] iotests: 181 does not work for all formats, Max Reitz, 2017/07/11
- [Qemu-block] [PULL 22/85] mirror: Fix inconsistent backing AioContext for after mirroring, Max Reitz, 2017/07/11
- [Qemu-block] [PULL 23/85] specs/qcow2: fix bitmap granularity qemu-specific note, Max Reitz, 2017/07/11
- [Qemu-block] [PULL 24/85] specs/qcow2: do not use wording 'bitmap header', Max Reitz, 2017/07/11
- [Qemu-block] [PULL 25/85] hbitmap: improve dirty iter, Max Reitz, 2017/07/11
- [Qemu-block] [PULL 26/85] tests: add hbitmap iter test, Max Reitz, 2017/07/11
- [Qemu-block] [PULL 27/85] block: fix bdrv_dirty_bitmap_granularity signature, Max Reitz, 2017/07/11
- [Qemu-block] [PULL 29/85] qcow2-refcount: rename inc_refcounts() and make it public, Max Reitz, 2017/07/11
- [Qemu-block] [PULL 28/85] block/dirty-bitmap: add deserialize_ones func,
Max Reitz <=
- [Qemu-block] [PULL 30/85] qcow2: add bitmaps extension, Max Reitz, 2017/07/11
- [Qemu-block] [PULL 31/85] block/dirty-bitmap: fix comment for BlockDirtyBitmap.disabled field, Max Reitz, 2017/07/11
- [Qemu-block] [PULL 32/85] block/dirty-bitmap: add readonly field to BdrvDirtyBitmap, Max Reitz, 2017/07/11
- [Qemu-block] [PULL 34/85] block: refactor bdrv_reopen_commit, Max Reitz, 2017/07/11
- [Qemu-block] [PULL 33/85] qcow2: autoloading dirty bitmaps, Max Reitz, 2017/07/11
- [Qemu-block] [PULL 35/85] block: new bdrv_reopen_bitmaps_rw interface, Max Reitz, 2017/07/11
- [Qemu-block] [PULL 38/85] block: bdrv_close: release bitmaps after drv->bdrv_close, Max Reitz, 2017/07/11
- [Qemu-block] [PULL 37/85] block/dirty-bitmap: add autoload field to BdrvDirtyBitmap, Max Reitz, 2017/07/11
- [Qemu-block] [PULL 36/85] qcow2: support .bdrv_reopen_bitmaps_rw, Max Reitz, 2017/07/11
- [Qemu-block] [PULL 39/85] block: introduce persistent dirty bitmaps, Max Reitz, 2017/07/11