]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/pve/0048-block-copy-before-write-create-block_copy-bitmap-in-.patch
backup: improve error when copy-before-write fails for fleecing
[pve-qemu.git] / debian / patches / pve / 0048-block-copy-before-write-create-block_copy-bitmap-in-.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
3 Date: Thu, 11 Apr 2024 11:29:24 +0200
4 Subject: [PATCH] block/copy-before-write: create block_copy bitmap in filter
5 node
6
7 Currently block_copy creates copy_bitmap in source node. But that is in
8 bad relation with .independent_close=true of copy-before-write filter:
9 source node may be detached and removed before .bdrv_close() handler
10 called, which should call block_copy_state_free(), which in turn should
11 remove copy_bitmap.
12
13 That's all not ideal: it would be better if internal bitmap of
14 block-copy object is not attached to any node. But that is not possible
15 now.
16
17 The simplest solution is just create copy_bitmap in filter node, where
18 anyway two other bitmaps are created.
19
20 Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
21 Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
22 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
23 ---
24 block/block-copy.c | 3 +-
25 block/copy-before-write.c | 2 +-
26 include/block/block-copy.h | 1 +
27 tests/qemu-iotests/257.out | 112 ++++++++++++++++++-------------------
28 4 files changed, 60 insertions(+), 58 deletions(-)
29
30 diff --git a/block/block-copy.c b/block/block-copy.c
31 index e13d7bc6b6..b61685f1a2 100644
32 --- a/block/block-copy.c
33 +++ b/block/block-copy.c
34 @@ -346,6 +346,7 @@ static int64_t block_copy_calculate_cluster_size(BlockDriverState *target,
35 }
36
37 BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
38 + BlockDriverState *copy_bitmap_bs,
39 const BdrvDirtyBitmap *bitmap,
40 Error **errp)
41 {
42 @@ -360,7 +361,7 @@ BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
43 return NULL;
44 }
45
46 - copy_bitmap = bdrv_create_dirty_bitmap(source->bs, cluster_size, NULL,
47 + copy_bitmap = bdrv_create_dirty_bitmap(copy_bitmap_bs, cluster_size, NULL,
48 errp);
49 if (!copy_bitmap) {
50 return NULL;
51 diff --git a/block/copy-before-write.c b/block/copy-before-write.c
52 index 0a219c2b75..d3b95bd600 100644
53 --- a/block/copy-before-write.c
54 +++ b/block/copy-before-write.c
55 @@ -470,7 +470,7 @@ static int cbw_open(BlockDriverState *bs, QDict *options, int flags,
56 ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) &
57 bs->file->bs->supported_zero_flags);
58
59 - s->bcs = block_copy_state_new(bs->file, s->target, bitmap, errp);
60 + s->bcs = block_copy_state_new(bs->file, s->target, bs, bitmap, errp);
61 if (!s->bcs) {
62 error_prepend(errp, "Cannot create block-copy-state: ");
63 ret = -EINVAL;
64 diff --git a/include/block/block-copy.h b/include/block/block-copy.h
65 index 0700953ab8..8b41643bfa 100644
66 --- a/include/block/block-copy.h
67 +++ b/include/block/block-copy.h
68 @@ -25,6 +25,7 @@ typedef struct BlockCopyState BlockCopyState;
69 typedef struct BlockCopyCallState BlockCopyCallState;
70
71 BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
72 + BlockDriverState *copy_bitmap_bs,
73 const BdrvDirtyBitmap *bitmap,
74 Error **errp);
75
76 diff --git a/tests/qemu-iotests/257.out b/tests/qemu-iotests/257.out
77 index aa76131ca9..c33dd7f3a9 100644
78 --- a/tests/qemu-iotests/257.out
79 +++ b/tests/qemu-iotests/257.out
80 @@ -120,16 +120,16 @@ write -P0x67 0x3fe0000 0x20000
81 "granularity": 65536,
82 "persistent": false,
83 "recording": false
84 - }
85 - ],
86 - "drive0": [
87 + },
88 {
89 "busy": false,
90 "count": 0,
91 "granularity": 65536,
92 "persistent": false,
93 "recording": false
94 - },
95 + }
96 + ],
97 + "drive0": [
98 {
99 "busy": false,
100 "count": 458752,
101 @@ -596,16 +596,16 @@ write -P0x67 0x3fe0000 0x20000
102 "granularity": 65536,
103 "persistent": false,
104 "recording": false
105 - }
106 - ],
107 - "drive0": [
108 + },
109 {
110 "busy": false,
111 "count": 0,
112 "granularity": 65536,
113 "persistent": false,
114 "recording": false
115 - },
116 + }
117 + ],
118 + "drive0": [
119 {
120 "busy": false,
121 "count": 458752,
122 @@ -865,16 +865,16 @@ write -P0x67 0x3fe0000 0x20000
123 "granularity": 65536,
124 "persistent": false,
125 "recording": false
126 - }
127 - ],
128 - "drive0": [
129 + },
130 {
131 "busy": false,
132 "count": 0,
133 "granularity": 65536,
134 "persistent": false,
135 "recording": false
136 - },
137 + }
138 + ],
139 + "drive0": [
140 {
141 "busy": false,
142 "count": 458752,
143 @@ -1341,16 +1341,16 @@ write -P0x67 0x3fe0000 0x20000
144 "granularity": 65536,
145 "persistent": false,
146 "recording": false
147 - }
148 - ],
149 - "drive0": [
150 + },
151 {
152 "busy": false,
153 "count": 0,
154 "granularity": 65536,
155 "persistent": false,
156 "recording": false
157 - },
158 + }
159 + ],
160 + "drive0": [
161 {
162 "busy": false,
163 "count": 458752,
164 @@ -1610,16 +1610,16 @@ write -P0x67 0x3fe0000 0x20000
165 "granularity": 65536,
166 "persistent": false,
167 "recording": false
168 - }
169 - ],
170 - "drive0": [
171 + },
172 {
173 "busy": false,
174 "count": 0,
175 "granularity": 65536,
176 "persistent": false,
177 "recording": false
178 - },
179 + }
180 + ],
181 + "drive0": [
182 {
183 "busy": false,
184 "count": 458752,
185 @@ -2086,16 +2086,16 @@ write -P0x67 0x3fe0000 0x20000
186 "granularity": 65536,
187 "persistent": false,
188 "recording": false
189 - }
190 - ],
191 - "drive0": [
192 + },
193 {
194 "busy": false,
195 "count": 0,
196 "granularity": 65536,
197 "persistent": false,
198 "recording": false
199 - },
200 + }
201 + ],
202 + "drive0": [
203 {
204 "busy": false,
205 "count": 458752,
206 @@ -2355,16 +2355,16 @@ write -P0x67 0x3fe0000 0x20000
207 "granularity": 65536,
208 "persistent": false,
209 "recording": false
210 - }
211 - ],
212 - "drive0": [
213 + },
214 {
215 "busy": false,
216 "count": 0,
217 "granularity": 65536,
218 "persistent": false,
219 "recording": false
220 - },
221 + }
222 + ],
223 + "drive0": [
224 {
225 "busy": false,
226 "count": 458752,
227 @@ -2831,16 +2831,16 @@ write -P0x67 0x3fe0000 0x20000
228 "granularity": 65536,
229 "persistent": false,
230 "recording": false
231 - }
232 - ],
233 - "drive0": [
234 + },
235 {
236 "busy": false,
237 "count": 0,
238 "granularity": 65536,
239 "persistent": false,
240 "recording": false
241 - },
242 + }
243 + ],
244 + "drive0": [
245 {
246 "busy": false,
247 "count": 458752,
248 @@ -3100,16 +3100,16 @@ write -P0x67 0x3fe0000 0x20000
249 "granularity": 65536,
250 "persistent": false,
251 "recording": false
252 - }
253 - ],
254 - "drive0": [
255 + },
256 {
257 "busy": false,
258 "count": 0,
259 "granularity": 65536,
260 "persistent": false,
261 "recording": false
262 - },
263 + }
264 + ],
265 + "drive0": [
266 {
267 "busy": false,
268 "count": 458752,
269 @@ -3576,16 +3576,16 @@ write -P0x67 0x3fe0000 0x20000
270 "granularity": 65536,
271 "persistent": false,
272 "recording": false
273 - }
274 - ],
275 - "drive0": [
276 + },
277 {
278 "busy": false,
279 "count": 0,
280 "granularity": 65536,
281 "persistent": false,
282 "recording": false
283 - },
284 + }
285 + ],
286 + "drive0": [
287 {
288 "busy": false,
289 "count": 458752,
290 @@ -3845,16 +3845,16 @@ write -P0x67 0x3fe0000 0x20000
291 "granularity": 65536,
292 "persistent": false,
293 "recording": false
294 - }
295 - ],
296 - "drive0": [
297 + },
298 {
299 "busy": false,
300 "count": 0,
301 "granularity": 65536,
302 "persistent": false,
303 "recording": false
304 - },
305 + }
306 + ],
307 + "drive0": [
308 {
309 "busy": false,
310 "count": 458752,
311 @@ -4321,16 +4321,16 @@ write -P0x67 0x3fe0000 0x20000
312 "granularity": 65536,
313 "persistent": false,
314 "recording": false
315 - }
316 - ],
317 - "drive0": [
318 + },
319 {
320 "busy": false,
321 "count": 0,
322 "granularity": 65536,
323 "persistent": false,
324 "recording": false
325 - },
326 + }
327 + ],
328 + "drive0": [
329 {
330 "busy": false,
331 "count": 458752,
332 @@ -4590,16 +4590,16 @@ write -P0x67 0x3fe0000 0x20000
333 "granularity": 65536,
334 "persistent": false,
335 "recording": false
336 - }
337 - ],
338 - "drive0": [
339 + },
340 {
341 "busy": false,
342 "count": 0,
343 "granularity": 65536,
344 "persistent": false,
345 "recording": false
346 - },
347 + }
348 + ],
349 + "drive0": [
350 {
351 "busy": false,
352 "count": 458752,
353 @@ -5066,16 +5066,16 @@ write -P0x67 0x3fe0000 0x20000
354 "granularity": 65536,
355 "persistent": false,
356 "recording": false
357 - }
358 - ],
359 - "drive0": [
360 + },
361 {
362 "busy": false,
363 "count": 0,
364 "granularity": 65536,
365 "persistent": false,
366 "recording": false
367 - },
368 + }
369 + ],
370 + "drive0": [
371 {
372 "busy": false,
373 "count": 458752,