Re: [PATCH 1/2] io_uring: ensure recv and recvmsg handle MSG_WAITALL correctly

Jens Axboe
2022-03-24T00:36:02Z

On 3/23/22 6:32 PM, Stefan Metzmacher wrote:
> Hi Jens,
>
>> @@ -5524,12 +5542,22 @@ static int io_recv(struct io_kiocb *req, unsigned int issue_flags)
>> return -EAGAIN;
>> if (ret == -ERESTARTSYS)
>> ret = -EINTR;
>> + if (ret > 0 && io_net_retry(sock, flags)) {
>> + sr->len -= ret;
>> + sr->buf += ret;
>> + sr->done_io += ret;
>> + return -EAGAIN;
>> + }
>> req_set_fail(req);
>> } else if ((flags & MSG_WAITALL) && (msg.msg_flags & (MSG_TRUNC | MSG_CTRUNC))) {
>> out_free:
>> req_set_fail(req);
>
> The change only affects retry based socket io in the main thread, correct?

Not sure I follow - it affects retries for streams based sockets, where
previously they could be broken into two pieces when they should not be.

> The truncated mesages still trigger req_set_fail if MSG_WAITALL was set?

If we don't retry, regardless of flags, then we'll set failure on the
request to break links. If it ends up transferring the whole amount,
regardless of whether or not it happens in one go or not, it will not
fail links.

--
Jens Axboe