]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
io_uring/rw: fix short rw error handling
authorPavel Begunkov <asml.silence@gmail.com>
Sun, 16 Oct 2022 21:42:56 +0000 (22:42 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Thu, 24 Nov 2022 13:25:07 +0000 (14:25 +0100)
commit4293a694bb67b02d22639e98cabfb2ffe77d7221
treef124ab7f3218af02d341d7e7faa45ba65302da6f
parent77bee90280fa33d8554db1dd8666d1a9ff6d28d5
io_uring/rw: fix short rw error handling

BugLink: https://bugs.launchpad.net/bugs/1996825
[ upstream commit 89473c1a9205760c4fa6d158058da7b594a815f0 ]

We have a couple of problems, first reports of unexpected link breakage
for reads when cqe->res indicates that the IO was done in full. The
reason here is partial IO with retries.

TL;DR; we compare the result in __io_complete_rw_common() against
req->cqe.res, but req->cqe.res doesn't store the full length but rather
the length left to be done. So, when we pass the full corrected result
via kiocb_done() -> __io_complete_rw_common(), it fails.

The second problem is that we don't try to correct res in
io_complete_rw(), which, for instance, might be a problem for O_DIRECT
but when a prefix of data was cached in the page cache. We also
definitely don't want to pass a corrected result into io_rw_done().

The fix here is to leave __io_complete_rw_common() alone, always pass
not corrected result into it and fix it up as the last step just before
actually finishing the I/O.

Cc: stable@vger.kernel.org
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/io_uring.c