* [PATCH v2] nvme/tcp: handle tls partially sent records in write_space()
@ 2025-10-10 4:25 Wilfred Mallawa
2025-10-10 5:25 ` Damien Le Moal
2025-10-10 7:03 ` Hannes Reinecke
0 siblings, 2 replies; 5+ messages in thread
From: Wilfred Mallawa @ 2025-10-10 4:25 UTC (permalink / raw)
To: linux-nvme, linux-kernel
Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
Hannes Reinecke, Wilfred Mallawa
From: Wilfred Mallawa <wilfred.mallawa@wdc.com>
With TLS enabled, records that are encrypted and appended to TLS TX
list can fail to see a retry if the underlying TCP socket is busy, for
example, hitting an EAGAIN from tcp_sendmsg_locked(). This is not known
to the NVMe TCP driver, as the TLS layer successfully generated a record.
Typically, the TLS write_space() callback would ensure such records are
retried, but in the NVMe TCP Host driver, write_space() invokes
nvme_tcp_write_space(). This causes a partially sent record in the TLS TX
list to timeout after not being retried.
This patch fixes the above by calling queue->write_space(), which calls
into the TLS layer to retry any pending records.
Fixes: be8e82caa685 ("nvme-tcp: enable TLS handshake upcall")
Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
---
V2:
- Unconditionally invoke TLS write_space(). This means we don't need
to export tls_is_partially_sent_record()
---
drivers/nvme/host/tcp.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 1413788ca7d5..6016510577bd 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -1079,8 +1079,13 @@ static void nvme_tcp_write_space(struct sock *sk)
read_lock_bh(&sk->sk_callback_lock);
queue = sk->sk_user_data;
+
if (likely(queue && sk_stream_is_writeable(sk))) {
clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ /* Ensure pending TLS partial records are retried */
+ if (nvme_tcp_queue_tls(queue))
+ queue->write_space(sk);
+
queue_work_on(queue->io_cpu, nvme_tcp_wq, &queue->io_work);
}
read_unlock_bh(&sk->sk_callback_lock);
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v2] nvme/tcp: handle tls partially sent records in write_space()
2025-10-10 4:25 [PATCH v2] nvme/tcp: handle tls partially sent records in write_space() Wilfred Mallawa
@ 2025-10-10 5:25 ` Damien Le Moal
2025-10-10 7:21 ` Wilfred Mallawa
2025-10-10 7:03 ` Hannes Reinecke
1 sibling, 1 reply; 5+ messages in thread
From: Damien Le Moal @ 2025-10-10 5:25 UTC (permalink / raw)
To: Wilfred Mallawa, linux-nvme, linux-kernel
Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
Hannes Reinecke, Wilfred Mallawa
On 2025/10/10 13:25, Wilfred Mallawa wrote:
> From: Wilfred Mallawa <wilfred.mallawa@wdc.com>
>
> With TLS enabled, records that are encrypted and appended to TLS TX
> list can fail to see a retry if the underlying TCP socket is busy, for
> example, hitting an EAGAIN from tcp_sendmsg_locked(). This is not known
> to the NVMe TCP driver, as the TLS layer successfully generated a record.
>
> Typically, the TLS write_space() callback would ensure such records are
> retried, but in the NVMe TCP Host driver, write_space() invokes
> nvme_tcp_write_space(). This causes a partially sent record in the TLS TX
> list to timeout after not being retried.
>
> This patch fixes the above by calling queue->write_space(), which calls
> into the TLS layer to retry any pending records.
>
> Fixes: be8e82caa685 ("nvme-tcp: enable TLS handshake upcall")
> Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
> ---
> V2:
> - Unconditionally invoke TLS write_space(). This means we don't need
> to export tls_is_partially_sent_record()
> ---
> drivers/nvme/host/tcp.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
> index 1413788ca7d5..6016510577bd 100644
> --- a/drivers/nvme/host/tcp.c
> +++ b/drivers/nvme/host/tcp.c
> @@ -1079,8 +1079,13 @@ static void nvme_tcp_write_space(struct sock *sk)
>
> read_lock_bh(&sk->sk_callback_lock);
> queue = sk->sk_user_data;
> +
White space change... Remove please.
> if (likely(queue && sk_stream_is_writeable(sk))) {
> clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
> + /* Ensure pending TLS partial records are retried */
> + if (nvme_tcp_queue_tls(queue))
> + queue->write_space(sk);
> +
Maybe remove this empty line too.
> queue_work_on(queue->io_cpu, nvme_tcp_wq, &queue->io_work);
> }
> read_unlock_bh(&sk->sk_callback_lock);
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2] nvme/tcp: handle tls partially sent records in write_space()
2025-10-10 5:25 ` Damien Le Moal
@ 2025-10-10 7:21 ` Wilfred Mallawa
0 siblings, 0 replies; 5+ messages in thread
From: Wilfred Mallawa @ 2025-10-10 7:21 UTC (permalink / raw)
To: dlemoal@kernel.org, linux-nvme@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: kbusch@kernel.org, hch, axboe@kernel.dk, sagi@grimberg.me,
hare@suse.de
On Fri, 2025-10-10 at 14:25 +0900, Damien Le Moal wrote:
> On 2025/10/10 13:25, Wilfred Mallawa wrote:
> > From: Wilfred Mallawa <wilfred.mallawa@wdc.com>
> >
> > With TLS enabled, records that are encrypted and appended to TLS TX
> > list can fail to see a retry if the underlying TCP socket is busy,
> > for
> > example, hitting an EAGAIN from tcp_sendmsg_locked(). This is not
> > known
> > to the NVMe TCP driver, as the TLS layer successfully generated a
> > record.
> >
> > Typically, the TLS write_space() callback would ensure such records
> > are
> > retried, but in the NVMe TCP Host driver, write_space() invokes
> > nvme_tcp_write_space(). This causes a partially sent record in the
> > TLS TX
> > list to timeout after not being retried.
> >
> > This patch fixes the above by calling queue->write_space(), which
> > calls
> > into the TLS layer to retry any pending records.
> >
> > Fixes: be8e82caa685 ("nvme-tcp: enable TLS handshake upcall")
> > Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
> > ---
> > V2:
> > - Unconditionally invoke TLS write_space(). This means we don't
> > need
> > to export tls_is_partially_sent_record()
> > ---
> > drivers/nvme/host/tcp.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
> > index 1413788ca7d5..6016510577bd 100644
> > --- a/drivers/nvme/host/tcp.c
> > +++ b/drivers/nvme/host/tcp.c
> > @@ -1079,8 +1079,13 @@ static void nvme_tcp_write_space(struct sock
> > *sk)
> >
> > read_lock_bh(&sk->sk_callback_lock);
> > queue = sk->sk_user_data;
> > +
>
> White space change... Remove please.
>
> > if (likely(queue && sk_stream_is_writeable(sk))) {
> > clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
> > + /* Ensure pending TLS partial records are retried
> > */
> > + if (nvme_tcp_queue_tls(queue))
> > + queue->write_space(sk);
> > +
>
> Maybe remove this empty line too.
Okay, Fixed in V3. Thanks!
Wilfred
>
> > queue_work_on(queue->io_cpu, nvme_tcp_wq, &queue-
> > >io_work);
> > }
> > read_unlock_bh(&sk->sk_callback_lock);
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] nvme/tcp: handle tls partially sent records in write_space()
2025-10-10 4:25 [PATCH v2] nvme/tcp: handle tls partially sent records in write_space() Wilfred Mallawa
2025-10-10 5:25 ` Damien Le Moal
@ 2025-10-10 7:03 ` Hannes Reinecke
2025-10-10 7:24 ` Wilfred Mallawa
1 sibling, 1 reply; 5+ messages in thread
From: Hannes Reinecke @ 2025-10-10 7:03 UTC (permalink / raw)
To: Wilfred Mallawa, linux-nvme, linux-kernel
Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
Wilfred Mallawa
On 10/10/25 06:25, Wilfred Mallawa wrote:
> From: Wilfred Mallawa <wilfred.mallawa@wdc.com>
>
> With TLS enabled, records that are encrypted and appended to TLS TX
> list can fail to see a retry if the underlying TCP socket is busy, for
> example, hitting an EAGAIN from tcp_sendmsg_locked(). This is not known
> to the NVMe TCP driver, as the TLS layer successfully generated a record.
>
> Typically, the TLS write_space() callback would ensure such records are
> retried, but in the NVMe TCP Host driver, write_space() invokes
> nvme_tcp_write_space(). This causes a partially sent record in the TLS TX
> list to timeout after not being retried.
>
> This patch fixes the above by calling queue->write_space(), which calls
> into the TLS layer to retry any pending records.
>
> Fixes: be8e82caa685 ("nvme-tcp: enable TLS handshake upcall")
> Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
> ---
> V2:
> - Unconditionally invoke TLS write_space(). This means we don't need
> to export tls_is_partially_sent_record()
> ---
> drivers/nvme/host/tcp.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
> index 1413788ca7d5..6016510577bd 100644
> --- a/drivers/nvme/host/tcp.c
> +++ b/drivers/nvme/host/tcp.c
> @@ -1079,8 +1079,13 @@ static void nvme_tcp_write_space(struct sock *sk)
>
> read_lock_bh(&sk->sk_callback_lock);
> queue = sk->sk_user_data;
> +
> if (likely(queue && sk_stream_is_writeable(sk))) {
> clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
> + /* Ensure pending TLS partial records are retried */
> + if (nvme_tcp_queue_tls(queue))
> + queue->write_space(sk);
> +
> queue_work_on(queue->io_cpu, nvme_tcp_wq, &queue->io_work);
> }
> read_unlock_bh(&sk->sk_callback_lock);
Minus the whitespace change:
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@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
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2] nvme/tcp: handle tls partially sent records in write_space()
2025-10-10 7:03 ` Hannes Reinecke
@ 2025-10-10 7:24 ` Wilfred Mallawa
0 siblings, 0 replies; 5+ messages in thread
From: Wilfred Mallawa @ 2025-10-10 7:24 UTC (permalink / raw)
To: Hannes Reinecke, linux-nvme, linux-kernel
Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg
On Fri, 2025-10-10 at 09:03 +0200, Hannes Reinecke wrote:
> On 10/10/25 06:25, Wilfred Mallawa wrote:
> > From: Wilfred Mallawa <wilfred.mallawa@wdc.com>
> >
> > With TLS enabled, records that are encrypted and appended to TLS TX
> > list can fail to see a retry if the underlying TCP socket is busy,
> > for
> > example, hitting an EAGAIN from tcp_sendmsg_locked(). This is not
> > known
> > to the NVMe TCP driver, as the TLS layer successfully generated a
> > record.
> >
> > Typically, the TLS write_space() callback would ensure such records
> > are
> > retried, but in the NVMe TCP Host driver, write_space() invokes
> > nvme_tcp_write_space(). This causes a partially sent record in the
> > TLS TX
> > list to timeout after not being retried.
> >
> > This patch fixes the above by calling queue->write_space(), which
> > calls
> > into the TLS layer to retry any pending records.
> >
> > Fixes: be8e82caa685 ("nvme-tcp: enable TLS handshake upcall")
> > Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
> > ---
> > V2:
> > - Unconditionally invoke TLS write_space(). This means we
> > don't need
> > to export tls_is_partially_sent_record()
> > ---
> > drivers/nvme/host/tcp.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
> > index 1413788ca7d5..6016510577bd 100644
> > --- a/drivers/nvme/host/tcp.c
> > +++ b/drivers/nvme/host/tcp.c
> > @@ -1079,8 +1079,13 @@ static void nvme_tcp_write_space(struct sock
> > *sk)
> >
> > read_lock_bh(&sk->sk_callback_lock);
> > queue = sk->sk_user_data;
> > +
> > if (likely(queue && sk_stream_is_writeable(sk))) {
> > clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
> > + /* Ensure pending TLS partial records are retried
> > */
> > + if (nvme_tcp_queue_tls(queue))
> > + queue->write_space(sk);
> > +
> > queue_work_on(queue->io_cpu, nvme_tcp_wq, &queue-
> > >io_work);
> > }
> > read_unlock_bh(&sk->sk_callback_lock);
>
> Minus the whitespace change:
>
> Reviewed-by: Hannes Reinecke <hare@suse.de>
Ah only just saw this, sent a V3 with the white-space fixed. Thanks for
the review!
Regards,
Wilfred
>
> Cheers,
>
> Hannes
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-10-10 7:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-10 4:25 [PATCH v2] nvme/tcp: handle tls partially sent records in write_space() Wilfred Mallawa
2025-10-10 5:25 ` Damien Le Moal
2025-10-10 7:21 ` Wilfred Mallawa
2025-10-10 7:03 ` Hannes Reinecke
2025-10-10 7:24 ` Wilfred Mallawa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).