]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/pve/0046-block-copy-before-write-fix-permission.patch
implement support for backup fleecing
[pve-qemu.git] / debian / patches / pve / 0046-block-copy-before-write-fix-permission.patch
CommitLineData
20209d8d
TL
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
3Date: Thu, 11 Apr 2024 11:29:22 +0200
4Subject: [PATCH] block/copy-before-write: fix permission
5
6In case when source node does not have any parents, the condition still
7works as required: backup job do create the parent by
8
9 block_job_create -> block_job_add_bdrv -> bdrv_root_attach_child
10
11Still, in this case checking @perm variable doesn't work, as backup job
12creates the root blk with empty permissions (as it rely on CBW filter
13to require correct permissions and don't want to create extra
14conflicts).
15
16So, we should not check @perm.
17
18The hack may be dropped entirely when transactional insertion of
19filter (when we don't try to recalculate permissions in intermediate
20state, when filter does conflict with original parent of the source
21node) merged (old big series
22"[PATCH v5 00/45] Transactional block-graph modifying API"[1] and it's
23current 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
28Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
29Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
30Signed-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
35diff --git a/block/copy-before-write.c b/block/copy-before-write.c
36index 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 }