Blame 0005-block-fix-detect-zeroes-with-BDRV_REQ_REGISTERED_BUF.patch

fb1517
From db788c896eb1378ebc1f20dcc4954616a7631919 Mon Sep 17 00:00:00 2001
fb1517
From: Stefan Hajnoczi <stefanha@redhat.com>
fb1517
Date: Tue, 7 Feb 2023 15:37:16 -0500
d8ea84
Subject: [PATCH 5/6] block: fix detect-zeroes= with BDRV_REQ_REGISTERED_BUF
fb1517
fb1517
When a write request is converted into a write zeroes request by the
fb1517
detect-zeroes= feature, it is no longer associated with an I/O buffer.
fb1517
The BDRV_REQ_REGISTERED_BUF flag doesn't make sense without an I/O
fb1517
buffer and must be cleared because bdrv_co_do_pwrite_zeroes() fails with
fb1517
-EINVAL when it's set.
fb1517
fb1517
Fiona Ebner <f.ebner@proxmox.com> bisected and diagnosed this QEMU 7.2
fb1517
regression where writes containing zeroes to a blockdev with
fb1517
discard=unmap,detect-zeroes=unmap fail.
fb1517
fb1517
Buglink: https://gitlab.com/qemu-project/qemu/-/issues/1404
fb1517
Fixes: e8b6535533be ("block: add BDRV_REQ_REGISTERED_BUF request flag")
fb1517
Tested-by: Fiona Ebner <f.ebner@proxmox.com>
fb1517
Cc: qemu-stable@nongnu.org
fb1517
Reviewed-by: Eric Blake <eblake@redhat.com>
fb1517
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
fb1517
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
fb1517
Message-Id: <20230207203719.242926-2-stefanha@redhat.com>
fb1517
(cherry picked from commit 3c5867156eb81c7c71611d078b2c5c2c863f884a)
fb1517
---
fb1517
 block/io.c | 3 +++
fb1517
 1 file changed, 3 insertions(+)
fb1517
fb1517
diff --git a/block/io.c b/block/io.c
fb1517
index b9424024f9..bbaa0d1b2d 100644
fb1517
--- a/block/io.c
fb1517
+++ b/block/io.c
fb1517
@@ -2087,6 +2087,9 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
fb1517
         if (bs->detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP) {
fb1517
             flags |= BDRV_REQ_MAY_UNMAP;
fb1517
         }
fb1517
+
fb1517
+        /* Can't use optimization hint with bufferless zero write */
fb1517
+        flags &= ~BDRV_REQ_REGISTERED_BUF;
fb1517
     }
fb1517
 
fb1517
     if (ret < 0) {
fb1517
-- 
fb1517
2.37.3
fb1517