Skip to contentSkip to conversation

NFS: inherit parent transport protocol for referral mounts

PATCH In review Gaurav Gangalwar 2 participants 3 messages Dec 2, 2025 – Dec 3, 2025 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CAJiE4OkW6XT71xvv49VN5STPx7dQ6GxV+-Rz1=55JhoFPyM7PQ@mail.gmail.com

#1 lore raw

PATCH v2 1/1 NFS: inherit parent transport protocol for referral mounts

When following NFS referrals, the client always attempts RDMA first (if compiled in), even when the parent mount uses TCP. This causes unnecessary timeouts when the referral server doesn't support RDMA.

Modify nfs4_create_referral_server() to check the parent client's transport protocol. Only attempt RDMA if the parent is using RDMA, otherwise use the parent's protocol (TCP/TCP-TLS) directly.

This eliminates connection delays for TCP-based referrals in environments where RDMA is compiled in but not deployed.

---
Changes since v1:
- Removed module parameter.

---
 fs/nfs/nfs4client.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
fs/nfs/nfs4client.c +12 -5
index 3a4baed993c9..39a0424523e5 100644
@@ -1258,12 +1258,19 @@ struct nfs_server *nfs4_create_referral_server(struct fs_context *fc)
 	nfs_server_copy_userdata(server, parent_server);
 
 	/* Get a client representation */
+	/*
+	 * Only try RDMA if the parent client is using RDMA. This avoids
+	 * connection delays when parent uses TCP and referral server doesn't
+	 * support RDMA.
+	 */
 #if IS_ENABLED(CONFIG_SUNRPC_XPRT_RDMA)
-	rpc_set_port(&ctx->nfs_server.address, NFS_RDMA_PORT);
-	cl_init.proto = XPRT_TRANSPORT_RDMA;
-	error = nfs4_set_client(server, &cl_init);
-	if (!error)
-		goto init_server;
+	if (parent_client->cl_proto == XPRT_TRANSPORT_RDMA) {
+		rpc_set_port(&ctx->nfs_server.address, NFS_RDMA_PORT);
+		cl_init.proto = XPRT_TRANSPORT_RDMA;
+		error = nfs4_set_client(server, &cl_init);
+		if (!error)
+			goto init_server;
+	}
 #endif	/* IS_ENABLED(CONFIG_SUNRPC_XPRT_RDMA) */
 
 	cl_init.proto = XPRT_TRANSPORT_TCP;
Signature · 1 line
2.43.7
maintainer
#2 lore raw
Quoted 49 lines · Gaurav Gangalwar

When following NFS referrals, the client always attempts RDMA first (if compiled in), even when the parent mount uses TCP. This causes unnecessary timeouts when the referral server doesn't support RDMA.

Modify nfs4_create_referral_server() to check the parent client's transport protocol. Only attempt RDMA if the parent is using RDMA, otherwise use the parent's protocol (TCP/TCP-TLS) directly.

This eliminates connection delays for TCP-based referrals in environments where RDMA is compiled in but not deployed.

---
Changes since v1:
- Removed module parameter.

---
 fs/nfs/nfs4client.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
fs/nfs/nfs4client.c +12 -5
index 3a4baed993c9..39a0424523e5 100644
@@ -1258,12 +1258,19 @@ struct nfs_server 
 *nfs4_create_referral_server(struct fs_context *fc)
 	nfs_server_copy_userdata(server, parent_server);
 
 	/* Get a client representation */
+	/*
+	 * Only try RDMA if the parent client is using RDMA. This avoids
+	 * connection delays when parent uses TCP and referral server doesn't
+	 * support RDMA.
+	 */
 #if IS_ENABLED(CONFIG_SUNRPC_XPRT_RDMA)
-	rpc_set_port(&ctx->nfs_server.address, NFS_RDMA_PORT);
-	cl_init.proto = XPRT_TRANSPORT_RDMA;
-	error = nfs4_set_client(server, &cl_init);
-	if (!error)
-		goto init_server;
+	if (parent_client->cl_proto == XPRT_TRANSPORT_RDMA) {
+		rpc_set_port(&ctx->nfs_server.address, NFS_RDMA_PORT);
+		cl_init.proto = XPRT_TRANSPORT_RDMA;
+		error = nfs4_set_client(server, &cl_init);
+		if (!error)
+			goto init_server;
+	}
 #endif	/* IS_ENABLED(CONFIG_SUNRPC_XPRT_RDMA) */
 
Quoted 3 lines

cl_init.proto = XPRT_TRANSPORT_TCP;

Signature · 1 line
2.43.7

The reason it tries RDMA first is because RDMA is supposed to fail quickly when there's no RDMA-capable path to the remote. If RDMA is taking a long time to fail, there's a problem elsewhere.

Signature · 1 line
Chuck Lever

A message that is not in the archive (sent off-list or not yet received): CAJiE4O=gK4A8zJVXKGawqb=hx9uwNXNfh1yotVkDDmSfM1DA2A@mail.gmail.com

maintainer
#4 lore raw
Quoted 65 lines · gaurav gangalwar

Reply inline

Quoted 53 lines · Chuck Lever
Quoted 25 lines · Gaurav Gangalwar

When following NFS referrals, the client always attempts RDMA first (if compiled in), even when the parent mount uses TCP. This causes unnecessary timeouts when the referral server doesn't support RDMA.

Modify nfs4_create_referral_server() to check the parent client's transport protocol. Only attempt RDMA if the parent is using RDMA, otherwise use the parent's protocol (TCP/TCP-TLS) directly.

This eliminates connection delays for TCP-based referrals in environments where RDMA is compiled in but not deployed.

---
Changes since v1:
- Removed module parameter.

---
 fs/nfs/nfs4client.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
fs/nfs/nfs4client.c +0 -0
index 3a4baed993c9..39a0424523e5 100644

fs/nfs/nfs4client.c struct nfs_server · line 1264

Quoted 7 lines
fs/nfs/nfs4client.c +3 -0
@@ -1258,12 +1258,19 @@ struct nfs_server
 *nfs4_create_referral_server(struct fs_context *fc)
      nfs_server_copy_userdata(server, parent_server);
 
      /* Get a client representation */
+     /*
+      * Only try RDMA if the parent client is using RDMA. This avoids
+      * connection delays when parent uses TCP and referral server

doesn't

Quoted 17 lines
fs/nfs/nfs4client.c +9 -5
+      * support RDMA.
+      */
 #if IS_ENABLED(CONFIG_SUNRPC_XPRT_RDMA)
-     rpc_set_port(&ctx->nfs_server.address, NFS_RDMA_PORT);
-     cl_init.proto = XPRT_TRANSPORT_RDMA;
-     error = nfs4_set_client(server, &cl_init);
-     if (!error)
-             goto init_server;
+     if (parent_client->cl_proto == XPRT_TRANSPORT_RDMA) {
+             rpc_set_port(&ctx->nfs_server.address, NFS_RDMA_PORT);
+             cl_init.proto = XPRT_TRANSPORT_RDMA;
+             error = nfs4_set_client(server, &cl_init);
+             if (!error)
+                     goto init_server;
+     }
 #endif       /* IS_ENABLED(CONFIG_SUNRPC_XPRT_RDMA) */
 
Quoted 8 lines
Quoted 3 lines
      cl_init.proto = XPRT_TRANSPORT_TCP;

--
2.43.7

The reason it tries RDMA first is because RDMA is supposed to fail quickly when there's no RDMA-capable path to the remote. If RDMA is taking a long time to fail, there's a problem elsewhere.

Quoted 5 lines

Yes, if client is not RDMA capable then it fails quickly since transport class won't be registered and xprt_create_transport will fail early without even trying to connect as we check for xprt_class_find_by_ident. But when client is RDMA capable but server is not then it tries to connect and times out after 3 mins.

The client should be able to tell quickly that there is not a complete RDMA-enabled path from client to server. Can you describe your network?

Signature · 1 line
Chuck Lever