aboutsummaryrefslogtreecommitdiff
path: root/block/copy-before-write.c
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2021-08-24 11:38:31 +0300
committerHanna Reitz <hreitz@redhat.com>2021-09-01 14:03:11 +0200
commitb518e9e9ef7a28aa559a05d44dd734e83ae75f9d (patch)
tree11eb3251f94ac482e3a4c4a0bd368bb71896de03 /block/copy-before-write.c
parent2a6511dfeb0d1bd10211b264177afbc360f9bd9d (diff)
block/backup: move cluster size calculation to block-copy
The main consumer of cluster-size is block-copy. Let's calculate it here instead of passing through backup-top. We are going to publish copy-before-write filter soon, so it will be created through options. But we don't want for now to make explicit option for cluster-size, let's continue to calculate it automatically. So, now is the time to get rid of cluster_size argument for bdrv_cbw_append(). Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20210824083856.17408-10-vsementsov@virtuozzo.com> [hreitz: Add qemu/error-report.h include to block/block-copy.c] Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Diffstat (limited to 'block/copy-before-write.c')
-rw-r--r--block/copy-before-write.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/block/copy-before-write.c b/block/copy-before-write.c
index 235251a640..a7996d54db 100644
--- a/block/copy-before-write.c
+++ b/block/copy-before-write.c
@@ -37,7 +37,6 @@
typedef struct BDRVCopyBeforeWriteState {
BlockCopyState *bcs;
BdrvChild *target;
- int64_t cluster_size;
} BDRVCopyBeforeWriteState;
static coroutine_fn int cbw_co_preadv(
@@ -52,13 +51,14 @@ static coroutine_fn int cbw_do_copy_before_write(BlockDriverState *bs,
{
BDRVCopyBeforeWriteState *s = bs->opaque;
uint64_t off, end;
+ int64_t cluster_size = block_copy_cluster_size(s->bcs);
if (flags & BDRV_REQ_WRITE_UNCHANGED) {
return 0;
}
- off = QEMU_ALIGN_DOWN(offset, s->cluster_size);
- end = QEMU_ALIGN_UP(offset + bytes, s->cluster_size);
+ off = QEMU_ALIGN_DOWN(offset, cluster_size);
+ end = QEMU_ALIGN_UP(offset + bytes, cluster_size);
return block_copy(s->bcs, off, end - off, true);
}
@@ -169,7 +169,6 @@ BlockDriver bdrv_cbw_filter = {
BlockDriverState *bdrv_cbw_append(BlockDriverState *source,
BlockDriverState *target,
const char *filter_node_name,
- uint64_t cluster_size,
bool compress,
BlockCopyState **bcs,
Error **errp)
@@ -214,9 +213,8 @@ BlockDriverState *bdrv_cbw_append(BlockDriverState *source,
}
appended = true;
- state->cluster_size = cluster_size;
state->bcs = block_copy_state_new(top->backing, state->target,
- cluster_size, false, compress, errp);
+ false, compress, errp);
if (!state->bcs) {
error_prepend(errp, "Cannot create block-copy-state: ");
goto fail;