Blame SOURCES/kvm-qcow2-Fix-alloc_cluster_abort-for-pre-existing-clust.patch

be904d
From bd97bbbce54da301407d51cae35e09ba2a12b160 Mon Sep 17 00:00:00 2001
be904d
From: Max Reitz <mreitz@redhat.com>
be904d
Date: Mon, 13 Jul 2020 14:24:48 -0400
be904d
Subject: [PATCH 1/4] qcow2: Fix alloc_cluster_abort() for pre-existing
be904d
 clusters
be904d
be904d
RH-Author: Max Reitz <mreitz@redhat.com>
be904d
Message-id: <20200713142451.289703-2-mreitz@redhat.com>
be904d
Patchwork-id: 97954
be904d
O-Subject: [RHEL-8.3.0 qemu-kvm PATCH 1/4] qcow2: Fix alloc_cluster_abort() for pre-existing clusters
be904d
Bugzilla: 1807057
be904d
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
be904d
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
be904d
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
be904d
be904d
handle_alloc() reuses preallocated zero clusters.  If anything goes
be904d
wrong during the data write, we do not change their L2 entry, so we
be904d
must not let qcow2_alloc_cluster_abort() free them.
be904d
be904d
Fixes: 8b24cd141549b5b264baeddd4e72902cfb5de23b
be904d
Cc: qemu-stable@nongnu.org
be904d
Signed-off-by: Max Reitz <mreitz@redhat.com>
be904d
Message-Id: <20200225143130.111267-2-mreitz@redhat.com>
be904d
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
be904d
(cherry picked from commit 3ede935fdbbd5f7b24b4724bbfb8938acb5956d8)
be904d
Signed-off-by: Max Reitz <mreitz@redhat.com>
be904d
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
be904d
---
be904d
 block/qcow2-cluster.c | 2 +-
be904d
 1 file changed, 1 insertion(+), 1 deletion(-)
be904d
be904d
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
be904d
index 9d04f8d77b..1970797ce5 100644
be904d
--- a/block/qcow2-cluster.c
be904d
+++ b/block/qcow2-cluster.c
be904d
@@ -1015,7 +1015,7 @@ err:
be904d
 void qcow2_alloc_cluster_abort(BlockDriverState *bs, QCowL2Meta *m)
be904d
 {
be904d
     BDRVQcow2State *s = bs->opaque;
be904d
-    if (!has_data_file(bs)) {
be904d
+    if (!has_data_file(bs) && !m->keep_old_clusters) {
be904d
         qcow2_free_clusters(bs, m->alloc_offset,
be904d
                             m->nb_clusters << s->cluster_bits,
be904d
                             QCOW2_DISCARD_NEVER);
be904d
-- 
be904d
2.27.0
be904d