]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/extra/0007-block-fix-detect-zeroes-with-BDRV_REQ_REGISTERED_BUF.patch
add patch to fix issue with VirtIO disk using detect-zeroes=unmap
[pve-qemu.git] / debian / patches / extra / 0007-block-fix-detect-zeroes-with-BDRV_REQ_REGISTERED_BUF.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Stefan Hajnoczi <stefanha@redhat.com>
3 Date: Thu, 26 Jan 2023 15:13:58 -0500
4 Subject: [PATCH] block: fix detect-zeroes= with BDRV_REQ_REGISTERED_BUF
5
6 When a write request is converted into a write zeroes request by the
7 detect-zeroes= feature, it is no longer associated with an I/O buffer.
8 The BDRV_REQ_REGISTERED_BUF flag doesn't make sense without an I/O
9 buffer and must be cleared because bdrv_co_do_pwrite_zeroes() fails with
10 -EINVAL when it's set.
11
12 Fiona Ebner <f.ebner@proxmox.com> bisected and diagnosed this QEMU 7.2
13 regression where writes containing zeroes to a blockdev with
14 discard=unmap,detect-zeroes=unmap fail.
15
16 Buglink: https://gitlab.com/qemu-project/qemu/-/issues/1404
17 Fixes: e8b6535533be ("block: add BDRV_REQ_REGISTERED_BUF request flag")
18 Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
19 ---
20 block/io.c | 3 +++
21 1 file changed, 3 insertions(+)
22
23 diff --git a/block/io.c b/block/io.c
24 index b9424024f9..bbaa0d1b2d 100644
25 --- a/block/io.c
26 +++ b/block/io.c
27 @@ -2087,6 +2087,9 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
28 if (bs->detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP) {
29 flags |= BDRV_REQ_MAY_UNMAP;
30 }
31 +
32 + /* Can't use optimization hint with bufferless zero write */
33 + flags &= ~BDRV_REQ_REGISTERED_BUF;
34 }
35
36 if (ret < 0) {