[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 04/19] block/copy-before-write: add bitmap open parameter
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v2 04/19] block/copy-before-write: add bitmap open parameter |
Date: |
Fri, 27 Aug 2021 21:17:53 +0300 |
This brings "incremental" mode to copy-before-write filter: user can
specify bitmap so that filter will copy only "dirty" areas.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
qapi/block-core.json | 10 +++++++++-
block/copy-before-write.c | 30 +++++++++++++++++++++++++++++-
2 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 6764d8b84f..c42d23752d 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -4063,11 +4063,19 @@
#
# @target: The target for copy-before-write operations.
#
+# @bitmap: If specified, copy-before-write filter will do
+# copy-before-write operations only for dirty regions of the
+# bitmap. Bitmap size must be equal to length of file and
+# target child of the filter. Note also, that bitmap is used
+# only to initialize internal bitmap of the process, so further
+# modifications (or removing) of specified bitmap doesn't
+# influence the filter.
+#
# Since: 6.2
##
{ 'struct': 'BlockdevOptionsCbw',
'base': 'BlockdevOptionsGenericFormat',
- 'data': { 'target': 'BlockdevRef' } }
+ 'data': { 'target': 'BlockdevRef', '*bitmap': 'BlockDirtyBitmap' } }
##
# @BlockdevOptions:
diff --git a/block/copy-before-write.c b/block/copy-before-write.c
index d31ca61111..e3456ad6aa 100644
--- a/block/copy-before-write.c
+++ b/block/copy-before-write.c
@@ -148,6 +148,7 @@ static int cbw_open(BlockDriverState *bs, QDict *options,
int flags,
Error **errp)
{
BDRVCopyBeforeWriteState *s = bs->opaque;
+ BdrvDirtyBitmap *bitmap = NULL;
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds,
BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
@@ -162,6 +163,33 @@ static int cbw_open(BlockDriverState *bs, QDict *options,
int flags,
return -EINVAL;
}
+ if (qdict_haskey(options, "bitmap.node") ||
+ qdict_haskey(options, "bitmap.name"))
+ {
+ const char *bitmap_node, *bitmap_name;
+
+ if (!qdict_haskey(options, "bitmap.node")) {
+ error_setg(errp, "bitmap.node is not specified");
+ return -EINVAL;
+ }
+
+ if (!qdict_haskey(options, "bitmap.name")) {
+ error_setg(errp, "bitmap.name is not specified");
+ return -EINVAL;
+ }
+
+ bitmap_node = qdict_get_str(options, "bitmap.node");
+ bitmap_name = qdict_get_str(options, "bitmap.name");
+ qdict_del(options, "bitmap.node");
+ qdict_del(options, "bitmap.name");
+
+ bitmap = block_dirty_bitmap_lookup(bitmap_node, bitmap_name, NULL,
+ errp);
+ if (!bitmap) {
+ return -EINVAL;
+ }
+ }
+
bs->total_sectors = bs->file->bs->total_sectors;
bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED |
(BDRV_REQ_FUA & bs->file->bs->supported_write_flags);
@@ -169,7 +197,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, NULL, errp);
+ s->bcs = block_copy_state_new(bs->file, s->target, bitmap, 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, 2021/08/27
- [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 <=
- [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
- [PATCH v2 18/19] qapi: backup: add immutable-source parameter, Vladimir Sementsov-Ogievskiy, 2021/08/27
- [PATCH v2 19/19] iotests/image-fleecing: test push backup with fleecing, Vladimir Sementsov-Ogievskiy, 2021/08/27