@@ -25,7 +25,8 @@ typedef struct BlockCopyState BlockCopyState;
typedef struct BlockCopyCallState BlockCopyCallState;
BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
- BdrvDirtyBitmap *bitmap, Error **errp);
+ BdrvDirtyBitmap *bitmap,
+ bool write_unchanged, Error **errp);
/* Function should be called prior any actual copy request */
void block_copy_set_copy_opts(BlockCopyState *s, bool use_copy_range,
@@ -279,7 +279,8 @@ void block_copy_set_copy_opts(BlockCopyState *s, bool use_copy_range,
bool compress)
{
/* Keep BDRV_REQ_SERIALISING set (or not set) in block_copy_state_new() */
- s->write_flags = (s->write_flags & BDRV_REQ_SERIALISING) |
+ s->write_flags = (s->write_flags &
+ (BDRV_REQ_SERIALISING | BDRV_REQ_WRITE_UNCHANGED)) |
(compress ? BDRV_REQ_WRITE_COMPRESSED : 0);
if (s->max_transfer < s->cluster_size) {
@@ -340,7 +341,8 @@ static int64_t block_copy_calculate_cluster_size(BlockDriverState *target,
}
BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
- BdrvDirtyBitmap *bitmap, Error **errp)
+ BdrvDirtyBitmap *bitmap,
+ bool write_unchanged, Error **errp)
{
ERRP_GUARD();
BlockCopyState *s;
@@ -393,7 +395,8 @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
.copy_bitmap = copy_bitmap,
.cluster_size = cluster_size,
.len = bdrv_dirty_bitmap_size(copy_bitmap),
- .write_flags = (is_fleecing ? BDRV_REQ_SERIALISING : 0),
+ .write_flags = (is_fleecing ? BDRV_REQ_SERIALISING : 0) |
+ (write_unchanged ? BDRV_REQ_WRITE_UNCHANGED : 0),
.mem = shres_create(BLOCK_COPY_MAX_MEM),
.max_transfer = QEMU_ALIGN_DOWN(
block_copy_max_transfer(source, target),
@@ -212,7 +212,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, bitmap, errp);
+ s->bcs = block_copy_state_new(bs->file, s->target, bitmap, false, errp);
if (!s->bcs) {
error_prepend(errp, "Cannot create block-copy-state: ");
return -EINVAL;
We are going to implement push backup with fleecing scheme. This means that backup job will be a fleecing user and therefore will not need separate copy-before-write filter. Instead it will consider source as constant unchanged drive. Of course backup will want to unshare writes on source for this case. But we want to do copy-before-write operations. Still these operations may be considered as write-unchanged. Add corresponding option to block-copy now, to use in the following commit. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> --- include/block/block-copy.h | 3 ++- block/block-copy.c | 9 ++++++--- block/copy-before-write.c | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-)