[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 19/33] block/copy-before-write: initialize block-copy bitmap
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v7 19/33] block/copy-before-write: initialize block-copy bitmap |
Date: |
Wed, 4 Aug 2021 12:37:59 +0300 |
We are going to publish copy-before-write filter to be used in separate
of backup. Future step would support bitmap for the filter. But let's
start from full set bitmap.
We have to modify backup, as bitmap is first initialized by
copy-before-write filter, and then backup modifies it.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
block/backup.c | 16 +++++++---------
block/copy-before-write.c | 4 ++++
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/block/backup.c b/block/backup.c
index 4869f1e5da..687d2882bc 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -233,18 +233,16 @@ static void backup_init_bcs_bitmap(BackupBlockJob *job)
BdrvDirtyBitmap *bcs_bitmap = block_copy_dirty_bitmap(job->bcs);
if (job->sync_mode == MIRROR_SYNC_MODE_BITMAP) {
+ bdrv_clear_dirty_bitmap(bcs_bitmap, NULL);
ret = bdrv_dirty_bitmap_merge_internal(bcs_bitmap, job->sync_bitmap,
NULL, true);
assert(ret);
- } else {
- if (job->sync_mode == MIRROR_SYNC_MODE_TOP) {
- /*
- * We can't hog the coroutine to initialize this thoroughly.
- * Set a flag and resume work when we are able to yield safely.
- */
- block_copy_set_skip_unallocated(job->bcs, true);
- }
- bdrv_set_dirty_bitmap(bcs_bitmap, 0, job->len);
+ } else if (job->sync_mode == MIRROR_SYNC_MODE_TOP) {
+ /*
+ * We can't hog the coroutine to initialize this thoroughly.
+ * Set a flag and resume work when we are able to yield safely.
+ */
+ block_copy_set_skip_unallocated(job->bcs, true);
}
estimate = bdrv_get_dirty_count(bcs_bitmap);
diff --git a/block/copy-before-write.c b/block/copy-before-write.c
index 1cefcade78..2efe098aae 100644
--- a/block/copy-before-write.c
+++ b/block/copy-before-write.c
@@ -147,6 +147,7 @@ static void cbw_child_perm(BlockDriverState *bs, BdrvChild
*c,
static int cbw_init(BlockDriverState *bs, QDict *options, Error **errp)
{
BDRVCopyBeforeWriteState *s = bs->opaque;
+ BdrvDirtyBitmap *copy_bitmap;
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds,
BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
@@ -174,6 +175,9 @@ static int cbw_init(BlockDriverState *bs, QDict *options,
Error **errp)
return -EINVAL;
}
+ copy_bitmap = block_copy_dirty_bitmap(s->bcs);
+ bdrv_set_dirty_bitmap(copy_bitmap, 0, bdrv_dirty_bitmap_size(copy_bitmap));
+
return 0;
}
--
2.29.2
- [PATCH v7 16/33] block/copy-before-write: cbw_init(): use file child after attaching, (continued)
- [PATCH v7 16/33] block/copy-before-write: cbw_init(): use file child after attaching, Vladimir Sementsov-Ogievskiy, 2021/08/04
- [PATCH v7 14/33] block/copy-before-write: introduce cbw_init(), Vladimir Sementsov-Ogievskiy, 2021/08/04
- [PATCH v7 17/33] block/copy-before-write: bdrv_cbw_append(): drop unused compress arg, Vladimir Sementsov-Ogievskiy, 2021/08/04
- [PATCH v7 20/33] block/block-copy: make setting progress optional, Vladimir Sementsov-Ogievskiy, 2021/08/04
- [PATCH v7 18/33] block/copy-before-write: cbw_init(): use options, Vladimir Sementsov-Ogievskiy, 2021/08/04
- [PATCH v7 21/33] block/copy-before-write: make public block driver, Vladimir Sementsov-Ogievskiy, 2021/08/04
- [PATCH v7 19/33] block/copy-before-write: initialize block-copy bitmap,
Vladimir Sementsov-Ogievskiy <=
- [PATCH v7 22/33] qapi: publish copy-before-write filter, Vladimir Sementsov-Ogievskiy, 2021/08/04
- [PATCH v7 23/33] python/qemu/machine.py: refactor _qemu_args(), Vladimir Sementsov-Ogievskiy, 2021/08/04
- [PATCH v7 28/33] iotests: move 222 to tests/image-fleecing, Vladimir Sementsov-Ogievskiy, 2021/08/04
- [PATCH v7 24/33] python/qemu/machine: QEMUMachine: improve qmp() method, Vladimir Sementsov-Ogievskiy, 2021/08/04
- [PATCH v7 25/33] iotests.py: VM: add own __enter__ method, Vladimir Sementsov-Ogievskiy, 2021/08/04
- [PATCH v7 29/33] iotests.py: hmp_qemu_io: support qdev, Vladimir Sementsov-Ogievskiy, 2021/08/04