]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/pve/0051-backup-add-minimum-cluster-size-to-performance-optio.patch
backup: improve error when copy-before-write fails for fleecing
[pve-qemu.git] / debian / patches / pve / 0051-backup-add-minimum-cluster-size-to-performance-optio.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Fiona Ebner <f.ebner@proxmox.com>
3 Date: Thu, 11 Apr 2024 11:29:27 +0200
4 Subject: [PATCH] backup: add minimum cluster size to performance options
5
6 Useful to make discard-source work in the context of backup fleecing
7 when the fleecing image has a larger granularity than the backup
8 target.
9
10 Backup/block-copy will use at least this granularity for copy operations
11 and in particular, discard requests to the backup source will too. If
12 the granularity is too small, they will just be aligned down in
13 cbw_co_pdiscard_snapshot() and thus effectively ignored.
14
15 Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
16 Signed-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
25 diff --git a/block/backup.c b/block/backup.c
26 index 3dc955f625..ac5bd81338 100644
27 --- a/block/backup.c
28 +++ b/block/backup.c
29 @@ -430,7 +430,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
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 }
38 diff --git a/block/copy-before-write.c b/block/copy-before-write.c
39 index 4a8c5bdb62..9ca5ec5e5c 100644
40 --- a/block/copy-before-write.c
41 +++ b/block/copy-before-write.c
42 @@ -555,6 +555,7 @@ BlockDriverState *bdrv_cbw_append(BlockDriverState *source,
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 {
50 @@ -573,6 +574,7 @@ BlockDriverState *bdrv_cbw_append(BlockDriverState *source,
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) {
58 diff --git a/block/copy-before-write.h b/block/copy-before-write.h
59 index 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);
70 diff --git a/blockdev.c b/blockdev.c
71 index ce3fef924c..5ae1dde73c 100644
72 --- a/blockdev.c
73 +++ b/blockdev.c
74 @@ -2729,6 +2729,9 @@ static BlockJob *do_backup_common(BackupCommon *backup,
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) ||
84 diff --git a/qapi/block-core.json b/qapi/block-core.json
85 index 33e7e3c090..58fd637e86 100644
86 --- a/qapi/block-core.json
87 +++ b/qapi/block-core.json
88 @@ -1757,11 +1757,16 @@
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: