[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/23] block/block-copy: block_copy_state_new(): add bitmap parame
From: |
Hanna Reitz |
Subject: |
[PULL 10/23] block/block-copy: block_copy_state_new(): add bitmap parameter |
Date: |
Mon, 7 Mar 2022 11:35:36 +0100 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
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>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20220303194349.2304213-4-vsementsov@virtuozzo.com>
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
---
include/block/block-copy.h | 1 +
block/block-copy.c | 14 +++++++++++++-
block/copy-before-write.c | 2 +-
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/include/block/block-copy.h b/include/block/block-copy.h
index 99370fa38b..b80ad02299 100644
--- a/include/block/block-copy.h
+++ b/include/block/block-copy.h
@@ -25,6 +25,7 @@ typedef struct BlockCopyState BlockCopyState;
typedef struct BlockCopyCallState BlockCopyCallState;
BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
+ const BdrvDirtyBitmap *bitmap,
Error **errp);
/* Function should be called prior any actual copy request */
diff --git a/block/block-copy.c b/block/block-copy.c
index abda7a80bd..8aa6ee6a5c 100644
--- a/block/block-copy.c
+++ b/block/block-copy.c
@@ -384,8 +384,10 @@ static int64_t
block_copy_calculate_cluster_size(BlockDriverState *target,
}
BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
+ const BdrvDirtyBitmap *bitmap,
Error **errp)
{
+ ERRP_GUARD();
BlockCopyState *s;
int64_t cluster_size;
BdrvDirtyBitmap *copy_bitmap;
@@ -402,7 +404,17 @@ 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));
+ bdrv_release_dirty_bitmap(copy_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 8ea2548ed9..1af0c7e5c0 100644
--- a/block/copy-before-write.c
+++ b/block/copy-before-write.c
@@ -170,7 +170,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.34.1
- [PULL 00/23] Block patches, Hanna Reitz, 2022/03/07
- [PULL 05/23] tests/qemu-iotests/040: Skip TestCommitWithFilters without 'throttle', Hanna Reitz, 2022/03/07
- [PULL 04/23] block: fix preallocate filter: don't do unaligned preallocate requests, Hanna Reitz, 2022/03/07
- [PULL 01/23] ide: Increment BB in-flight counter for TRIM BH, Hanna Reitz, 2022/03/07
- [PULL 02/23] block/curl.c: Set error message string if curl_init_state() fails, Hanna Reitz, 2022/03/07
- [PULL 03/23] block/curl.c: Check error return from curl_easy_setopt(), Hanna Reitz, 2022/03/07
- [PULL 07/23] iotests: Write test output to TEST_DIR, Hanna Reitz, 2022/03/07
- [PULL 06/23] tests/qemu-iotests/testrunner: Quote "case not run" lines in TAP mode, Hanna Reitz, 2022/03/07
- [PULL 09/23] block/dirty-bitmap: bdrv_merge_dirty_bitmap(): add return value, Hanna Reitz, 2022/03/07
- [PULL 10/23] block/block-copy: block_copy_state_new(): add bitmap parameter,
Hanna Reitz <=
- [PULL 12/23] block/block-copy: add block_copy_reset(), Hanna Reitz, 2022/03/07
- [PULL 13/23] block: intoduce reqlist, Hanna Reitz, 2022/03/07
- [PULL 11/23] block/copy-before-write: add bitmap open parameter, Hanna Reitz, 2022/03/07
- [PULL 16/23] block/reqlist: add reqlist_wait_all(), Hanna Reitz, 2022/03/07
- [PULL 17/23] block/io: introduce block driver snapshot-access API, Hanna Reitz, 2022/03/07
- [PULL 22/23] iotests/image-fleecing: add test case with bitmap, Hanna Reitz, 2022/03/07
- [PULL 14/23] block/reqlist: reqlist_find_conflict(): use ranges_overlap(), Hanna Reitz, 2022/03/07
- [PULL 18/23] block: introduce snapshot-access block driver, Hanna Reitz, 2022/03/07
- [PULL 20/23] iotests/image-fleecing: add test-case for fleecing format node, Hanna Reitz, 2022/03/07
- [PULL 21/23] iotests.py: add qemu_io_pipe_and_status(), Hanna Reitz, 2022/03/07