]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/pve/0042-Revert-block-rbd-implement-bdrv_co_block_status.patch
backup: improve error when copy-before-write fails for fleecing
[pve-qemu.git] / debian / patches / pve / 0042-Revert-block-rbd-implement-bdrv_co_block_status.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Fabian Ebner <f.ebner@proxmox.com>
3 Date: Tue, 17 May 2022 09:46:02 +0200
4 Subject: [PATCH] Revert "block/rbd: implement bdrv_co_block_status"
5
6 During backup, bdrv_co_block_status is called for each block copy
7 chunk. When RBD is used, the current implementation with
8 rbd_diff_iterate2() using whole_object=true takes about linearly more
9 time, depending on the image size. Since there are linearly more
10 chunks, the slowdown is quadratic, becoming unacceptable for large
11 images (starting somewhere between 500-1000 GiB in my testing).
12
13 This reverts commit 0347a8fd4c3faaedf119be04c197804be40a384b as a
14 stop-gap measure, until it's clear how to make the implemenation
15 more efficient.
16
17 Upstream bug report:
18 https://gitlab.com/qemu-project/qemu/-/issues/1026
19
20 Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
21 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
22 ---
23 block/rbd.c | 112 ----------------------------------------------------
24 1 file changed, 112 deletions(-)
25
26 diff --git a/block/rbd.c b/block/rbd.c
27 index 0913a0af39..1dab254517 100644
28 --- a/block/rbd.c
29 +++ b/block/rbd.c
30 @@ -108,12 +108,6 @@ typedef struct RBDTask {
31 int64_t ret;
32 } RBDTask;
33
34 -typedef struct RBDDiffIterateReq {
35 - uint64_t offs;
36 - uint64_t bytes;
37 - bool exists;
38 -} RBDDiffIterateReq;
39 -
40 static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
41 BlockdevOptionsRbd *opts, bool cache,
42 const char *keypairs, const char *secretid,
43 @@ -1456,111 +1450,6 @@ static ImageInfoSpecific *qemu_rbd_get_specific_info(BlockDriverState *bs,
44 return spec_info;
45 }
46
47 -/*
48 - * rbd_diff_iterate2 allows to interrupt the exection by returning a negative
49 - * value in the callback routine. Choose a value that does not conflict with
50 - * an existing exitcode and return it if we want to prematurely stop the
51 - * execution because we detected a change in the allocation status.
52 - */
53 -#define QEMU_RBD_EXIT_DIFF_ITERATE2 -9000
54 -
55 -static int qemu_rbd_diff_iterate_cb(uint64_t offs, size_t len,
56 - int exists, void *opaque)
57 -{
58 - RBDDiffIterateReq *req = opaque;
59 -
60 - assert(req->offs + req->bytes <= offs);
61 - /*
62 - * we do not diff against a snapshot so we should never receive a callback
63 - * for a hole.
64 - */
65 - assert(exists);
66 -
67 - if (!req->exists && offs > req->offs) {
68 - /*
69 - * we started in an unallocated area and hit the first allocated
70 - * block. req->bytes must be set to the length of the unallocated area
71 - * before the allocated area. stop further processing.
72 - */
73 - req->bytes = offs - req->offs;
74 - return QEMU_RBD_EXIT_DIFF_ITERATE2;
75 - }
76 -
77 - if (req->exists && offs > req->offs + req->bytes) {
78 - /*
79 - * we started in an allocated area and jumped over an unallocated area,
80 - * req->bytes contains the length of the allocated area before the
81 - * unallocated area. stop further processing.
82 - */
83 - return QEMU_RBD_EXIT_DIFF_ITERATE2;
84 - }
85 -
86 - req->bytes += len;
87 - req->exists = true;
88 -
89 - return 0;
90 -}
91 -
92 -static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
93 - bool want_zero, int64_t offset,
94 - int64_t bytes, int64_t *pnum,
95 - int64_t *map,
96 - BlockDriverState **file)
97 -{
98 - BDRVRBDState *s = bs->opaque;
99 - int status, r;
100 - RBDDiffIterateReq req = { .offs = offset };
101 - uint64_t features, flags;
102 -
103 - assert(offset + bytes <= s->image_size);
104 -
105 - /* default to all sectors allocated */
106 - status = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID;
107 - *map = offset;
108 - *file = bs;
109 - *pnum = bytes;
110 -
111 - /* check if RBD image supports fast-diff */
112 - r = rbd_get_features(s->image, &features);
113 - if (r < 0) {
114 - return status;
115 - }
116 - if (!(features & RBD_FEATURE_FAST_DIFF)) {
117 - return status;
118 - }
119 -
120 - /* check if RBD fast-diff result is valid */
121 - r = rbd_get_flags(s->image, &flags);
122 - if (r < 0) {
123 - return status;
124 - }
125 - if (flags & RBD_FLAG_FAST_DIFF_INVALID) {
126 - return status;
127 - }
128 -
129 - r = rbd_diff_iterate2(s->image, NULL, offset, bytes, true, true,
130 - qemu_rbd_diff_iterate_cb, &req);
131 - if (r < 0 && r != QEMU_RBD_EXIT_DIFF_ITERATE2) {
132 - return status;
133 - }
134 - assert(req.bytes <= bytes);
135 - if (!req.exists) {
136 - if (r == 0) {
137 - /*
138 - * rbd_diff_iterate2 does not invoke callbacks for unallocated
139 - * areas. This here catches the case where no callback was
140 - * invoked at all (req.bytes == 0).
141 - */
142 - assert(req.bytes == 0);
143 - req.bytes = bytes;
144 - }
145 - status = BDRV_BLOCK_ZERO | BDRV_BLOCK_OFFSET_VALID;
146 - }
147 -
148 - *pnum = req.bytes;
149 - return status;
150 -}
151 -
152 static int64_t coroutine_fn qemu_rbd_co_getlength(BlockDriverState *bs)
153 {
154 BDRVRBDState *s = bs->opaque;
155 @@ -1796,7 +1685,6 @@ static BlockDriver bdrv_rbd = {
156 #ifdef LIBRBD_SUPPORTS_WRITE_ZEROES
157 .bdrv_co_pwrite_zeroes = qemu_rbd_co_pwrite_zeroes,
158 #endif
159 - .bdrv_co_block_status = qemu_rbd_co_block_status,
160
161 .bdrv_snapshot_create = qemu_rbd_snap_create,
162 .bdrv_snapshot_delete = qemu_rbd_snap_remove,