[pve-devel] [HACK qemu 07/13] block/block-copy: always consider source cluster size too
Fiona Ebner
f.ebner at proxmox.com
Thu Jan 25 15:41:43 CET 2024
With backup fleecing, it might be necessary to discard the source.
There will be an assertion failure if bitmaps on the source side have
a bigger granularity than the block copy's cluster size, so just
consider the source side too.
This also supersedes the hunk in block/backup.c added by
"PVE-Backup: add backup-dump block driver".
Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
Still need to wait on a response from upstream. For now this hack, so
that the RFC as a whole doesn't have to wait.
block/backup.c | 8 --------
block/block-copy.c | 22 ++++++++++++++--------
2 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/block/backup.c b/block/backup.c
index 51f9d28115..7950bff27e 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -435,14 +435,6 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
}
cluster_size = block_copy_cluster_size(bcs);
- if (cluster_size < 0) {
- goto error;
- }
-
- BlockDriverInfo bdi;
- if (bdrv_get_info(bs, &bdi) == 0) {
- cluster_size = MAX(cluster_size, bdi.cluster_size);
- }
if (perf->max_chunk && perf->max_chunk < cluster_size) {
error_setg(errp, "Required max-chunk (%" PRIi64 ") is less than backup "
diff --git a/block/block-copy.c b/block/block-copy.c
index 05cfccfda8..cf750ef670 100644
--- a/block/block-copy.c
+++ b/block/block-copy.c
@@ -310,13 +310,19 @@ void block_copy_set_copy_opts(BlockCopyState *s, bool use_copy_range,
}
}
-static int64_t block_copy_calculate_cluster_size(BlockDriverState *target,
+static int64_t block_copy_calculate_cluster_size(BlockDriverState *source,
+ BlockDriverState *target,
Error **errp)
{
int ret;
+ int64_t source_cluster_size = BLOCK_COPY_CLUSTER_SIZE_DEFAULT;
BlockDriverInfo bdi;
bool target_does_cow = bdrv_backing_chain_next(target);
+ if (bdrv_get_info(source, &bdi) == 0) {
+ source_cluster_size = MAX(source_cluster_size, bdi.cluster_size);
+ }
+
/*
* If there is no backing file on the target, we cannot rely on COW if our
* backup cluster size is smaller than the target cluster size. Even for
@@ -327,11 +333,11 @@ static int64_t block_copy_calculate_cluster_size(BlockDriverState *target,
/* Cluster size is not defined */
warn_report("The target block device doesn't provide "
"information about the block size and it doesn't have a "
- "backing file. The default block size of %u bytes is "
+ "backing file. The source's or default block size of %ld bytes is "
"used. If the actual block size of the target exceeds "
- "this default, the backup may be unusable",
- BLOCK_COPY_CLUSTER_SIZE_DEFAULT);
- return BLOCK_COPY_CLUSTER_SIZE_DEFAULT;
+ "this value, the backup may be unusable",
+ source_cluster_size);
+ return source_cluster_size;
} else if (ret < 0 && !target_does_cow) {
error_setg_errno(errp, -ret,
"Couldn't determine the cluster size of the target image, "
@@ -341,10 +347,10 @@ static int64_t block_copy_calculate_cluster_size(BlockDriverState *target,
return ret;
} else if (ret < 0 && target_does_cow) {
/* Not fatal; just trudge on ahead. */
- return BLOCK_COPY_CLUSTER_SIZE_DEFAULT;
+ return source_cluster_size;
}
- return MAX(BLOCK_COPY_CLUSTER_SIZE_DEFAULT, bdi.cluster_size);
+ return MAX(source_cluster_size, bdi.cluster_size);
}
BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
@@ -358,7 +364,7 @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
BdrvDirtyBitmap *copy_bitmap;
bool is_fleecing;
- cluster_size = block_copy_calculate_cluster_size(target->bs, errp);
+ cluster_size = block_copy_calculate_cluster_size(source->bs, target->bs, errp);
if (cluster_size < 0) {
return NULL;
}
--
2.39.2
More information about the pve-devel
mailing list