mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] nvmet-tcp: match the MAXH2CDATA comment to its byte value
@ 2026-12-03 10:32 Kenta Akagi
  2026-12-03 10:32 ` [PATCH 2/2] nvmet-tcp: advertise a 4 MiB MDTS limit Kenta Akagi
  0 siblings, 1 reply; 2+ messages in thread
From: Kenta Akagi @ 2026-12-03 10:32 UTC (permalink / raw)
  To: Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni,
	Ibrahim Hashimov, Keith Busch
  Cc: linux-nvme, linux-kernel, gerencia, mlombard, Kenta Akagi

NVMET_TCP_MAXH2CDATA is 0x400000, or 4 MiB. Update its comment to match
the existing value. The constant and its users are unchanged.

Signed-off-by: Kenta Akagi <kenta.akagi@linecorp.com>
---
 drivers/nvme/target/tcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
index 8a2e0e056131..c70804efb853 100644
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -24,7 +24,7 @@
 #include "nvmet.h"

 #define NVMET_TCP_DEF_INLINE_DATA_SIZE	(4 * PAGE_SIZE)
-#define NVMET_TCP_MAXH2CDATA		0x400000 /* 16M arbitrary limit */
+#define NVMET_TCP_MAXH2CDATA		0x400000 /* 4 MiB arbitrary limit */
 #define NVMET_TCP_BACKLOG 128

 static int param_store_val(const char *str, int *val, int min, int max)
-- 
2.51.2

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 2/2] nvmet-tcp: advertise a 4 MiB MDTS limit
  2026-12-03 10:32 [PATCH 1/2] nvmet-tcp: match the MAXH2CDATA comment to its byte value Kenta Akagi
@ 2026-12-03 10:32 ` Kenta Akagi
  0 siblings, 0 replies; 2+ messages in thread
From: Kenta Akagi @ 2026-12-03 10:32 UTC (permalink / raw)
  To: Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni,
	Ibrahim Hashimov, Keith Busch
  Cc: linux-nvme, linux-kernel, gerencia, mlombard, Kenta Akagi, stable

Commit 4a3f00262a04 ("nvmet-tcp: bound SGL data length before allocating
command buffers") added a command-wide SGL length check before buffer
allocation. The check rejects lengths above NVMET_TCP_MAXH2CDATA,
currently 4 MiB. ICResp MAXH2CDATA only limits the data in each H2CData
PDU; it does not advertise a maximum command transfer size.

However, nvmet-tcp does not provide get_mdts, so Identify Controller
reports MDTS=0 (no maximum transfer size) by default. An initiator can
therefore submit commands transferring more than 4 MiB, which the target
rejects with NVME_SC_SGL_INVALID_DATA | NVME_STATUS_DNR.

Provide an nvmet-tcp get_mdts callback returning NVMET_TCP_MAX_MDTS,
set to 10. With the current CAP.MPSMIN of zero, this advertises 4 MiB.
The existing allocation protection and per-PDU limits are unchanged.

MDTS and MAXH2CDATA describe different limits, but nvmet_tcp_map_data()
also uses NVMET_TCP_MAXH2CDATA as a command-wide allocation limit.
Match the advertised MDTS to this existing limit so initiators avoid
submitting commands that the target rejects.

MDTS enforcement remains a follow-up. Passthrough is unchanged:
nvmet_passthru_override_id_ctrl() may report MDTS > 10, but no failure
has been reproduced.

Fixes: 4a3f00262a04 ("nvmet-tcp: bound SGL data length before
allocating command buffers")
Reported-by: Alfonso Kuen <gerencia@idkmanager.com>
Link: https://lore.kernel.org/linux-nvme/20260829013900.10392-1-gerencia@idkmanager.com/
Cc: stable@vger.kernel.org
Signed-off-by: Kenta Akagi <kenta.akagi@linecorp.com>
---
 drivers/nvme/target/tcp.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
index c70804efb853..6507ebc3b5ac 100644
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -24,6 +24,7 @@
 #include "nvmet.h"

 #define NVMET_TCP_DEF_INLINE_DATA_SIZE	(4 * PAGE_SIZE)
+#define NVMET_TCP_MAX_MDTS		10 /* 4 MiB with CAP.MPSMIN == 0 */
 #define NVMET_TCP_MAXH2CDATA		0x400000 /* 4 MiB arbitrary limit */
 #define NVMET_TCP_BACKLOG 128

@@ -2301,6 +2302,11 @@ static ssize_t nvmet_tcp_host_port_addr(struct
nvmet_ctrl *ctrl,
 			(struct sockaddr *)&queue->sockaddr_peer);
 }

+static u8 nvmet_tcp_get_mdts(const struct nvmet_ctrl *ctrl)
+{
+	return NVMET_TCP_MAX_MDTS;
+}
+
 static const struct nvmet_fabrics_ops nvmet_tcp_ops = {
 	.owner			= THIS_MODULE,
 	.type			= NVMF_TRTYPE_TCP,
@@ -2312,6 +2318,7 @@ static const struct nvmet_fabrics_ops nvmet_tcp_ops = {
 	.install_queue		= nvmet_tcp_install_queue,
 	.disc_traddr		= nvmet_tcp_disc_port_addr,
 	.host_traddr		= nvmet_tcp_host_port_addr,
+	.get_mdts		= nvmet_tcp_get_mdts,
 };

 static int __init nvmet_tcp_init(void)
-- 
2.51.2

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-03 10:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-03 10:32 [PATCH 1/2] nvmet-tcp: match the MAXH2CDATA comment to its byte value Kenta Akagi
2026-12-03 10:32 ` [PATCH 2/2] nvmet-tcp: advertise a 4 MiB MDTS limit Kenta Akagi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®