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"
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).
13 This reverts commit 0347a8fd4c3faaedf119be04c197804be40a384b as a
14 stop-gap measure, until it's clear how to make the implemenation
18 https://gitlab.com/qemu-project/qemu/-/issues/1026
20 Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
21 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
23 block/rbd.c | 112 ----------------------------------------------------
24 1 file changed, 112 deletions(-)
26 diff --git a/block/rbd.c b/block/rbd.c
27 index 0913a0af39..1dab254517 100644
30 @@ -108,12 +108,6 @@ typedef struct RBDTask {
34 -typedef struct RBDDiffIterateReq {
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,
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.
53 -#define QEMU_RBD_EXIT_DIFF_ITERATE2 -9000
55 -static int qemu_rbd_diff_iterate_cb(uint64_t offs, size_t len,
56 - int exists, void *opaque)
58 - RBDDiffIterateReq *req = opaque;
60 - assert(req->offs + req->bytes <= offs);
62 - * we do not diff against a snapshot so we should never receive a callback
67 - if (!req->exists && offs > req->offs) {
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.
73 - req->bytes = offs - req->offs;
74 - return QEMU_RBD_EXIT_DIFF_ITERATE2;
77 - if (req->exists && offs > req->offs + req->bytes) {
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.
83 - return QEMU_RBD_EXIT_DIFF_ITERATE2;
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,
96 - BlockDriverState **file)
98 - BDRVRBDState *s = bs->opaque;
100 - RBDDiffIterateReq req = { .offs = offset };
101 - uint64_t features, flags;
103 - assert(offset + bytes <= s->image_size);
105 - /* default to all sectors allocated */
106 - status = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID;
111 - /* check if RBD image supports fast-diff */
112 - r = rbd_get_features(s->image, &features);
116 - if (!(features & RBD_FEATURE_FAST_DIFF)) {
120 - /* check if RBD fast-diff result is valid */
121 - r = rbd_get_flags(s->image, &flags);
125 - if (flags & RBD_FLAG_FAST_DIFF_INVALID) {
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) {
134 - assert(req.bytes <= bytes);
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).
142 - assert(req.bytes == 0);
145 - status = BDRV_BLOCK_ZERO | BDRV_BLOCK_OFFSET_VALID;
152 static int64_t coroutine_fn qemu_rbd_co_getlength(BlockDriverState *bs)
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,
159 - .bdrv_co_block_status = qemu_rbd_co_block_status,
161 .bdrv_snapshot_create = qemu_rbd_snap_create,
162 .bdrv_snapshot_delete = qemu_rbd_snap_remove,