Skip to content

Commit 664264b

Browse files
author
Ming Lei
committed
io_uring/net: only retry recv bundle for a full transfer
JIRA: https://issues.redhat.com/browse/RHEL-106845 commit 3a08988 Author: Jens Axboe <axboe@kernel.dk> Date: Wed May 21 18:51:49 2025 -0600 io_uring/net: only retry recv bundle for a full transfer If a shorter than assumed transfer was seen, a partial buffer will have been filled. For that case it isn't sane to attempt to fill more into the bundle before posting a completion, as that will cause a gap in the received data. Check if the iterator has hit zero and only allow to continue a bundle operation if that is the case. Also ensure that for putting finished buffers, only the current transfer is accounted. Otherwise too many buffers may be put for a short transfer. Link: axboe/liburing#1409 Cc: stable@vger.kernel.org Fixes: 7c71a0a ("io_uring/net: improve recv bundles") Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Ming Lei <ming.lei@redhat.com>
1 parent 582643d commit 664264b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

io_uring/net.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -818,18 +818,24 @@ static inline bool io_recv_finish(struct io_kiocb *req, int *ret,
818818
cflags |= IORING_CQE_F_SOCK_NONEMPTY;
819819

820820
if (sr->flags & IORING_RECVSEND_BUNDLE) {
821-
cflags |= io_put_kbufs(req, *ret, io_bundle_nbufs(kmsg, *ret),
821+
size_t this_ret = *ret - sr->done_io;
822+
823+
cflags |= io_put_kbufs(req, *ret, io_bundle_nbufs(kmsg, this_ret),
822824
issue_flags);
823825
if (sr->retry)
824826
cflags = req->cqe.flags | (cflags & CQE_F_MASK);
825827
/* bundle with no more immediate buffers, we're done */
826828
if (req->flags & REQ_F_BL_EMPTY)
827829
goto finish;
828-
/* if more is available, retry and append to this one */
829-
if (!sr->retry && kmsg->msg.msg_inq > 0 && *ret > 0) {
830+
/*
831+
* If more is available AND it was a full transfer, retry and
832+
* append to this one
833+
*/
834+
if (!sr->retry && kmsg->msg.msg_inq > 0 && this_ret > 0 &&
835+
!iov_iter_count(&kmsg->msg.msg_iter)) {
830836
req->cqe.flags = cflags & ~CQE_F_MASK;
831837
sr->len = kmsg->msg.msg_inq;
832-
sr->done_io += *ret;
838+
sr->done_io += this_ret;
833839
sr->retry = true;
834840
return false;
835841
}

0 commit comments

Comments
 (0)