Skip to contentSkip to conversation

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.

PATCH In review Gaurav Gangalwar 2 participants 2 messages Dec 1, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

Add module parameter 'nfs4_inherit_referral_transport' (default: Y) to control this behavior, allowing administrators to restore the previous "always try RDMA" behavior if needed.

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

---
 fs/nfs/nfs4_fs.h    |  1 +
 fs/nfs/nfs4client.c | 18 +++++++++++++-----
 fs/nfs/super.c      |  8 ++++++++
 3 files changed, 22 insertions(+), 5 deletions(-)
fs/nfs/nfs4_fs.h +1 -0
index c34c89af9c7d..d8516fb8a711 100644
@@ -548,6 +548,7 @@ extern unsigned short max_session_cb_slots;
 extern unsigned short send_implementation_id;
 extern bool recover_lost_locks;
 extern short nfs_delay_retrans;
+extern bool nfs4_inherit_referral_transport;
 
 #define NFS4_CLIENT_ID_UNIQ_LEN		(64)
 extern char nfs4_client_id_uniquifier[NFS4_CLIENT_ID_UNIQ_LEN];
fs/nfs/nfs4client.c +13 -5
index 3a4baed993c9..7fb39bf662af 100644
@@ -1258,12 +1258,20 @@ struct nfs_server *nfs4_create_referral_server(struct fs_context *fc)
 	nfs_server_copy_userdata(server, parent_server);
 
 	/* Get a client representation */
+	/*
+	 * If nfs4_inherit_referral_transport is enabled (default), 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 (!nfs4_inherit_referral_transport ||
+	    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;
fs/nfs/super.c +8 -0
index 72dee6f3050e..cb9618a0df0f 100644
@@ -1426,6 +1426,8 @@ unsigned short max_session_cb_slots = NFS4_DEF_CB_SLOT_TABLE_SIZE;
 unsigned short send_implementation_id = 1;
 char nfs4_client_id_uniquifier[NFS4_CLIENT_ID_UNIQ_LEN] = "";
 bool recover_lost_locks = false;
+/* Inherit parent transport for referral mounts */
+bool nfs4_inherit_referral_transport = true;
 short nfs_delay_retrans = -1;
 
 EXPORT_SYMBOL_GPL(nfs_callback_nr_threads);
@@ -1437,6 +1439,7 @@ EXPORT_SYMBOL_GPL(max_session_cb_slots);
 EXPORT_SYMBOL_GPL(send_implementation_id);
 EXPORT_SYMBOL_GPL(nfs4_client_id_uniquifier);
 EXPORT_SYMBOL_GPL(recover_lost_locks);
+EXPORT_SYMBOL_GPL(nfs4_inherit_referral_transport);
 EXPORT_SYMBOL_GPL(nfs_delay_retrans);
 
 #define NFS_CALLBACK_MAXPORTNR (65535U)
@@ -1486,6 +1489,11 @@ MODULE_PARM_DESC(recover_lost_locks,
 		 "If the server reports that a lock might be lost, "
 		 "try to recover it risking data corruption.");
 
+module_param(nfs4_inherit_referral_transport, bool, 0644);
+MODULE_PARM_DESC(nfs4_inherit_referral_transport,
+		 "Referral mounts inherit parent's transport protocol. "
+		 "If disabled, always try RDMA first (default=Y)");
+
 module_param_named(delay_retrans, nfs_delay_retrans, short, 0644);
 MODULE_PARM_DESC(delay_retrans,
 		 "Unless negative, specifies the number of times the NFSv4 "
Signature · 1 line
2.43.7
maintainer
#1 lore raw
Quoted 10 lines · Gaurav Gangalwar

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.

Add module parameter 'nfs4_inherit_referral_transport' (default: Y) to control this behavior, allowing administrators to restore the previous "always try RDMA" behavior if needed.

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

Do we really need the module parameter? If you go back to Chuck's commit 530ea4219231 ("nfs: Referrals should use the same proto setting as their parent") then his intention was to make the RDMA behaviour inheritable, and that has always been my preference too.

It is all the more important now that we also have TLS protection, which would break when we default to RDMA.

Quoted 91 lines

---
 fs/nfs/nfs4_fs.h    |  1 +
 fs/nfs/nfs4client.c | 18 +++++++++++++-----
 fs/nfs/super.c      |  8 ++++++++

 3 files changed, 22 insertions(+), 5 deletions(-)
fs/nfs/nfs4_fs.h +1 -0
index c34c89af9c7d..d8516fb8a711 100644
@@ -548,6 +548,7 @@ extern unsigned short max_session_cb_slots;
  extern unsigned short send_implementation_id;
  extern bool recover_lost_locks;
  extern short nfs_delay_retrans;
+extern bool nfs4_inherit_referral_transport;


 #define NFS4_CLIENT_ID_UNIQ_LEN (64)
 extern char nfs4_client_id_uniquifier[NFS4_CLIENT_ID_UNIQ_LEN];

fs/nfs/nfs4client.c +0 -0
index 3a4baed993c9..7fb39bf662af 100644
@@ -1258,12 +1258,20 @@ struct nfs_server
 *nfs4_create_referral_server(struct fs_context *fc)
  	nfs_server_copy_userdata(server, parent_server);


  /* Get a client representation */

fs/nfs/nfs4client.c +2 -0
+	/*
+	 * If nfs4_inherit_referral_transport is enabled (default),

only try

fs/nfs/nfs4client.c +1 -0
+	 * RDMA if the parent client is using RDMA. This avoids

connection

fs/nfs/nfs4client.c +1 -0
+	 * delays when parent uses TCP and referral server doesn't

support RDMA.

fs/nfs/nfs4client.c +1 -0
+	 */

 #if IS_ENABLED(CONFIG_SUNRPC_XPRT_RDMA)

fs/nfs/nfs4client.c +3 -5
-	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 (!nfs4_inherit_referral_transport ||
+	    parent_client->cl_proto == XPRT_TRANSPORT_RDMA) {
+		rpc_set_port(&ctx->nfs_server.address,

NFS_RDMA_PORT);

fs/nfs/nfs4client.c +5 -0
+		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;

fs/nfs/super.c +2 -0
index 72dee6f3050e..cb9618a0df0f 100644
@@ -1426,6 +1426,8 @@ unsigned short max_session_cb_slots =
 NFS4_DEF_CB_SLOT_TABLE_SIZE;
  unsigned short send_implementation_id = 1;
  char nfs4_client_id_uniquifier[NFS4_CLIENT_ID_UNIQ_LEN] = "";
  bool recover_lost_locks = false;
+/* Inherit parent transport for referral mounts */
+bool nfs4_inherit_referral_transport = true;
  short nfs_delay_retrans = -1;


 EXPORT_SYMBOL_GPL(nfs_callback_nr_threads);

fs/nfs/super.c +1 -0
@@ -1437,6 +1439,7 @@ EXPORT_SYMBOL_GPL(max_session_cb_slots);
  EXPORT_SYMBOL_GPL(send_implementation_id);
  EXPORT_SYMBOL_GPL(nfs4_client_id_uniquifier);
  EXPORT_SYMBOL_GPL(recover_lost_locks);
+EXPORT_SYMBOL_GPL(nfs4_inherit_referral_transport);
  EXPORT_SYMBOL_GPL(nfs_delay_retrans);


 #define NFS_CALLBACK_MAXPORTNR (65535U)

fs/nfs/super.c +0 -0
@@ -1486,6 +1489,11 @@ MODULE_PARM_DESC(recover_lost_locks,

  "If the server reports that a lock might be lost, " "try to recover it risking data corruption.");

fs/nfs/super.c +3 -0
+module_param(nfs4_inherit_referral_transport, bool, 0644);
+MODULE_PARM_DESC(nfs4_inherit_referral_transport,
+		 "Referral mounts inherit parent's transport

protocol. "

fs/nfs/super.c +2 -0
+		 "If disabled, always try RDMA first (default=Y)");
+

 module_param_named(delay_retrans, nfs_delay_retrans, short, 0644); MODULE_PARM_DESC(delay_retrans,
  "Unless negative, specifies the number of times the NFSv4 "

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected], [email protected]