[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 03/19] block/block-copy: block_copy_state_new(): add bitmap pa
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v2 03/19] block/block-copy: block_copy_state_new(): add bitmap parameter |
Date: |
Fri, 27 Aug 2021 21:17:52 +0300 |
This will be used in the following commit to bring "incremental" mode
to copy-before-write filter.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
include/block/block-copy.h | 2 +-
block/block-copy.c | 14 ++++++++++++--
block/copy-before-write.c | 2 +-
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/include/block/block-copy.h b/include/block/block-copy.h
index 99370fa38b..8da4cec1b6 100644
--- a/include/block/block-copy.h
+++ b/include/block/block-copy.h
@@ -25,7 +25,7 @@ typedef struct BlockCopyState BlockCopyState;
typedef struct BlockCopyCallState BlockCopyCallState;
BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
- Error **errp);
+ BdrvDirtyBitmap *bitmap, Error **errp);
/* Function should be called prior any actual copy request */
void block_copy_set_copy_opts(BlockCopyState *s, bool use_copy_range,
diff --git a/block/block-copy.c b/block/block-copy.c
index c39cb5fda7..65019d0d1d 100644
--- a/block/block-copy.c
+++ b/block/block-copy.c
@@ -383,8 +383,9 @@ static int64_t
block_copy_calculate_cluster_size(BlockDriverState *target,
}
BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
- Error **errp)
+ BdrvDirtyBitmap *bitmap, Error **errp)
{
+ ERRP_GUARD();
BlockCopyState *s;
int64_t cluster_size;
BdrvDirtyBitmap *copy_bitmap;
@@ -401,7 +402,16 @@ BlockCopyState *block_copy_state_new(BdrvChild *source,
BdrvChild *target,
return NULL;
}
bdrv_disable_dirty_bitmap(copy_bitmap);
- bdrv_set_dirty_bitmap(copy_bitmap, 0, bdrv_dirty_bitmap_size(copy_bitmap));
+ if (bitmap) {
+ if (!bdrv_merge_dirty_bitmap(copy_bitmap, bitmap, NULL, errp)) {
+ error_prepend(errp, "Failed to merge bitmap '%s' to internal "
+ "copy-bitmap: ", bdrv_dirty_bitmap_name(bitmap));
+ return NULL;
+ }
+ } else {
+ bdrv_set_dirty_bitmap(copy_bitmap, 0,
+ bdrv_dirty_bitmap_size(copy_bitmap));
+ }
/*
* If source is in backing chain of target assume that target is going to
be
diff --git a/block/copy-before-write.c b/block/copy-before-write.c
index f5551cd15b..d31ca61111 100644
--- a/block/copy-before-write.c
+++ b/block/copy-before-write.c
@@ -169,7 +169,7 @@ static int cbw_open(BlockDriverState *bs, QDict *options,
int flags,
((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) &
bs->file->bs->supported_zero_flags);
- s->bcs = block_copy_state_new(bs->file, s->target, errp);
+ s->bcs = block_copy_state_new(bs->file, s->target, NULL, errp);
if (!s->bcs) {
error_prepend(errp, "Cannot create block-copy-state: ");
return -EINVAL;
--
2.29.2
- [PATCH v2 00/19] Make image fleecing more usable, Vladimir Sementsov-Ogievskiy, 2021/08/27
- [PATCH v2 01/19] block/block-copy: move copy_bitmap initialization to block_copy_state_new(), Vladimir Sementsov-Ogievskiy, 2021/08/27
- [PATCH v2 03/19] block/block-copy: block_copy_state_new(): add bitmap parameter,
Vladimir Sementsov-Ogievskiy <=
- [PATCH v2 02/19] block/dirty-bitmap: bdrv_merge_dirty_bitmap(): add return value, Vladimir Sementsov-Ogievskiy, 2021/08/27
- [PATCH v2 04/19] block/copy-before-write: add bitmap open parameter, Vladimir Sementsov-Ogievskiy, 2021/08/27
- [PATCH v2 05/19] block/block-copy: add block_copy_reset(), Vladimir Sementsov-Ogievskiy, 2021/08/27
- [PATCH v2 13/19] block/copy-before-write: use write-unchanged in fleecing mode, Vladimir Sementsov-Ogievskiy, 2021/08/27
- [PATCH v2 06/19] block: intoduce reqlist, Vladimir Sementsov-Ogievskiy, 2021/08/27
- [PATCH v2 07/19] block/dirty-bitmap: introduce bdrv_dirty_bitmap_status(), Vladimir Sementsov-Ogievskiy, 2021/08/27
- [PATCH v2 11/19] block/copy-before-write: support fleecing block driver, Vladimir Sementsov-Ogievskiy, 2021/08/27
- [PATCH v2 09/19] block: introduce FleecingState class, Vladimir Sementsov-Ogievskiy, 2021/08/27
- [PATCH v2 16/19] iotests/image-fleecing: add test case with bitmap, Vladimir Sementsov-Ogievskiy, 2021/08/27
- [PATCH v2 14/19] iotests/image-fleecing: add test-case for fleecing format node, Vladimir Sementsov-Ogievskiy, 2021/08/27