Skip to content

Commit eacc6df

Browse files
committed
io_uring: remove punt of short reads to async context
We currently punt any short read on a regular file to async context, but this fails if the short read is due to running into EOF. This is especially problematic since we only do the single prep for commands now, as we don't reset kiocb->ki_pos. This can result in a 4k read on a 1k file returning zero, as we detect the short read and then retry from async context. At the time of retry, the position is now 1k, and we end up reading nothing, and hence return 0. Instead of trying to patch around the fact that short reads can be legitimate and won't succeed in case of retry, remove the logic to punt a short read to async context. Simply return it. Signed-off-by: Jens Axboe <[email protected]>
1 parent fd1c4bc commit eacc6df

File tree

1 file changed

+0
-12
lines changed

1 file changed

+0
-12
lines changed

fs/io_uring.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,18 +1863,6 @@ static int io_read(struct io_kiocb *req, struct io_kiocb **nxt,
18631863
else
18641864
ret2 = loop_rw_iter(READ, req->file, kiocb, &iter);
18651865

1866-
/*
1867-
* In case of a short read, punt to async. This can happen
1868-
* if we have data partially cached. Alternatively we can
1869-
* return the short read, in which case the application will
1870-
* need to issue another SQE and wait for it. That SQE will
1871-
* need async punt anyway, so it's more efficient to do it
1872-
* here.
1873-
*/
1874-
if (force_nonblock && !(req->flags & REQ_F_NOWAIT) &&
1875-
(req->flags & REQ_F_ISREG) &&
1876-
ret2 > 0 && ret2 < io_size)
1877-
ret2 = -EAGAIN;
18781866
/* Catch -EAGAIN return for forced non-blocking submission */
18791867
if (!force_nonblock || ret2 != -EAGAIN) {
18801868
kiocb_done(kiocb, ret2, nxt, req->in_async);

0 commit comments

Comments
 (0)