[PATCH 2/2] nvme-tcp: fix I/O stalls on congested sockets

Sagi Grimberg sagi at grimberg.me
Mon Apr 28 04:24:29 PDT 2025



On 28/04/2025 9:50, Hannes Reinecke wrote:
> When the socket is busy processing nvme_tcp_try_recv() might
> return -EAGAIN, but this doesn't automatically imply that
> the sending side is blocked, too.
> So check if there are pending requests once nvme_tcp_try_recv()
> returns -EAGAIN and continue with the sending loop to avoid
> I/O stalls.
>
> Acked-by: Chris Leech <cleech at redhat.com>
> Signed-off-by: Hannes Reinecke <hare at kernel.org>
> ---
>   drivers/nvme/host/tcp.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
> index 10ccd7cf5b8c..5c73af022273 100644
> --- a/drivers/nvme/host/tcp.c
> +++ b/drivers/nvme/host/tcp.c
> @@ -1363,7 +1363,7 @@ static int nvme_tcp_try_recv(struct nvme_tcp_queue *queue)
>   	queue->nr_cqe = 0;
>   	consumed = sock->ops->read_sock(sk, &rd_desc, nvme_tcp_recv_skb);
>   	release_sock(sk);
> -	return consumed;
> +	return consumed == -EAGAIN ? 0 : consumed;
>   }
>   
>   static void nvme_tcp_io_work(struct work_struct *w)
> @@ -1391,6 +1391,11 @@ static void nvme_tcp_io_work(struct work_struct *w)
>   		else if (unlikely(result < 0))
>   			return;
>   
> +		/* did we get some space after spending time in recv? */
> +		if (nvme_tcp_queue_has_pending(queue) &&
> +		    sk_stream_is_writeable(queue->sock->sk))
> +			pending = true;
> +
>   		if (!pending || !queue->rd_enabled)
>   			return;
>   

Looks fine,

Need Kamaljit to verify it.



More information about the Linux-nvme mailing list