]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/pve/0046-block-copy-before-write-fix-permission.patch
backup: improve error when copy-before-write fails for fleecing
[pve-qemu.git] / debian / patches / pve / 0046-block-copy-before-write-fix-permission.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:22 +0200
4 Subject: [PATCH] block/copy-before-write: fix permission
5
6 In case when source node does not have any parents, the condition still
7 works as required: backup job do create the parent by
8
9 block_job_create -> block_job_add_bdrv -> bdrv_root_attach_child
10
11 Still, in this case checking @perm variable doesn't work, as backup job
12 creates the root blk with empty permissions (as it rely on CBW filter
13 to require correct permissions and don't want to create extra
14 conflicts).
15
16 So, we should not check @perm.
17
18 The hack may be dropped entirely when transactional insertion of
19 filter (when we don't try to recalculate permissions in intermediate
20 state, when filter does conflict with original parent of the source
21 node) merged (old big series
22 "[PATCH v5 00/45] Transactional block-graph modifying API"[1] and it's
23 current in-flight part is "[PATCH v8 0/7] blockdev-replace"[2])
24
25 [1] https://patchew.org/QEMU/20220330212902.590099-1-vsementsov@openvz.org/
26 [2] https://patchew.org/QEMU/20231017184444.932733-1-vsementsov@yandex-team.ru/
27
28 Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
29 Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
30 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
31 ---
32 block/copy-before-write.c | 10 +++++++---
33 1 file changed, 7 insertions(+), 3 deletions(-)
34
35 diff --git a/block/copy-before-write.c b/block/copy-before-write.c
36 index b866e42271..a2dddf6f57 100644
37 --- a/block/copy-before-write.c
38 +++ b/block/copy-before-write.c
39 @@ -364,9 +364,13 @@ static void cbw_child_perm(BlockDriverState *bs, BdrvChild *c,
40 perm, shared, nperm, nshared);
41
42 if (!QLIST_EMPTY(&bs->parents)) {
43 - if (perm & BLK_PERM_WRITE) {
44 - *nperm = *nperm | BLK_PERM_CONSISTENT_READ;
45 - }
46 + /*
47 + * Note, that source child may be shared with backup job. Backup job
48 + * does create own blk parent on copy-before-write node, so this
49 + * works even if source node does not have any parents before backup
50 + * start
51 + */
52 + *nperm = *nperm | BLK_PERM_CONSISTENT_READ;
53 *nshared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE);
54 }
55 }