Commit 5634622bcb ("file-posix: allow BLKZEROOUT with -t writeback")
enables the BLKZEROOUT ioctl when using 'writeback' cache, regressing
certain 'qemu-img convert' invocations, because of a pre-existing
issue. Namely, the BLKZEROOUT ioctl might fail with errno EINVAL when
the request is shorter than the block size of the block device. Ensure
that bdrv_co_do_zero_pwritev() only issues requests respecting the
block driver's pwrite_zeroes_alignment. The file-posix host_device
block driver already initializes that value.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3257
Resolves: https://bugzilla.proxmox.com/show_bug.cgi?id=7197
Cc: [email protected]
Suggested-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Fiona Ebner <[email protected]>
---

This breaks the following iotests with qcow2:
154 177 179 204 271
See the following commits for details.

If we decide to go with the current approach, I will re-order in the
next version to avoid the temporary breakage, but I felt like it would
be easier to look at the issues with this patch order here.

 block/io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/io.c b/block/io.c
index 403a45f91d..12dc153573 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2155,7 +2155,8 @@ bdrv_co_do_zero_pwritev(BdrvChild *child, int64_t offset, 
int64_t bytes,
 {
     BlockDriverState *bs = child->bs;
     QEMUIOVector local_qiov;
-    uint64_t align = bs->bl.request_alignment;
+    uint64_t align = MAX(bs->bl.pwrite_zeroes_alignment,
+                         bs->bl.request_alignment);
     int ret = 0;
     bool padding;
     BdrvRequestPadding pad;
-- 
2.47.3



Reply via email to