[PATCHv2] nvme-tcp: Implement recvmsg() receive flow

Hannes Reinecke hare at suse.de
Thu Nov 27 03:37:05 PST 2025


On 11/27/25 08:53, Hannes Reinecke wrote:
> On 11/26/25 09:58, Sagi Grimberg wrote:
>>
>>
>> On 26/11/2025 9:32, Sagi Grimberg wrote:
>>>
>>>
>>> On 20/10/2025 11:58, Hannes Reinecke wrote:
>>>> The nvme-tcp code is using the ->read_sock() interface to
>>>> read data from the wire. While this interface gives us access
>>>> to the skbs themselves (and so might be able to reduce latency)
>>>> it does not interpret the skbs.
>>>> Additionally for TLS these skbs have to be re-constructed from
>>>> the TLS stream data, rendering any advantage questionable.
>>>> But the main drawback for TLS is that we do not get access to
>>>> the TLS control messages, so if we receive any of those message
>>>> the only choice we have is to tear down the connection and restart.
>>>> This patch switches the receive side over to use recvmsg(), which
>>>> provides us full access to the TLS control messages and is also
>>>> more efficient when working with TLS as skbs do not need to be
>>>> artificially constructed.
>>>
>>> Hannes,
>>>
> [ .. ]>>> @@ -940,25 +965,22 @@ static int nvme_tcp_recv_data(struct
>>>> nvme_tcp_queue *queue, struct sk_buff *skb,
>>>>           }
>>>>             /* we can read only from what is left in this bio */
>>>> -        recv_len = min_t(size_t, recv_len,
>>>> -                iov_iter_count(&req->iter));
>>>> +        memset(&msg, 0, sizeof(msg));
>>>> +        msg.msg_iter = req->iter;
>>>> +        msg.msg_flags = MSG_DONTWAIT;
>>
>> Shouldn't this be initialized outside of the loop? then the loop 
>> becomes while (msg_data_left(&msg)) ?
>>
> I'll check.
> 
Ah, no, we can't.
The conditional above might move to the next bio, and reset 'req->iter'
to point to the next bio iterator.
So we need re-initialize the message here.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare at suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich



More information about the Linux-nvme mailing list