* [PATCH for-next v2 0/2] rw link fixes
@ 2022-09-26 23:44 Pavel Begunkov
2022-09-26 23:44 ` [PATCH for-next v2 1/2] io_uring/rw: fix unexpected link breakage Pavel Begunkov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Pavel Begunkov @ 2022-09-26 23:44 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
1/2 fixes an unexpected link breakage issue with reads.
2/2 makes pre-retry setup fails a bit nicer.
v2: rebase and add tested-by
Pavel Begunkov (2):
io_uring/rw: fix unexpected link breakage
io_uring/rw: don't lose short results on io_setup_async_rw()
io_uring/rw.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
--
2.37.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH for-next v2 1/2] io_uring/rw: fix unexpected link breakage
2022-09-26 23:44 [PATCH for-next v2 0/2] rw link fixes Pavel Begunkov
@ 2022-09-26 23:44 ` Pavel Begunkov
2022-09-26 23:44 ` [PATCH for-next v2 2/2] io_uring/rw: don't lose short results on io_setup_async_rw() Pavel Begunkov
2022-09-27 0:44 ` [PATCH for-next v2 0/2] rw link fixes Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2022-09-26 23:44 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence, Beld Zhang
req->cqe.res is set in io_read() to the amount of bytes left to be done,
which is used to figure out whether to fail a read or not. However,
io_read() may do another without returning, and we stash the previous
value into ->bytes_done but forget to update cqe.res. Then we ask a read
to do strictly less than cqe.res but expect the return to be exactly
cqe.res.
Fix the bug by updating cqe.res for retries.
Cc: [email protected]
Reported-and-Tested-by: Beld Zhang <[email protected]>
Signed-off-by: Pavel Begunkov <[email protected]>
---
io_uring/rw.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/io_uring/rw.c b/io_uring/rw.c
index 59c92a4616b8..ed14322aadb9 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -793,6 +793,7 @@ int io_read(struct io_kiocb *req, unsigned int issue_flags)
return -EAGAIN;
}
+ req->cqe.res = iov_iter_count(&s->iter);
/*
* Now retry read with the IOCB_WAITQ parts set in the iocb. If
* we get -EIOCBQUEUED, then we'll get a notification when the
--
2.37.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH for-next v2 2/2] io_uring/rw: don't lose short results on io_setup_async_rw()
2022-09-26 23:44 [PATCH for-next v2 0/2] rw link fixes Pavel Begunkov
2022-09-26 23:44 ` [PATCH for-next v2 1/2] io_uring/rw: fix unexpected link breakage Pavel Begunkov
@ 2022-09-26 23:44 ` Pavel Begunkov
2022-09-27 0:44 ` [PATCH for-next v2 0/2] rw link fixes Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2022-09-26 23:44 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
If a retry io_setup_async_rw() fails we lose result from the first
io_iter_do_read(), which is a problem mostly for streams/sockets.
Cc: [email protected]
Signed-off-by: Pavel Begunkov <[email protected]>
---
io_uring/rw.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/io_uring/rw.c b/io_uring/rw.c
index ed14322aadb9..1ae1e52ab4cb 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -764,10 +764,12 @@ int io_read(struct io_kiocb *req, unsigned int issue_flags)
iov_iter_restore(&s->iter, &s->iter_state);
ret2 = io_setup_async_rw(req, iovec, s, true);
- if (ret2)
- return ret2;
-
iovec = NULL;
+ if (ret2) {
+ ret = ret > 0 ? ret : ret2;
+ goto done;
+ }
+
io = req->async_data;
s = &io->s;
/*
--
2.37.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH for-next v2 0/2] rw link fixes
2022-09-26 23:44 [PATCH for-next v2 0/2] rw link fixes Pavel Begunkov
2022-09-26 23:44 ` [PATCH for-next v2 1/2] io_uring/rw: fix unexpected link breakage Pavel Begunkov
2022-09-26 23:44 ` [PATCH for-next v2 2/2] io_uring/rw: don't lose short results on io_setup_async_rw() Pavel Begunkov
@ 2022-09-27 0:44 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2022-09-27 0:44 UTC (permalink / raw)
To: io-uring, Pavel Begunkov
On Tue, 27 Sep 2022 00:44:38 +0100, Pavel Begunkov wrote:
> 1/2 fixes an unexpected link breakage issue with reads.
> 2/2 makes pre-retry setup fails a bit nicer.
>
> v2: rebase and add tested-by
>
> Pavel Begunkov (2):
> io_uring/rw: fix unexpected link breakage
> io_uring/rw: don't lose short results on io_setup_async_rw()
>
> [...]
Applied, thanks!
[1/2] io_uring/rw: fix unexpected link breakage
commit: bf68b5b34311ee57ed40749a1257a30b46127556
[2/2] io_uring/rw: don't lose short results on io_setup_async_rw()
commit: c278d9f8ac0db5590909e6d9e85b5ca2b786704f
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-27 0:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-26 23:44 [PATCH for-next v2 0/2] rw link fixes Pavel Begunkov
2022-09-26 23:44 ` [PATCH for-next v2 1/2] io_uring/rw: fix unexpected link breakage Pavel Begunkov
2022-09-26 23:44 ` [PATCH for-next v2 2/2] io_uring/rw: don't lose short results on io_setup_async_rw() Pavel Begunkov
2022-09-27 0:44 ` [PATCH for-next v2 0/2] rw link fixes Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox