[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [RFC PATCH COLO v2 10/13] Backup: clear all bitmap when doi
From: |
Wen Congyang |
Subject: |
[Qemu-block] [RFC PATCH COLO v2 10/13] Backup: clear all bitmap when doing block checkpoint |
Date: |
Wed, 25 Mar 2015 17:36:11 +0800 |
Signed-off-by: Wen Congyang <address@hidden>
Signed-off-by: zhanghailiang <address@hidden>
Signed-off-by: Gonglei <address@hidden>
Cc: Jeff Cody <address@hidden>
---
block/backup.c | 12 ++++++++++++
include/block/block_int.h | 1 +
include/qemu/hbitmap.h | 8 ++++++++
util/hbitmap.c | 19 +++++++++++++++++++
4 files changed, 40 insertions(+)
diff --git a/block/backup.c b/block/backup.c
index 1c535b1..4e9d535 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -435,3 +435,15 @@ void backup_start(BlockDriverState *bs, BlockDriverState
*target,
job->common.co = qemu_coroutine_create(backup_run);
qemu_coroutine_enter(job->common.co, job);
}
+
+void backup_do_checkpoint(BlockJob *job, Error **errp)
+{
+ BackupBlockJob *backup_job = container_of(job, BackupBlockJob, common);
+
+ if (job->driver != &backup_job_driver) {
+ error_setg(errp, "It is not backup job");
+ return;
+ }
+
+ hbitmap_reset_all(backup_job->bitmap);
+}
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 624945d..45d547b 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -628,6 +628,7 @@ void backup_start(BlockDriverState *bs, BlockDriverState
*target,
BlockdevOnError on_target_error,
BlockCompletionFunc *cb, void *opaque,
Error **errp);
+void backup_do_checkpoint(BlockJob *job, Error **errp);
void blk_dev_change_media_cb(BlockBackend *blk, bool load);
bool blk_dev_has_removable_media(BlockBackend *blk);
diff --git a/include/qemu/hbitmap.h b/include/qemu/hbitmap.h
index 550d7ce..95a55e4 100644
--- a/include/qemu/hbitmap.h
+++ b/include/qemu/hbitmap.h
@@ -109,6 +109,14 @@ void hbitmap_set(HBitmap *hb, uint64_t start, uint64_t
count);
void hbitmap_reset(HBitmap *hb, uint64_t start, uint64_t count);
/**
+ * hbitmap_reset_all:
+ * @hb: HBitmap to operate on.
+ *
+ * Reset all bits in an HBitmap.
+ */
+void hbitmap_reset_all(HBitmap *hb);
+
+/**
* hbitmap_get:
* @hb: HBitmap to operate on.
* @item: Bit to query (0-based).
diff --git a/util/hbitmap.c b/util/hbitmap.c
index ab13971..4111ca5 100644
--- a/util/hbitmap.c
+++ b/util/hbitmap.c
@@ -353,6 +353,25 @@ void hbitmap_reset(HBitmap *hb, uint64_t start, uint64_t
count)
hb_reset_between(hb, HBITMAP_LEVELS - 1, start, last);
}
+void hbitmap_reset_all(HBitmap *hb)
+{
+#if 0
+ hbitmap_reset(hb, 0, hb->size << hb->granularity);
+#else
+ uint64_t size = hb->size;
+ unsigned int i;
+
+ /* Same as hbitmap_alloc() except memset() */
+ for (i = HBITMAP_LEVELS; i-- > 0; ) {
+ size = MAX((size + BITS_PER_LONG - 1) >> BITS_PER_LEVEL, 1);
+ memset(hb->levels[i], 0, size * sizeof(unsigned long));
+ }
+
+ assert(size == 1);
+ hb->levels[0][0] |= 1UL << (BITS_PER_LONG - 1);
+#endif
+}
+
bool hbitmap_get(const HBitmap *hb, uint64_t item)
{
/* Compute position and bit in the last layer. */
--
2.1.0
- Re: [Qemu-block] [RFC PATCH COLO v2 04/13] Add new block driver interfaces to control block replication, (continued)
[Qemu-block] [RFC PATCH COLO v2 10/13] Backup: clear all bitmap when doing block checkpoint,
Wen Congyang <=
[Qemu-block] [RFC PATCH COLO v2 07/13] allow writing to the backing file, Wen Congyang, 2015/03/25
[Qemu-block] [RFC PATCH COLO v2 09/13] block: Parse "backing_reference" option to reference existing BDS, Wen Congyang, 2015/03/25
[Qemu-block] [RFC PATCH COLO v2 12/13] skip nbd_target when starting block replication, Wen Congyang, 2015/03/25
[Qemu-block] [RFC PATCH COLO v2 13/13] Don't allow a disk use backing reference target, Wen Congyang, 2015/03/25
[Qemu-block] [RFC PATCH COLO v2 11/13] qcow2: support colo, Wen Congyang, 2015/03/25