public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 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.
@ 2025-12-01  9:07 Gaurav Gangalwar
  2025-12-01 17:26 ` Trond Myklebust
  0 siblings, 1 reply; 2+ messages in thread
From: Gaurav Gangalwar @ 2025-12-01  9:07 UTC (permalink / raw)
  To: trondmy, anna, tom, chuck.lever; +Cc: linux-nfs, linux-rdma, 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.

Signed-off-by: Gaurav Gangalwar <gaurav.gangalwar@gmail.com>
---
 fs/nfs/nfs4_fs.h    |  1 +
 fs/nfs/nfs4client.c | 18 +++++++++++++-----
 fs/nfs/super.c      |  8 ++++++++
 3 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index c34c89af9c7d..d8516fb8a711 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -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];
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index 3a4baed993c9..7fb39bf662af 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -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;
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 72dee6f3050e..cb9618a0df0f 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -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 "
-- 
2.43.7


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

end of thread, other threads:[~2025-12-01 17:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-01  9:07 [PATCH] 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 Gaurav Gangalwar
2025-12-01 17:26 ` Trond Myklebust

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