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