|
|
495e37 |
From f035b5250529eed8d12e0b93b1b6d6f2c50003f6 Mon Sep 17 00:00:00 2001
|
|
|
495e37 |
From: Peter Lieven <pl@kamp.de>
|
|
|
495e37 |
Date: Thu, 13 Jan 2022 15:44:26 +0100
|
|
|
495e37 |
Subject: [PATCH 5/5] block/rbd: workaround for ceph issue #53784
|
|
|
495e37 |
|
|
|
495e37 |
RH-Author: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
495e37 |
RH-MergeRequest: 68: block/rbd: fix handling of holes in .bdrv_co_block_status
|
|
|
495e37 |
RH-Commit: [2/2] 5feaa2e20a77886cc1a84cdf212ade3dcda28289 (sgarzarella/qemu-kvm-c-9-s)
|
|
|
495e37 |
RH-Bugzilla: 2034791
|
|
|
495e37 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
495e37 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
495e37 |
RH-Acked-by: Hanna Reitz <hreitz@redhat.com>
|
|
|
495e37 |
|
|
|
495e37 |
librbd had a bug until early 2022 that affected all versions of ceph that
|
|
|
495e37 |
supported fast-diff. This bug results in reporting of incorrect offsets
|
|
|
495e37 |
if the offset parameter to rbd_diff_iterate2 is not object aligned.
|
|
|
495e37 |
|
|
|
495e37 |
This patch works around this bug for pre Quincy versions of librbd.
|
|
|
495e37 |
|
|
|
495e37 |
Fixes: 0347a8fd4c3faaedf119be04c197804be40a384b
|
|
|
495e37 |
Cc: qemu-stable@nongnu.org
|
|
|
495e37 |
Signed-off-by: Peter Lieven <pl@kamp.de>
|
|
|
495e37 |
Message-Id: <20220113144426.4036493-3-pl@kamp.de>
|
|
|
495e37 |
Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
|
|
|
495e37 |
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
495e37 |
Tested-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
495e37 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
495e37 |
(cherry picked from commit fc176116cdea816ceb8dd969080b2b95f58edbc0)
|
|
|
495e37 |
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
495e37 |
---
|
|
|
495e37 |
block/rbd.c | 42 ++++++++++++++++++++++++++++++++++++++++--
|
|
|
495e37 |
1 file changed, 40 insertions(+), 2 deletions(-)
|
|
|
495e37 |
|
|
|
495e37 |
diff --git a/block/rbd.c b/block/rbd.c
|
|
|
495e37 |
index 20bb896c4a..8f183eba2a 100644
|
|
|
495e37 |
--- a/block/rbd.c
|
|
|
495e37 |
+++ b/block/rbd.c
|
|
|
495e37 |
@@ -1320,6 +1320,7 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
|
|
|
495e37 |
int status, r;
|
|
|
495e37 |
RBDDiffIterateReq req = { .offs = offset };
|
|
|
495e37 |
uint64_t features, flags;
|
|
|
495e37 |
+ uint64_t head = 0;
|
|
|
495e37 |
|
|
|
495e37 |
assert(offset + bytes <= s->image_size);
|
|
|
495e37 |
|
|
|
495e37 |
@@ -1347,7 +1348,43 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
|
|
|
495e37 |
return status;
|
|
|
495e37 |
}
|
|
|
495e37 |
|
|
|
495e37 |
- r = rbd_diff_iterate2(s->image, NULL, offset, bytes, true, true,
|
|
|
495e37 |
+#if LIBRBD_VERSION_CODE < LIBRBD_VERSION(1, 17, 0)
|
|
|
495e37 |
+ /*
|
|
|
495e37 |
+ * librbd had a bug until early 2022 that affected all versions of ceph that
|
|
|
495e37 |
+ * supported fast-diff. This bug results in reporting of incorrect offsets
|
|
|
495e37 |
+ * if the offset parameter to rbd_diff_iterate2 is not object aligned.
|
|
|
495e37 |
+ * Work around this bug by rounding down the offset to object boundaries.
|
|
|
495e37 |
+ * This is OK because we call rbd_diff_iterate2 with whole_object = true.
|
|
|
495e37 |
+ * However, this workaround only works for non cloned images with default
|
|
|
495e37 |
+ * striping.
|
|
|
495e37 |
+ *
|
|
|
495e37 |
+ * See: https://tracker.ceph.com/issues/53784
|
|
|
495e37 |
+ */
|
|
|
495e37 |
+
|
|
|
495e37 |
+ /* check if RBD image has non-default striping enabled */
|
|
|
495e37 |
+ if (features & RBD_FEATURE_STRIPINGV2) {
|
|
|
495e37 |
+ return status;
|
|
|
495e37 |
+ }
|
|
|
495e37 |
+
|
|
|
495e37 |
+#pragma GCC diagnostic push
|
|
|
495e37 |
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
|
495e37 |
+ /*
|
|
|
495e37 |
+ * check if RBD image is a clone (= has a parent).
|
|
|
495e37 |
+ *
|
|
|
495e37 |
+ * rbd_get_parent_info is deprecated from Nautilus onwards, but the
|
|
|
495e37 |
+ * replacement rbd_get_parent is not present in Luminous and Mimic.
|
|
|
495e37 |
+ */
|
|
|
495e37 |
+ if (rbd_get_parent_info(s->image, NULL, 0, NULL, 0, NULL, 0) != -ENOENT) {
|
|
|
495e37 |
+ return status;
|
|
|
495e37 |
+ }
|
|
|
495e37 |
+#pragma GCC diagnostic pop
|
|
|
495e37 |
+
|
|
|
495e37 |
+ head = req.offs & (s->object_size - 1);
|
|
|
495e37 |
+ req.offs -= head;
|
|
|
495e37 |
+ bytes += head;
|
|
|
495e37 |
+#endif
|
|
|
495e37 |
+
|
|
|
495e37 |
+ r = rbd_diff_iterate2(s->image, NULL, req.offs, bytes, true, true,
|
|
|
495e37 |
qemu_rbd_diff_iterate_cb, &req;;
|
|
|
495e37 |
if (r < 0 && r != QEMU_RBD_EXIT_DIFF_ITERATE2) {
|
|
|
495e37 |
return status;
|
|
|
495e37 |
@@ -1366,7 +1403,8 @@ static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
|
|
|
495e37 |
status = BDRV_BLOCK_ZERO | BDRV_BLOCK_OFFSET_VALID;
|
|
|
495e37 |
}
|
|
|
495e37 |
|
|
|
495e37 |
- *pnum = req.bytes;
|
|
|
495e37 |
+ assert(req.bytes > head);
|
|
|
495e37 |
+ *pnum = req.bytes - head;
|
|
|
495e37 |
return status;
|
|
|
495e37 |
}
|
|
|
495e37 |
|
|
|
495e37 |
--
|
|
|
495e37 |
2.27.0
|
|
|
495e37 |
|