]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/extra/0006-block-io-Update-BSC-only-if-want_zero-is-true.patch
update submodule and patches to 6.2.0
[pve-qemu.git] / debian / patches / extra / 0006-block-io-Update-BSC-only-if-want_zero-is-true.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Hanna Reitz <hreitz@redhat.com>
3 Date: Tue, 18 Jan 2022 17:59:59 +0100
4 Subject: [PATCH] block/io: Update BSC only if want_zero is true
5
6 We update the block-status cache whenever we get new information from a
7 bdrv_co_block_status() call to the block driver. However, if we have
8 passed want_zero=false to that call, it may flag areas containing zeroes
9 as data, and so we would update the block-status cache with wrong
10 information.
11
12 Therefore, we should not update the cache with want_zero=false.
13
14 Reported-by: Nir Soffer <nsoffer@redhat.com>
15 Fixes: 0bc329fbb00 ("block: block-status cache for data regions")
16 Reviewed-by: Nir Soffer <nsoffer@redhat.com>
17 Cc: qemu-stable@nongnu.org
18 Signed-off-by: Hanna Reitz <hreitz@redhat.com>
19 Message-Id: <20220118170000.49423-2-hreitz@redhat.com>
20 Reviewed-by: Eric Blake <eblake@redhat.com>
21 Signed-off-by: Eric Blake <eblake@redhat.com>
22 ---
23 block/io.c | 6 +++++-
24 1 file changed, 5 insertions(+), 1 deletion(-)
25
26 diff --git a/block/io.c b/block/io.c
27 index bb0a254def..4e4cb556c5 100644
28 --- a/block/io.c
29 +++ b/block/io.c
30 @@ -2497,8 +2497,12 @@ static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs,
31 * non-protocol nodes, and then it is never used. However, filling
32 * the cache requires an RCU update, so double check here to avoid
33 * such an update if possible.
34 + *
35 + * Check want_zero, because we only want to update the cache when we
36 + * have accurate information about what is zero and what is data.
37 */
38 - if (ret == (BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID) &&
39 + if (want_zero &&
40 + ret == (BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID) &&
41 QLIST_EMPTY(&bs->children))
42 {
43 /*