migration: add incremental mode on drive-mirror
cover migration: add incremental mode on drive-mirror
From: mahaocong <[email protected]>
This patch adds possibility to start mirroring with user-created-bitmap. The use-case is, for live migration with ceph rbd image. I think the new function may be used to reduce the initial dirty block number on drive-mirror by using user-created-bitmap instead of created from block-backing-chain, comparing with full mode and top mode, and thus accelerate the live-migration speed.
This function should be used with backup. My test steps is as follows:
1.create rbd image in ceph cluster, and map nbd device with rbd image. 2.create a new bitmap attached to drive.
3.create a full backup on nbd device and sync it to the rbd image. 4.create new image in destination host and set it's backingfile as rbd image. 5.start incremental mirroring to destination with dirty-bitmap from step 2. 6.live migrate VM to destination, bitmap should be migrated too. 7.unmap nbd in source host and map in destination.
Then I can use incremental backup to sync data and renew bitmap. If live migrate VM again, repeat step 4 to step 7. The first live-migration depend on full backup, but in the next live-migration, we can reuse backup data and bitmap to reduce the initial dirty block number on mirror.
User-created-bitmap should be migrated, which record dirty block starting in backup and in live-migration.
mahaocong (1):
mirror: add incremental mode support. when use incremental in drive-mirror
by qmp-command, drive-mirror create unnamed-bitmap with the same granularity of user-bitmap setting on qmp-command. Next, copy It's hbitmap to unnamed-bitmap. Then, start mirror with this unnamed-bitmap.
dirty-bitmap: add new API to copy dirty-bitmap.
hbitmap: add new function to copy hbitmap.
block/dirty-bitmap.c | 14 ++++++++++ block/mirror.c | 63 +++++++++++++++++++++++++++++++++++--------- blockdev.c | 36 +++++++++++++++++++++++-- include/block/block_int.h | 3 ++- include/block/dirty-bitmap.h | 3 +++ include/qemu/hbitmap.h | 2 ++ qapi/block-core.json | 9 ++++++- util/hbitmap.c | 28 ++++++++++++++++++++ 8 files changed, 141 insertions(+), 17 deletions(-)
Signature · 1 line
2.14.1
PATCH 1/1 add incremental mode on drive-mirror
From: mahaocong <[email protected]>
--- block/dirty-bitmap.c | 14 ++++++++++ block/mirror.c | 63 +++++++++++++++++++++++++++++++++++--------- blockdev.c | 36 +++++++++++++++++++++++-- include/block/block_int.h | 3 ++- include/block/dirty-bitmap.h | 3 +++ include/qemu/hbitmap.h | 2 ++ qapi/block-core.json | 9 ++++++- util/hbitmap.c | 28 ++++++++++++++++++++ 8 files changed, 141 insertions(+), 17 deletions(-)
block/dirty-bitmap.c +14 -0
@@ -348,6 +348,20 @@ BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap(BlockDriverState *bs,return ret; } +BdrvDirtyBitmap *bdrv_copy_dirty_bitmap_locked (BdrvDirtyBitmap *src, +BdrvDirtyBitmap *dest, +Error **errp) +{ +qemu_mutex_lock (src->mutex); +if (!hbitmap_copy (dest->bitmap, src->bitmap)) { +error_setg (errp,"Error: copy src bitmap failed" ); +return NULL ; + } +qemu_mutex_unlock (src->mutex); + +return dest; +} +/** * Truncates _all_ bitmaps attached to a BDS. * Called with BQL taken.
block/mirror.c +50 -13
123 lines not on this page · raw message
blockdev.c +34 -2
@@ -3663,6 +3663,8 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,BlockDriverState *target, bool has_replaces, const char *replaces, enum MirrorSyncMode sync, + bool has_bitmap_name, + const char *bitmap_name, BlockMirrorBackingMode backing_mode, bool has_speed, int64_t speed, bool has_granularity, uint32_t granularity,
@@ -3680,6 +3682,7 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs, Error **errp) {int job_flags =JOB_DEFAULT ; +BdrvDirtyBitmap *src_bitmap;if (!has_speed) { speed =0 ;
@@ -3702,6 +3705,23 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,if (!has_filter_node_name) { filter_node_name =NULL ; } +if (!has_bitmap_name) { + bitmap_name =NULL ; + } +/* +* In incremental mode, we should create null name bitmap by +* using user bitmap's granularity. +*/ +if (sync ==MIRROR_SYNC_MODE_INCREMENTAL && bitmap_name !=NULL ) { + src_bitmap =bdrv_find_dirty_bitmap (bs, bitmap_name); +if (!src_bitmap) { +error_setg (errp,"Error: can't find dirty bitmap " +"before start incremental drive-mirror" ); +return ; + } + granularity =bdrv_dirty_bitmap_granularity (src_bitmap); + } +if (!has_copy_mode) { copy_mode =MIRROR_COPY_MODE_BACKGROUND ; }
@@ -3739,7 +3759,7 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,*/ mirror_start (job_id, bs, target, has_replaces ? replaces :NULL , job_flags, - speed, granularity, buf_size, sync, backing_mode, + speed, granularity, buf_size, sync, bitmap_name, backing_mode, on_source_error, on_target_error, unmap, filter_node_name, copy_mode, errp); }
@@ -3786,6 +3806,16 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)if (arg->sync ==MIRROR_SYNC_MODE_NONE ) { source = bs; } +if ((arg->sync ==MIRROR_SYNC_MODE_INCREMENTAL ) && + (!arg->has_bitmap_name)) { +error_setg (errp,"incremental mode must specify the bitmap name" ); + goto out; + } +if ((arg->sync ==MIRROR_SYNC_MODE_INCREMENTAL ) && + (arg->has_granularity)) { +error_setg (errp,"incremental mode can not set bitmap granularity" ); + goto out; + } size =bdrv_getlength (bs);if (size <0 ) {
@@ -3880,6 +3910,7 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) blockdev_mirror_common(arg->has_job_id ? arg->job_id : NULL, bs, target_bs, arg->has_replaces, arg->replaces, arg->sync, + arg->has_bitmap_name, arg->bitmap_name, backing_mode, arg->has_speed, arg->speed, arg->has_granularity, arg->granularity, arg->has_buf_size, arg->buf_size,
@@ -3937,7 +3968,8 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,bdrv_set_aio_context (target_bs, aio_context); blockdev_mirror_common(has_job_id ? job_id : NULL, bs, target_bs, - has_replaces, replaces, sync, backing_mode, + has_replaces, replaces, sync, false, NULL, + backing_mode, has_speed, speed, has_granularity, granularity, has_buf_size, buf_size,
include/block/block_int.h +2 -1
@@ -1054,7 +1054,8 @@ void mirror_start(const char *job_id, BlockDriverState *bs, BlockDriverState *target, const char *replaces, int creation_flags, int64_t speed, uint32_t granularity, int64_t buf_size, - MirrorSyncMode mode, BlockMirrorBackingMode backing_mode, + MirrorSyncMode mode, const char *bitmap_name, + BlockMirrorBackingMode backing_mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, bool unmap, const char *filter_node_name,
include/block/dirty-bitmap.h +3 -0
@@ -21,6 +21,9 @@ BdrvDirtyBitmap *bdrv_dirty_bitmap_abdicate(BlockDriverState *bs,BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap (BlockDriverState *bs,BdrvDirtyBitmap *bitmap,Error **errp); +BdrvDirtyBitmap *bdrv_copy_dirty_bitmap_locked (BdrvDirtyBitmap *src, +BdrvDirtyBitmap *dest, +Error **errp);void bdrv_dirty_bitmap_enable_successor (BdrvDirtyBitmap *bitmap);BdrvDirtyBitmap *bdrv_find_dirty_bitmap (BlockDriverState *bs,const char *name);
include/qemu/hbitmap.h +2 -0
@@ -91,6 +91,8 @@ bool hbitmap_merge(const HBitmap *a, const HBitmap *b, HBitmap *result);*/ bool hbitmap_can_merge (const HBitmap *a,const HBitmap *b); +bool hbitmap_copy (HBitmap *dst,const HBitmap *src); +/** * hbitmap_empty: * @hb: HBitmap to operate on.
qapi/block-core.json +8 -1
@@ -1727,6 +1727,13 @@ # (all the disk, only the sectors allocated in the topmost image, or # only new I/O). # +# @bitmap-name: the name of user-created-bitmap which is used to initialize the +# unnamed-bitmap used on incremental drive-mirror. It's hbitmap +# will be copy to mirror bitmap. If user select incremental mode, +# bitmap-name should not be null, and can not set granularity for +# the mirror bitmap should have the same granularity with +# user-created-bitmap. +# # @granularity: granularity of the dirty bitmap, default is 64K # if the image format doesn't have clusters, 4K if the clusters # are smaller than that, else the cluster size. Must be a
@@ -1768,7 +1775,7 @@ { 'struct': 'DriveMirror', 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str', '*format': 'str', '*node-name': 'str', '*replaces': 'str', - 'sync': 'MirrorSyncMode', '*mode': 'NewImageMode', + 'sync': 'MirrorSyncMode', '*bitmap-name': 'str', '*mode': 'NewImageMode', '*speed': 'int', '*granularity': 'uint32', '*buf-size': 'int', '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError',
util/hbitmap.c +28 -0
@@ -765,6 +765,34 @@ bool hbitmap_merge(const HBitmap *a, const HBitmap *b, HBitmap *result)return true; } +/* +* Copy HBitmaps form src to dst. +* +* @return true if the copy was successful, +* false if it was not attempted. +*/ +bool hbitmap_copy (HBitmap *dst,const HBitmap *src) +{ +int i; + +if ((dst->size != src->size) || (dst->granularity != src->granularity)) { +return false; + } + +if (hbitmap_count (src) ==0 ) { +return true; + } + +for (i =HBITMAP_LEVELS -1 ; i >=0 ; i--) { +memcpy (dst->levels[i], src->levels[i], + src->sizes[i] *sizeof (unsigned long )); + } + + dst->count = src->count; +return true; +} + +HBitmap *hbitmap_create_meta (HBitmap *hb,int chunk_size) {assert (!(chunk_size & (chunk_size -1 )));
Signature · 1 line
2.14.1
Re: [Qemu-devel] [PATCH v1 1/1] add incremental mode on drive-mirror
Hi!
it's a very brief review, but hope it will help.
Quoted 19 lines · mahaocong
From: mahaocong <[email protected]>
Signed-off-by mahaocong <[email protected]>--- block/dirty-bitmap.c | 14 ++++++++++ block/mirror.c | 63 +++++++++++++++++++++++++++++++++++--------- blockdev.c | 36 +++++++++++++++++++++++-- include/block/block_int.h | 3 ++- include/block/dirty-bitmap.h | 3 +++ include/qemu/hbitmap.h | 2 ++ qapi/block-core.json | 9 ++++++- util/hbitmap.c | 28 ++++++++++++++++++++ 8 files changed, 141 insertions(+), 17 deletions(-)block/dirty-bitmap.c +0
-0
block/dirty-bitmap.c BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap(BlockDriverState *bs, · line 353
Quoted 6 lines
block/dirty-bitmap.c +3
-0@@ -348,6 +348,20 @@ BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap(BlockDriverState *bs,return ret; } +BdrvDirtyBitmap *bdrv_copy_dirty_bitmap_locked (BdrvDirtyBitmap *src, +BdrvDirtyBitmap *dest, +Error **errp)
common notation in the file is opposite: _locked for functions, which need external locking
block/dirty-bitmap.c BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap(BlockDriverState *bs, · line 363
Quoted 10 lines
block/dirty-bitmap.c +10
-0+{ +qemu_mutex_lock (src->mutex); +if (!hbitmap_copy (dest->bitmap, src->bitmap)) { +error_setg (errp,"Error: copy src bitmap failed" ); +return NULL ; + } +qemu_mutex_unlock (src->mutex); + +return dest; +}
please, keep new bitmap related feature (copy) in a separate patch
Quoted 47 lines
block/dirty-bitmap.c +1
-0+/** * Truncates _all_ bitmaps attached to a BDS. * Called with BQL taken. block/mirror.c +24
-0@@ -50,6 +50,8 @@ typedef struct MirrorBlockJob {/* Used to block operations on the drive-mirror-replace target */ Error *replace_blocker;bool is_none_mode; +bool is_inc_mode; +char *bitmap_name;BlockMirrorBackingMode backing_mode;MirrorCopyMode copy_mode;BlockdevOnError on_source_error, on_target_error;@@ -814,6 +816,28 @@ static int coroutine_fn mirror_dirty_init(MirrorBlockJob *s)return 0 ; } +/* +* init dirty bitmap by using user bitmap. usr->hbitmap will be copy to +* mirror bitmap->hbitmap instead of reuse it. +*/ +static int coroutine_fn mirror_dirty_init_incremental(MirrorBlockJob *s) +{ +BlockDriverState *bs = s->mirror_top_bs->backing->bs; +BdrvDirtyBitmap *src, *dest; + + dest = s->dirty_bitmap; + src =bdrv_find_dirty_bitmap (bs, s->bitmap_name); +if (!src) { +return -1 ; + } + +if (!bdrv_copy_dirty_bitmap_locked (src, dest,NULL )) { +return -1 ; + } + +return 0 ; +} +/* Called when going out of the streaming phase to flush the bulk of the * data to the medium, or just before completing. */
block/mirror.c static int coroutine_fn mirror_run(Job *job, Error **errp) · line 943
Quoted 10 lines
block/mirror.c +4
-3@@ -913,9 +937,17 @@ static int coroutine_fn mirror_run(Job *job, Error **errp) s->last_pause_ns =qemu_clock_get_ns (QEMU_CLOCK_REALTIME );if (!s->is_none_mode) { - ret =mirror_dirty_init (s); -if (ret <0 ||job_is_cancelled (&s->common.job)) { - goto immediate_exit; +/* incremental mode */ +if (s->is_inc_mode) { + ret =mirror_dirty_init_incremental (s); +if (ret <0 ||job_is_cancelled (&s->common.job)) {
bitmap copying don't have yield point, so checking for cancelled is not needed here
Quoted 57 lines
block/mirror.c +16
-6+ goto immediate_exit; + } + }else { + ret =mirror_dirty_init (s); +if (ret <0 ||job_is_cancelled (&s->common.job)) { + goto immediate_exit; + } } }@@ -1484,7 +1516,9 @@ static void mirror_start_job(const char *job_id, BlockDriverState *bs, BlockCompletionFunc *cb, void *opaque, const BlockJobDriver *driver, - bool is_none_mode, BlockDriverState *base, + bool is_none_mode, bool is_inc_mode, + const char *bitmap_name, + BlockDriverState *base, bool auto_complete, const char *filter_node_name, bool is_mirror, MirrorCopyMode copy_mode, Error **errp)@@ -1598,6 +1632,8 @@ static void mirror_start_job(const char *job_id, BlockDriverState *bs, s->on_source_error = on_source_error; s->on_target_error = on_target_error; s->is_none_mode = is_none_mode; + s->is_inc_mode = is_inc_mode; + s->bitmap_name =g_strdup (bitmap_name); s->backing_mode = backing_mode; s->copy_mode = copy_mode; s->base = base;@@ -1648,6 +1684,7 @@ fail:bdrv_ref (mirror_top_bs);g_free (s->replaces); +g_free (s->bitmap_name);blk_unref (s->target); bs_opaque->job =NULL ;job_early_fail (&s->common.job);@@ -1664,26 +1701,25 @@ void mirror_start(const char *job_id, BlockDriverState *bs, BlockDriverState *target, const char *replaces, int creation_flags, int64_t speed, uint32_t granularity, int64_t buf_size, - MirrorSyncMode mode, BlockMirrorBackingMode backing_mode, + MirrorSyncMode mode, const char *bitmap_name, + BlockMirrorBackingMode backing_mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, bool unmap, const char *filter_node_name, MirrorCopyMode copy_mode, Error **errp) { - bool is_none_mode; + bool is_none_mode, is_inc_mode;BlockDriverState *base; -if (mode ==MIRROR_SYNC_MODE_INCREMENTAL ) { -error_setg (errp,"Sync mode 'incremental' not supported" ); -return ;
block/mirror.c void mirror_start(const char *job_id, BlockDriverState *bs, · line 1720
Quoted 10 lines
block/mirror.c +2
-3- } is_none_mode = mode ==MIRROR_SYNC_MODE_NONE ; + is_inc_mode = mode ==MIRROR_SYNC_MODE_INCREMENTAL ; base = mode ==MIRROR_SYNC_MODE_TOP ?backing_bs (bs) :NULL ; mirror_start_job(job_id, bs, creation_flags, target, replaces, speed, granularity, buf_size, backing_mode, on_source_error, on_target_error, unmap, NULL, NULL, - &mirror_job_driver, is_none_mode, base, false, - filter_node_name, true, copy_mode, errp); + &mirror_job_driver, is_none_mode, is_inc_mode,
semantics becomes strange: why not to just pass mode instead of two bools?
On the other hand, even bitmap_name != NULL is enough to understand that mode is incremental, so we don't need new paramter
Quoted 38 lines
block/mirror.c +4
-1+ bitmap_name, base, false, filter_node_name, true, + copy_mode, errp); } void commit_active_start(const char *job_id, BlockDriverState *bs,@@ -1707,7 +1743,8 @@ void commit_active_start(const char *job_id, BlockDriverState *bs,mirror_start_job (job_id, bs, creation_flags, base,NULL , speed,0 ,0 ,MIRROR_LEAVE_BACKING_CHAIN , on_error, on_error, true, cb, opaque, - &commit_active_job_driver, false, base, auto_complete, + &commit_active_job_driver, false, false, +NULL , base, auto_complete, filter_node_name, false,MIRROR_COPY_MODE_BACKGROUND , &local_err);if (local_err) {blockdev.c +3
-0@@ -3663,6 +3663,8 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,BlockDriverState *target, bool has_replaces, const char *replaces, enum MirrorSyncMode sync, + bool has_bitmap_name, + const char *bitmap_name, BlockMirrorBackingMode backing_mode, bool has_speed, int64_t speed, bool has_granularity, uint32_t granularity,@@ -3680,6 +3682,7 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs, Error **errp) {int job_flags =JOB_DEFAULT ; +BdrvDirtyBitmap *src_bitmap;if (!has_speed) { speed =0 ;@@ -3702,6 +3705,23 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,if (!has_filter_node_name) {
blockdev.c static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs, · line 3715
Quoted 10 lines
blockdev.c +8
-0filter_node_name =NULL ; } +if (!has_bitmap_name) { + bitmap_name =NULL ; + } +/* +* In incremental mode, we should create null name bitmap by +* using user bitmap's granularity. +*/ +if (sync ==MIRROR_SYNC_MODE_INCREMENTAL && bitmap_name !=NULL ) {
I think, these two ^^^ conditions must be equal, so, better assert it than check both
blockdev.c static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs, · line 3716
Quoted 1 line
blockdev.c +1
-0+ src_bitmap =bdrv_find_dirty_bitmap (bs, bitmap_name);
and if we have to find bitmap here, why to ...
Quoted 12 lines
blockdev.c +8
-0+if (!src_bitmap) { +error_setg (errp,"Error: can't find dirty bitmap " +"before start incremental drive-mirror" ); +return ; + } + granularity =bdrv_dirty_bitmap_granularity (src_bitmap); + } +if (!has_copy_mode) { copy_mode =MIRROR_COPY_MODE_BACKGROUND ; }
blockdev.c static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs, · line 3762
Quoted 5 lines
blockdev.c +1
-1@@ -3739,7 +3759,7 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,*/ mirror_start(job_id, bs, target, has_replaces ? replaces : NULL, job_flags, - speed, granularity, buf_size, sync, backing_mode, + speed, granularity, buf_size, sync, bitmap_name, backing_mode,
... still pass bitmap_name here, and then find bitmap again?
Quoted 84 lines
blockdev.c +13
-1on_source_error, on_target_error, unmap, filter_node_name, copy_mode, errp); }@@ -3786,6 +3806,16 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)if (arg->sync ==MIRROR_SYNC_MODE_NONE ) { source = bs; } +if ((arg->sync ==MIRROR_SYNC_MODE_INCREMENTAL ) && + (!arg->has_bitmap_name)) { +error_setg (errp,"incremental mode must specify the bitmap name" ); + goto out; + } +if ((arg->sync ==MIRROR_SYNC_MODE_INCREMENTAL ) && + (arg->has_granularity)) { +error_setg (errp,"incremental mode can not set bitmap granularity" ); + goto out; + } size =bdrv_getlength (bs);if (size <0 ) {@@ -3880,6 +3910,7 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) blockdev_mirror_common(arg->has_job_id ? arg->job_id : NULL, bs, target_bs, arg->has_replaces, arg->replaces, arg->sync, + arg->has_bitmap_name, arg->bitmap_name, backing_mode, arg->has_speed, arg->speed, arg->has_granularity, arg->granularity, arg->has_buf_size, arg->buf_size,@@ -3937,7 +3968,8 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,bdrv_set_aio_context (target_bs, aio_context); blockdev_mirror_common(has_job_id ? job_id : NULL, bs, target_bs, - has_replaces, replaces, sync, backing_mode, + has_replaces, replaces, sync, false, NULL, + backing_mode, has_speed, speed, has_granularity, granularity, has_buf_size, buf_size,include/block/block_int.h +2
-1@@ -1054,7 +1054,8 @@ void mirror_start(const char *job_id, BlockDriverState *bs, BlockDriverState *target, const char *replaces, int creation_flags, int64_t speed, uint32_t granularity, int64_t buf_size, - MirrorSyncMode mode, BlockMirrorBackingMode backing_mode, + MirrorSyncMode mode, const char *bitmap_name, + BlockMirrorBackingMode backing_mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, bool unmap, const char *filter_node_name,include/block/dirty-bitmap.h +3
-0@@ -21,6 +21,9 @@ BdrvDirtyBitmap *bdrv_dirty_bitmap_abdicate(BlockDriverState *bs,BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap (BlockDriverState *bs,BdrvDirtyBitmap *bitmap,Error **errp); +BdrvDirtyBitmap *bdrv_copy_dirty_bitmap_locked (BdrvDirtyBitmap *src, +BdrvDirtyBitmap *dest, +Error **errp);void bdrv_dirty_bitmap_enable_successor (BdrvDirtyBitmap *bitmap);BdrvDirtyBitmap *bdrv_find_dirty_bitmap (BlockDriverState *bs,const char *name);include/qemu/hbitmap.h +2
-0@@ -91,6 +91,8 @@ bool hbitmap_merge(const HBitmap *a, const HBitmap *b, HBitmap *result);*/ bool hbitmap_can_merge (const HBitmap *a,const HBitmap *b); +bool hbitmap_copy (HBitmap *dst,const HBitmap *src); +/** * hbitmap_empty: * @hb: HBitmap to operate on. qapi/block-core.json +0
-0
qapi/block-core.json line 1735
Quoted 9 lines
qapi/block-core.json +6
-0@@ -1727,6 +1727,13 @@ # (all the disk, only the sectors allocated in the topmost image, or # only new I/O). # +# @bitmap-name: the name of user-created-bitmap which is used to initialize the +# unnamed-bitmap used on incremental drive-mirror. It's hbitmap +# will be copy to mirror bitmap. If user select incremental mode, +# bitmap-name should not be null, and can not set granularity for +# the mirror bitmap should have the same granularity with +# user-created-bitmap.
1. agree with Eric, that it should be just @bitmap.
2. I don't sure in common semantics of new incremental mode: you implement it in the way you describe, just init mirror bitmap from user chosen bitmap. But if guest writes to the non-dirty range of given bitmap, this data will be mirrored. However, as I understand from your cover letter, you don't need such behavior.
Quoted 53 lines
qapi/block-core.json +2
-1+# # @granularity: granularity of the dirty bitmap, default is 64K # if the image format doesn't have clusters, 4K if the clusters # are smaller than that, else the cluster size. Must be a@@ -1768,7 +1775,7 @@ { 'struct': 'DriveMirror', 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str', '*format': 'str', '*node-name': 'str', '*replaces': 'str', - 'sync': 'MirrorSyncMode', '*mode': 'NewImageMode', + 'sync': 'MirrorSyncMode', '*bitmap-name': 'str', '*mode': 'NewImageMode', '*speed': 'int', '*granularity': 'uint32', '*buf-size': 'int', '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError',util/hbitmap.c +28
-0@@ -765,6 +765,34 @@ bool hbitmap_merge(const HBitmap *a, const HBitmap *b, HBitmap *result)return true; } +/* +* Copy HBitmaps form src to dst. +* +* @return true if the copy was successful, +* false if it was not attempted. +*/ +bool hbitmap_copy (HBitmap *dst,const HBitmap *src) +{ +int i; + +if ((dst->size != src->size) || (dst->granularity != src->granularity)) { +return false; + } + +if (hbitmap_count (src) ==0 ) { +return true; + } + +for (i =HBITMAP_LEVELS -1 ; i >=0 ; i--) { +memcpy (dst->levels[i], src->levels[i], + src->sizes[i] *sizeof (unsigned long )); + } + + dst->count = src->count; +return true; +} + +HBitmap *hbitmap_create_meta (HBitmap *hb,int chunk_size) {assert (!(chunk_size & (chunk_size -1 )));
Signature · 2 lines
Best regards, Vladimir