cryptospore / rpms / qemu-kvm

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