5b15e2ecaf
Notable changes: * The only big change is the switch to using a custom QIOChannel for savevm-async, because the previously used QEMUFileOps was dropped. Changes to the current implementation: * Switch to vector based methods as required for an IO channel. For short reads the passed-in IO vector is stuffed with zeroes at the end, just to be sure. * For reading: The documentation in include/io/channel.h states that at least one byte should be read, so also error out when whe are at the very end instead of returning 0. * For reading: Fix off-by-one error when request goes beyond end. The wrong code piece was: if ((pos + size) > maxlen) { size = maxlen - pos - 1; } Previously, the last byte would not be read. It's actually possible to get a snapshot .raw file that has content all the way up the final 512 byte (= BDRV_SECTOR_SIZE) boundary without any trailing zero bytes (I wrote a script to do it). Luckily, it didn't cause a real issue, because qemu_loadvm_state() is not interested in the final (i.e. QEMU_VM_VMDESCRIPTION) section. The buffer for reading it is simply freed up afterwards and the function will assume that it read the whole section, even if that's not the case. * For writing: Make use of the generated blk_pwritev() wrapper instead of manually wrapping the coroutine to simplify and save a few lines. * Adapt to changed interfaces for blk_{pread,pwrite}: * a9262f551e ("block: Change blk_{pread,pwrite}() param order") * 3b35d4542c ("block: Add a 'flags' param to blk_pread()") * bf5b16fa40 ("block: Make blk_{pread,pwrite}() return 0 on success") Those changes especially affected the qemu-img dd patches, because the context also changed, but also some of our block drivers used the functions. * Drop qemu-common.h include: it got renamed after essentially everything was moved to other headers. The only remaining user I could find for things dropped from the header between 7.0 and 7.1 was qemu_get_vm_name() in the iscsi-initiatorname patch, but it already includes the header to which the function was moved. Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
162 lines
5.3 KiB
Diff
162 lines
5.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Fabian Ebner <f.ebner@proxmox.com>
|
|
Date: Tue, 17 May 2022 09:46:02 +0200
|
|
Subject: [PATCH] Revert "block/rbd: implement bdrv_co_block_status"
|
|
|
|
During backup, bdrv_co_block_status is called for each block copy
|
|
chunk. When RBD is used, the current implementation with
|
|
rbd_diff_iterate2() using whole_object=true takes about linearly more
|
|
time, depending on the image size. Since there are linearly more
|
|
chunks, the slowdown is quadratic, becoming unacceptable for large
|
|
images (starting somewhere between 500-1000 GiB in my testing).
|
|
|
|
This reverts commit 0347a8fd4c3faaedf119be04c197804be40a384b as a
|
|
stop-gap measure, until it's clear how to make the implemenation
|
|
more efficient.
|
|
|
|
Upstream bug report:
|
|
https://gitlab.com/qemu-project/qemu/-/issues/1026
|
|
|
|
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
|
|
---
|
|
block/rbd.c | 112 ----------------------------------------------------
|
|
1 file changed, 112 deletions(-)
|
|
|
|
diff --git a/block/rbd.c b/block/rbd.c
|
|
index 98f4ba2620..efcbbe5949 100644
|
|
--- a/block/rbd.c
|
|
+++ b/block/rbd.c
|
|
@@ -97,12 +97,6 @@ typedef struct RBDTask {
|
|
int64_t ret;
|
|
} RBDTask;
|
|
|
|
-typedef struct RBDDiffIterateReq {
|
|
- uint64_t offs;
|
|
- uint64_t bytes;
|
|
- bool exists;
|
|
-} RBDDiffIterateReq;
|
|
-
|
|
static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
|
|
BlockdevOptionsRbd *opts, bool cache,
|
|
const char *keypairs, const char *secretid,
|
|
@@ -1293,111 +1287,6 @@ static ImageInfoSpecific *qemu_rbd_get_specific_info(BlockDriverState *bs,
|
|
return spec_info;
|
|
}
|
|
|
|
-/*
|
|
- * rbd_diff_iterate2 allows to interrupt the exection by returning a negative
|
|
- * value in the callback routine. Choose a value that does not conflict with
|
|
- * an existing exitcode and return it if we want to prematurely stop the
|
|
- * execution because we detected a change in the allocation status.
|
|
- */
|
|
-#define QEMU_RBD_EXIT_DIFF_ITERATE2 -9000
|
|
-
|
|
-static int qemu_rbd_diff_iterate_cb(uint64_t offs, size_t len,
|
|
- int exists, void *opaque)
|
|
-{
|
|
- RBDDiffIterateReq *req = opaque;
|
|
-
|
|
- assert(req->offs + req->bytes <= offs);
|
|
- /*
|
|
- * we do not diff against a snapshot so we should never receive a callback
|
|
- * for a hole.
|
|
- */
|
|
- assert(exists);
|
|
-
|
|
- if (!req->exists && offs > req->offs) {
|
|
- /*
|
|
- * we started in an unallocated area and hit the first allocated
|
|
- * block. req->bytes must be set to the length of the unallocated area
|
|
- * before the allocated area. stop further processing.
|
|
- */
|
|
- req->bytes = offs - req->offs;
|
|
- return QEMU_RBD_EXIT_DIFF_ITERATE2;
|
|
- }
|
|
-
|
|
- if (req->exists && offs > req->offs + req->bytes) {
|
|
- /*
|
|
- * we started in an allocated area and jumped over an unallocated area,
|
|
- * req->bytes contains the length of the allocated area before the
|
|
- * unallocated area. stop further processing.
|
|
- */
|
|
- return QEMU_RBD_EXIT_DIFF_ITERATE2;
|
|
- }
|
|
-
|
|
- req->bytes += len;
|
|
- req->exists = true;
|
|
-
|
|
- return 0;
|
|
-}
|
|
-
|
|
-static int coroutine_fn qemu_rbd_co_block_status(BlockDriverState *bs,
|
|
- bool want_zero, int64_t offset,
|
|
- int64_t bytes, int64_t *pnum,
|
|
- int64_t *map,
|
|
- BlockDriverState **file)
|
|
-{
|
|
- BDRVRBDState *s = bs->opaque;
|
|
- int status, r;
|
|
- RBDDiffIterateReq req = { .offs = offset };
|
|
- uint64_t features, flags;
|
|
-
|
|
- assert(offset + bytes <= s->image_size);
|
|
-
|
|
- /* default to all sectors allocated */
|
|
- status = BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID;
|
|
- *map = offset;
|
|
- *file = bs;
|
|
- *pnum = bytes;
|
|
-
|
|
- /* check if RBD image supports fast-diff */
|
|
- r = rbd_get_features(s->image, &features);
|
|
- if (r < 0) {
|
|
- return status;
|
|
- }
|
|
- if (!(features & RBD_FEATURE_FAST_DIFF)) {
|
|
- return status;
|
|
- }
|
|
-
|
|
- /* check if RBD fast-diff result is valid */
|
|
- r = rbd_get_flags(s->image, &flags);
|
|
- if (r < 0) {
|
|
- return status;
|
|
- }
|
|
- if (flags & RBD_FLAG_FAST_DIFF_INVALID) {
|
|
- return status;
|
|
- }
|
|
-
|
|
- r = rbd_diff_iterate2(s->image, NULL, offset, bytes, true, true,
|
|
- qemu_rbd_diff_iterate_cb, &req);
|
|
- if (r < 0 && r != QEMU_RBD_EXIT_DIFF_ITERATE2) {
|
|
- return status;
|
|
- }
|
|
- assert(req.bytes <= bytes);
|
|
- if (!req.exists) {
|
|
- if (r == 0) {
|
|
- /*
|
|
- * rbd_diff_iterate2 does not invoke callbacks for unallocated
|
|
- * areas. This here catches the case where no callback was
|
|
- * invoked at all (req.bytes == 0).
|
|
- */
|
|
- assert(req.bytes == 0);
|
|
- req.bytes = bytes;
|
|
- }
|
|
- status = BDRV_BLOCK_ZERO | BDRV_BLOCK_OFFSET_VALID;
|
|
- }
|
|
-
|
|
- *pnum = req.bytes;
|
|
- return status;
|
|
-}
|
|
-
|
|
static int64_t qemu_rbd_getlength(BlockDriverState *bs)
|
|
{
|
|
BDRVRBDState *s = bs->opaque;
|
|
@@ -1633,7 +1522,6 @@ static BlockDriver bdrv_rbd = {
|
|
#ifdef LIBRBD_SUPPORTS_WRITE_ZEROES
|
|
.bdrv_co_pwrite_zeroes = qemu_rbd_co_pwrite_zeroes,
|
|
#endif
|
|
- .bdrv_co_block_status = qemu_rbd_co_block_status,
|
|
|
|
.bdrv_snapshot_create = qemu_rbd_snap_create,
|
|
.bdrv_snapshot_delete = qemu_rbd_snap_remove,
|