qemu-kvm/kvm-block-io-Update-BSC-only-if-want_zero-is-true.patch
Miroslav Rezanina 0daf0004a7 * Mon Feb 14 2022 Miroslav Rezanina <mrezanin@redhat.com> - 6.2.0-8
- kvm-numa-Enable-numa-for-SGX-EPC-sections.patch [bz#2033708]
- kvm-numa-Support-SGX-numa-in-the-monitor-and-Libvirt-int.patch [bz#2033708]
- kvm-doc-Add-the-SGX-numa-description.patch [bz#2033708]
- kvm-Enable-SGX-RH-Only.patch [bz#2033708]
- kvm-qapi-Cleanup-SGX-related-comments-and-restore-sectio.patch [bz#2033708]
- kvm-block-io-Update-BSC-only-if-want_zero-is-true.patch [bz#2041461]
- kvm-iotests-block-status-cache-New-test.patch [bz#2041461]
- kvm-iotests-Test-qemu-img-convert-of-zeroed-data-cluster.patch [bz#1882917]
- kvm-qemu-img-make-is_allocated_sectors-more-efficient.patch [bz#1882917]
- kvm-block-backend-prevent-dangling-BDS-pointers-across-a.patch [bz#2040123]
- kvm-iotests-stream-error-on-reset-New-test.patch [bz#2040123]
- kvm-hw-arm-smmuv3-Fix-device-reset.patch [bz#2042481]
- Resolves: bz#2033708
  ([Intel 9.0 Feat] qemu-kvm: SGX 1.5 (SGX1 + Flexible Launch Control) support)
- Resolves: bz#2041461
  (Inconsistent block status reply in qemu-nbd)
- Resolves: bz#1882917
  (the target image size is incorrect when converting a badly fragmented file)
- Resolves: bz#2040123
  (Qemu core dumped when do block-stream to a snapshot node on non-enough space storage)
- Resolves: bz#2042481
  ([aarch64] Launch guest with "default-bus-bypass-iommu=off,iommu=smmuv3" and "iommu_platform=on", guest hangs after system_reset)
2022-02-14 06:48:51 -05:00

57 lines
2.3 KiB
Diff

From a6b472de71f6ebbe44025e1348c90e6f1f2b2326 Mon Sep 17 00:00:00 2001
From: Hanna Reitz <hreitz@redhat.com>
Date: Tue, 18 Jan 2022 17:59:59 +0100
Subject: [PATCH 06/12] block/io: Update BSC only if want_zero is true
RH-Author: Hanna Reitz <hreitz@redhat.com>
RH-MergeRequest: 69: block/io: Update BSC only if want_zero is true
RH-Commit: [1/2] ad19ff86c3420cafe5a9e785ee210e482fbc8cd7 (hreitz/qemu-kvm-c-9-s)
RH-Bugzilla: 2041461
RH-Acked-by: Eric Blake <eblake@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
We update the block-status cache whenever we get new information from a
bdrv_co_block_status() call to the block driver. However, if we have
passed want_zero=false to that call, it may flag areas containing zeroes
as data, and so we would update the block-status cache with wrong
information.
Therefore, we should not update the cache with want_zero=false.
Reported-by: Nir Soffer <nsoffer@redhat.com>
Fixes: 0bc329fbb00 ("block: block-status cache for data regions")
Reviewed-by: Nir Soffer <nsoffer@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20220118170000.49423-2-hreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 113b727ce788335cf76f65355d670c9bc130fd75)
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
---
block/io.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/block/io.c b/block/io.c
index bb0a254def..4e4cb556c5 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2497,8 +2497,12 @@ static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs,
* non-protocol nodes, and then it is never used. However, filling
* the cache requires an RCU update, so double check here to avoid
* such an update if possible.
+ *
+ * Check want_zero, because we only want to update the cache when we
+ * have accurate information about what is zero and what is data.
*/
- if (ret == (BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID) &&
+ if (want_zero &&
+ ret == (BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID) &&
QLIST_EMPTY(&bs->children))
{
/*
--
2.27.0