Dirty bitmap changes for migration/persistence work
v4 cover Dirty bitmap changes for migration/persistence work
v4: Rebase.
Add rev-by from John in patches 1-5, 7, 8.
Remove BdrvDirtyBitmap typedef from dirty-bitmap.h in patch 4. [Max] Add assertion on bm->meta in patch 9. [John]
Two major features are added to block dirty bitmap (and underlying HBitmap) in this series: meta bitmap and serialization, together with all other supportive patches.
Both operations are common in dirty bitmap migration and persistence: they need to find whether and which part of the dirty bitmap in question has changed with meta dirty bitmap, and they need to write it to the target with serialization.
Fam Zheng (13):
backup: Use Bitmap to replace "s->bitmap"
block: Include hbitmap.h in block.h
typedefs: Add BdrvDirtyBitmap
block: Move block dirty bitmap code to separate files
block: Remove unused typedef of BlockDriverDirtyHandler
block: Hide HBitmap in block dirty bitmap interface
HBitmap: Introduce "meta" bitmap to track bit changes
tests: Add test code for meta bitmap
block: Support meta dirty bitmap
block: Add two dirty bitmap getters
block: Assert that bdrv_release_dirty_bitmap succeeded
tests: Add test code for hbitmap serialization
block: More operations for meta dirty bitmap
Vladimir Sementsov-Ogievskiy (2):
hbitmap: serialization
block: BdrvDirtyBitmap serialization interface
block.c | 360 ----------------------------- block/Makefile.objs | 2 +- block/backup.c | 25 +- block/dirty-bitmap.c | 535 +++++++++++++++++++++++++++++++++++++++++++ block/mirror.c | 15 +- include/block/block.h | 40 +--- include/block/dirty-bitmap.h | 75 ++++++ include/qemu/hbitmap.h | 96 ++++++++ include/qemu/typedefs.h | 2 + tests/test-hbitmap.c | 255 +++++++++++++++++++++ util/hbitmap.c | 203 ++++++++++++++-- 11 files changed, 1177 insertions(+), 431 deletions(-) create mode 100644 block/dirty-bitmap.c create mode 100644 include/block/dirty-bitmap.h
Signature · 1 line
2.4.3
PATCH v4 1/15 backup: Use Bitmap to replace "s->bitmap"
"s->bitmap" tracks done sectors, we only check bit states without using any iterator which HBitmap is good for. Switch to "Bitmap" which is simpler and more memory efficient.
Meanwhile, rename it to done_bitmap, to reflect the intention.
--- block/backup.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
block/backup.c +6 -5
@@ -20,6 +20,7 @@#include "qapi/qmp/qerror.h" #include "qemu/ratelimit.h" #include "sysemu/block-backend.h" +#include "qemu/bitmap.h" #define BACKUP_CLUSTER_SIZE_DEFAULT (1 << 16)#define SLICE_TIME 100000000ULL/* ns */
@@ -42,7 +43,7 @@ typedef struct BackupBlockJob {BlockdevOnError on_target_error;CoRwlock flush_rwlock;uint64_t sectors_read; -HBitmap *bitmap; +unsigned long *done_bitmap;int64_t cluster_size; QLIST_HEAD(, CowRequest) inflight_reqs; } BackupBlockJob;
@@ -116,7 +117,7 @@ static int coroutine_fn backup_do_cow(BlockDriverState *bs,cow_request_begin (&cow_request, job, start, end);for (; start < end; start++) { -if (hbitmap_get (job->bitmap, start)) { +if (test_bit (start, job->done_bitmap)) {trace_backup_do_cow_skip (job, start);continue ;/* already copied */ }
@@ -167,7 +168,7 @@ static int coroutine_fn backup_do_cow(BlockDriverState *bs, goto out; } -hbitmap_set (job->bitmap, start,1 ); +set_bit (start, job->done_bitmap);/* Publish progress, guest I/O counts as progress too. Note that the * offset field is an opaque progress value, it is not a disk offset.
@@ -399,7 +400,7 @@ static void coroutine_fn backup_run(void *opaque) start =0 ; end =DIV_ROUND_UP (job->common.len, job->cluster_size); - job->bitmap =hbitmap_alloc (end,0 ); + job->done_bitmap =bitmap_new (end);bdrv_set_enable_write_cache (target, true);if (target->blk) {
@@ -480,7 +481,7 @@ static void coroutine_fn backup_run(void *opaque)/* wait until pending backup_do_cow() calls have completed */ qemu_co_rwlock_wrlock (&job->flush_rwlock);qemu_co_rwlock_unlock (&job->flush_rwlock); -hbitmap_free (job->bitmap); +g_free (job->done_bitmap);if (target->blk) {blk_iostatus_disable (target->blk);
Signature · 1 line
2.4.3
PATCH v4 2/15 block: Include hbitmap.h in block.h
In reply to Fam Zheng--- include/block/block.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/block/block.h +1 -1
@@ -8,6 +8,7 @@#include "block/accounting.h" #include "qapi/qmp/qobject.h" #include "qapi-types.h" +#include "qemu/hbitmap.h" /* block.c */ typedef struct BlockDriver BlockDriver ;
@@ -475,7 +476,6 @@ void *qemu_try_blockalign(BlockDriverState *bs, size_t size);void *qemu_try_blockalign0 (BlockDriverState *bs,size_t size);bool bdrv_qiov_is_aligned (BlockDriverState *bs,QEMUIOVector *qiov); -struct HBitmapIter ;typedef struct BdrvDirtyBitmap BdrvDirtyBitmap ; BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, uint32_t granularity,
Signature · 1 line
2.4.3
PATCH v4 3/15 typedefs: Add BdrvDirtyBitmap
In reply to Fam ZhengFollowing patches to refactor and move block dirty bitmap code could use this.
--- include/block/block.h | 1 - include/qemu/typedefs.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-)
include/block/block.h +0 -1
@@ -476,7 +476,6 @@ void *qemu_try_blockalign(BlockDriverState *bs, size_t size);void *qemu_try_blockalign0 (BlockDriverState *bs,size_t size);bool bdrv_qiov_is_aligned (BlockDriverState *bs,QEMUIOVector *qiov); -typedef struct BdrvDirtyBitmap BdrvDirtyBitmap ; BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, uint32_t granularity, const char *name,
include/qemu/typedefs.h +1 -0
@@ -10,6 +10,7 @@ typedef struct AddressSpace AddressSpace;typedef struct AioContext AioContext ;typedef struct AllwinnerAHCIState AllwinnerAHCIState ;typedef struct AudioState AudioState ; +typedef struct BdrvDirtyBitmap BdrvDirtyBitmap ;typedef struct BlockBackend BlockBackend ;typedef struct BlockBackendRootState BlockBackendRootState ;typedef struct BlockDriverState BlockDriverState ;
Signature · 1 line
2.4.3
PATCH v4 4/15 block: Move block dirty bitmap code to separate files
In reply to Fam ZhengThe only code change is making bdrv_dirty_bitmap_truncate public. It is used in block.c.
Also two long lines (bdrv_get_dirty) are wrapped.
--- block.c | 360 ---------------------------------------- block/Makefile.objs | 2 +- block/dirty-bitmap.c | 387 +++++++++++++++++++++++++++++++++++++++++++ include/block/block.h | 35 +--- include/block/dirty-bitmap.h | 44 +++++ 5 files changed, 433 insertions(+), 395 deletions(-) create mode 100644 block/dirty-bitmap.c create mode 100644 include/block/dirty-bitmap.h
block.c +0 -360
@@ -53,23 +53,6 @@#include <windows.h> #endif -/** -* A BdrvDirtyBitmap can be in three possible states: -* (1) successor is NULL and disabled is false: full r/w mode -* (2) successor is NULL and disabled is true: read only mode ("disabled") -* (3) successor is set: frozen mode. -* A frozen bitmap cannot be renamed, deleted, anonymized, cleared, set, -* or enabled. A frozen bitmap can only abdicate() or reclaim(). -*/ -struct BdrvDirtyBitmap { -HBitmap *bitmap;/* Dirty sector bitmap implementation */ -BdrvDirtyBitmap *successor;/* Anonymous child; implies frozen status */ -char *name;/* Optional non-empty unique ID */ -int64_t size;/* Size of the bitmap (Number of sectors) */ -bool disabled;/* Bitmap is read-only */ -QLIST_ENTRY (BdrvDirtyBitmap) list; -}; -#define NOT_DONE 0x7fffffff/* used while emulated sync operation in progress */ struct BdrvStates bdrv_states =QTAILQ_HEAD_INITIALIZER (bdrv_states);
@@ -88,9 +71,6 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename,BlockDriverState *parent, const BdrvChildRole *child_role, Error **errp); -static void bdrv_dirty_bitmap_truncate (BlockDriverState *bs); -static void bdrv_release_named_dirty_bitmaps (BlockDriverState *bs); -/* If non-zero, use only whitelisted block drivers */ static int use_bdrv_whitelist;
@@ -3431,346 +3411,6 @@ void bdrv_lock_medium(BlockDriverState *bs, bool locked) } } -BdrvDirtyBitmap *bdrv_find_dirty_bitmap (BlockDriverState *bs,const char *name) -{ -BdrvDirtyBitmap *bm; - -assert (name); - QLIST_FOREACH(bm, &bs->dirty_bitmaps, list) { -if (bm->name && !strcmp (name, bm->name)) { -return bm; - } - } -return NULL ; -} - -void bdrv_dirty_bitmap_make_anon (BdrvDirtyBitmap *bitmap) -{ -assert (!bdrv_dirty_bitmap_frozen (bitmap)); -g_free (bitmap->name); - bitmap->name =NULL ; -} - -BdrvDirtyBitmap *bdrv_create_dirty_bitmap (BlockDriverState *bs, -uint32_t granularity, -const char *name, -Error **errp) -{ -int64_t bitmap_size; -BdrvDirtyBitmap *bitmap; -uint32_t sector_granularity; - -assert ((granularity & (granularity -1 )) ==0 ); - -if (name &&bdrv_find_dirty_bitmap (bs, name)) { -error_setg (errp,"Bitmap already exists: %s" , name); -return NULL ; - } - sector_granularity = granularity >>BDRV_SECTOR_BITS ; -assert (sector_granularity); - bitmap_size =bdrv_nb_sectors (bs); -if (bitmap_size <0 ) { -error_setg_errno (errp, -bitmap_size,"could not get length of device" ); - errno = -bitmap_size; -return NULL ; - } - bitmap =g_new0 (BdrvDirtyBitmap,1 ); - bitmap->bitmap =hbitmap_alloc (bitmap_size,ctz32 (sector_granularity)); - bitmap->size = bitmap_size; - bitmap->name =g_strdup (name); - bitmap->disabled = false; -QLIST_INSERT_HEAD (&bs->dirty_bitmaps, bitmap, list); -return bitmap; -} - -bool bdrv_dirty_bitmap_frozen (BdrvDirtyBitmap *bitmap) -{ -return bitmap->successor; -} - -bool bdrv_dirty_bitmap_enabled (BdrvDirtyBitmap *bitmap) -{ -return !(bitmap->disabled || bitmap->successor); -} - -DirtyBitmapStatus bdrv_dirty_bitmap_status (BdrvDirtyBitmap *bitmap) -{ -if (bdrv_dirty_bitmap_frozen (bitmap)) { -return DIRTY_BITMAP_STATUS_FROZEN ; - }else if (!bdrv_dirty_bitmap_enabled (bitmap)) { -return DIRTY_BITMAP_STATUS_DISABLED ; - }else { -return DIRTY_BITMAP_STATUS_ACTIVE ; - } -} - -/** -* Create a successor bitmap destined to replace this bitmap after an operation. -* Requires that the bitmap is not frozen and has no successor. -*/ -int bdrv_dirty_bitmap_create_successor (BlockDriverState *bs, -BdrvDirtyBitmap *bitmap,Error **errp) -{ -uint64_t granularity; -BdrvDirtyBitmap *child; - -if (bdrv_dirty_bitmap_frozen (bitmap)) { -error_setg (errp,"Cannot create a successor for a bitmap that is " -"currently frozen" ); -return -1 ; - } -assert (!bitmap->successor); - -/* Create an anonymous successor */ - granularity =bdrv_dirty_bitmap_granularity (bitmap); - child =bdrv_create_dirty_bitmap (bs, granularity,NULL , errp); -if (!child) { -return -1 ; - } - -/* Successor will be on or off based on our current state. */ - child->disabled = bitmap->disabled; - -/* Install the successor and freeze the parent */ - bitmap->successor = child; -return 0 ; -} - -/** -* For a bitmap with a successor, yield our name to the successor, -* delete the old bitmap, and return a handle to the new bitmap. -*/ -BdrvDirtyBitmap *bdrv_dirty_bitmap_abdicate (BlockDriverState *bs, -BdrvDirtyBitmap *bitmap, -Error **errp) -{ -char *name; -BdrvDirtyBitmap *successor = bitmap->successor; - -if (successor ==NULL ) { -error_setg (errp,"Cannot relinquish control if " -"there's no successor present" ); -return NULL ; - } - - name = bitmap->name; - bitmap->name =NULL ; - successor->name = name; - bitmap->successor =NULL ; -bdrv_release_dirty_bitmap (bs, bitmap); - -return successor; -} - -/** -* In cases of failure where we can no longer safely delete the parent, -* we may wish to re-join the parent and child/successor. -* The merged parent will be un-frozen, but not explicitly re-enabled. -*/ -BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap (BlockDriverState *bs, -BdrvDirtyBitmap *parent, -Error **errp) -{ -BdrvDirtyBitmap *successor = parent->successor; - -if (!successor) { -error_setg (errp,"Cannot reclaim a successor when none is present" ); -return NULL ; - } - -if (!hbitmap_merge (parent->bitmap, successor->bitmap)) { -error_setg (errp,"Merging of parent and successor bitmap failed" ); -return NULL ; - } -bdrv_release_dirty_bitmap (bs, successor); - parent->successor =NULL ; - -return parent; -} - -/** -* Truncates _all_ bitmaps attached to a BDS. -*/ -static void bdrv_dirty_bitmap_truncate (BlockDriverState *bs) -{ -BdrvDirtyBitmap *bitmap; -uint64_t size =bdrv_nb_sectors (bs); - - QLIST_FOREACH(bitmap, &bs->dirty_bitmaps, list) { -assert (!bdrv_dirty_bitmap_frozen (bitmap)); -hbitmap_truncate (bitmap->bitmap, size); - bitmap->size = size; - } -} - -static void bdrv_do_release_matching_dirty_bitmap (BlockDriverState *bs, -BdrvDirtyBitmap *bitmap, -bool only_named) -{ -BdrvDirtyBitmap *bm, *next; - QLIST_FOREACH_SAFE(bm, &bs->dirty_bitmaps, list, next) { -if ((!bitmap || bm == bitmap) && (!only_named || bm->name)) { -assert (!bdrv_dirty_bitmap_frozen (bm)); -QLIST_REMOVE (bm, list); -hbitmap_free (bm->bitmap); -g_free (bm->name); -g_free (bm); - -if (bitmap) { -return ; - } - } - } -} - -void bdrv_release_dirty_bitmap (BlockDriverState *bs,BdrvDirtyBitmap *bitmap) -{ -bdrv_do_release_matching_dirty_bitmap (bs, bitmap, false); -} - -/** -* Release all named dirty bitmaps attached to a BDS (for use in bdrv_close()). -* There must not be any frozen bitmaps attached. -*/ -static void bdrv_release_named_dirty_bitmaps (BlockDriverState *bs) -{ -bdrv_do_release_matching_dirty_bitmap (bs,NULL , true); -} - -void bdrv_disable_dirty_bitmap (BdrvDirtyBitmap *bitmap) -{ -assert (!bdrv_dirty_bitmap_frozen (bitmap)); - bitmap->disabled = true; -} - -void bdrv_enable_dirty_bitmap (BdrvDirtyBitmap *bitmap) -{ -assert (!bdrv_dirty_bitmap_frozen (bitmap)); - bitmap->disabled = false; -} - -BlockDirtyInfoList *bdrv_query_dirty_bitmaps (BlockDriverState *bs) -{ -BdrvDirtyBitmap *bm; -BlockDirtyInfoList *list =NULL ; -BlockDirtyInfoList **plist = &list; - - QLIST_FOREACH(bm, &bs->dirty_bitmaps, list) { -BlockDirtyInfo *info =g_new0 (BlockDirtyInfo,1 ); -BlockDirtyInfoList *entry =g_new0 (BlockDirtyInfoList,1 ); - info->count =bdrv_get_dirty_count (bm); - info->granularity =bdrv_dirty_bitmap_granularity (bm); - info->has_name = !!bm->name; - info->name =g_strdup (bm->name); - info->status =bdrv_dirty_bitmap_status (bm); - entry->value = info; - *plist = entry; - plist = &entry->next; - } - -return list; -} - -int bdrv_get_dirty (BlockDriverState *bs,BdrvDirtyBitmap *bitmap,int64_t sector) -{ -if (bitmap) { -return hbitmap_get (bitmap->bitmap, sector); - }else { -return 0 ; - } -} - -/** -* Chooses a default granularity based on the existing cluster size, -* but clamped between [4K, 64K]. Defaults to 64K in the case that there -* is no cluster size information available. -*/ -uint32_t bdrv_get_default_bitmap_granularity (BlockDriverState *bs) -{ -BlockDriverInfo bdi; -uint32_t granularity; - -if (bdrv_get_info (bs, &bdi) >=0 && bdi.cluster_size >0 ) { - granularity =MAX (4096 , bdi.cluster_size); - granularity =MIN (65536 , granularity); - }else { - granularity =65536 ; - } - -return granularity; -} - -uint32_t bdrv_dirty_bitmap_granularity (BdrvDirtyBitmap *bitmap) -{ -return BDRV_SECTOR_SIZE <<hbitmap_granularity (bitmap->bitmap); -} - -void bdrv_dirty_iter_init (BdrvDirtyBitmap *bitmap,HBitmapIter *hbi) -{ -hbitmap_iter_init (hbi, bitmap->bitmap,0 ); -} - -void bdrv_set_dirty_bitmap (BdrvDirtyBitmap *bitmap, -int64_t cur_sector,int nr_sectors) -{ -assert (bdrv_dirty_bitmap_enabled (bitmap)); -hbitmap_set (bitmap->bitmap, cur_sector, nr_sectors); -} - -void bdrv_reset_dirty_bitmap (BdrvDirtyBitmap *bitmap, -int64_t cur_sector,int nr_sectors) -{ -assert (bdrv_dirty_bitmap_enabled (bitmap)); -hbitmap_reset (bitmap->bitmap, cur_sector, nr_sectors); -} - -void bdrv_clear_dirty_bitmap (BdrvDirtyBitmap *bitmap,HBitmap **out) -{ -assert (bdrv_dirty_bitmap_enabled (bitmap)); -if (!out) { -hbitmap_reset_all (bitmap->bitmap); - }else { -HBitmap *backup = bitmap->bitmap; - bitmap->bitmap =hbitmap_alloc (bitmap->size, -hbitmap_granularity (backup)); - *out = backup; - } -} - -void bdrv_undo_clear_dirty_bitmap (BdrvDirtyBitmap *bitmap,HBitmap *in) -{ -HBitmap *tmp = bitmap->bitmap; -assert (bdrv_dirty_bitmap_enabled (bitmap)); - bitmap->bitmap = in; -hbitmap_free (tmp); -} - -void bdrv_set_dirty (BlockDriverState *bs,int64_t cur_sector, -int nr_sectors) -{ -BdrvDirtyBitmap *bitmap; - QLIST_FOREACH(bitmap, &bs->dirty_bitmaps, list) { -if (!bdrv_dirty_bitmap_enabled (bitmap)) { -continue ; - } -hbitmap_set (bitmap->bitmap, cur_sector, nr_sectors); - } -} - -/** -* Advance an HBitmapIter to an arbitrary offset. -*/ -void bdrv_set_dirty_iter (HBitmapIter *hbi,int64_t offset) -{ -assert (hbi->hb); -hbitmap_iter_init (hbi, hbi->hb, offset); -} - -int64_t bdrv_get_dirty_count (BdrvDirtyBitmap *bitmap) -{ -return hbitmap_count (bitmap->bitmap); -} -/* Get a reference to bs */ void bdrv_ref (BlockDriverState *bs) {
block/Makefile.objs +1 -1
@@ -20,7 +20,7 @@ block-obj-$(CONFIG_RBD) += rbd.o block-obj-$(CONFIG_GLUSTERFS) += gluster.o block-obj-$(CONFIG_ARCHIPELAGO) += archipelago.o block-obj-$(CONFIG_LIBSSH2) += ssh.o -block-obj-y += accounting.o +block-obj-y += accounting.o dirty-bitmap.o block-obj-y += write-threshold.o common-obj-y += stream.o
block/dirty-bitmap.c new file +387 -0
387 lines not on this page · raw message
include/block/block.h +1 -34
@@ -6,6 +6,7 @@#include "qemu/option.h" #include "qemu/coroutine.h" #include "block/accounting.h" +#include "block/dirty-bitmap.h" #include "qapi/qmp/qobject.h" #include "qapi-types.h" #include "qemu/hbitmap.h"
@@ -476,40 +477,6 @@ void *qemu_try_blockalign(BlockDriverState *bs, size_t size);void *qemu_try_blockalign0 (BlockDriverState *bs,size_t size);bool bdrv_qiov_is_aligned (BlockDriverState *bs,QEMUIOVector *qiov); -BdrvDirtyBitmap *bdrv_create_dirty_bitmap (BlockDriverState *bs, -uint32_t granularity, -const char *name, -Error **errp); -int bdrv_dirty_bitmap_create_successor (BlockDriverState *bs, -BdrvDirtyBitmap *bitmap, -Error **errp); -BdrvDirtyBitmap *bdrv_dirty_bitmap_abdicate (BlockDriverState *bs, -BdrvDirtyBitmap *bitmap, -Error **errp); -BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap (BlockDriverState *bs, -BdrvDirtyBitmap *bitmap, -Error **errp); -BdrvDirtyBitmap *bdrv_find_dirty_bitmap (BlockDriverState *bs, -const char *name); -void bdrv_dirty_bitmap_make_anon (BdrvDirtyBitmap *bitmap); -void bdrv_release_dirty_bitmap (BlockDriverState *bs,BdrvDirtyBitmap *bitmap); -void bdrv_disable_dirty_bitmap (BdrvDirtyBitmap *bitmap); -void bdrv_enable_dirty_bitmap (BdrvDirtyBitmap *bitmap); -BlockDirtyInfoList *bdrv_query_dirty_bitmaps (BlockDriverState *bs); -uint32_t bdrv_get_default_bitmap_granularity (BlockDriverState *bs); -uint32_t bdrv_dirty_bitmap_granularity (BdrvDirtyBitmap *bitmap); -bool bdrv_dirty_bitmap_enabled (BdrvDirtyBitmap *bitmap); -bool bdrv_dirty_bitmap_frozen (BdrvDirtyBitmap *bitmap); -DirtyBitmapStatus bdrv_dirty_bitmap_status (BdrvDirtyBitmap *bitmap); -int bdrv_get_dirty (BlockDriverState *bs,BdrvDirtyBitmap *bitmap,int64_t sector); -void bdrv_set_dirty_bitmap (BdrvDirtyBitmap *bitmap, -int64_t cur_sector,int nr_sectors); -void bdrv_reset_dirty_bitmap (BdrvDirtyBitmap *bitmap, -int64_t cur_sector,int nr_sectors); -void bdrv_dirty_iter_init (BdrvDirtyBitmap *bitmap,struct HBitmapIter *hbi); -void bdrv_set_dirty_iter (struct HBitmapIter *hbi,int64_t offset); -int64_t bdrv_get_dirty_count (BdrvDirtyBitmap *bitmap); -void bdrv_enable_copy_on_read (BlockDriverState *bs);void bdrv_disable_copy_on_read (BlockDriverState *bs);
include/block/dirty-bitmap.h new file +44 -0
44 lines not on this page · raw message
Signature · 1 line
2.4.3
PATCH v4 5/15 block: Remove unused typedef of BlockDriverDirtyHandler
In reply to Fam Zheng--- include/block/block.h | 2 -- 1 file changed, 2 deletions(-)
include/block/block.h +0 -2
@@ -322,8 +322,6 @@ BlockDriverState *check_to_replace_node(BlockDriverState *parent_bs, const char *node_name, Error **errp);/* async block I/O */ -typedef void BlockDriverDirtyHandler (BlockDriverState *bs,int64_t sector, -int sector_num);BlockAIOCB *bdrv_aio_readv (BlockDriverState *bs,int64_t sector_num,QEMUIOVector *iov,int nb_sectors,BlockCompletionFunc *cb,void *opaque);
Signature · 1 line
2.4.3
PATCH v4 6/15 block: Hide HBitmap in block dirty bitmap interface
In reply to Fam ZhengHBitmap is an implementation detail of block dirty bitmap that should be hidden from users. Introduce a BdrvDirtyBitmapIter to encapsulate the underlying HBitmapIter.
A small difference in the interface is, before, an HBitmapIter is initialized in place, now the new BdrvDirtyBitmapIter must be dynamically allocated because the structure definition is in block.c.
Two current users are converted too.
--- block/backup.c | 14 ++++++++------ block/dirty-bitmap.c | 39 +++++++++++++++++++++++++++++++++------ block/mirror.c | 15 +++++++++------ include/block/dirty-bitmap.h | 7 +++++-- include/qemu/typedefs.h | 1 + 5 files changed, 56 insertions(+), 20 deletions(-)
block/backup.c +8 -6
@@ -330,14 +330,14 @@ static int coroutine_fn backup_run_incremental(BackupBlockJob *job)int64_t last_cluster =-1 ;int64_t sectors_per_cluster =cluster_size_sectors (job);BlockDriverState *bs = job->common.bs; -HBitmapIter hbi; +BdrvDirtyBitmapIter *dbi; granularity =bdrv_dirty_bitmap_granularity (job->sync_bitmap); clusters_per_iter =MAX ((granularity / job->cluster_size),1 ); -bdrv_dirty_iter_init (job->sync_bitmap, &hbi); + dbi =bdrv_dirty_iter_new (job->sync_bitmap,0 );/* Find the next dirty sector(s) */ -while ((sector =hbitmap_iter_next (&hbi)) !=-1 ) { +while ((sector =bdrv_dirty_iter_next (dbi)) !=-1 ) { cluster = sector / sectors_per_cluster;/* Fake progress updates for any clusters we skipped */
@@ -349,7 +349,7 @@ static int coroutine_fn backup_run_incremental(BackupBlockJob *job) for (end = cluster + clusters_per_iter; cluster < end; cluster++) { do { if (yield_and_check(job)) { - return ret; + goto out; } ret = backup_do_cow(bs, cluster * sectors_per_cluster, sectors_per_cluster, &error_is_read,
@@ -357,7 +357,7 @@ static int coroutine_fn backup_run_incremental(BackupBlockJob *job)if ((ret <0 ) &&backup_error_action (job, error_is_read, -ret) ==BLOCK_ERROR_ACTION_REPORT ) { -return ret; + goto out; } }while (ret <0 ); }
@@ -365,7 +365,7 @@ static int coroutine_fn backup_run_incremental(BackupBlockJob *job)/* If the bitmap granularity is smaller than the backup granularity, * we need to advance the iterator pointer to the next cluster. */ if (granularity < job->cluster_size) { -bdrv_set_dirty_iter (&hbi, cluster * sectors_per_cluster); +bdrv_set_dirty_iter (dbi, cluster * sectors_per_cluster); } last_cluster = cluster -1 ;
@@ -377,6 +377,8 @@ static int coroutine_fn backup_run_incremental(BackupBlockJob *job) job->common.offset += ((end - last_cluster -1 ) * job->cluster_size); } +out: +bdrv_dirty_iter_free (dbi);return ret; }
block/dirty-bitmap.c +33 -6
@@ -42,9 +42,15 @@ struct BdrvDirtyBitmap {char *name;/* Optional non-empty unique ID */ int64_t size;/* Size of the bitmap (Number of sectors) */ bool disabled;/* Bitmap is read-only */ +int active_iterators;/* How many iterators are active */ QLIST_ENTRY (BdrvDirtyBitmap) list; }; +struct BdrvDirtyBitmapIter { +HBitmapIter hbi; +BdrvDirtyBitmap *bitmap; +}; +BdrvDirtyBitmap *bdrv_find_dirty_bitmap (BlockDriverState *bs,const char *name) {BdrvDirtyBitmap *bm;
@@ -212,6 +218,7 @@ void bdrv_dirty_bitmap_truncate(BlockDriverState *bs) QLIST_FOREACH(bitmap, &bs->dirty_bitmaps, list) {assert (!bdrv_dirty_bitmap_frozen (bitmap)); +assert (!bitmap->active_iterators);hbitmap_truncate (bitmap->bitmap, size); bitmap->size = size; }
@@ -224,6 +231,7 @@ static void bdrv_do_release_matching_dirty_bitmap(BlockDriverState *bs,BdrvDirtyBitmap *bm, *next; QLIST_FOREACH_SAFE(bm, &bs->dirty_bitmaps, list, next) {if ((!bitmap || bm == bitmap) && (!only_named || bm->name)) { +assert (!bitmap->active_iterators);assert (!bdrv_dirty_bitmap_frozen (bm));QLIST_REMOVE (bm, list);hbitmap_free (bm->bitmap);
@@ -320,9 +328,29 @@ uint32_t bdrv_dirty_bitmap_granularity(BdrvDirtyBitmap *bitmap)return BDRV_SECTOR_SIZE <<hbitmap_granularity (bitmap->bitmap); } -void bdrv_dirty_iter_init (BdrvDirtyBitmap *bitmap,HBitmapIter *hbi) +BdrvDirtyBitmapIter *bdrv_dirty_iter_new (BdrvDirtyBitmap *bitmap, +uint64_t first_sector) { -hbitmap_iter_init (hbi, bitmap->bitmap,0 ); +BdrvDirtyBitmapIter *iter =g_new (BdrvDirtyBitmapIter,1 ); +hbitmap_iter_init (&iter->hbi, bitmap->bitmap, first_sector); + iter->bitmap = bitmap; + bitmap->active_iterators++; +return iter; +} + +void bdrv_dirty_iter_free (BdrvDirtyBitmapIter *iter) +{ +if (!iter) { +return ; + } +assert (iter->bitmap->active_iterators >0 ); + iter->bitmap->active_iterators--; +g_free (iter); +} + +int64_t bdrv_dirty_iter_next (BdrvDirtyBitmapIter *iter) +{ +return hbitmap_iter_next (&iter->hbi); } void bdrv_set_dirty_bitmap(BdrvDirtyBitmap *bitmap,
@@ -373,12 +401,11 @@ void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector, }/** -* Advance an HBitmapIter to an arbitrary offset. +* Advance an BdrvDirtyBitmapIter to an arbitrary offset. */ -void bdrv_set_dirty_iter (HBitmapIter *hbi,int64_t offset) +void bdrv_set_dirty_iter (BdrvDirtyBitmapIter *iter,int64_t sector_num) { -assert (hbi->hb); -hbitmap_iter_init (hbi, hbi->hb, offset); +hbitmap_iter_init (&iter->hbi, iter->hbi.hb, sector_num); }int64_t bdrv_get_dirty_count (BdrvDirtyBitmap *bitmap)
block/mirror.c +9 -6
@@ -52,7 +52,7 @@ typedef struct MirrorBlockJob {int64_t bdev_length;unsigned long *cow_bitmap;BdrvDirtyBitmap *dirty_bitmap; -HBitmapIter hbi; +BdrvDirtyBitmapIter *dbi;uint8_t *buf; QSIMPLEQ_HEAD(, MirrorBuffer) buf_free;int buf_free_count;
@@ -304,10 +304,11 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s)int64_t end = s->bdev_length /BDRV_SECTOR_SIZE ;int sectors_per_chunk = s->granularity >>BDRV_SECTOR_BITS ; - sector_num =hbitmap_iter_next (&s->hbi); + sector_num =bdrv_dirty_iter_next (s->dbi);if (sector_num <0 ) { -bdrv_dirty_iter_init (s->dirty_bitmap, &s->hbi); - sector_num =hbitmap_iter_next (&s->hbi); +bdrv_dirty_iter_free (s->dbi); + s->dbi =bdrv_dirty_iter_new (s->dirty_bitmap,0 ); + sector_num =bdrv_dirty_iter_next (s->dbi);trace_mirror_restart_iter (s,bdrv_get_dirty_count (s->dirty_bitmap));assert (sector_num >=0 ); }
@@ -330,7 +331,7 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s)mirror_wait_for_io (s);/* Now retry. */ }else { - hbitmap_next =hbitmap_iter_next (&s->hbi); + hbitmap_next =bdrv_dirty_iter_next (s->dbi);assert (hbitmap_next == next_sector); nb_chunks++; }
@@ -577,7 +578,8 @@ static void coroutine_fn mirror_run(void *opaque) } } -bdrv_dirty_iter_init (s->dirty_bitmap, &s->hbi); +bdrv_dirty_iter_free (s->dbi); + s->dbi =bdrv_dirty_iter_new (s->dirty_bitmap,0 );for (;;) {uint64_t delay_ns =0 ;int64_t cnt;
@@ -688,6 +690,7 @@ immediate_exit:qemu_vfree (s->buf);g_free (s->cow_bitmap);g_free (s->in_flight_bitmap); +bdrv_dirty_iter_free (s->dbi);bdrv_release_dirty_bitmap (bs, s->dirty_bitmap);if (s->target->blk) {blk_iostatus_disable (s->target->blk);
include/block/dirty-bitmap.h +5 -2
@@ -36,8 +36,11 @@ void bdrv_set_dirty_bitmap(BdrvDirtyBitmap *bitmap, int64_t cur_sector, int nr_sectors);void bdrv_reset_dirty_bitmap (BdrvDirtyBitmap *bitmap,int64_t cur_sector,int nr_sectors); -void bdrv_dirty_iter_init (BdrvDirtyBitmap *bitmap,struct HBitmapIter *hbi); -void bdrv_set_dirty_iter (struct HBitmapIter *hbi,int64_t offset); +BdrvDirtyBitmapIter *bdrv_dirty_iter_new (BdrvDirtyBitmap *bitmap, +uint64_t first_sector); +void bdrv_dirty_iter_free (BdrvDirtyBitmapIter *iter); +int64_t bdrv_dirty_iter_next (BdrvDirtyBitmapIter *iter); +void bdrv_set_dirty_iter (BdrvDirtyBitmapIter *hbi,int64_t sector_num);int64_t bdrv_get_dirty_count (BdrvDirtyBitmap *bitmap);void bdrv_dirty_bitmap_truncate (BlockDriverState *bs);
include/qemu/typedefs.h +1 -0
@@ -11,6 +11,7 @@ typedef struct AioContext AioContext;typedef struct AllwinnerAHCIState AllwinnerAHCIState ;typedef struct AudioState AudioState ;typedef struct BdrvDirtyBitmap BdrvDirtyBitmap ; +typedef struct BdrvDirtyBitmapIter BdrvDirtyBitmapIter ;typedef struct BlockBackend BlockBackend ;typedef struct BlockBackendRootState BlockBackendRootState ;typedef struct BlockDriverState BlockDriverState ;
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH v4 06/15] block: Hide HBitmap in block dirty bitmap interface
Quoted 7 lines · Fam Zheng
HBitmap is an implementation detail of block dirty bitmap that should be hidden from users. Introduce a BdrvDirtyBitmapIter to encapsulate the underlying HBitmapIter.
A small difference in the interface is, before, an HBitmapIter is initialized in place, now the new BdrvDirtyBitmapIter must be dynamically allocated because the structure definition is in
block.c.
It's block/dirty-bitmap.c now. :-)
Quoted 11 lines
Two current users are converted too.
Signed-off-by Fam Zheng <[email protected]>--- block/backup.c | 14 ++++++++------ block/dirty-bitmap.c | 39 +++++++++++++++++++++++++++++++++------ block/mirror.c | 15 +++++++++------ include/block/dirty-bitmap.h | 7 +++++-- include/qemu/typedefs.h | 1 + 5 files changed, 56 insertions(+), 20 deletions(-)
[...]
Quoted 4 lines
block/dirty-bitmap.c +0
-0
[...]
block/dirty-bitmap.c void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector, · line 404
Quoted 6 lines
block/dirty-bitmap.c +1
-1@@ -373,12 +401,11 @@ void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector, }/** -* Advance an HBitmapIter to an arbitrary offset. +* Advance an BdrvDirtyBitmapIter to an arbitrary offset.
This should be "a BdrvDirtyBitmapIter".
Quoted 14 lines
block/dirty-bitmap.c +2
-3*/ -void bdrv_set_dirty_iter (HBitmapIter *hbi,int64_t offset) +void bdrv_set_dirty_iter (BdrvDirtyBitmapIter *iter,int64_t sector_num) { -assert (hbi->hb); -hbitmap_iter_init (hbi, hbi->hb, offset); +hbitmap_iter_init (&iter->hbi, iter->hbi.hb, sector_num); }int64_t bdrv_get_dirty_count (BdrvDirtyBitmap *bitmap)block/mirror.c +0
-0
[...]
block/mirror.c static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) · line 310
Quoted 11 lines
block/mirror.c +3
-3@@ -304,10 +304,11 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s)int64_t end = s->bdev_length /BDRV_SECTOR_SIZE ;int sectors_per_chunk = s->granularity >>BDRV_SECTOR_BITS ; - sector_num =hbitmap_iter_next (&s->hbi); + sector_num =bdrv_dirty_iter_next (s->dbi);if (sector_num <0 ) { -bdrv_dirty_iter_init (s->dirty_bitmap, &s->hbi); - sector_num =hbitmap_iter_next (&s->hbi); +bdrv_dirty_iter_free (s->dbi); + s->dbi =bdrv_dirty_iter_new (s->dirty_bitmap,0 );
Works, but wouldn't bdrv_set_dirty_iter(s->dbi, 0); suffice?
block/mirror.c static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) · line 334
Quoted 10 lines
block/mirror.c +2
-1+ sector_num =bdrv_dirty_iter_next (s->dbi);trace_mirror_restart_iter (s,bdrv_get_dirty_count (s->dirty_bitmap));assert (sector_num >=0 ); }@@ -330,7 +331,7 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s)mirror_wait_for_io (s);/* Now retry. */ }else { - hbitmap_next =hbitmap_iter_next (&s->hbi); + hbitmap_next =bdrv_dirty_iter_next (s->dbi);
It would make sense to change this variable's name from hbitmap_next to e.g. bdrv_dirty_next or bs_next_dirty.
block/mirror.c static void coroutine_fn mirror_run(void *opaque) · line 582
Quoted 10 lines
block/mirror.c +2
-1assert (hbitmap_next == next_sector); nb_chunks++; }@@ -577,7 +578,8 @@ static void coroutine_fn mirror_run(void *opaque) } } -bdrv_dirty_iter_init (s->dirty_bitmap, &s->hbi); +bdrv_dirty_iter_free (s->dbi); + s->dbi =bdrv_dirty_iter_new (s->dirty_bitmap,0 );
Again, bdrv_set_dirty_iter(s->dbi, 0); should work just fine.
Since this patch is technically correct, I could still imagine giving an R-b, but I'm really reluctant to do so because of the bdrv_dirty_iter_free()/bdrv_dirty_iter_new() pairs.
Max
Quoted 42 lines
block/mirror.c +1
-0for (;;) {uint64_t delay_ns =0 ;int64_t cnt;@@ -688,6 +690,7 @@ immediate_exit:qemu_vfree (s->buf);g_free (s->cow_bitmap);g_free (s->in_flight_bitmap); +bdrv_dirty_iter_free (s->dbi);bdrv_release_dirty_bitmap (bs, s->dirty_bitmap);if (s->target->blk) {blk_iostatus_disable (s->target->blk);include/block/dirty-bitmap.h +5
-2@@ -36,8 +36,11 @@ void bdrv_set_dirty_bitmap(BdrvDirtyBitmap *bitmap, int64_t cur_sector, int nr_sectors);void bdrv_reset_dirty_bitmap (BdrvDirtyBitmap *bitmap,int64_t cur_sector,int nr_sectors); -void bdrv_dirty_iter_init (BdrvDirtyBitmap *bitmap,struct HBitmapIter *hbi); -void bdrv_set_dirty_iter (struct HBitmapIter *hbi,int64_t offset); +BdrvDirtyBitmapIter *bdrv_dirty_iter_new (BdrvDirtyBitmap *bitmap, +uint64_t first_sector); +void bdrv_dirty_iter_free (BdrvDirtyBitmapIter *iter); +int64_t bdrv_dirty_iter_next (BdrvDirtyBitmapIter *iter); +void bdrv_set_dirty_iter (BdrvDirtyBitmapIter *hbi,int64_t sector_num);int64_t bdrv_get_dirty_count (BdrvDirtyBitmap *bitmap);void bdrv_dirty_bitmap_truncate (BlockDriverState *bs);include/qemu/typedefs.h +1
-0@@ -11,6 +11,7 @@ typedef struct AioContext AioContext;typedef struct AllwinnerAHCIState AllwinnerAHCIState ;typedef struct AudioState AudioState ;typedef struct BdrvDirtyBitmap BdrvDirtyBitmap ; +typedef struct BdrvDirtyBitmapIter BdrvDirtyBitmapIter ;typedef struct BlockBackend BlockBackend ;typedef struct BlockBackendRootState BlockBackendRootState ;typedef struct BlockDriverState BlockDriverState ;
Re: [Qemu-devel] [PATCH v4 06/15] block: Hide HBitmap in block dirty bitmap interface
Quoted 93 lines · Max Reitz
Quoted 7 lines · Fam Zheng
HBitmap is an implementation detail of block dirty bitmap that should be hidden from users. Introduce a BdrvDirtyBitmapIter to encapsulate the underlying HBitmapIter.
A small difference in the interface is, before, an HBitmapIter is initialized in place, now the new BdrvDirtyBitmapIter must be dynamically allocated because the structure definition is in
block.c.It's
block/dirty-bitmap.cnow. :-)Quoted 11 lines
Two current users are converted too.
Signed-off-by Fam Zheng <[email protected]>--- block/backup.c | 14 ++++++++------ block/dirty-bitmap.c | 39 +++++++++++++++++++++++++++++++++------ block/mirror.c | 15 +++++++++------ include/block/dirty-bitmap.h | 7 +++++-- include/qemu/typedefs.h | 1 + 5 files changed, 56 insertions(+), 20 deletions(-)[...]
Quoted 4 lines
block/dirty-bitmap.c +0
-0[...]
block/dirty-bitmap.c void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector, · line 404
Quoted 6 lines
block/dirty-bitmap.c +1
-1@@ -373,12 +401,11 @@ void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector, }/** -* Advance an HBitmapIter to an arbitrary offset. +* Advance an BdrvDirtyBitmapIter to an arbitrary offset. This should be "a BdrvDirtyBitmapIter".
Quoted 14 lines
block/dirty-bitmap.c +2
-3*/ -void bdrv_set_dirty_iter (HBitmapIter *hbi,int64_t offset) +void bdrv_set_dirty_iter (BdrvDirtyBitmapIter *iter,int64_t sector_num) { -assert (hbi->hb); -hbitmap_iter_init (hbi, hbi->hb, offset); +hbitmap_iter_init (&iter->hbi, iter->hbi.hb, sector_num); }int64_t bdrv_get_dirty_count (BdrvDirtyBitmap *bitmap)block/mirror.c +0
-0[...]
block/mirror.c static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) · line 310
Quoted 11 lines
block/mirror.c +3
-3@@ -304,10 +304,11 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s)int64_t end = s->bdev_length /BDRV_SECTOR_SIZE ;int sectors_per_chunk = s->granularity >>BDRV_SECTOR_BITS ; - sector_num =hbitmap_iter_next (&s->hbi); + sector_num =bdrv_dirty_iter_next (s->dbi);if (sector_num <0 ) { -bdrv_dirty_iter_init (s->dirty_bitmap, &s->hbi); - sector_num =hbitmap_iter_next (&s->hbi); +bdrv_dirty_iter_free (s->dbi); + s->dbi =bdrv_dirty_iter_new (s->dirty_bitmap,0 );Works, but wouldn't
bdrv_set_dirty_iter(s->dbi, 0); suffice?block/mirror.c static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) · line 334
Quoted 10 lines
block/mirror.c +2
-1+ sector_num =bdrv_dirty_iter_next (s->dbi);trace_mirror_restart_iter (s,bdrv_get_dirty_count (s->dirty_bitmap));assert (sector_num >=0 ); }@@ -330,7 +331,7 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s)mirror_wait_for_io (s);/* Now retry. */ }else { - hbitmap_next =hbitmap_iter_next (&s->hbi); + hbitmap_next =bdrv_dirty_iter_next (s->dbi);It would make sense to change this variable's name from
hbitmap_nextto e.g.bdrv_dirty_nextorbs_next_dirty.Quoted 7 lines
block/mirror.c +0
-0assert (hbitmap_next == next_sector); nb_chunks++; }@@ -577,7 +578,8 @@ static void coroutine_fn mirror_run(void *opaque) } }
Quoted 5 lines
block/mirror.c static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s) · line 310
Quoted 3 lines
block/mirror.c +2
-1-bdrv_dirty_iter_init (s->dirty_bitmap, &s->hbi); +bdrv_dirty_iter_free (s->dbi); + s->dbi =bdrv_dirty_iter_new (s->dirty_bitmap,0 );Again,
bdrv_set_dirty_iter(s->dbi, 0); should work just fine.
OK, here it wouldn't because s->dbi is still NULL. Why do we need the bdrv_dirty_iter_free(), then? It wasn't present in v3.
Max
Quoted 50 lines
Since this patch is technically correct, I could still imagine giving an R-b, but I'm really reluctant to do so because of the bdrv_dirty_iter_free()/bdrv_dirty_iter_new() pairs.
Max
Quoted 42 lines
block/mirror.c +1
-0for (;;) {uint64_t delay_ns =0 ;int64_t cnt;@@ -688,6 +690,7 @@ immediate_exit:qemu_vfree (s->buf);g_free (s->cow_bitmap);g_free (s->in_flight_bitmap); +bdrv_dirty_iter_free (s->dbi);bdrv_release_dirty_bitmap (bs, s->dirty_bitmap);if (s->target->blk) {blk_iostatus_disable (s->target->blk);include/block/dirty-bitmap.h +5
-2@@ -36,8 +36,11 @@ void bdrv_set_dirty_bitmap(BdrvDirtyBitmap *bitmap, int64_t cur_sector, int nr_sectors);void bdrv_reset_dirty_bitmap (BdrvDirtyBitmap *bitmap,int64_t cur_sector,int nr_sectors); -void bdrv_dirty_iter_init (BdrvDirtyBitmap *bitmap,struct HBitmapIter *hbi); -void bdrv_set_dirty_iter (struct HBitmapIter *hbi,int64_t offset); +BdrvDirtyBitmapIter *bdrv_dirty_iter_new (BdrvDirtyBitmap *bitmap, +uint64_t first_sector); +void bdrv_dirty_iter_free (BdrvDirtyBitmapIter *iter); +int64_t bdrv_dirty_iter_next (BdrvDirtyBitmapIter *iter); +void bdrv_set_dirty_iter (BdrvDirtyBitmapIter *hbi,int64_t sector_num);int64_t bdrv_get_dirty_count (BdrvDirtyBitmap *bitmap);void bdrv_dirty_bitmap_truncate (BlockDriverState *bs);include/qemu/typedefs.h +1
-0@@ -11,6 +11,7 @@ typedef struct AioContext AioContext;typedef struct AllwinnerAHCIState AllwinnerAHCIState ;typedef struct AudioState AudioState ;typedef struct BdrvDirtyBitmap BdrvDirtyBitmap ; +typedef struct BdrvDirtyBitmapIter BdrvDirtyBitmapIter ;typedef struct BlockBackend BlockBackend ;typedef struct BlockBackendRootState BlockBackendRootState ;typedef struct BlockDriverState BlockDriverState ;
PATCH v4 7/15 HBitmap: Introduce "meta" bitmap to track bit changes
In reply to Fam ZhengUpon each bit toggle, the corresponding bit in the meta bitmap will be set.
--- block/dirty-bitmap.c | 2 +- include/qemu/hbitmap.h | 17 +++++++++++++ util/hbitmap.c | 66 ++++++++++++++++++++++++++++++++++++++------------ 3 files changed, 69 insertions(+), 16 deletions(-)
block/dirty-bitmap.c +1 -1
@@ -231,7 +231,7 @@ static void bdrv_do_release_matching_dirty_bitmap(BlockDriverState *bs,BdrvDirtyBitmap *bm, *next; QLIST_FOREACH_SAFE(bm, &bs->dirty_bitmaps, list, next) {if ((!bitmap || bm == bitmap) && (!only_named || bm->name)) { -assert (!bitmap->active_iterators); +assert (!bm->active_iterators);assert (!bdrv_dirty_bitmap_frozen (bm));QLIST_REMOVE (bm, list);hbitmap_free (bm->bitmap);
include/qemu/hbitmap.h +17 -0
@@ -178,6 +178,23 @@ void hbitmap_iter_init(HBitmapIter *hbi, const HBitmap *hb, uint64_t first);*/ unsigned long hbitmap_iter_skip_words (HBitmapIter *hbi); +/* hbitmap_create_meta: +* Create a "meta" hbitmap to track dirtiness of the bits in this HBitmap. +* The caller owns the created bitmap and must call hbitmap_free_meta(hb) to +* free it. +* +* @hb: The HBitmap to operate on. +* @chunk_size: How many bits in @hb does one bit in the meta track. +*/ +HBitmap *hbitmap_create_meta (HBitmap *hb,int chunk_size); + +/* hbitmap_free_meta: +* Free the meta bitmap of @hb. +* +* @hb: The HBitmap whose meta bitmap should be freed. +*/ +void hbitmap_free_meta (HBitmap *hb); +/** * hbitmap_iter_next: * @hbi: HBitmapIter to operate on.
util/hbitmap.c +51 -15
142 lines not on this page · raw message
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH v4 07/15] HBitmap: Introduce "meta" bitmap to track bit changes
Quoted 16 lines · Fam Zheng
Upon each bit toggle, the corresponding bit in the meta bitmap will be set.
Signed-off-by Fam Zheng <[email protected]>Reviewed-by John Snow <[email protected]>--- block/dirty-bitmap.c | 2 +- include/qemu/hbitmap.h | 17 +++++++++++++ util/hbitmap.c | 66 ++++++++++++++++++++++++++++++++++++++------------ 3 files changed, 69 insertions(+), 16 deletions(-)block/dirty-bitmap.c +0
-0
block/dirty-bitmap.c static void bdrv_do_release_matching_dirty_bitmap(BlockDriverState *bs, · line 234
Quoted 5 lines
block/dirty-bitmap.c +1
-1@@ -231,7 +231,7 @@ static void bdrv_do_release_matching_dirty_bitmap(BlockDriverState *bs,BdrvDirtyBitmap *bm, *next; QLIST_FOREACH_SAFE(bm, &bs->dirty_bitmaps, list, next) {if ((!bitmap || bm == bitmap) && (!only_named || bm->name)) { -assert (!bitmap->active_iterators); +assert (!bm->active_iterators);
I guess this should be squashed into patch 6. Good point, by the way, yes, using bitmap is wrong here. :-)
Max
PATCH v4 8/15 tests: Add test code for meta bitmap
In reply to Fam Zheng--- tests/test-hbitmap.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+)
tests/test-hbitmap.c +116 -0
@@ -12,6 +12,7 @@#include "qemu/osdep.h" #include <glib.h> #include "qemu/hbitmap.h" +#include "block/block.h" #define LOG_BITS_PER_LONG (BITS_PER_LONG == 32 ? 5 : 6)
@@ -21,6 +22,7 @@ typedef struct TestHBitmapData { HBitmap *hb; + HBitmap *meta; unsigned long *bits; size_t size; size_t old_size;
@@ -92,6 +94,14 @@ static void hbitmap_test_init(TestHBitmapData *data, } } +static void hbitmap_test_init_meta (TestHBitmapData *data, +uint64_t size,int granularity, +int meta_chunk) +{ +hbitmap_test_init (data, size, granularity); + data->meta =hbitmap_create_meta (data->hb, meta_chunk); +} +static inline size_t hbitmap_test_array_size (size_t bits) {size_t n = (bits +BITS_PER_LONG -1 ) /BITS_PER_LONG ;
@@ -134,6 +144,9 @@ static void hbitmap_test_teardown(TestHBitmapData *data, const void *unused) {if (data->hb) { +if (data->meta) { +hbitmap_free_meta (data->hb); + }hbitmap_free (data->hb); data->hb =NULL ; }
@@ -635,6 +648,103 @@ static void test_hbitmap_truncate_shrink_large(TestHBitmapData *data,hbitmap_test_truncate (data, size, -diff,0 ); } +static void hbitmap_check_meta (TestHBitmapData *data, +int64_t start,int count) +{ +int64_t i; + +for (i =0 ; i < data->size; i++) { +if (i >= start && i < start + count) { +g_assert (hbitmap_get (data->meta, i)); + }else { +g_assert (!hbitmap_get (data->meta, i)); + } + } +} + +static void hbitmap_test_meta (TestHBitmapData *data, +int64_t start,int count, +int64_t check_start,int check_count) +{ +hbitmap_reset_all (data->hb); +hbitmap_reset_all (data->meta); + +/* Test "unset" -> "unset" will not update meta. */ +hbitmap_reset (data->hb, start, count); +hbitmap_check_meta (data,0 ,0 ); + +/* Test "unset" -> "set" will update meta */ +hbitmap_set (data->hb, start, count); +hbitmap_check_meta (data, check_start, check_count); + +/* Test "set" -> "set" will not update meta */ +hbitmap_reset_all (data->meta); +hbitmap_set (data->hb, start, count); +hbitmap_check_meta (data,0 ,0 ); + +/* Test "set" -> "unset" will update meta */ +hbitmap_reset_all (data->meta); +hbitmap_reset (data->hb, start, count); +hbitmap_check_meta (data, check_start, check_count); +} + +static void hbitmap_test_meta_do (TestHBitmapData *data,int chunk_size) +{ +uint64_t size = chunk_size *100 ; +hbitmap_test_init_meta (data, size,0 , chunk_size); + +hbitmap_test_meta (data,0 ,1 ,0 , chunk_size); +hbitmap_test_meta (data,0 , chunk_size,0 , chunk_size); +hbitmap_test_meta (data, chunk_size -1 ,1 ,0 , chunk_size); +hbitmap_test_meta (data, chunk_size -1 ,2 ,0 , chunk_size *2 ); +hbitmap_test_meta (data, chunk_size -1 , chunk_size +1 ,0 , chunk_size *2 ); +hbitmap_test_meta (data, chunk_size -1 , chunk_size +2 ,0 , chunk_size *3 ); +hbitmap_test_meta (data,7 * chunk_size -1 , chunk_size +2 , +6 * chunk_size, chunk_size *3 ); +hbitmap_test_meta (data, size -1 ,1 , size - chunk_size, chunk_size); +hbitmap_test_meta (data,0 , size,0 , size); +} + +static void test_hbitmap_meta_byte (TestHBitmapData *data,const void *unused) +{ +hbitmap_test_meta_do (data,BITS_PER_BYTE ); +} + +static void test_hbitmap_meta_word (TestHBitmapData *data,const void *unused) +{ +hbitmap_test_meta_do (data,BITS_PER_LONG ); +} + +static void test_hbitmap_meta_sector (TestHBitmapData *data,const void *unused) +{ +hbitmap_test_meta_do (data,BDRV_SECTOR_SIZE *BITS_PER_BYTE ); +} + +/** +* Create an HBitmap and test set/unset. +*/ +static void test_hbitmap_meta_one (TestHBitmapData *data,const void *unused) +{ +int i; +int64_t offsets[] = { +0 ,1 ,L1 -1 ,L1 ,L1 +1 ,L2 -1 ,L2 ,L2 +1 ,L3 -1 ,L3 ,L3 +1 + }; + +hbitmap_test_init_meta (data,L3 *2 ,0 ,1 ); +for (i =0 ; i <ARRAY_SIZE (offsets); i++) { +hbitmap_test_meta (data, offsets[i],1 , offsets[i],1 ); +hbitmap_test_meta (data, offsets[i],L1 , offsets[i],L1 ); +hbitmap_test_meta (data, offsets[i],L2 , offsets[i],L2 ); + } +} + +static void test_hbitmap_meta_zero (TestHBitmapData *data,const void *unused) +{ +hbitmap_test_init_meta (data,0 ,0 ,1 ); + +hbitmap_check_meta (data,0 ,0 ); +} +static void hbitmap_test_add (const char *testpath,void (*test_func)(TestHBitmapData *data,const void *user_data)) {
@@ -684,6 +794,12 @@ int main(int argc, char **argv) test_hbitmap_truncate_grow_large);hbitmap_test_add ("/hbitmap/truncate/shrink/large" , test_hbitmap_truncate_shrink_large); + +hbitmap_test_add ("/hbitmap/meta/zero" , test_hbitmap_meta_zero); +hbitmap_test_add ("/hbitmap/meta/one" , test_hbitmap_meta_one); +hbitmap_test_add ("/hbitmap/meta/byte" , test_hbitmap_meta_byte); +hbitmap_test_add ("/hbitmap/meta/word" , test_hbitmap_meta_word); +hbitmap_test_add ("/hbitmap/meta/sector" , test_hbitmap_meta_sector);g_test_run ();return 0 ;
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH v4 08/15] tests: Add test code for meta bitmap
Quoted 78 lines · Fam Zheng
Signed-off-by Fam Zheng <[email protected]>Reviewed-by John Snow <[email protected]>--- tests/test-hbitmap.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+)tests/test-hbitmap.c +36
-0@@ -12,6 +12,7 @@#include "qemu/osdep.h" #include <glib.h> #include "qemu/hbitmap.h" +#include "block/block.h" #define LOG_BITS_PER_LONG (BITS_PER_LONG == 32 ? 5 : 6)@@ -21,6 +22,7 @@ typedef struct TestHBitmapData { HBitmap *hb; + HBitmap *meta; unsigned long *bits; size_t size; size_t old_size;@@ -92,6 +94,14 @@ static void hbitmap_test_init(TestHBitmapData *data, } } +static void hbitmap_test_init_meta (TestHBitmapData *data, +uint64_t size,int granularity, +int meta_chunk) +{ +hbitmap_test_init (data, size, granularity); + data->meta =hbitmap_create_meta (data->hb, meta_chunk); +} +static inline size_t hbitmap_test_array_size (size_t bits) {size_t n = (bits +BITS_PER_LONG -1 ) /BITS_PER_LONG ;@@ -134,6 +144,9 @@ static void hbitmap_test_teardown(TestHBitmapData *data, const void *unused) {if (data->hb) { +if (data->meta) { +hbitmap_free_meta (data->hb); + }hbitmap_free (data->hb); data->hb =NULL ; }@@ -635,6 +648,103 @@ static void test_hbitmap_truncate_shrink_large(TestHBitmapData *data,hbitmap_test_truncate (data, size, -diff,0 ); } +static void hbitmap_check_meta (TestHBitmapData *data, +int64_t start,int count) +{ +int64_t i; + +for (i =0 ; i < data->size; i++) { +if (i >= start && i < start + count) { +g_assert (hbitmap_get (data->meta, i)); + }else { +g_assert (!hbitmap_get (data->meta, i)); + } + } +} + +static void hbitmap_test_meta (TestHBitmapData *data, +int64_t start,int count, +int64_t check_start,int check_count) +{ +hbitmap_reset_all (data->hb); +hbitmap_reset_all (data->meta); + +/* Test "unset" -> "unset" will not update meta. */ +hbitmap_reset (data->hb, start, count);
tests/test-hbitmap.c static void test_hbitmap_truncate_shrink_large(TestHBitmapData *data, · line 683
Quoted 10 lines
tests/test-hbitmap.c +10
-0+hbitmap_check_meta (data,0 ,0 ); + +/* Test "unset" -> "set" will update meta */ +hbitmap_set (data->hb, start, count); +hbitmap_check_meta (data, check_start, check_count); + +/* Test "set" -> "set" will not update meta */ +hbitmap_reset_all (data->meta); +hbitmap_set (data->hb, start, count); +hbitmap_check_meta (data,0 ,0 );
Well, but if you'd do an hbitmap_set(data->hb, start, count + 1), then it would update meta, right?
I forgot to mention in my reply to patch 7 that the check whether anything in the range passed to hbitmap_set() has been changed in order to determine whether all of that range should be set in the meta bitmap seemed a bit excessive. I don't think this will hurt anyone, but still.
(So this is not a NACK, just a question.)
Max
Quoted 81 lines
tests/test-hbitmap.c +70
-0+ +/* Test "set" -> "unset" will update meta */ +hbitmap_reset_all (data->meta); +hbitmap_reset (data->hb, start, count); +hbitmap_check_meta (data, check_start, check_count); +} + +static void hbitmap_test_meta_do (TestHBitmapData *data,int chunk_size) +{ +uint64_t size = chunk_size *100 ; +hbitmap_test_init_meta (data, size,0 , chunk_size); + +hbitmap_test_meta (data,0 ,1 ,0 , chunk_size); +hbitmap_test_meta (data,0 , chunk_size,0 , chunk_size); +hbitmap_test_meta (data, chunk_size -1 ,1 ,0 , chunk_size); +hbitmap_test_meta (data, chunk_size -1 ,2 ,0 , chunk_size *2 ); +hbitmap_test_meta (data, chunk_size -1 , chunk_size +1 ,0 , chunk_size *2 ); +hbitmap_test_meta (data, chunk_size -1 , chunk_size +2 ,0 , chunk_size *3 ); +hbitmap_test_meta (data,7 * chunk_size -1 , chunk_size +2 , +6 * chunk_size, chunk_size *3 ); +hbitmap_test_meta (data, size -1 ,1 , size - chunk_size, chunk_size); +hbitmap_test_meta (data,0 , size,0 , size); +} + +static void test_hbitmap_meta_byte (TestHBitmapData *data,const void *unused) +{ +hbitmap_test_meta_do (data,BITS_PER_BYTE ); +} + +static void test_hbitmap_meta_word (TestHBitmapData *data,const void *unused) +{ +hbitmap_test_meta_do (data,BITS_PER_LONG ); +} + +static void test_hbitmap_meta_sector (TestHBitmapData *data,const void *unused) +{ +hbitmap_test_meta_do (data,BDRV_SECTOR_SIZE *BITS_PER_BYTE ); +} + +/** +* Create an HBitmap and test set/unset. +*/ +static void test_hbitmap_meta_one (TestHBitmapData *data,const void *unused) +{ +int i; +int64_t offsets[] = { +0 ,1 ,L1 -1 ,L1 ,L1 +1 ,L2 -1 ,L2 ,L2 +1 ,L3 -1 ,L3 ,L3 +1 + }; + +hbitmap_test_init_meta (data,L3 *2 ,0 ,1 ); +for (i =0 ; i <ARRAY_SIZE (offsets); i++) { +hbitmap_test_meta (data, offsets[i],1 , offsets[i],1 ); +hbitmap_test_meta (data, offsets[i],L1 , offsets[i],L1 ); +hbitmap_test_meta (data, offsets[i],L2 , offsets[i],L2 ); + } +} + +static void test_hbitmap_meta_zero (TestHBitmapData *data,const void *unused) +{ +hbitmap_test_init_meta (data,0 ,0 ,1 ); + +hbitmap_check_meta (data,0 ,0 ); +} +static void hbitmap_test_add (const char *testpath,void (*test_func)(TestHBitmapData *data,const void *user_data)) {@@ -684,6 +794,12 @@ int main(int argc, char **argv) test_hbitmap_truncate_grow_large);hbitmap_test_add ("/hbitmap/truncate/shrink/large" , test_hbitmap_truncate_shrink_large); + +hbitmap_test_add ("/hbitmap/meta/zero" , test_hbitmap_meta_zero); +hbitmap_test_add ("/hbitmap/meta/one" , test_hbitmap_meta_one); +hbitmap_test_add ("/hbitmap/meta/byte" , test_hbitmap_meta_byte); +hbitmap_test_add ("/hbitmap/meta/word" , test_hbitmap_meta_word); +hbitmap_test_add ("/hbitmap/meta/sector" , test_hbitmap_meta_sector);g_test_run ();return 0 ;
Re: [Qemu-devel] [PATCH v4 08/15] tests: Add test code for meta bitmap
Quoted 11 lines · Max Reitz
tests/test-hbitmap.c static void test_hbitmap_truncate_shrink_large(TestHBitmapData *data, · line 683
Quoted 8 lines
tests/test-hbitmap.c +8
-0+/* Test "unset" -> "set" will update meta */ +hbitmap_set (data->hb, start, count); +hbitmap_check_meta (data, check_start, check_count); + +/* Test "set" -> "set" will not update meta */ +hbitmap_reset_all (data->meta); +hbitmap_set (data->hb, start, count); +hbitmap_check_meta (data,0 ,0 );Well, but if you'd do an
hbitmap_set(data->hb, start, count + 1), then it would update meta, right?
Yes.
Quoted 5 lines
I forgot to mention in my reply to patch 7 that the check whether anything in the range passed to
hbitmap_set()has been changed in order to determine whether all of that range should be set in the meta bitmap seemed a bit excessive. I don't think this will hurt anyone, but still.
It is. It has been on my list to optimize the unnecessary meta update away but I haven't done that yet.
Fam
Quoted 5 lines
(So this is not a NACK, just a question.)
Max
PATCH v4 9/15 block: Support meta dirty bitmap
In reply to Fam ZhengThe added group of operations enables tracking of the changed bits in the dirty bitmap.
--- block/dirty-bitmap.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ include/block/dirty-bitmap.h | 9 ++++++++ 2 files changed, 61 insertions(+)
block/dirty-bitmap.c +52 -0
@@ -38,6 +38,7 @@*/ struct BdrvDirtyBitmap {HBitmap *bitmap;/* Dirty sector bitmap implementation */ +HBitmap *meta;/* Meta dirty bitmap */ BdrvDirtyBitmap *successor;/* Anonymous child; implies frozen status */ char *name;/* Optional non-empty unique ID */ int64_t size;/* Size of the bitmap (Number of sectors) */
@@ -103,6 +104,56 @@ BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs,return bitmap; } +/* bdrv_create_meta_dirty_bitmap +* +* Create a meta dirty bitmap that tracks the changes of bits in @bitmap. I.e. +* when a dirty status bit in @bitmap is changed (either from reset to set or +* the other way around), its respective meta dirty bitmap bit will be marked +* dirty as well. +* +* @bitmap: the block dirty bitmap for which to create a meta dirty bitmap. +* @chunk_size: how many bytes of bitmap data does each bit in the meta bitmap +* track. +*/ +void bdrv_create_meta_dirty_bitmap (BdrvDirtyBitmap *bitmap, +int chunk_size) +{ +assert (!bitmap->meta); + bitmap->meta =hbitmap_create_meta (bitmap->bitmap, + chunk_size *BITS_PER_BYTE ); +} + +void bdrv_release_meta_dirty_bitmap (BdrvDirtyBitmap *bitmap) +{ +assert (bitmap->meta); +hbitmap_free_meta (bitmap->bitmap); + bitmap->meta =NULL ; +} + +int bdrv_dirty_bitmap_get_meta (BlockDriverState *bs, +BdrvDirtyBitmap *bitmap,int64_t sector, +int nb_sectors) +{ +uint64_t i; +int gran =bdrv_dirty_bitmap_granularity (bitmap) >>BDRV_SECTOR_BITS ; + +/* To optimize: we can make hbitmap to internally check the range in a +* coarse level, or at least do it word by word. */ +for (i = sector; i < sector + nb_sectors; i += gran) { +if (hbitmap_get (bitmap->meta, i)) { +return true; + } + } +return false; +} + +void bdrv_dirty_bitmap_reset_meta (BlockDriverState *bs, +BdrvDirtyBitmap *bitmap,int64_t sector, +int nb_sectors) +{ +hbitmap_reset (bitmap->meta, sector, nb_sectors); +} +bool bdrv_dirty_bitmap_frozen (BdrvDirtyBitmap *bitmap) {return bitmap->successor;
@@ -233,6 +284,7 @@ static void bdrv_do_release_matching_dirty_bitmap(BlockDriverState *bs,if ((!bitmap || bm == bitmap) && (!only_named || bm->name)) {assert (!bm->active_iterators);assert (!bdrv_dirty_bitmap_frozen (bm)); +assert (!bm->meta);QLIST_REMOVE (bm, list);hbitmap_free (bm->bitmap);g_free (bm->name);
include/block/dirty-bitmap.h +9 -0
@@ -8,6 +8,9 @@ BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs,uint32_t granularity, const char *name, Error **errp); +void bdrv_create_meta_dirty_bitmap (BdrvDirtyBitmap *bitmap, +int chunk_size); +void bdrv_release_meta_dirty_bitmap (BdrvDirtyBitmap *bitmap);int bdrv_dirty_bitmap_create_successor (BlockDriverState *bs,BdrvDirtyBitmap *bitmap,Error **errp);
@@ -36,6 +39,12 @@ void bdrv_set_dirty_bitmap(BdrvDirtyBitmap *bitmap, int64_t cur_sector, int nr_sectors);void bdrv_reset_dirty_bitmap (BdrvDirtyBitmap *bitmap,int64_t cur_sector,int nr_sectors); +int bdrv_dirty_bitmap_get_meta (BlockDriverState *bs, +BdrvDirtyBitmap *bitmap,int64_t sector, +int nb_sectors); +void bdrv_dirty_bitmap_reset_meta (BlockDriverState *bs, +BdrvDirtyBitmap *bitmap,int64_t sector, +int nb_sectors);BdrvDirtyBitmapIter *bdrv_dirty_iter_new (BdrvDirtyBitmap *bitmap,uint64_t first_sector);void bdrv_dirty_iter_free (BdrvDirtyBitmapIter *iter);
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH v4 09/15] block: Support meta dirty bitmap
Quoted 8 lines · Fam Zheng
The added group of operations enables tracking of the changed bits in the dirty bitmap.
Signed-off-by Fam Zheng <[email protected]>--- block/dirty-bitmap.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ include/block/dirty-bitmap.h | 9 ++++++++ 2 files changed, 61 insertions(+)
Should we truncate the meta bitmaps in bdrv_dirty_bitmap_truncate()?
Max
Re: [Qemu-devel] [PATCH v4 09/15] block: Support meta dirty bitmap
Quoted 4 lines · Max Reitz
Quoted 3 lines · Fam Zheng
The added group of operations enables tracking of the changed bits in the dirty bitmap.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Fam Zheng <[email protected]>--- block/dirty-bitmap.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ include/block/dirty-bitmap.h | 9 ++++++++ 2 files changed, 61 insertions(+)Should we truncate the meta bitmaps in
bdrv_dirty_bitmap_truncate()?
Yes, adding that. Thanks!
Fam
PATCH v4 10/15 block: Add two dirty bitmap getters
In reply to Fam ZhengFor dirty bitmap users to get the size and the name of a BdrvDirtyBitmap.
--- block/dirty-bitmap.c | 10 ++++++++++ include/block/dirty-bitmap.h | 2 ++ 2 files changed, 12 insertions(+)
block/dirty-bitmap.c +10 -0
@@ -154,6 +154,16 @@ void bdrv_dirty_bitmap_reset_meta(BlockDriverState *bs,hbitmap_reset (bitmap->meta, sector, nb_sectors); } +int64_t bdrv_dirty_bitmap_size (const BdrvDirtyBitmap *bitmap) +{ +return bitmap->size; +} + +const char *bdrv_dirty_bitmap_name (const BdrvDirtyBitmap *bitmap) +{ +return bitmap->name; +} +bool bdrv_dirty_bitmap_frozen (BdrvDirtyBitmap *bitmap) {return bitmap->successor;
include/block/dirty-bitmap.h +2 -0
@@ -32,6 +32,8 @@ uint32_t bdrv_get_default_bitmap_granularity(BlockDriverState *bs);uint32_t bdrv_dirty_bitmap_granularity (BdrvDirtyBitmap *bitmap);bool bdrv_dirty_bitmap_enabled (BdrvDirtyBitmap *bitmap);bool bdrv_dirty_bitmap_frozen (BdrvDirtyBitmap *bitmap); +const char *bdrv_dirty_bitmap_name (const BdrvDirtyBitmap *bitmap); +int64_t bdrv_dirty_bitmap_size (const BdrvDirtyBitmap *bitmap);DirtyBitmapStatus bdrv_dirty_bitmap_status (BdrvDirtyBitmap *bitmap);int bdrv_get_dirty (BlockDriverState *bs,BdrvDirtyBitmap *bitmap,int64_t sector);
Signature · 1 line
2.4.3
PATCH v4 11/15 block: Assert that bdrv_release_dirty_bitmap succeeded
In reply to Fam ZhengWe use a loop over bs->dirty_bitmaps to make sure the caller is only releasing a bitmap owned by bs. Let's also assert that in this case the caller is releasing a bitmap that does exist.
--- block/dirty-bitmap.c | 3 +++ 1 file changed, 3 insertions(+)
block/dirty-bitmap.c +3 -0
@@ -305,6 +305,9 @@ static void bdrv_do_release_matching_dirty_bitmap(BlockDriverState *bs, } } } +if (bitmap) { +abort (); + } }void bdrv_release_dirty_bitmap (BlockDriverState *bs,BdrvDirtyBitmap *bitmap)
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH v4 11/15] block: Assert that bdrv_release_dirty_bitmap succeeded
Quoted 8 lines · Fam Zheng
We use a loop over
bs->dirty_bitmapsto make sure the caller is only releasing a bitmap owned by bs. Let's also assert that in this case the caller is releasing a bitmap that does exist.Signed-off-by Fam Zheng <[email protected]>--- block/dirty-bitmap.c | 3 +++ 1 file changed, 3 insertions(+)
PATCH v4 12/15 hbitmap: serialization
In reply to Fam ZhengFrom: Vladimir Sementsov-Ogievskiy <[email protected]>
Functions to serialize / deserialize(restore) HBitmap. HBitmap should be saved to linear sequence of bits independently of endianness and bitmap array element (unsigned long) size. Therefore Little Endian is chosen.
These functions are appropriate for dirty bitmap migration, restoring the bitmap in several steps is available. To save performance, every step writes only the last level of the bitmap. All other levels are restored by hbitmap_deserialize_finish() as a last step of restoring. So, HBitmap is inconsistent while restoring.
--- include/qemu/hbitmap.h | 79 ++++++++++++++++++++++++++++ util/hbitmap.c | 137 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 216 insertions(+)
include/qemu/hbitmap.h +79 -0
@@ -146,6 +146,85 @@ void hbitmap_reset_all(HBitmap *hb);bool hbitmap_get (const HBitmap *hb,uint64_t item);/** +* hbitmap_serialization_granularity: +* @hb: HBitmap to operate on. +* +* Granularity of serialization chunks, used by other serialization functions. +* For every chunk: +* 1. Chunk start should be aligned to this granularity. +* 2. Chunk size should be aligned too, except for last chunk (for which +* start + count == hb->size) +*/ +uint64_t hbitmap_serialization_granularity (const HBitmap *hb); + +/** +* hbitmap_serialization_size: +* @hb: HBitmap to operate on. +* @start: Starting bit +* @count: Number of bits +* +* Return number of bytes hbitmap_(de)serialize_part needs +*/ +uint64_t hbitmap_serialization_size (const HBitmap *hb, +uint64_t start,uint64_t count); + +/** +* hbitmap_serialize_part +* @hb: HBitmap to operate on. +* @buf: Buffer to store serialized bitmap. +* @start: First bit to store. +* @count: Number of bits to store. +* +* Stores HBitmap data corresponding to given region. The format of saved data +* is linear sequence of bits, so it can be used by hbitmap_deserialize_part +* independently of endianness and size of HBitmap level array elements +*/ +void hbitmap_serialize_part (const HBitmap *hb,uint8_t *buf, +uint64_t start,uint64_t count); + +/** +* hbitmap_deserialize_part +* @hb: HBitmap to operate on. +* @buf: Buffer to restore bitmap data from. +* @start: First bit to restore. +* @count: Number of bits to restore. +* @finish: Whether to call hbitmap_deserialize_finish automatically. +* +* Restores HBitmap data corresponding to given region. The format is the same +* as for hbitmap_serialize_part. +* +* If @finish is false, caller must call hbitmap_serialize_finish before using +* the bitmap. +*/ +void hbitmap_deserialize_part (HBitmap *hb,uint8_t *buf, +uint64_t start,uint64_t count, +bool finish); + +/** +* hbitmap_deserialize_zeroes +* @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 zeroes. +* +* If @finish is false, caller must call hbitmap_serialize_finish before using +* the bitmap. +*/ +void hbitmap_deserialize_zeroes (HBitmap *hb,uint64_t start,uint64_t count, +bool finish); + +/** +* hbitmap_deserialize_finish +* @hb: HBitmap to operate on. +* +* Repair HBitmap after calling hbitmap_deserialize_data. Actually, all HBitmap +* layers are restored here. +*/ +void hbitmap_deserialize_finish (HBitmap *hb); + +/** * hbitmap_free: * @hb: HBitmap to operate on. *
util/hbitmap.c +137 -0
143 lines not on this page · raw message
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH v4 12/15] hbitmap: serialization
Quoted 19 lines · Fam Zheng
From: Vladimir Sementsov-Ogievskiy <[email protected]>
Functions to serialize / deserialize(restore) HBitmap. HBitmap should be saved to linear sequence of bits independently of endianness and bitmap array element (unsigned long) size. Therefore Little Endian is chosen.
These functions are appropriate for dirty bitmap migration, restoring the bitmap in several steps is available. To save performance, every step writes only the last level of the bitmap. All other levels are restored by
hbitmap_deserialize_finish()as a last step of restoring. So, HBitmap is inconsistent while restoring.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>[Fix left shift operand to 1UL; add "finish" parameter. - Fam]Signed-off-by Fam Zheng <[email protected]>--- include/qemu/hbitmap.h | 79 ++++++++++++++++++++++++++++ util/hbitmap.c | 137 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 216 insertions(+)
[...]
Quoted 57 lines
util/hbitmap.c +49
-0@@ -395,6 +395,143 @@ bool hbitmap_get(const HBitmap *hb, uint64_t item)return (hb->levels[HBITMAP_LEVELS -1 ][pos >>BITS_PER_LEVEL ] & bit) !=0 ; } +uint64_t hbitmap_serialization_granularity (const HBitmap *hb) +{ +/* Require at least 64 bit granularity to be safe on both 64 bit and 32 bit +* hosts. */ +return 64 << hb->granularity; +} + +/* Start should be aligned to serialization granularity, chunk size should be +* aligned to serialization granularity too, except for last chunk. +*/ +static void serialization_chunk (const HBitmap *hb, +uint64_t start,uint64_t count, +unsigned long **first_el,size_t *el_count) +{ +uint64_t last = start + count -1 ; +uint64_t gran =hbitmap_serialization_granularity (hb); + +assert ((start & (gran -1 )) ==0 ); +assert ((last >> hb->granularity) < hb->size); +if ((last >> hb->granularity) != hb->size -1 ) { +assert ((count & (gran -1 )) ==0 ); + } + + start = (start >> hb->granularity) >>BITS_PER_LEVEL ; + last = (last >> hb->granularity) >>BITS_PER_LEVEL ; + + *first_el = &hb->levels[HBITMAP_LEVELS -1 ][start]; + *el_count = last - start +1 ; +} + +uint64_t hbitmap_serialization_size (const HBitmap *hb, +uint64_t start,uint64_t count) +{ +uint64_t el_count; +unsigned long *cur; + +if (!count) { +return 0 ; + } +serialization_chunk (hb, start, count, &cur, &el_count); + +return el_count *sizeof (unsigned long ); +} + +void hbitmap_serialize_part (const HBitmap *hb,uint8_t *buf, +uint64_t start,uint64_t count) +{ +uint64_t el_count; +unsigned long *cur, *end;
util/hbitmap.c bool hbitmap_get(const HBitmap *hb, uint64_t item) · line 456
Quoted 10 lines
util/hbitmap.c +10
-0+ +if (!count) { +return ; + } +serialization_chunk (hb, start, count, &cur, &el_count); + end = cur + el_count; + +while (cur != end) { +unsigned long el = + (BITS_PER_LONG ==32 ?cpu_to_le32 (*cur) :cpu_to_le64 (*cur));
Looks a bit fishy, but I can't come up with anything better.
(Other than adding cpu_to_leul(); we already do have leul_to_cpu(), so that wouldn't be too far off.)
util/hbitmap.c bool hbitmap_get(const HBitmap *hb, uint64_t item) · line 458
Quoted 2 lines
util/hbitmap.c +2
-0+ +memcpy (buf, &el,sizeof (el));
One could have used cpu_to_le32/64w((uint32/64_t *)buf, *cur); instead.
Maybe I'd like the following better:
#if BITS_PER_LONG == 32cpu_to_le32w((uint32_t *)buf, *cur);
#elif BITS_PER_LONG == 64cpu_to_le64w((uint64_t *)buf, *cur);
#else
#error Unknown long size
#endif
Or just
#else /* BITS_PER_LONG == 64 */
instead of the #elif. I think that's safe to assume.
Quoted 16 lines
util/hbitmap.c +16
-0+ buf +=sizeof (el); + cur++; + } +} + +void hbitmap_deserialize_part (HBitmap *hb,uint8_t *buf, +uint64_t start,uint64_t count, +bool finish) +{ +uint64_t el_count; +unsigned long *cur, *end; + +if (!count) { +return ; + } +serialization_chunk (hb, start, count, &cur, &el_count);
util/hbitmap.c bool hbitmap_get(const HBitmap *hb, uint64_t item) · line 484
Quoted 10 lines
util/hbitmap.c +10
-0+ end = cur + el_count; + +while (cur != end) { +memcpy (cur, buf,sizeof (*cur)); + +if (BITS_PER_LONG ==32 ) { +le32_to_cpus ((uint32_t *)cur); + }else { +le64_to_cpus ((uint64_t *)cur); + }
Here, I'd definitely like that variant better, i.e.
#if BITS_PER_LONG == 32le32_to_cpuw(cur, *(uint32_t *)buf);
#else /* BITS_PER_LONG == 64 */le64_to_cpuw(cur, *(uint64_t *)buf);
#endif
Unless a language lawyer NACKs this because the pointer cast violates strict aliasing.
If so, I still strongly recommend replacing the if by an #if, not least because this saves us the pointer cast on cur.
(Or does it? Maybe one still needs to explicitly cast an unsigned long * to uint32_t * even if both have the same size. However, in that case we can still do *cur = le32/64_to_cpu(*cur). The above would then become:
#if BITS_PER_LONG == 32
*cur = le32_to_cpu(*(uint32_t *)buf);
#else /* BITS_PER_LONG == 64 */
*cur = le64_to_cpu(*(uint64_t *)buf);
#endif
)
Quoted 25 lines
util/hbitmap.c +25
-0+ + buf +=sizeof (unsigned long ); + cur++; + } +if (finish) { +hbitmap_deserialize_finish (hb); + } +} + +void hbitmap_deserialize_zeroes (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,0 , el_count *sizeof (unsigned long )); +if (finish) { +hbitmap_deserialize_finish (hb); + } +}
util/hbitmap.c bool hbitmap_get(const HBitmap *hb, uint64_t item) · line 519
Quoted 10 lines
util/hbitmap.c +10
-0+ +void hbitmap_deserialize_finish (HBitmap *bitmap) +{ +int64_t i, size, prev_size; +int lev; + +/* restore levels starting from penultimate to zero level, assuming +* that the last level is ok */ + size =MAX ((bitmap->size +BITS_PER_LONG -1 ) >>BITS_PER_LEVEL ,1 ); +for (lev =HBITMAP_LEVELS -1 ; lev-- >0 ; ) {
I'm always amazed of how much this notation (x-- > 0, or x --> 0, even worse) confuses me. Or rather I'm always amazed of how much it confuses me and how much other people love it (as opposed to me, who's rather unhappy every time he doesn't use all of the three "parameters" for a for loop).
This time I wondered why we start at HBITMAP_LEVELS - 1 -- that's the ultimate and not the penultimate level after all. But of course, the loop condition is evaluated before the loop is executed for the first time, so we will indeed start at HBITMAP_LEVELS - 2.
So, yeah, this is correct.
util/hbitmap.c bool hbitmap_get(const HBitmap *hb, uint64_t item) · line 524
Quoted 5 lines
util/hbitmap.c +5
-0+ prev_size = size; + size =MAX ((size +BITS_PER_LONG -1 ) >>BITS_PER_LEVEL ,1 ); +memset (bitmap->levels[lev],0 , size *sizeof (unsigned long )); + +for (i =0 ; i < prev_size; ++i) {
I hate using stand-alone pre-increment for scalars with a passion.
Unfortunately, checkpatch does not.
(All of the above are me just nagging and giving optional suggestions.)
Quoted 14 lines
util/hbitmap.c +10
-0+if (bitmap->levels[lev +1 ][i]) { + bitmap->levels[lev][i >>BITS_PER_LEVEL ] |= +1UL << (i & (BITS_PER_LONG -1 )); + } + } + } + + bitmap->levels[0 ][0 ] |=1UL << (BITS_PER_LONG -1 ); +} +void hbitmap_free (HBitmap *hb) {unsigned i;
Re: [Qemu-devel] [PATCH v4 12/15] hbitmap: serialization
Quoted 108 lines · Max Reitz
Quoted 19 lines · Fam Zheng
From: Vladimir Sementsov-Ogievskiy <[email protected]>
Functions to serialize / deserialize(restore) HBitmap. HBitmap should be saved to linear sequence of bits independently of endianness and bitmap array element (unsigned long) size. Therefore Little Endian is chosen.
These functions are appropriate for dirty bitmap migration, restoring the bitmap in several steps is available. To save performance, every step writes only the last level of the bitmap. All other levels are restored by
hbitmap_deserialize_finish()as a last step of restoring. So, HBitmap is inconsistent while restoring.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>[Fix left shift operand to 1UL; add "finish" parameter. - Fam]Signed-off-by Fam Zheng <[email protected]>--- include/qemu/hbitmap.h | 79 ++++++++++++++++++++++++++++ util/hbitmap.c | 137 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 216 insertions(+)[...]
Quoted 57 lines
util/hbitmap.c +49
-0@@ -395,6 +395,143 @@ bool hbitmap_get(const HBitmap *hb, uint64_t item)return (hb->levels[HBITMAP_LEVELS -1 ][pos >>BITS_PER_LEVEL ] & bit) !=0 ; } +uint64_t hbitmap_serialization_granularity (const HBitmap *hb) +{ +/* Require at least 64 bit granularity to be safe on both 64 bit and 32 bit +* hosts. */ +return 64 << hb->granularity; +} + +/* Start should be aligned to serialization granularity, chunk size should be +* aligned to serialization granularity too, except for last chunk. +*/ +static void serialization_chunk (const HBitmap *hb, +uint64_t start,uint64_t count, +unsigned long **first_el,size_t *el_count) +{ +uint64_t last = start + count -1 ; +uint64_t gran =hbitmap_serialization_granularity (hb); + +assert ((start & (gran -1 )) ==0 ); +assert ((last >> hb->granularity) < hb->size); +if ((last >> hb->granularity) != hb->size -1 ) { +assert ((count & (gran -1 )) ==0 ); + } + + start = (start >> hb->granularity) >>BITS_PER_LEVEL ; + last = (last >> hb->granularity) >>BITS_PER_LEVEL ; + + *first_el = &hb->levels[HBITMAP_LEVELS -1 ][start]; + *el_count = last - start +1 ; +} + +uint64_t hbitmap_serialization_size (const HBitmap *hb, +uint64_t start,uint64_t count) +{ +uint64_t el_count; +unsigned long *cur; + +if (!count) { +return 0 ; + } +serialization_chunk (hb, start, count, &cur, &el_count); + +return el_count *sizeof (unsigned long ); +} + +void hbitmap_serialize_part (const HBitmap *hb,uint8_t *buf, +uint64_t start,uint64_t count) +{ +uint64_t el_count; +unsigned long *cur, *end;util/hbitmap.c bool hbitmap_get(const HBitmap *hb, uint64_t item) · line 456
Quoted 10 lines
util/hbitmap.c +10
-0+ +if (!count) { +return ; + } +serialization_chunk (hb, start, count, &cur, &el_count); + end = cur + el_count; + +while (cur != end) { +unsigned long el = + (BITS_PER_LONG ==32 ?cpu_to_le32 (*cur) :cpu_to_le64 (*cur));Looks a bit fishy, but I can't come up with anything better.
(Other than adding
cpu_to_leul(); we already do haveleul_to_cpu(), so that wouldn't be too far off.)util/hbitmap.c bool hbitmap_get(const HBitmap *hb, uint64_t item) · line 458
Quoted 2 lines
util/hbitmap.c +2
-0+ +memcpy (buf, &el,sizeof (el));One could have used cpu_to_le32/64w((uint32/64_t *)buf, *cur); instead.
Maybe I'd like the following better:
#if
BITS_PER_LONG== 32cpu_to_le32w((uint32_t *)buf, *cur);
#elifBITS_PER_LONG== 64cpu_to_le64w((uint64_t *)buf, *cur);
#else
#error Unknown long size
#endif
Quoted 5 lines
Or just
#else /*
BITS_PER_LONG== 64 */instead of the #elif. I think that's safe to assume.
I think (BITS_PER_LONG == 32 ? .. : ..) should be optimised away by compiler in any case.. However adding cpu_to_leul should be better.
Quoted 94 lines
Quoted 17 lines
util/hbitmap.c +16
-0+ buf +=sizeof (el); + cur++; + } +} + +void hbitmap_deserialize_part (HBitmap *hb,uint8_t *buf, +uint64_t start,uint64_t count, +bool finish) +{ +uint64_t el_count; +unsigned long *cur, *end; + +if (!count) { +return ; + } +serialization_chunk (hb, start, count, &cur, &el_count);util/hbitmap.c bool hbitmap_get(const HBitmap *hb, uint64_t item) · line 484
Quoted 10 lines
util/hbitmap.c +10
-0+ end = cur + el_count; + +while (cur != end) { +memcpy (cur, buf,sizeof (*cur)); + +if (BITS_PER_LONG ==32 ) { +le32_to_cpus ((uint32_t *)cur); + }else { +le64_to_cpus ((uint64_t *)cur); + }Here, I'd definitely like that variant better, i.e.
#if
BITS_PER_LONG== 32le32_to_cpuw(cur, *(uint32_t *)buf);
#else /*BITS_PER_LONG== 64 */le64_to_cpuw(cur, *(uint64_t *)buf);
#endifUnless a language lawyer NACKs this because the pointer cast violates strict aliasing.
If so, I still strongly recommend replacing the if by an #if, not least because this saves us the pointer cast on cur.
(Or does it? Maybe one still needs to explicitly cast an unsigned long * to
uint32_t* even if both have the same size. However, in that case we can still do *cur = le32/64_to_cpu(*cur). The above would then become:#if
BITS_PER_LONG== 32
*cur =le32_to_cpu(*(uint32_t *)buf);
#else /*BITS_PER_LONG== 64 */
*cur =le64_to_cpu(*(uint64_t *)buf);
#endif)
Quoted 25 lines
util/hbitmap.c +25
-0+ + buf +=sizeof (unsigned long ); + cur++; + } +if (finish) { +hbitmap_deserialize_finish (hb); + } +} + +void hbitmap_deserialize_zeroes (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,0 , el_count *sizeof (unsigned long )); +if (finish) { +hbitmap_deserialize_finish (hb); + } +}util/hbitmap.c bool hbitmap_get(const HBitmap *hb, uint64_t item) · line 519
Quoted 10 lines
util/hbitmap.c +10
-0+ +void hbitmap_deserialize_finish (HBitmap *bitmap) +{ +int64_t i, size, prev_size; +int lev; + +/* restore levels starting from penultimate to zero level, assuming +* that the last level is ok */ + size =MAX ((bitmap->size +BITS_PER_LONG -1 ) >>BITS_PER_LEVEL ,1 ); +for (lev =HBITMAP_LEVELS -1 ; lev-- >0 ; ) {I'm always amazed of how much this notation (x-- > 0, or x --> 0, even worse) confuses me. Or rather I'm always amazed of how much it confuses me and how much other people love it (as opposed to me, who's rather unhappy every time he doesn't use all of the three "parameters" for a for loop).
Quoted 6 lines
This time I wondered why we start at
HBITMAP_LEVELS- 1 -- that's the ultimate and not the penultimate level after all. But of course, the loop condition is evaluated before the loop is executed for the first time, so we will indeed start atHBITMAP_LEVELS- 2.So, yeah, this is correct.
This strange notation is used in several places in hbitmap.c, so, I've reused it) I don't like it, but to fix it it should be fixed everywhere in the file as a separate patch I think..
Quoted 7 lines
util/hbitmap.c bool hbitmap_get(const HBitmap *hb, uint64_t item) · line 524
Quoted 6 lines
util/hbitmap.c +5
-0+ prev_size = size; + size =MAX ((size +BITS_PER_LONG -1 ) >>BITS_PER_LEVEL ,1 ); +memset (bitmap->levels[lev],0 , size *sizeof (unsigned long )); + +for (i =0 ; i < prev_size; ++i) {I hate using stand-alone pre-increment for scalars with a passion.
I just prefer to write it in the same way for scalars and iterators, for c and c++.
Quoted 21 lines
Unfortunately, checkpatch does not.
Reviewed-by Max Reitz <[email protected]>(All of the above are me just nagging and giving optional suggestions.)
Quoted 14 lines
util/hbitmap.c +10
-0+if (bitmap->levels[lev +1 ][i]) { + bitmap->levels[lev][i >>BITS_PER_LEVEL ] |= +1UL << (i & (BITS_PER_LONG -1 )); + } + } + } + + bitmap->levels[0 ][0 ] |=1UL << (BITS_PER_LONG -1 ); +} +void hbitmap_free (HBitmap *hb) {unsigned i;
Signature · 2 lines
Best regards, Vladimir
PATCH v4 13/15 block: BdrvDirtyBitmap serialization interface
In reply to Fam ZhengFrom: Vladimir Sementsov-Ogievskiy <[email protected]>
Several functions to provide necessary access to BdrvDirtyBitmap for block-migration.c
--- block/dirty-bitmap.c | 37 +++++++++++++++++++++++++++++++++++++ include/block/dirty-bitmap.h | 14 ++++++++++++++ 2 files changed, 51 insertions(+)
block/dirty-bitmap.c +37 -0
@@ -453,6 +453,43 @@ void bdrv_undo_clear_dirty_bitmap(BdrvDirtyBitmap *bitmap, HBitmap *in)hbitmap_free (tmp); } +uint64_t bdrv_dirty_bitmap_serialization_size (const BdrvDirtyBitmap *bitmap, +uint64_t start,uint64_t count) +{ +return hbitmap_serialization_size (bitmap->bitmap, start, count); +} + +uint64_t bdrv_dirty_bitmap_serialization_align (const BdrvDirtyBitmap *bitmap) +{ +return hbitmap_serialization_granularity (bitmap->bitmap); +} + +void bdrv_dirty_bitmap_serialize_part (const BdrvDirtyBitmap *bitmap, +uint8_t *buf,uint64_t start, +uint64_t count) +{ +hbitmap_serialize_part (bitmap->bitmap, buf, start, count); +} + +void bdrv_dirty_bitmap_deserialize_part (BdrvDirtyBitmap *bitmap, +uint8_t *buf,uint64_t start, +uint64_t count,bool finish) +{ +hbitmap_deserialize_part (bitmap->bitmap, buf, start, count, finish); +} + +void bdrv_dirty_bitmap_deserialize_zeroes (BdrvDirtyBitmap *bitmap, +uint64_t start,uint64_t count, +bool finish) +{ +hbitmap_deserialize_zeroes (bitmap->bitmap, start, count, finish); +} + +void bdrv_dirty_bitmap_deserialize_finish (BdrvDirtyBitmap *bitmap) +{ +hbitmap_deserialize_finish (bitmap->bitmap); +} +void bdrv_set_dirty (BlockDriverState *bs,int64_t cur_sector,int nr_sectors) {
include/block/dirty-bitmap.h +14 -0
@@ -55,4 +55,18 @@ void bdrv_set_dirty_iter(BdrvDirtyBitmapIter *hbi, int64_t sector_num);int64_t bdrv_get_dirty_count (BdrvDirtyBitmap *bitmap);void bdrv_dirty_bitmap_truncate (BlockDriverState *bs); +uint64_t bdrv_dirty_bitmap_serialization_size (const BdrvDirtyBitmap *bitmap, +uint64_t start,uint64_t count); +uint64_t bdrv_dirty_bitmap_serialization_align (const BdrvDirtyBitmap *bitmap); +void bdrv_dirty_bitmap_serialize_part (const BdrvDirtyBitmap *bitmap, +uint8_t *buf,uint64_t start, +uint64_t count); +void bdrv_dirty_bitmap_deserialize_part (BdrvDirtyBitmap *bitmap, +uint8_t *buf,uint64_t start, +uint64_t count,bool finish); +void bdrv_dirty_bitmap_deserialize_zeroes (BdrvDirtyBitmap *bitmap, +uint64_t start,uint64_t count, +bool finish); +void bdrv_dirty_bitmap_deserialize_finish (BdrvDirtyBitmap *bitmap); +#endif
Signature · 1 line
2.4.3
PATCH v4 14/15 tests: Add test code for hbitmap serialization
In reply to Fam Zheng--- tests/test-hbitmap.c | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+)
tests/test-hbitmap.c +139 -0
@@ -12,6 +12,7 @@#include "qemu/osdep.h" #include <glib.h> #include "qemu/hbitmap.h" +#include "qemu/bitmap.h" #include "block/block.h" #define LOG_BITS_PER_LONG (BITS_PER_LONG == 32 ? 5 : 6)
@@ -738,6 +739,16 @@ static void test_hbitmap_meta_one(TestHBitmapData *data, const void *unused) } } +static void test_hbitmap_serialize_granularity (TestHBitmapData *data, +const void *unused) +{ +int r; + +hbitmap_test_init (data,L3 *2 ,3 ); + r =hbitmap_serialization_granularity (data->hb); + g_assert_cmpint(r, ==, BITS_PER_LONG << 3); +} +static void test_hbitmap_meta_zero (TestHBitmapData *data,const void *unused) {hbitmap_test_init_meta (data,0 ,0 ,1 );
@@ -745,6 +756,125 @@ static void test_hbitmap_meta_zero(TestHBitmapData *data, const void *unused)hbitmap_check_meta (data,0 ,0 ); } +static void hbitmap_test_serialize_range (TestHBitmapData *data, +uint8_t *buf,size_t buf_size, +uint64_t pos,uint64_t count) +{ +size_t i; + +assert (hbitmap_granularity (data->hb) ==0 ); +hbitmap_reset_all (data->hb); +memset (buf,0 , buf_size); +if (count) { +hbitmap_set (data->hb, pos, count); + } +hbitmap_serialize_part (data->hb, buf,0 , data->size); +for (i =0 ; i < data->size; i++) { +int is_set =test_bit (i, (unsigned long *)buf); +if (i >= pos && i < pos + count) { +g_assert (is_set); + }else { +g_assert (!is_set); + } + } +hbitmap_reset_all (data->hb); +hbitmap_deserialize_part (data->hb, buf,0 , data->size, true); + +for (i =0 ; i < data->size; i++) { +int is_set =hbitmap_get (data->hb, i); +if (i >= pos && i < pos + count) { +g_assert (is_set); + }else { +g_assert (!is_set); + } + } +} + +static void test_hbitmap_serialize_basic (TestHBitmapData *data, +const void *unused) +{ +int i, j; +size_t buf_size; +uint8_t *buf; +uint64_t positions[] = {0 ,1 ,L1 -1 ,L1 ,L2 -1 ,L2 ,L2 +1 ,L3 -1 }; +int num_positions =sizeof (positions) /sizeof (positions[0 ]); + +hbitmap_test_init (data,L3 ,0 ); + buf_size =hbitmap_serialization_size (data->hb,0 , data->size); + buf =g_malloc0 (buf_size); + +for (i =0 ; i < num_positions; i++) { +for (j =0 ; j < num_positions; j++) { +hbitmap_test_serialize_range (data, buf, buf_size, + positions[i], +MIN (positions[j],L3 - positions[i])); + } + } + +g_free (buf); +} + +static void test_hbitmap_serialize_part (TestHBitmapData *data, +const void *unused) +{ +int i, j, k; +size_t buf_size; +uint8_t *buf; +uint64_t positions[] = {0 ,1 ,L1 -1 ,L1 ,L2 -1 ,L2 ,L2 +1 ,L3 -1 }; +int num_positions =sizeof (positions) /sizeof (positions[0 ]); + +hbitmap_test_init (data,L3 ,0 ); + buf_size =L2 ; + buf =g_malloc0 (buf_size); + +for (i =0 ; i < num_positions; i++) { +hbitmap_set (data->hb, positions[i],1 ); + } + +for (i =0 ; i < data->size; i += buf_size) { +hbitmap_serialize_part (data->hb, buf, i, buf_size); +for (j =0 ; j < buf_size; j++) { +bool should_set = false; +for (k =0 ; k < num_positions; k++) { +if (positions[k] == j + i) { + should_set = true; +break ; + } + } + g_assert_cmpint(should_set, ==, test_bit(j, (unsigned long *)buf)); + } + } + +g_free (buf); +} + +static void test_hbitmap_serialize_zeroes (TestHBitmapData *data, +const void *unused) +{ +int i; +HBitmapIter iter; +int64_t next; +uint64_t positions[] = {0 ,L1 ,L2 ,L3 -L1 }; +int num_positions =sizeof (positions) /sizeof (positions[0 ]); + +hbitmap_test_init (data,L3 ,0 ); + +for (i =0 ; i < num_positions; i++) { +hbitmap_set (data->hb, positions[i],L1 ); + } + +for (i =0 ; i < num_positions; i++) { +hbitmap_deserialize_zeroes (data->hb, positions[i],L1 , true); +hbitmap_iter_init (&iter, data->hb,0 ); + next =hbitmap_iter_next (&iter); +if (i == num_positions -1 ) { + g_assert_cmpint(next, ==, -1); + }else { + g_assert_cmpint(next, ==, positions[i + 1]); + } + } +} +static void hbitmap_test_add (const char *testpath,void (*test_func)(TestHBitmapData *data,const void *user_data)) {
@@ -800,6 +930,15 @@ int main(int argc, char **argv)hbitmap_test_add ("/hbitmap/meta/byte" , test_hbitmap_meta_byte);hbitmap_test_add ("/hbitmap/meta/word" , test_hbitmap_meta_word);hbitmap_test_add ("/hbitmap/meta/sector" , test_hbitmap_meta_sector); + +hbitmap_test_add ("/hbitmap/serialize/granularity" , + test_hbitmap_serialize_granularity); +hbitmap_test_add ("/hbitmap/serialize/basic" , + test_hbitmap_serialize_basic); +hbitmap_test_add ("/hbitmap/serialize/part" , + test_hbitmap_serialize_part); +hbitmap_test_add ("/hbitmap/serialize/zeroes" , + test_hbitmap_serialize_zeroes);g_test_run ();return 0 ;
Signature · 1 line
2.4.3
PATCH v4 15/15 block: More operations for meta dirty bitmap
In reply to Fam ZhengCallers can create an iterator of meta bitmap with bdrv_dirty_meta_iter_new(), then use the bdrv_dirty_iter_* operations on it. Meta iterators are also counted by bitmap->active_iterators.
Also add a couple of functions to retrieve granularity and count.
--- block/dirty-bitmap.c | 19 +++++++++++++++++++ include/block/dirty-bitmap.h | 3 +++ 2 files changed, 22 insertions(+)
block/dirty-bitmap.c +19 -0
@@ -393,6 +393,11 @@ uint32_t bdrv_dirty_bitmap_granularity(BdrvDirtyBitmap *bitmap)return BDRV_SECTOR_SIZE <<hbitmap_granularity (bitmap->bitmap); } +uint32_t bdrv_dirty_bitmap_meta_granularity (BdrvDirtyBitmap *bitmap) +{ +return BDRV_SECTOR_SIZE <<hbitmap_granularity (bitmap->meta); +} +BdrvDirtyBitmapIter *bdrv_dirty_iter_new (BdrvDirtyBitmap *bitmap,uint64_t first_sector) {
@@ -403,6 +408,15 @@ BdrvDirtyBitmapIter *bdrv_dirty_iter_new(BdrvDirtyBitmap *bitmap,return iter; } +BdrvDirtyBitmapIter *bdrv_dirty_meta_iter_new (BdrvDirtyBitmap *bitmap) +{ +BdrvDirtyBitmapIter *iter =g_new (BdrvDirtyBitmapIter,1 ); +hbitmap_iter_init (&iter->hbi, bitmap->meta,0 ); + iter->bitmap = bitmap; + bitmap->active_iterators++; +return iter; +} +void bdrv_dirty_iter_free (BdrvDirtyBitmapIter *iter) {if (!iter) {
@@ -514,3 +528,8 @@ int64_t bdrv_get_dirty_count(BdrvDirtyBitmap *bitmap) {return hbitmap_count (bitmap->bitmap); } + +int64_t bdrv_get_meta_dirty_count (BdrvDirtyBitmap *bitmap) +{ +return hbitmap_count (bitmap->meta); +}
include/block/dirty-bitmap.h +3 -0
@@ -30,6 +30,7 @@ void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap);BlockDirtyInfoList *bdrv_query_dirty_bitmaps (BlockDriverState *bs);uint32_t bdrv_get_default_bitmap_granularity (BlockDriverState *bs);uint32_t bdrv_dirty_bitmap_granularity (BdrvDirtyBitmap *bitmap); +uint32_t bdrv_dirty_bitmap_meta_granularity (BdrvDirtyBitmap *bitmap);bool bdrv_dirty_bitmap_enabled (BdrvDirtyBitmap *bitmap);bool bdrv_dirty_bitmap_frozen (BdrvDirtyBitmap *bitmap);const char *bdrv_dirty_bitmap_name (const BdrvDirtyBitmap *bitmap);
@@ -47,12 +48,14 @@ int bdrv_dirty_bitmap_get_meta(BlockDriverState *bs,void bdrv_dirty_bitmap_reset_meta (BlockDriverState *bs,BdrvDirtyBitmap *bitmap,int64_t sector,int nb_sectors); +BdrvDirtyBitmapIter *bdrv_dirty_meta_iter_new (BdrvDirtyBitmap *bitmap);BdrvDirtyBitmapIter *bdrv_dirty_iter_new (BdrvDirtyBitmap *bitmap,uint64_t first_sector);void bdrv_dirty_iter_free (BdrvDirtyBitmapIter *iter);int64_t bdrv_dirty_iter_next (BdrvDirtyBitmapIter *iter);void bdrv_set_dirty_iter (BdrvDirtyBitmapIter *hbi,int64_t sector_num);int64_t bdrv_get_dirty_count (BdrvDirtyBitmap *bitmap); +int64_t bdrv_get_meta_dirty_count (BdrvDirtyBitmap *bitmap);void bdrv_dirty_bitmap_truncate (BlockDriverState *bs); uint64_t bdrv_dirty_bitmap_serialization_size(const BdrvDirtyBitmap *bitmap,
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH v4 15/15] block: More operations for meta dirty bitmap
Quoted 11 lines · Fam Zheng
Callers can create an iterator of meta bitmap with
bdrv_dirty_meta_iter_new(), then use the bdrv_dirty_iter_* operations on it. Meta iterators are also counted bybitmap->active_iterators.Also add a couple of functions to retrieve granularity and count.
Signed-off-by Fam Zheng <[email protected]>--- block/dirty-bitmap.c | 19 +++++++++++++++++++ include/block/dirty-bitmap.h | 3 +++ 2 files changed, 22 insertions(+)
Max Reitz
AppliedQuoted 33 lines · Fam Zheng
v4: Rebase.
Add rev-by from John in patches 1-5, 7, 8.
Remove BdrvDirtyBitmap typedef fromdirty-bitmap.hin patch 4. [Max] Add assertion onbm->metain patch 9. [John]Two major features are added to block dirty bitmap (and underlying HBitmap) in this series: meta bitmap and serialization, together with all other supportive patches.
Both operations are common in dirty bitmap migration and persistence: they need to find whether and which part of the dirty bitmap in question has changed with meta dirty bitmap, and they need to write it to the target with serialization.
Fam Zheng (13):
backup: Use Bitmap to replace "s->bitmap"
block: Includehbitmap.hinblock.h
typedefs: Add BdrvDirtyBitmap
block: Move block dirty bitmap code to separate files
block: Remove unused typedef of BlockDriverDirtyHandler
block: Hide HBitmap in block dirty bitmap interface
HBitmap: Introduce "meta" bitmap to track bit changes
tests: Add test code for meta bitmap
block: Support meta dirty bitmap
block: Add two dirty bitmap getters
block: Assert thatbdrv_release_dirty_bitmapsucceeded
tests: Add test code for hbitmap serialization
block: More operations for meta dirty bitmapVladimir Sementsov-Ogievskiy (2):
hbitmap: serialization
block: BdrvDirtyBitmap serialization interface
Quoted 14 lines
block.c | 360 ----------------------------- block/Makefile.objs | 2 +- block/backup.c | 25 +- block/dirty-bitmap.c | 535 +++++++++++++++++++++++++++++++++++++++++++ block/mirror.c | 15 +- include/block/block.h | 40 +--- include/block/dirty-bitmap.h | 75 ++++++ include/qemu/hbitmap.h | 96 ++++++++ include/qemu/typedefs.h | 2 + tests/test-hbitmap.c | 255 +++++++++++++++++++++ util/hbitmap.c | 203 ++++++++++++++-- 11 files changed, 1177 insertions(+), 431 deletions(-) create mode 100644 block/dirty-bitmap.c create mode 100644 include/block/dirty-bitmap.h
Thanks, applied patches 1 through 5 to my block tree (because of the large code movement in patch 4):
https://github.com/XanClic/qemu/commits/block
Max
Quoted 49 lines · Max Reitz
Quoted 33 lines · Fam Zheng
v4: Rebase.
Add rev-by from John in patches 1-5, 7, 8.
Remove BdrvDirtyBitmap typedef fromdirty-bitmap.hin patch 4. [Max] Add assertion onbm->metain patch 9. [John]Two major features are added to block dirty bitmap (and underlying HBitmap) in this series: meta bitmap and serialization, together with all other supportive patches.
Both operations are common in dirty bitmap migration and persistence: they need to find whether and which part of the dirty bitmap in question has changed with meta dirty bitmap, and they need to write it to the target with serialization.
Fam Zheng (13):
backup: Use Bitmap to replace "s->bitmap"
block: Includehbitmap.hinblock.h
typedefs: Add BdrvDirtyBitmap
block: Move block dirty bitmap code to separate files
block: Remove unused typedef of BlockDriverDirtyHandler
block: Hide HBitmap in block dirty bitmap interface
HBitmap: Introduce "meta" bitmap to track bit changes
tests: Add test code for meta bitmap
block: Support meta dirty bitmap
block: Add two dirty bitmap getters
block: Assert thatbdrv_release_dirty_bitmapsucceeded
tests: Add test code for hbitmap serialization
block: More operations for meta dirty bitmapVladimir Sementsov-Ogievskiy (2):
hbitmap: serialization
block: BdrvDirtyBitmap serialization interfaceQuoted 14 lines
block.c | 360 ----------------------------- block/Makefile.objs | 2 +- block/backup.c | 25 +- block/dirty-bitmap.c | 535 +++++++++++++++++++++++++++++++++++++++++++ block/mirror.c | 15 +- include/block/block.h | 40 +--- include/block/dirty-bitmap.h | 75 ++++++ include/qemu/hbitmap.h | 96 ++++++++ include/qemu/typedefs.h | 2 + tests/test-hbitmap.c | 255 +++++++++++++++++++++ util/hbitmap.c | 203 ++++++++++++++-- 11 files changed, 1177 insertions(+), 431 deletions(-) create mode 100644 block/dirty-bitmap.c create mode 100644 include/block/dirty-bitmap.h
Quoted 7 lines
Thanks, applied patches 1 through 5 to my block tree (because of the large code movement in patch 4):
https://github.com/XanClic/qemu/commits/block
Max
You're a saint, thank you :)
Hi!
Are you going to update the series in the near future?
Quoted 48 lines · Fam Zheng
v4: Rebase.
Add rev-by from John in patches 1-5, 7, 8.
Remove BdrvDirtyBitmap typedef fromdirty-bitmap.hin patch 4. [Max] Add assertion onbm->metain patch 9. [John]Two major features are added to block dirty bitmap (and underlying HBitmap) in this series: meta bitmap and serialization, together with all other supportive patches.
Both operations are common in dirty bitmap migration and persistence: they need to find whether and which part of the dirty bitmap in question has changed with meta dirty bitmap, and they need to write it to the target with serialization.
Fam Zheng (13):
backup: Use Bitmap to replace "s->bitmap"
block: Includehbitmap.hinblock.h
typedefs: Add BdrvDirtyBitmap
block: Move block dirty bitmap code to separate files
block: Remove unused typedef of BlockDriverDirtyHandler
block: Hide HBitmap in block dirty bitmap interface
HBitmap: Introduce "meta" bitmap to track bit changes
tests: Add test code for meta bitmap
block: Support meta dirty bitmap
block: Add two dirty bitmap getters
block: Assert thatbdrv_release_dirty_bitmapsucceeded
tests: Add test code for hbitmap serialization
block: More operations for meta dirty bitmapVladimir Sementsov-Ogievskiy (2):
hbitmap: serialization
block: BdrvDirtyBitmap serialization interfaceblock.c | 360 ----------------------------- block/Makefile.objs | 2 +- block/backup.c | 25 +- block/dirty-bitmap.c | 535 +++++++++++++++++++++++++++++++++++++++++++ block/mirror.c | 15 +- include/block/block.h | 40 +--- include/block/dirty-bitmap.h | 75 ++++++ include/qemu/hbitmap.h | 96 ++++++++ include/qemu/typedefs.h | 2 + tests/test-hbitmap.c | 255 +++++++++++++++++++++ util/hbitmap.c | 203 ++++++++++++++-- 11 files changed, 1177 insertions(+), 431 deletions(-)create mode 100644
block/dirty-bitmap.c
create mode 100644include/block/dirty-bitmap.h
Signature · 2 lines
Best regards, Vladimir
Quoted 3 lines · Vladimir Sementsov-Ogievskiy
Hi!
Are you going to update the series in the near future?
Yes, probably in a couple days.
Fam
Quoted 57 lines · Fam Zheng
Quoted 48 lines
v4: Rebase.
Add rev-by from John in patches 1-5, 7, 8.
Remove BdrvDirtyBitmap typedef fromdirty-bitmap.hin patch 4. [Max] Add assertion onbm->metain patch 9. [John]Two major features are added to block dirty bitmap (and underlying HBitmap) in this series: meta bitmap and serialization, together with all other supportive patches.
Both operations are common in dirty bitmap migration and persistence: they need to find whether and which part of the dirty bitmap in question has changed with meta dirty bitmap, and they need to write it to the target with serialization.
Fam Zheng (13):
backup: Use Bitmap to replace "s->bitmap"
block: Includehbitmap.hinblock.h
typedefs: Add BdrvDirtyBitmap
block: Move block dirty bitmap code to separate files
block: Remove unused typedef of BlockDriverDirtyHandler
block: Hide HBitmap in block dirty bitmap interface
HBitmap: Introduce "meta" bitmap to track bit changes
tests: Add test code for meta bitmap
block: Support meta dirty bitmap
block: Add two dirty bitmap getters
block: Assert thatbdrv_release_dirty_bitmapsucceeded
tests: Add test code for hbitmap serialization
block: More operations for meta dirty bitmapVladimir Sementsov-Ogievskiy (2):
hbitmap: serialization
block: BdrvDirtyBitmap serialization interfaceblock.c | 360 ----------------------------- block/Makefile.objs | 2 +- block/backup.c | 25 +- block/dirty-bitmap.c | 535 +++++++++++++++++++++++++++++++++++++++++++ block/mirror.c | 15 +- include/block/block.h | 40 +--- include/block/dirty-bitmap.h | 75 ++++++ include/qemu/hbitmap.h | 96 ++++++++ include/qemu/typedefs.h | 2 + tests/test-hbitmap.c | 255 +++++++++++++++++++++ util/hbitmap.c | 203 ++++++++++++++-- 11 files changed, 1177 insertions(+), 431 deletions(-)create mode 100644
block/dirty-bitmap.c
create mode 100644include/block/dirty-bitmap.hSignature · 2 lines
Best regards, Vladimir
Hi, what are the plans?
Quoted 63 lines · Fam Zheng
Quoted 3 lines · Vladimir Sementsov-Ogievskiy
Hi!
Are you going to update the series in the near future?
Yes, probably in a couple days.
Fam
Quoted 55 lines · Fam Zheng
Quoted 48 lines
v4: Rebase.
Add rev-by from John in patches 1-5, 7, 8.
Remove BdrvDirtyBitmap typedef fromdirty-bitmap.hin patch 4. [Max] Add assertion onbm->metain patch 9. [John]Two major features are added to block dirty bitmap (and underlying HBitmap) in this series: meta bitmap and serialization, together with all other supportive patches.
Both operations are common in dirty bitmap migration and persistence: they need to find whether and which part of the dirty bitmap in question has changed with meta dirty bitmap, and they need to write it to the target with serialization.
Fam Zheng (13):
backup: Use Bitmap to replace "s->bitmap"
block: Includehbitmap.hinblock.h
typedefs: Add BdrvDirtyBitmap
block: Move block dirty bitmap code to separate files
block: Remove unused typedef of BlockDriverDirtyHandler
block: Hide HBitmap in block dirty bitmap interface
HBitmap: Introduce "meta" bitmap to track bit changes
tests: Add test code for meta bitmap
block: Support meta dirty bitmap
block: Add two dirty bitmap getters
block: Assert thatbdrv_release_dirty_bitmapsucceeded
tests: Add test code for hbitmap serialization
block: More operations for meta dirty bitmapVladimir Sementsov-Ogievskiy (2):
hbitmap: serialization
block: BdrvDirtyBitmap serialization interfaceblock.c | 360 ----------------------------- block/Makefile.objs | 2 +- block/backup.c | 25 +- block/dirty-bitmap.c | 535 +++++++++++++++++++++++++++++++++++++++++++ block/mirror.c | 15 +- include/block/block.h | 40 +--- include/block/dirty-bitmap.h | 75 ++++++ include/qemu/hbitmap.h | 96 ++++++++ include/qemu/typedefs.h | 2 + tests/test-hbitmap.c | 255 +++++++++++++++++++++ util/hbitmap.c | 203 ++++++++++++++-- 11 files changed, 1177 insertions(+), 431 deletions(-)create mode 100644
block/dirty-bitmap.ccreate mode 100644include/block/dirty-bitmap.hSignature · 2 lines
Best regards, Vladimir
Signature · 2 lines
Best regards, Vladimir
Quoted 2 lines · Vladimir Sementsov-Ogievskiy
Hi, what are the plans?
I'm not sure. Fam, part of this series was merged, wasn't it?
Do you have outstanding work that you'd like me to take over and push through for you?
--js
Quoted 73 lines · Fam Zheng
Quoted 70 lines · Vladimir Sementsov-Ogievskiy
Quoted 3 lines
Hi!
Are you going to update the series in the near future?
Yes, probably in a couple days.
Fam
Quoted 62 lines · Fam Zheng
Quoted 55 lines
v4: Rebase.
Add rev-by from John in patches 1-5, 7, 8.
Remove BdrvDirtyBitmap typedef fromdirty-bitmap.hin patch 4.
[Max]Add assertion on bm->meta in patch 9. [John]Two major features are added to block dirty bitmap (and underlying HBitmap) in
this series: meta bitmap and serialization, together with all other supportive
patches.Both operations are common in dirty bitmap migration and
persistence: they need
to find whether and which part of the dirty bitmap in question has changed with
meta dirty bitmap, and they need to write it to the target with serialization.Fam Zheng (13):
backup: Use Bitmap to replace "s->bitmap"
block: Includehbitmap.hinblock.h
typedefs: Add BdrvDirtyBitmap
block: Move block dirty bitmap code to separate files
block: Remove unused typedef of BlockDriverDirtyHandler
block: Hide HBitmap in block dirty bitmap interface
HBitmap: Introduce "meta" bitmap to track bit changes
tests: Add test code for meta bitmap
block: Support meta dirty bitmap
block: Add two dirty bitmap getters
block: Assert thatbdrv_release_dirty_bitmapsucceeded
tests: Add test code for hbitmap serialization
block: More operations for meta dirty bitmapVladimir Sementsov-Ogievskiy (2):
hbitmap: serialization
block: BdrvDirtyBitmap serialization interfaceblock.c | 360 ----------------------------- block/Makefile.objs | 2 +- block/backup.c | 25 +- block/dirty-bitmap.c | 535 +++++++++++++++++++++++++++++++++++++++++++ block/mirror.c | 15 +- include/block/block.h | 40 +--- include/block/dirty-bitmap.h | 75 ++++++ include/qemu/hbitmap.h | 96 ++++++++ include/qemu/typedefs.h | 2 + tests/test-hbitmap.c | 255 +++++++++++++++++++++ util/hbitmap.c | 203 ++++++++++++++-- 11 files changed, 1177 insertions(+), 431 deletions(-)create mode 100644
block/dirty-bitmap.ccreate mode 100644include/block/dirty-bitmap.hSignature · 2 lines
Best regards, Vladimir
Signature · 1 line
—js
Quoted 10 lines · John Snow
Quoted 2 lines · Vladimir Sementsov-Ogievskiy
Hi, what are the plans?
I'm not sure. Fam, part of this series was merged, wasn't it?
Do you have outstanding work that you'd like me to take over and push through for you?
I will rebase patches 6 - 15, address comments from Max on this revision and send v5 soon. You are very welcome to take over from there! Thanks a lot!
Fam
Quoted 79 lines
--js
Quoted 73 lines · Fam Zheng
Quoted 70 lines · Vladimir Sementsov-Ogievskiy
Quoted 3 lines
Hi!
Are you going to update the series in the near future?
Yes, probably in a couple days.
Fam
Quoted 62 lines · Fam Zheng
Quoted 55 lines
v4: Rebase.
Add rev-by from John in patches 1-5, 7, 8.
Remove BdrvDirtyBitmap typedef fromdirty-bitmap.hin patch 4.
[Max]Add assertion on bm->meta in patch 9. [John]Two major features are added to block dirty bitmap (and underlying HBitmap) in
this series: meta bitmap and serialization, together with all other supportive
patches.Both operations are common in dirty bitmap migration and
persistence: they need
to find whether and which part of the dirty bitmap in question has changed with
meta dirty bitmap, and they need to write it to the target with serialization.Fam Zheng (13):
backup: Use Bitmap to replace "s->bitmap"
block: Includehbitmap.hinblock.h
typedefs: Add BdrvDirtyBitmap
block: Move block dirty bitmap code to separate files
block: Remove unused typedef of BlockDriverDirtyHandler
block: Hide HBitmap in block dirty bitmap interface
HBitmap: Introduce "meta" bitmap to track bit changes
tests: Add test code for meta bitmap
block: Support meta dirty bitmap
block: Add two dirty bitmap getters
block: Assert thatbdrv_release_dirty_bitmapsucceeded
tests: Add test code for hbitmap serialization
block: More operations for meta dirty bitmapVladimir Sementsov-Ogievskiy (2):
hbitmap: serialization
block: BdrvDirtyBitmap serialization interfaceblock.c | 360 ----------------------------- block/Makefile.objs | 2 +- block/backup.c | 25 +- block/dirty-bitmap.c | 535 +++++++++++++++++++++++++++++++++++++++++++ block/mirror.c | 15 +- include/block/block.h | 40 +--- include/block/dirty-bitmap.h | 75 ++++++ include/qemu/hbitmap.h | 96 ++++++++ include/qemu/typedefs.h | 2 + tests/test-hbitmap.c | 255 +++++++++++++++++++++ util/hbitmap.c | 203 ++++++++++++++-- 11 files changed, 1177 insertions(+), 431 deletions(-)create mode 100644
block/dirty-bitmap.ccreate mode 100644include/block/dirty-bitmap.hSignature · 2 lines
Best regards, VladimirSignature · 1 line
—js