cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-block-rbd-fix-handling-of-holes-in-.bdrv_co_block_st.patch

432cb7
From f4b7133d7aeb1d0b9115d01b5cff4df7f6b24e78 Mon Sep 17 00:00:00 2001
432cb7
From: Peter Lieven <pl@kamp.de>
432cb7
Date: Thu, 13 Jan 2022 15:44:25 +0100
432cb7
Subject: [PATCH 5/6] block/rbd: fix handling of holes in .bdrv_co_block_status
432cb7
432cb7
RH-Author: Stefano Garzarella <sgarzare@redhat.com>
432cb7
RH-MergeRequest: 110: block/rbd: fix handling of holes in .bdrv_co_block_status
432cb7
RH-Commit: [1/2] 352656a5c77cc7855b476c3559a10c6aa64a4f58
432cb7
RH-Bugzilla: 2037135
432cb7
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
432cb7
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
432cb7
RH-Acked-by: Hanna Reitz <hreitz@redhat.com>
432cb7
432cb7
the assumption that we can't hit a hole if we do not diff against a snapshot was wrong.
432cb7
432cb7
We can see a hole in an image if we diff against base if there exists an older snapshot
432cb7
of the image and we have discarded blocks in the image where the snapshot has data.
432cb7
432cb7
Fix this by simply handling a hole like an unallocated area. There are no callbacks
432cb7
for unallocated areas so just bail out if we hit a hole.
432cb7
432cb7
Fixes: 0347a8fd4c3faaedf119be04c197804be40a384b
432cb7
Suggested-by: Ilya Dryomov <idryomov@gmail.com>
432cb7
Cc: qemu-stable@nongnu.org
432cb7
Signed-off-by: Peter Lieven <pl@kamp.de>
432cb7
Message-Id: <20220113144426.4036493-2-pl@kamp.de>
432cb7
Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
432cb7
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
432cb7
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
432cb7
(cherry picked from commit 9e302f64bb407a9bb097b626da97228c2654cfee)
432cb7
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
432cb7
---
432cb7
 block/rbd.c | 10 +++++-----
432cb7
 1 file changed, 5 insertions(+), 5 deletions(-)
432cb7
432cb7
diff --git a/block/rbd.c b/block/rbd.c
432cb7
index def96292e0..20bb896c4a 100644
432cb7
--- a/block/rbd.c
432cb7
+++ b/block/rbd.c
432cb7
@@ -1279,11 +1279,11 @@ static int qemu_rbd_diff_iterate_cb(uint64_t offs, size_t len,
432cb7
     RBDDiffIterateReq *req = opaque;
432cb7
 
432cb7
     assert(req->offs + req->bytes <= offs);
432cb7
-    /*
432cb7
-     * we do not diff against a snapshot so we should never receive a callback
432cb7
-     * for a hole.
432cb7
-     */
432cb7
-    assert(exists);
432cb7
+
432cb7
+    /* treat a hole like an unallocated area and bail out */
432cb7
+    if (!exists) {
432cb7
+        return 0;
432cb7
+    }
432cb7
 
432cb7
     if (!req->exists && offs > req->offs) {
432cb7
         /*
432cb7
-- 
432cb7
2.27.0
432cb7