summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Maydell2020-11-24 18:40:00 +0100
committerPeter Maydell2020-11-24 18:40:00 +0100
commitc0e0a9b13177c27ea8c887fef5613e5d72818b85 (patch)
tree2ab3098f31ca0a8bf6f67e2ad98f9e5179e694d0
parentMerge remote-tracking branch 'remotes/gkurz-gitlab/tags/9p-fix-2020-11-24' in... (diff)
parentqcow2: Fix corruption on write_zeroes with MAY_UNMAP (diff)
downloadqemu-c0e0a9b13177c27ea8c887fef5613e5d72818b85.tar.gz
qemu-c0e0a9b13177c27ea8c887fef5613e5d72818b85.tar.xz
qemu-c0e0a9b13177c27ea8c887fef5613e5d72818b85.zip
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Patches for 5.2.0-rc3: - qcow2: Fix corruption on write_zeroes with MAY_UNMAP # gpg: Signature made Tue 24 Nov 2020 14:23:36 GMT # gpg: using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6 # gpg: issuer "kwolf@redhat.com" # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full] # Primary key fingerprint: DC3D EB15 9A9A F95D 3D74 56FE 7F09 B272 C88F 2FD6 * remotes/kevin/tags/for-upstream: qcow2: Fix corruption on write_zeroes with MAY_UNMAP Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--block/qcow2-cluster.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 485b4cb92e..bd0597842f 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -2010,14 +2010,17 @@ static int zero_in_l2_slice(BlockDriverState *bs, uint64_t offset,
continue;
}
+ /* First update L2 entries */
qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice);
- if (unmap) {
- qcow2_free_any_cluster(bs, old_l2_entry, QCOW2_DISCARD_REQUEST);
- }
set_l2_entry(s, l2_slice, l2_index + i, new_l2_entry);
if (has_subclusters(s)) {
set_l2_bitmap(s, l2_slice, l2_index + i, new_l2_bitmap);
}
+
+ /* Then decrease the refcount */
+ if (unmap) {
+ qcow2_free_any_cluster(bs, old_l2_entry, QCOW2_DISCARD_REQUEST);
+ }
}
qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);