]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/extra/0020-io_uring-fix-short-read-slow-path.patch
add two more stable patches
[pve-qemu.git] / debian / patches / extra / 0020-io_uring-fix-short-read-slow-path.patch
CommitLineData
0e88ec19
FE
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Dominique Martinet <dominique.martinet@atmark-techno.com>
3Date: Thu, 30 Jun 2022 10:01:37 +0900
4Subject: [PATCH] io_uring: fix short read slow path
5
6sqeq.off here is the offset to read within the disk image, so obviously
7not 'nread' (the amount we just read), but as the author meant to write
8its current value incremented by the amount we just read.
9
10Normally recent versions of linux will not issue short reads,
11but it can happen so we should fix this.
12
13This lead to weird image corruptions when short read happened
14
15Fixes: 6663a0a33764 ("block/io_uring: implements interfaces for io_uring")
16Link: https://lkml.kernel.org/r/YrrFGO4A1jS0GI0G@atmark-techno.com
17Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
18Message-Id: <20220630010137.2518851-1-dominique.martinet@atmark-techno.com>
19Reviewed-by: Hanna Reitz <hreitz@redhat.com>
20Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
21Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
22(cherry-picked from commit c06fc7ce147e57ab493bad9263f1601b8298484b)
23Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
24---
25 block/io_uring.c | 4 ++--
26 1 file changed, 2 insertions(+), 2 deletions(-)
27
28diff --git a/block/io_uring.c b/block/io_uring.c
29index 782afdb433..e451e55de0 100644
30--- a/block/io_uring.c
31+++ b/block/io_uring.c
32@@ -89,7 +89,7 @@ static void luring_resubmit_short_read(LuringState *s, LuringAIOCB *luringcb,
33 trace_luring_resubmit_short_read(s, luringcb, nread);
34
35 /* Update read position */
36- luringcb->total_read = nread;
37+ luringcb->total_read += nread;
38 remaining = luringcb->qiov->size - luringcb->total_read;
39
40 /* Shorten qiov */
41@@ -103,7 +103,7 @@ static void luring_resubmit_short_read(LuringState *s, LuringAIOCB *luringcb,
42 remaining);
43
44 /* Update sqe */
45- luringcb->sqeq.off = nread;
46+ luringcb->sqeq.off += nread;
47 luringcb->sqeq.addr = (__u64)(uintptr_t)luringcb->resubmit_qiov.iov;
48 luringcb->sqeq.len = luringcb->resubmit_qiov.niov;
49