]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/extra/0005-block-rbd-workaround-for-ceph-issue-53784.patch
update submodule and patches to 6.2.0
[pve-qemu.git] / debian / patches / extra / 0005-block-rbd-workaround-for-ceph-issue-53784.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Peter Lieven <pl@kamp.de>
3 Date: Thu, 13 Jan 2022 15:44:26 +0100
4 Subject: [PATCH] block/rbd: workaround for ceph issue #53784
5
6 librbd had a bug until early 2022 that affected all versions of ceph that
7 supported fast-diff. This bug results in reporting of incorrect offsets
8 if the offset parameter to rbd_diff_iterate2 is not object aligned.
9
10 This patch works around this bug for pre Quincy versions of librbd.
11
12 Fixes: 0347a8fd4c3faaedf119be04c197804be40a384b
13 Cc: qemu-stable@nongnu.org
14 Signed-off-by: Peter Lieven <pl@kamp.de>
15 Message-Id: <20220113144426.4036493-3-pl@kamp.de>
16 Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
17 Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
18 Tested-by: Stefano Garzarella <sgarzare@redhat.com>
19 Signed-off-by: Kevin Wolf <kwolf@redhat.com>
20 ---
21 block/rbd.c | 42 ++++++++++++++++++++++++++++++++++++++++--
22 1 file changed, 40 insertions(+), 2 deletions(-)
23
24 diff --git a/block/rbd.c b/block/rbd.c
25 index 20bb896c4a..8f183eba2a 100644
26 --- a/block/rbd.c
27 +++ b/block/rbd.c
28 @@ -1320,6 +1320,7 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
29 int status, r;
30 RBDDiffIterateReq req = { .offs = offset };
31 uint64_t features, flags;
32 + uint64_t head = 0;
33
34 assert(offset + bytes <= s->image_size);
35
36 @@ -1347,7 +1348,43 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
37 return status;
38 }
39
40 - r = rbd_diff_iterate2(s->image, NULL, offset, bytes, true, true,
41 +#if LIBRBD_VERSION_CODE < LIBRBD_VERSION(1, 17, 0)
42 + /*
43 + * librbd had a bug until early 2022 that affected all versions of ceph that
44 + * supported fast-diff. This bug results in reporting of incorrect offsets
45 + * if the offset parameter to rbd_diff_iterate2 is not object aligned.
46 + * Work around this bug by rounding down the offset to object boundaries.
47 + * This is OK because we call rbd_diff_iterate2 with whole_object = true.
48 + * However, this workaround only works for non cloned images with default
49 + * striping.
50 + *
51 + * See: https://tracker.ceph.com/issues/53784
52 + */
53 +
54 + /* check if RBD image has non-default striping enabled */
55 + if (features & RBD_FEATURE_STRIPINGV2) {
56 + return status;
57 + }
58 +
59 +#pragma GCC diagnostic push
60 +#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
61 + /*
62 + * check if RBD image is a clone (= has a parent).
63 + *
64 + * rbd_get_parent_info is deprecated from Nautilus onwards, but the
65 + * replacement rbd_get_parent is not present in Luminous and Mimic.
66 + */
67 + if (rbd_get_parent_info(s->image, NULL, 0, NULL, 0, NULL, 0) != -ENOENT) {
68 + return status;
69 + }
70 +#pragma GCC diagnostic pop
71 +
72 + head = req.offs & (s->object_size - 1);
73 + req.offs -= head;
74 + bytes += head;
75 +#endif
76 +
77 + r = rbd_diff_iterate2(s->image, NULL, req.offs, bytes, true, true,
78 qemu_rbd_diff_iterate_cb, &req);
79 if (r < 0 && r != QEMU_RBD_EXIT_DIFF_ITERATE2) {
80 return status;
81 @@ -1366,7 +1403,8 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
82 status = BDRV_BLOCK_ZERO | BDRV_BLOCK_OFFSET_VALID;
83 }
84
85 - *pnum = req.bytes;
86 + assert(req.bytes > head);
87 + *pnum = req.bytes - head;
88 return status;
89 }
90