]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/pve/0049-backup-add-minimum-cluster-size-to-performance-optio.patch
fix #5409: backup: fix copy-before-write timeout
[pve-qemu.git] / debian / patches / pve / 0049-backup-add-minimum-cluster-size-to-performance-optio.patch
CommitLineData
20209d8d
TL
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Fiona Ebner <f.ebner@proxmox.com>
3Date: Thu, 11 Apr 2024 11:29:27 +0200
4Subject: [PATCH] backup: add minimum cluster size to performance options
5
6Useful to make discard-source work in the context of backup fleecing
7when the fleecing image has a larger granularity than the backup
8target.
9
10Backup/block-copy will use at least this granularity for copy operations
11and in particular, discard requests to the backup source will too. If
12the granularity is too small, they will just be aligned down in
13cbw_co_pdiscard_snapshot() and thus effectively ignored.
14
15Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
16Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
17---
18 block/backup.c | 2 +-
19 block/copy-before-write.c | 2 ++
20 block/copy-before-write.h | 1 +
21 blockdev.c | 3 +++
22 qapi/block-core.json | 9 +++++++--
23 5 files changed, 14 insertions(+), 3 deletions(-)
24
25diff --git a/block/backup.c b/block/backup.c
4fbd50e2 26index 1963e47ab9..fe69723ada 100644
20209d8d
TL
27--- a/block/backup.c
28+++ b/block/backup.c
f1eed34a 29@@ -434,7 +434,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
20209d8d
TL
30 }
31
32 cbw = bdrv_cbw_append(bs, target, filter_node_name, discard_source,
33- &bcs, errp);
34+ perf->min_cluster_size, &bcs, errp);
35 if (!cbw) {
36 goto error;
37 }
38diff --git a/block/copy-before-write.c b/block/copy-before-write.c
51232e2e 39index 47b3cdd09f..bba58326d7 100644
20209d8d
TL
40--- a/block/copy-before-write.c
41+++ b/block/copy-before-write.c
4fbd50e2 42@@ -546,6 +546,7 @@ BlockDriverState *bdrv_cbw_append(BlockDriverState *source,
20209d8d
TL
43 BlockDriverState *target,
44 const char *filter_node_name,
45 bool discard_source,
46+ int64_t min_cluster_size,
47 BlockCopyState **bcs,
48 Error **errp)
49 {
4fbd50e2 50@@ -564,6 +565,7 @@ BlockDriverState *bdrv_cbw_append(BlockDriverState *source,
20209d8d
TL
51 }
52 qdict_put_str(opts, "file", bdrv_get_node_name(source));
53 qdict_put_str(opts, "target", bdrv_get_node_name(target));
54+ qdict_put_int(opts, "min-cluster-size", min_cluster_size);
55
56 top = bdrv_insert_node(source, opts, flags, errp);
57 if (!top) {
58diff --git a/block/copy-before-write.h b/block/copy-before-write.h
59index 01af0cd3c4..dc6cafe7fa 100644
60--- a/block/copy-before-write.h
61+++ b/block/copy-before-write.h
62@@ -40,6 +40,7 @@ BlockDriverState *bdrv_cbw_append(BlockDriverState *source,
63 BlockDriverState *target,
64 const char *filter_node_name,
65 bool discard_source,
66+ int64_t min_cluster_size,
67 BlockCopyState **bcs,
68 Error **errp);
69 void bdrv_cbw_drop(BlockDriverState *bs);
70diff --git a/blockdev.c b/blockdev.c
4fbd50e2 71index 1054a69279..cbe224387b 100644
20209d8d
TL
72--- a/blockdev.c
73+++ b/blockdev.c
4fbd50e2 74@@ -2654,6 +2654,9 @@ static BlockJob *do_backup_common(BackupCommon *backup,
20209d8d
TL
75 if (backup->x_perf->has_max_chunk) {
76 perf.max_chunk = backup->x_perf->max_chunk;
77 }
78+ if (backup->x_perf->has_min_cluster_size) {
79+ perf.min_cluster_size = backup->x_perf->min_cluster_size;
80+ }
81 }
82
83 if ((backup->sync == MIRROR_SYNC_MODE_BITMAP) ||
84diff --git a/qapi/block-core.json b/qapi/block-core.json
4fbd50e2 85index edbf6e78b9..6e7ee87633 100644
20209d8d
TL
86--- a/qapi/block-core.json
87+++ b/qapi/block-core.json
4fbd50e2 88@@ -1790,11 +1790,16 @@
20209d8d
TL
89 # it should not be less than job cluster size which is calculated
90 # as maximum of target image cluster size and 64k. Default 0.
91 #
92+# @min-cluster-size: Minimum size of blocks used by copy-before-write
93+# and background copy operations. Has to be a power of 2. No
94+# effect if smaller than the maximum of the target's cluster size
95+# and 64 KiB. Default 0. (Since 8.1)
96+#
97 # Since: 6.0
98 ##
99 { 'struct': 'BackupPerf',
100- 'data': { '*use-copy-range': 'bool',
101- '*max-workers': 'int', '*max-chunk': 'int64' } }
102+ 'data': { '*use-copy-range': 'bool', '*max-workers': 'int',
103+ '*max-chunk': 'int64', '*min-cluster-size': 'uint32' } }
104
105 ##
106 # @BackupCommon: