Skip to content

Commit 6e92c64

Browse files
committed
io_uring/net: don't clear msg_inq before io_recv_buf_select() needs it
For bundle receives to function properly, the previous iteration msg_inq value is needed to make a judgement call on how much data there is to receive. A previous fix ended up clearing it earlier as an error case would potentially errantly set IORING_CQE_F_SOCK_NONEMPTY if the request got failed. Move the assignment to post assigning buffers for the receive, but ensure that it's cleared for the buffer selection error case. With that, buffer selection has the right msg_inq value and can correctly bundle receives as designed. Noticed while testing where it was apparent than more than 1 buffer was never received. After fix was in place, multiple buffers are correctly picked for receive. This provides a 10x speedup for the test case, as the buffer size used was 64b. Fixes: 18414a4 ("io_uring/net: assign kmsg inq/flags before buffer selection") Signed-off-by: Jens Axboe <[email protected]>
1 parent dbcabac commit 6e92c64

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

io_uring/net.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,16 +1127,18 @@ int io_recv(struct io_kiocb *req, unsigned int issue_flags)
11271127
flags |= MSG_DONTWAIT;
11281128

11291129
retry_multishot:
1130-
kmsg->msg.msg_inq = -1;
1131-
kmsg->msg.msg_flags = 0;
1132-
11331130
if (io_do_buffer_select(req)) {
11341131
ret = io_recv_buf_select(req, kmsg, &len, issue_flags);
1135-
if (unlikely(ret))
1132+
if (unlikely(ret)) {
1133+
kmsg->msg.msg_inq = -1;
11361134
goto out_free;
1135+
}
11371136
sr->buf = NULL;
11381137
}
11391138

1139+
kmsg->msg.msg_flags = 0;
1140+
kmsg->msg.msg_inq = -1;
1141+
11401142
if (flags & MSG_WAITALL)
11411143
min_ret = iov_iter_count(&kmsg->msg.msg_iter);
11421144

0 commit comments

Comments
 (0)