NVME over MPTCP
Subsystems (5)
Geliang Tang
reviewercover NVME over MPTCP
From: Geliang Tang <[email protected]>
This series (previously named "MPTCP support to 'NVME over TCP'") had three RFC versions sent to Hannes in May, with subsequent revisions based on his input. Following that, I initiated the process of upstreaming the dependent "implement mptcp read_sock" series to the main MPTCP repository, which has now largely taken shape.
Currently, the biggest problem I'm facing is in Patch 6, where I'm unsure how to handle MSG_DONTWAIT. That's why I've sent this RFC version to get your opinions.
Based-on: <[email protected]>
Geliang Tang (6):
mptcp: add sock_set_nodelay
nvmet-tcp: add mptcp support
mptcp: add sock_set_reuseaddr
nvme-tcp: add mptcp support
selftests: mptcp: add NVMe-over-MPTCP test
nvmet-tcp: clear MSG_DONTWAIT for MPTCP (TODO: HELP WANTED)
drivers/nvme/host/tcp.c | 27 ++++++++- drivers/nvme/target/configfs.c | 1 + drivers/nvme/target/tcp.c | 54 ++++++++++++++++-- include/linux/nvme.h | 1 + include/net/mptcp.h | 8 +++ net/mptcp/protocol.c | 33 +++++++++++ tools/testing/selftests/net/mptcp/config | 7 +++ .../testing/selftests/net/mptcp/mptcp_nvme.sh | 57 +++++++++++++++++++ 8 files changed, 180 insertions(+), 8 deletions(-) create mode 100755 tools/testing/selftests/net/mptcp/mptcp_nvme.sh
Signature · 1 line
2.43.0
Geliang Tang
reviewerRFC 1/6 mptcp: add sock_set_nodelay
From: Geliang Tang <[email protected]>
This patch adds support for the TCP_NODELAY socket option in MPTCP by introducing a new mptcp_sock_set_nodelay() function. The implementation:
1. Exposes the function in include/net/mptcp.h for external use
2. Provides the actual implementation in protocol.c that:
- Locks the MPTCP master socket
- Retrieves the first subflow socket
- Sets TCP_NODELAY on the subflow using __tcp_sock_set_nodelay()
- Properly handles locking and error cases
The function follows MPTCP's standard pattern for modifying subflow options while maintaining proper socket locking semantics. When called, it will disable Nagle's algorithm on the underlying TCP subflow, which can help reduce latency for certain types of applications.
--- include/net/mptcp.h | 4 ++++ net/mptcp/protocol.c | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+)
include/net/mptcp.h +4 -0
@@ -237,6 +237,8 @@ static inline __be32 mptcp_reset_option(const struct sk_buff *skb) }void mptcp_active_detect_blackhole (struct sock *sk,bool expired); + +void mptcp_sock_set_nodelay (struct sock *sk);#else static inline void mptcp_init (void )
@@ -323,6 +325,8 @@ static inline struct request_sock *mptcp_subflow_reqsk_alloc(const struct requesstatic inline __be32 mptcp_reset_option (const struct sk_buff *skb) {return htonl (0u ); }static inline void mptcp_active_detect_blackhole (struct sock *sk,bool expired) { } + +static void mptcp_sock_set_nodelay (struct sock *sk) { }#endif /* CONFIG_MPTCP */ #if IS_ENABLED (CONFIG_MPTCP_IPV6 )
net/mptcp/protocol.c +18 -0
@@ -3696,6 +3696,24 @@ void mptcp_sock_graft(struct sock *sk, struct socket *parent)write_unlock_bh (&sk->sk_callback_lock); } +void mptcp_sock_set_nodelay (struct sock *sk) +{ +struct mptcp_sock *msk =mptcp_sk (sk); +struct sock *ssk; + +lock_sock (sk); + ssk =__mptcp_nmpc_sk (msk); +if (IS_ERR (ssk)) + goto unlock; + +lock_sock (ssk); +__tcp_sock_set_nodelay (ssk, true); +release_sock (ssk); +unlock: +release_sock (sk); +} +EXPORT_SYMBOL (mptcp_sock_set_nodelay); +bool mptcp_finish_join (struct sock *ssk) {struct mptcp_subflow_context *subflow =mptcp_subflow_ctx (ssk);
Signature · 1 line
2.43.0
kernel test robot
build botRe: [RFC mptcp-next 1/6] mptcp: add sock_set_nodelay
kernel test robot noticed the following build warnings:
Hi Geliang,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build warnings:
[auto build test WARNING on mptcp/export]
[also build test WARNING on mptcp/export-net linux-nvme/for-next linus/master v6.18-rc4 next-20251107] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Geliang-Tang/mptcp-add-sock_set_nodelay/20251107-113907 base: https://github.com/multipath-tcp/mptcp_net-next.git export patch link: https://lore.kernel.org/r/a1cf1ae0309392bee2e97b9a1640c7a056204fbd.1762485513.git.tanggeliang%40kylinos.cn patch subject: [RFC mptcp-next 1/6] mptcp: add sock_set_nodelay config: riscv-randconfig-002-20251108 (https://download.01.org/0day-ci/archive/20251108/[email protected]/config) compiler: riscv64-linux-gcc (GCC) 12.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251108/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from include/net/tcp.h:44,
from net/core/devmem.c:20:
>> include/net/mptcp.h:329:13: warning: 'mptcp_sock_set_nodelay' defined but not used [-Wunused-function]
329 | static void mptcp_sock_set_nodelay(struct sock *sk) { }
| ^~~~~~~~~~~~~~~~~~~~~~vim +/mptcp_sock_set_nodelay +329 include/net/mptcp.h
328
> 329 static void mptcp_sock_set_nodelay(struct sock *sk) { } 330 #endif /* CONFIG_MPTCP */
331
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Geliang Tang
reviewerRFC 2/6 nvmet-tcp: add mptcp support
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
This patch adds a new nvme target transport type NVMF_TRTYPE_MPTCP for MPTCP. And defines a new nvmet_fabrics_ops named nvmet_mptcp_ops, which is almost the same as nvmet_tcp_ops except .type.
Check if disc_addr.trtype is NVMF_TRTYPE_MPTCP in nvmet_tcp_add_port() to decide whether to pass IPPROTO_MPTCP to sock_create() to create a MPTCP socket instead of a TCP one.
This new nvmet_fabrics_ops can be switched in nvmet_tcp_done_recv_pdu() according to different protocol.
v2:
- use trtype instead of tsas (Hannes).
v3:
- check mptcp protocol from disc_addr.trtype instead of passing a
parameter (Hannes).
v4:
- check CONFIG_MPTCP.
v5:
- Thanks to Hui Zhu for helping me debug the following list corruption issue using gdb:
[ 13.043520][ T179] nvmet: adding nsid 1 to subsystem nqn.2014-08.org.nvmexpress.mptcpdev [ 13.197544][ T181] nvmet_tcp: enabling port 1234 (127.0.0.1:4420) [ 13.395800][ T182] slab MPTCP start ffff8880108f0b80 pointer offset 2480 size 2816 [ 13.396422][ T182] list_add corruption. prev->next should be next (ffff8880108f1530), but was ffff8885108f1530. (prev=ffff8880108f1530). [ 13.397064][ T182] ------------[ cut here ]------------ [ 13.397305][ T182] kernel BUG at lib/list_debug.c:32! [ 13.397668][ T182] Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI [ 13.397914][ T182] CPU: 1 UID: 0 PID: 182 Comm: nvme Not tainted 6.16.0-rc3+ #1 PREEMPT(full) [ 13.398282][ T182] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 - This issue was finally located in tcp_sock_set_nodelay(). When using MPTCP, set_nodelay of TCP cannot be invoked. We need to implement a MPTCP one.
--- drivers/nvme/host/tcp.c | 4 +++- drivers/nvme/target/configfs.c | 1 + drivers/nvme/target/tcp.c | 34 ++++++++++++++++++++++++++++++++-- include/linux/nvme.h | 1 + 4 files changed, 37 insertions(+), 3 deletions(-)
drivers/nvme/host/tcp.c +3 -1
@@ -19,6 +19,7 @@#include <linux/blk-mq.h> #include <net/busy_poll.h> #include <trace/events/sock.h> +#include <net/mptcp.h> #include "nvme.h" #include "fabrics.h"
@@ -1804,7 +1805,8 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid,tcp_sock_set_syncnt (queue->sock->sk,1 );/* Set TCP no delay */ -tcp_sock_set_nodelay (queue->sock->sk); + proto ==IPPROTO_MPTCP ?mptcp_sock_set_nodelay (queue->sock->sk) : +tcp_sock_set_nodelay (queue->sock->sk);/* * Cleanup whatever is sitting in the TCP transmit queue on socket
drivers/nvme/target/configfs.c +1 -0
@@ -37,6 +37,7 @@ static struct nvmet_type_name_map nvmet_transport[] = { { NVMF_TRTYPE_RDMA, "rdma" }, { NVMF_TRTYPE_FC, "fc" }, { NVMF_TRTYPE_TCP, "tcp" }, + { NVMF_TRTYPE_MPTCP, "mptcp" }, { NVMF_TRTYPE_PCI, "pci" }, { NVMF_TRTYPE_LOOP, "loop" }, };
drivers/nvme/target/tcp.c +32 -2
@@ -212,6 +212,7 @@ static DEFINE_MUTEX(nvmet_tcp_queue_mutex);static struct workqueue_struct *nvmet_tcp_wq;static const struct nvmet_fabrics_ops nvmet_tcp_ops; +static const struct nvmet_fabrics_ops nvmet_mptcp_ops;static void nvmet_tcp_free_cmd (struct nvmet_tcp_cmd *c);static void nvmet_tcp_free_cmd_buffers (struct nvmet_tcp_cmd *cmd);
@@ -999,6 +1000,7 @@ static int nvmet_tcp_done_recv_pdu(struct nvmet_tcp_queue *queue) {struct nvme_tcp_hdr *hdr = &queue->pdu.cmd.hdr;struct nvme_command *nvme_cmd = &queue->pdu.cmd.cmd; +const struct nvmet_fabrics_ops *ops;struct nvmet_req *req;int ret;
@@ -1039,7 +1041,9 @@ static int nvmet_tcp_done_recv_pdu(struct nvmet_tcp_queue *queue) req = &queue->cmd->req;memcpy (req->cmd, nvme_cmd,sizeof (*nvme_cmd)); -if (unlikely (!nvmet_req_init (req, &queue->nvme_sq, &nvmet_tcp_ops))) { + ops = queue->sock->sk->sk_protocol ==IPPROTO_MPTCP ? + &nvmet_mptcp_ops : &nvmet_tcp_ops; +if (unlikely (!nvmet_req_init (req, &queue->nvme_sq, ops))) { pr_err("failed cmd %p id %d opcode %d, data_len: %d, status: %04x\n", req->cmd, req->cmd->common.command_id, req->cmd->common.opcode,
@@ -2007,6 +2011,7 @@ static int nvmet_tcp_add_port(struct nvmet_port *nport) {struct nvmet_tcp_port *port;__kernel_sa_family_t af; +int proto =IPPROTO_TCP ;int ret; port =kzalloc (sizeof (*port),GFP_KERNEL );
@@ -2027,6 +2032,11 @@ static int nvmet_tcp_add_port(struct nvmet_port *nport) goto err_port; } +#ifdef CONFIG_MPTCP +if (nport->disc_addr.trtype ==NVMF_TRTYPE_MPTCP ) + proto =IPPROTO_MPTCP ; +#endif + ret =inet_pton_with_scope (&init_net, af, nport->disc_addr.traddr, nport->disc_addr.trsvcid, &port->addr);if (ret) {
@@ -2041,7 +2051,7 @@ static int nvmet_tcp_add_port(struct nvmet_port *nport) port->nport->inline_data_size =NVMET_TCP_DEF_INLINE_DATA_SIZE ; ret =sock_create (port->addr.ss_family,SOCK_STREAM , -IPPROTO_TCP , &port->sock); + proto, &port->sock);if (ret) {pr_err ("failed to create a socket\n" ); goto err_port;
@@ -2193,6 +2203,19 @@ static const struct nvmet_fabrics_ops nvmet_tcp_ops = { .host_traddr = nvmet_tcp_host_port_addr, }; +static const struct nvmet_fabrics_ops nvmet_mptcp_ops = { + .owner =THIS_MODULE , + .type =NVMF_TRTYPE_MPTCP , + .msdbd =1 , + .add_port = nvmet_tcp_add_port, + .remove_port = nvmet_tcp_remove_port, + .queue_response = nvmet_tcp_queue_response, + .delete_ctrl = nvmet_tcp_delete_ctrl, + .install_queue = nvmet_tcp_install_queue, + .disc_traddr = nvmet_tcp_disc_port_addr, + .host_traddr = nvmet_tcp_host_port_addr, +}; +static int __init nvmet_tcp_init (void ) {int ret;
@@ -2206,6 +2229,12 @@ static int __init nvmet_tcp_init(void)if (ret) goto err; + ret =nvmet_register_transport (&nvmet_mptcp_ops); +if (ret) { +nvmet_unregister_transport (&nvmet_tcp_ops); + goto err; + } +return 0 ; err:destroy_workqueue (nvmet_tcp_wq);
@@ -2216,6 +2245,7 @@ static void __exit nvmet_tcp_exit(void) {struct nvmet_tcp_queue *queue; +nvmet_unregister_transport (&nvmet_mptcp_ops);nvmet_unregister_transport (&nvmet_tcp_ops);flush_workqueue (nvmet_wq);
include/linux/nvme.h +1 -0
@@ -68,6 +68,7 @@ enum {NVMF_TRTYPE_RDMA =1 ,/* RDMA */ NVMF_TRTYPE_FC =2 ,/* Fibre Channel */ NVMF_TRTYPE_TCP =3 ,/* TCP/IP */ +NVMF_TRTYPE_MPTCP =4 ,/* Multipath TCP */ NVMF_TRTYPE_LOOP =254 ,/* Reserved for host usage */ NVMF_TRTYPE_MAX, };
Signature · 1 line
2.43.0
Geliang Tang
reviewerRFC 3/6 mptcp: add sock_set_reuseaddr
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
This patch adds support for the SO_REUSEADDR socket option in MPTCP by introducing a new mptcp_sock_set_reuseaddr() function. The implementation:
1. Exposes the function in include/net/mptcp.h for external use
2. Provides the actual implementation in protocol.c that:
- Locks the MPTCP master socket
- Retrieves the first subflow socket
- Sets SK_CAN_REUSE flag on the subflow
- Properly handles locking and error cases
The function follows the same pattern as other MPTCP socket option helpers, maintaining proper locking semantics while allowing address reuse on the underlying TCP subflows. This enables MPTCP sockets to bind to addresses that are already in use, which is particularly useful for:
- Server applications that need to restart quickly
- Applications using well-known ports
- Multi-homed scenarios where the same port may be used across interfaces
--- include/net/mptcp.h | 4 ++++ net/mptcp/protocol.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+)
include/net/mptcp.h +4 -0
@@ -239,6 +239,8 @@ static inline __be32 mptcp_reset_option(const struct sk_buff *skb)void mptcp_active_detect_blackhole (struct sock *sk,bool expired);void mptcp_sock_set_nodelay (struct sock *sk); + +void mptcp_sock_set_reuseaddr (struct sock *sk);#else static inline void mptcp_init (void )
@@ -327,6 +329,8 @@ static inline __be32 mptcp_reset_option(const struct sk_buff *skb) { return htostatic inline void mptcp_active_detect_blackhole (struct sock *sk,bool expired) { }static void mptcp_sock_set_nodelay (struct sock *sk) { } + +static void mptcp_sock_set_reuseaddr (struct sock *sk) { }#endif /* CONFIG_MPTCP */ #if IS_ENABLED (CONFIG_MPTCP_IPV6 )
net/mptcp/protocol.c +15 -0
@@ -3714,6 +3714,21 @@ void mptcp_sock_set_nodelay(struct sock *sk) }EXPORT_SYMBOL (mptcp_sock_set_nodelay); +void mptcp_sock_set_reuseaddr (struct sock *sk) +{ +struct mptcp_sock *msk =mptcp_sk (sk); +struct sock *ssk; + +lock_sock (sk); + ssk =__mptcp_nmpc_sk (msk); +if (IS_ERR (ssk)) + goto unlock; + ssk->sk_reuse =SK_CAN_REUSE ; +unlock: +release_sock (sk); +} +EXPORT_SYMBOL (mptcp_sock_set_reuseaddr); +bool mptcp_finish_join (struct sock *ssk) {struct mptcp_subflow_context *subflow =mptcp_subflow_ctx (ssk);
Signature · 1 line
2.43.0
kernel test robot
build botRe: [RFC mptcp-next 3/6] mptcp: add sock_set_reuseaddr
kernel test robot noticed the following build warnings:
Hi Geliang,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build warnings:
[auto build test WARNING on mptcp/export]
[also build test WARNING on mptcp/export-net linus/master v6.18-rc4 next-20251107] [cannot apply to linux-nvme/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Geliang-Tang/mptcp-add-sock_set_nodelay/20251107-113907 base: https://github.com/multipath-tcp/mptcp_net-next.git export patch link: https://lore.kernel.org/r/32da8f2876b30d35602232e9021d312bd105b2de.1762485513.git.tanggeliang%40kylinos.cn patch subject: [RFC mptcp-next 3/6] mptcp: add sock_set_reuseaddr config: riscv-randconfig-002-20251108 (https://download.01.org/0day-ci/archive/20251108/[email protected]/config) compiler: riscv64-linux-gcc (GCC) 12.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251108/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from include/net/tcp.h:44,
from net/core/devmem.c:20:
>> include/net/mptcp.h:333:13: warning: 'mptcp_sock_set_reuseaddr' defined but not used [-Wunused-function]
333 | static void mptcp_sock_set_reuseaddr(struct sock *sk) { }
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/net/mptcp.h:331:13: warning: 'mptcp_sock_set_nodelay' defined but not used [-Wunused-function]
331 | static void mptcp_sock_set_nodelay(struct sock *sk) { }
| ^~~~~~~~~~~~~~~~~~~~~~vim +/mptcp_sock_set_reuseaddr +333 include/net/mptcp.h
332
> 333 static void mptcp_sock_set_reuseaddr(struct sock *sk) { } 334 #endif /* CONFIG_MPTCP */
335
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Geliang Tang
reviewerRFC 4/6 nvme-tcp: add mptcp support
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
This patch defines a new nvmf_transport_ops named nvme_mptcp_transport, which is almost the same as nvme_tcp_transport except .type.
Check if opts->transport is "mptcp" in nvme_tcp_alloc_queue() to decide whether to pass IPPROTO_MPTCP to sock_create_kern() to create a MPTCP socket instead of a TCP one.
v2:
- use 'trtype' instead of '--mptcp' (Hannes)
v3:
- check mptcp protocol from opts->transport instead of passing a
parameter (Hannes).
v4:
- check CONFIG_MPTCP.
--- drivers/nvme/host/tcp.c | 23 ++++++++++++++++++++++- drivers/nvme/target/tcp.c | 10 ++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-)
drivers/nvme/host/tcp.c +22 -1
@@ -1767,6 +1767,7 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid, {struct nvme_tcp_ctrl *ctrl =to_tcp_ctrl (nctrl);struct nvme_tcp_queue *queue = &ctrl->queues[qid]; +int proto =IPPROTO_TCP ;int ret, rcv_pdu_size;struct file *sock_file;
@@ -1783,9 +1784,14 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid, queue->cmnd_capsule_len =sizeof (struct nvme_command ) +NVME_TCP_ADMIN_CCSZ ; +#ifdef CONFIG_MPTCP +if (!strcmp (ctrl->ctrl.opts->transport,"mptcp" )) + proto =IPPROTO_MPTCP ; +#endif + ret =sock_create_kern (current->nsproxy->net_ns, ctrl->addr.ss_family,SOCK_STREAM , -IPPROTO_TCP , &queue->sock); + proto, &queue->sock);if (ret) {dev_err (nctrl->device,"failed to create socket: %d\n" , ret);
@@ -3024,6 +3030,19 @@ static struct nvmf_transport_ops nvme_tcp_transport = { .create_ctrl = nvme_tcp_create_ctrl, }; +static struct nvmf_transport_ops nvme_mptcp_transport = { + .name ="mptcp" , + .module =THIS_MODULE , + .required_opts =NVMF_OPT_TRADDR , + .allowed_opts =NVMF_OPT_TRSVCID |NVMF_OPT_RECONNECT_DELAY | +NVMF_OPT_HOST_TRADDR |NVMF_OPT_CTRL_LOSS_TMO | +NVMF_OPT_HDR_DIGEST |NVMF_OPT_DATA_DIGEST | +NVMF_OPT_NR_WRITE_QUEUES |NVMF_OPT_NR_POLL_QUEUES | +NVMF_OPT_TOS |NVMF_OPT_HOST_IFACE |NVMF_OPT_TLS | +NVMF_OPT_KEYRING |NVMF_OPT_TLS_KEY |NVMF_OPT_CONCAT , + .create_ctrl = nvme_tcp_create_ctrl, +}; +static int __init nvme_tcp_init_module (void ) {unsigned int wq_flags =WQ_MEM_RECLAIM |WQ_HIGHPRI |WQ_SYSFS ;
@@ -3049,6 +3068,7 @@ static int __init nvme_tcp_init_module(void)atomic_set (&nvme_tcp_cpu_queues[cpu],0 );nvmf_register_transport (&nvme_tcp_transport); +nvmf_register_transport (&nvme_mptcp_transport);return 0 ; }
@@ -3056,6 +3076,7 @@ static void __exit nvme_tcp_cleanup_module(void) {struct nvme_tcp_ctrl *ctrl; +nvmf_unregister_transport (&nvme_mptcp_transport);nvmf_unregister_transport (&nvme_tcp_transport);mutex_lock (&nvme_tcp_ctrl_mutex);
drivers/nvme/target/tcp.c +8 -2
@@ -16,6 +16,7 @@#include <net/tls.h> #include <net/tls_prot.h> #include <net/handshake.h> +#include <net/mptcp.h> #include <linux/inet.h> #include <linux/llist.h> #include <trace/events/sock.h>
@@ -2060,8 +2061,13 @@ static int nvmet_tcp_add_port(struct nvmet_port *nport) port->sock->sk->sk_user_data = port; port->data_ready = port->sock->sk->sk_data_ready; port->sock->sk->sk_data_ready = nvmet_tcp_listen_data_ready; -sock_set_reuseaddr (port->sock->sk); -tcp_sock_set_nodelay (port->sock->sk); +if (proto ==IPPROTO_MPTCP ) { +mptcp_sock_set_reuseaddr (port->sock->sk); +mptcp_sock_set_nodelay (port->sock->sk); + }else { +sock_set_reuseaddr (port->sock->sk); +tcp_sock_set_nodelay (port->sock->sk); + }if (so_priority >0 )sock_set_priority (port->sock->sk, so_priority);
Signature · 1 line
2.43.0
Geliang Tang
reviewerRFC 5/6 selftests: mptcp: add NVMe-over-MPTCP test
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
This patch introduces a new selftest that evaluates NVMe-over-Fabrics performance when using MPTCP as the transport protocol. The test:
1. Sets up a local NVMe target configuration using:
- A loopback device as storage backend
- MPTCP as the transport type
- IPv4 addressing
2. Performs standard NVMe operations including:
- Discovery and connection
- Device listing
- Random read/write performance tests using fio
3. Cleans up all test resources
The test script (mptcp_nvme.sh) accepts parameters for transport type and target address, defaulting to MPTCP and localhost. It measures performance using fio with:
- 4 parallel jobs
- 256 I/O depth
- 4KB block size
- 10 second runtime
- Both random read and write patterns
Required kernel config options are added to the MPTCP selftest config file to support NVMe-over-TCP functionality.
This test helps validate MPTCP's suitability for storage networking workloads and provides a benchmark for performance comparisons.
--- tools/testing/selftests/net/mptcp/config | 7 +++ .../testing/selftests/net/mptcp/mptcp_nvme.sh | 57 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100755 tools/testing/selftests/net/mptcp/mptcp_nvme.sh
tools/testing/selftests/net/mptcp/config +7 -0
@@ -34,3 +34,10 @@ CONFIG_NFT_SOCKET=m CONFIG_NFT_TPROXY=m CONFIG_SYN_COOKIES=y CONFIG_VETH=y +CONFIG_CONFIGFS_FS=y +CONFIG_NVME_CORE=y +CONFIG_NVME_FABRICS=y +CONFIG_NVME_TCP=y +CONFIG_NVME_TARGET=y +CONFIG_NVME_TARGET_TCP=y +CONFIG_NVME_MULTIPATH=y
tools/testing/selftests/net/mptcp/mptcp_nvme.sh new file +57 -0
57 lines not on this page · raw message
Signature · 1 line
2.43.0
Geliang Tang
reviewerRFC 6/6 nvmet-tcp: clear MSG_DONTWAIT for MPTCP (TODO: HELP WANTED)
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
When running the tests from a previous commit in a loop, there is about a one in ten chance of reporting the following "timeout" error:
'''
[ 32.867710] nvme nvme0: I/O tag 1 (0001) type 4 opcode 0x2 (I/O Cmd) QID 2 timeout [ 32.867929] nvme nvme0: starting error recovery [ 32.867994] nvme nvme0: I/O tag 2 (0002) type 4 opcode 0x2 (I/O Cmd) QID 2 timeout [ 32.868112] nvme nvme0: I/O tag 3 (0003) type 4 opcode 0x2 (I/O Cmd) QID 2 timeout [ 32.868359] nvme nvme0: I/O tag 4 (0004) type 4 opcode 0x2 (I/O Cmd) QID 2 timeout [ 32.868446] nvme nvme0: I/O tag 5 (0005) type 4 opcode 0x2 (I/O Cmd) QID 2 timeout [ 32.868592] nvme0c0n1: I/O Cmd(0x2) @ LBA 1046528, 8 blocks, I/O Error (sct 0x3 / sc 0x70) [ 32.868817] recoverable transport error, dev nvme0c0n1, sector 1046528 op 0x0:(READ) flags 0x2080700 phys_seg 1 prio class 0 [ 32.868976] block nvme0n1: no usable path - requeuing I/O [ 32.869038] nvme nvme0: I/O tag 6 (0006) type 4 opcode 0x2 (I/O Cmd) QID 2 timeout [ 32.869119] nvme nvme0: I/O tag 7 (0007) type 4 opcode 0x2 (I/O Cmd) QID 2 timeout ... ... [ 32.877945] nvme nvme0: I/O tag 122 (107a) type 4 opcode 0x2 (I/O Cmd) QID 2 timeout [ 32.878025] block nvme0n1: no usable path - requeuing I/O [ 32.878079] block nvme0n1: no usable path - requeuing I/O [ 32.878128] block nvme0n1: no usable path - requeuing I/O [ 32.878180] block nvme0n1: no usable path - requeuing I/O [ 32.878238] block nvme0n1: no usable path - requeuing I/O [ 32.878296] block nvme0n1: no usable path - requeuing I/O [ 32.878350] block nvme0n1: no usable path - requeuing I/O [ 32.878403] block nvme0n1: no usable path - requeuing I/O [ 32.878455] block nvme0n1: no usable path - requeuing I/O [ 32.883603] nvme nvme0: Reconnecting in 10 seconds...
'''
Through debugging, I discovered that setting the MSG_DONTWAIT flag leads to MPTCP returning EAGAIN in mptcp_sendmsg.
This patch addresses it by dropping the MSG_DONTWAIT flag for MPTCP. I know this isn't an ideal fix, and I need your suggestions.
--- drivers/nvme/target/tcp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/nvme/target/tcp.c +8 -2
@@ -645,12 +645,15 @@ static int nvmet_try_send_data(struct nvmet_tcp_cmd *cmd, bool last_in_batch)while (cmd->cur_sg) {struct msghdr msg = { - .msg_flags =MSG_DONTWAIT |MSG_SPLICE_PAGES , + .msg_flags =MSG_SPLICE_PAGES , };struct page *page =sg_page (cmd->cur_sg);struct bio_vec bvec;u32 left = cmd->cur_sg->length - cmd->offset; +if (cmd->queue->sock->sk->sk_protocol !=IPPROTO_MPTCP ) + msg.msg_flags |=MSG_DONTWAIT ; +if ((!last_in_batch && cmd->queue->send_list_len) || cmd->wbytes_done + left < cmd->req.transfer_len || queue->data_digest || !queue->nvme_sq.sqhd_disabled)
@@ -694,12 +697,15 @@ static int nvmet_try_send_data(struct nvmet_tcp_cmd *cmd, bool last_in_batch)static int nvmet_try_send_response (struct nvmet_tcp_cmd *cmd,bool last_in_batch) { -struct msghdr msg = { .msg_flags =MSG_DONTWAIT |MSG_SPLICE_PAGES , }; +struct msghdr msg = { .msg_flags =MSG_SPLICE_PAGES , };struct bio_vec bvec;u8 hdgst =nvmet_tcp_hdgst_len (cmd->queue);int left =sizeof (*cmd->rsp_pdu) - cmd->offset + hdgst;int ret; +if (cmd->queue->sock->sk->sk_protocol !=IPPROTO_MPTCP ) + msg.msg_flags |=MSG_DONTWAIT ; +if (!last_in_batch && cmd->queue->send_list_len) msg.msg_flags |=MSG_MORE ;else
Signature · 1 line
2.43.0
Geliang Tang
reviewerRe: [RFC mptcp-next 6/6] nvmet-tcp: clear MSG_DONTWAIT for MPTCP (TODO: HELP WANTED)
Quoted 42 lines · Geliang Tang
From: Geliang Tang <[email protected]>
When running the tests from a previous commit in a loop, there is about a
one in ten chance of reporting the following "timeout" error:'''
[ 32.867710] nvme nvme0: I/O tag 1 (0001) type 4 opcode0x2(I/O Cmd) QID 2 timeout
[ 32.867929] nvme nvme0: starting error recovery
[ 32.867994] nvme nvme0: I/O tag 2 (0002) type 4 opcode0x2(I/O Cmd) QID 2 timeout
[ 32.868112] nvme nvme0: I/O tag 3 (0003) type 4 opcode0x2(I/O Cmd) QID 2 timeout
[ 32.868359] nvme nvme0: I/O tag 4 (0004) type 4 opcode0x2(I/O Cmd) QID 2 timeout
[ 32.868446] nvme nvme0: I/O tag 5 (0005) type 4 opcode0x2(I/O Cmd) QID 2 timeout
[ 32.868592] nvme0c0n1: I/O Cmd(0x2) @ LBA 1046528, 8 blocks, I/O Error (sct0x3/ sc0x70)
[ 32.868817] recoverable transport error, dev nvme0c0n1, sector 1046528 op 0x0:(READ) flags0x2080700phys_seg1 prio class 0 [ 32.868976] block nvme0n1: no usable path - requeuing I/O [ 32.869038] nvme nvme0: I/O tag 6 (0006) type 4 opcode0x2(I/O Cmd) QID 2 timeout
[ 32.869119] nvme nvme0: I/O tag 7 (0007) type 4 opcode0x2(I/O Cmd) QID 2 timeout
... ...
[ 32.877945] nvme nvme0: I/O tag 122 (107a) type 4 opcode0x2(I/O Cmd) QID 2 timeout
[ 32.878025] block nvme0n1: no usable path - requeuing I/O [ 32.878079] block nvme0n1: no usable path - requeuing I/O [ 32.878128] block nvme0n1: no usable path - requeuing I/O [ 32.878180] block nvme0n1: no usable path - requeuing I/O [ 32.878238] block nvme0n1: no usable path - requeuing I/O [ 32.878296] block nvme0n1: no usable path - requeuing I/O [ 32.878350] block nvme0n1: no usable path - requeuing I/O [ 32.878403] block nvme0n1: no usable path - requeuing I/O [ 32.878455] block nvme0n1: no usable path - requeuing I/O [ 32.883603] nvme nvme0: Reconnecting in 10 seconds... '''
Quoted 7 lines
Through debugging, I discovered that setting the
MSG_DONTWAITflag leads to
MPTCP returning EAGAIN inmptcp_sendmsg.This patch addresses it by dropping the
MSG_DONTWAITflag for MPTCP. I know
this isn't an ideal fix, and I need your suggestions.
Good news! With help from Paolo and Gang Yan, I have finally solved this issue. It turned out that the write_space function, overridden by NVMe, was unable to be invoked by MPTCP.
This can be fixed by making the following modifications:
net/mptcp/protocol.h +0 -0
@@ -973,7 @@ static inline void mptcp_write_space(struct sock *sk)/* pairs with memory barrier in mptcp_poll */ smp_mb ();if (mptcp_stream_memory_free (sk,1 )) -sk_stream_write_space (sk); +INDIRECT_CALL_1 (sk->sk_write_space, sk_stream_write_space, sk);
I'll send out v2 of this set soon.
Thanks,
-Geliang
Quoted 51 lines
Signed-off-by Geliang Tang <[email protected]>---
drivers/nvme/target/tcp.c | 10 ++++++++--1 file changed, 8 insertions(+), 2 deletions(-)drivers/nvme/target/tcp.c +0
-0@@ -645,12 +645,15 @@ static int nvmet_try_send_data(struct nvmet_tcp_cmd *cmd, bool last_in_batch)
while (cmd->cur_sg) {
struct msghdr msg = {drivers/nvme/target/tcp.c +0
-1- .msg_flags = MSG_DONTWAIT |
MSG_SPLICE_PAGES,drivers/nvme/target/tcp.c +1
-0+ .msg_flags = MSG_SPLICE_PAGES,};
struct page *page =sg_page(cmd->cur_sg); structbio_vecbvec;
u32 left =cmd->cur_sg->length-cmd->offset;drivers/nvme/target/tcp.c +1
-0+ if (cmd->queue->sock->sk->sk_protocol !=
IPPROTO_MPTCP)drivers/nvme/target/tcp.c +2
-0+ msg.msg_flags |=MSG_DONTWAIT ; +if ((!last_in_batch &&
cmd->queue->send_list_len) ||cmd->wbytes_done+ left <cmd->req.transfer_len|| queue->data_digest || !queue-Quoted 1 line
nvme_sq.sqhd_disabled)
drivers/nvme/target/tcp.c +1
-1@@ -694,12 +697,15 @@ static int nvmet_try_send_data(struct nvmet_tcp_cmd *cmd, bool last_in_batch) static int nvmet_try_send_response(struct nvmet_tcp_cmd *cmd, bool last_in_batch) { - struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_SPLICE_PAGES, }; + struct msghdr msg = { .msg_flags = MSG_SPLICE_PAGES, }; struct bio_vec bvec; u8 hdgst = nvmet_tcp_hdgst_len(cmd->queue); int left = sizeof(*cmd->rsp_pdu) - cmd->offset + hdgst; int ret;drivers/nvme/target/tcp.c +3
-0+if (cmd->queue->sock->sk->sk_protocol !=IPPROTO_MPTCP ) + msg.msg_flags |=MSG_DONTWAIT ; +if (!last_in_batch &&
cmd->queue->send_list_len) msg.msg_flags |=MSG_MORE;
else
Hi Geliang,
Thank you for your modifications, that's great!
But sadly, our CI spotted some issues with it when trying to build it.
You can find more details there:
https://github.com/multipath-tcp/mptcp_net-next/actions/runs/19157587244
Status: failure
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/4d1bb0e3c51a
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1020727
Feel free to reply to this email if you cannot access logs, if you need some support to fix the error, if this doesn't seem to be caused by your modifications or if the error is a false positive one.
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Hi Geliang,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal (except selftest_mptcp_join): Unstable: 1 failed test(s): packetdrill_dss 🔴
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Unstable: 1 failed test(s): packetdrill_dss 🔴
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/19157587224
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/4d1bb0e3c51a
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1020727
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)