NFSv4/flexfiles: couple back with NFSv3
Subsystems (2)
PATCH 1/1 NFSv4/flexfiles: couple back with NFSv3
Commit 7a375cafc14e ("NFSv4/flexfiles: honor FF_FLAGS_NO_IO_THRU_MDS on fatal DS connect errors") uncovered an unexpected issue, EPROTONOSUPPORT from a missing nfsv3 module during pNFS flexfiles I/O operation turned a harmless WARN + fallback to MDS into a forever retry op.
Flexfiles is decoupled from NFSv3 after commit a68c6fbb638a ("nfs41:
drop dependency between flexfiles layout driver and NFSv3 modules"), so we trusted on legacy symbol_request(nfs3_set_ds_client) -> request_module at runtime to load NFSv3 module in case it's not loaded.
However this approach has some problematic scenarios, an unprivileged container may be denied by SELinux policy to load nfsv3 module, leading to writeback hang, other scenario is boot hang on NFSv4 root mounted hosts, where we get deadlocked trying to fetch from the filesystem the usermode helpers necessary for request_module to proceed.
So, couple back NFSv3 with flexfiles to make sure both are loaded on i.e. mount time, and remove the scaffolding associated with symbol_request() mechanism now that we have a hard dependency on the code with nfs3_set_ds_client.
--- fs/nfs/Kconfig | 2 +- fs/nfs/nfs4super.c | 3 --- fs/nfs/pnfs.h | 5 ----- fs/nfs/pnfs_nfs.c | 34 ++-------------------------------- 4 files changed, 3 insertions(+), 41 deletions(-)
fs/nfs/Kconfig +1 -1
@@ -143,7 +143,7 @@ config PNFS_SCSI_LAYOUT config PNFS_FLEXFILE_LAYOUT tristate - depends on NFS_V4 + depends on NFS_V4 && NFS_V3 default NFS_V4 config NFS_V4_1_IMPLEMENTATION_ID_DOMAIN
fs/nfs/nfs4super.c +0 -3
@@ -297,9 +297,6 @@ static int __init init_nfs_v4(void) static void __exit exit_nfs_v4(void) { -/* Not called in the _init(), conditionally loaded */ -nfs4_pnfs_v3_ds_connect_unload (); -unregister_nfs_version (&nfs_v4);#ifdef CONFIG_NFS_V4_2 nfs4_xattr_cache_exit ();
fs/nfs/pnfs.h +0 -5
@@ -504,7 +504,6 @@ void nfs4_pnfs_ds_put(struct nfs4_pnfs_ds *ds);struct nfs4_pnfs_ds *nfs4_pnfs_ds_add (const struct net *net,struct list_head *dsaddrs,u32 version,gfp_t gfp_flags); -void nfs4_pnfs_v3_ds_connect_unload (void ); int nfs4_pnfs_ds_connect(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds, struct nfs4_deviceid_node *devid, unsigned int timeo, unsigned int retrans, unsigned int nconnect,
@@ -972,10 +971,6 @@ static inline struct nfs4_threshold *pnfs_mdsthreshold_alloc(void)return NULL ; } -static inline void nfs4_pnfs_v3_ds_connect_unload (void ) -{ -} -static inline bool nfs4_layout_refresh_old_stateid (nfs4_stateid *dst,struct pnfs_layout_range *dst_range,struct inode *inode)
fs/nfs/pnfs_nfs.c +2 -32
@@ -838,33 +838,6 @@ static void nfs4_clear_ds_conn_bit(struct nfs4_pnfs_ds *ds)clear_and_wake_up_bit (NFS4DS_CONNECTING , &ds->ds_state); } -static struct nfs_client *(*get_v3_ds_connect)( -struct nfs_server *mds_srv, -const struct sockaddr_storage *ds_addr, -int ds_addrlen, -int ds_proto, -unsigned int ds_timeo, -unsigned int ds_retrans, -unsigned int ds_nconnect); - -static bool load_v3_ds_connect (void ) -{ -if (!get_v3_ds_connect) { - get_v3_ds_connect =symbol_request (nfs3_set_ds_client); -WARN_ON_ONCE (!get_v3_ds_connect); - } - -return (get_v3_ds_connect !=NULL ); -} - -void nfs4_pnfs_v3_ds_connect_unload (void ) -{ -if (get_v3_ds_connect) { -symbol_put (nfs3_set_ds_client); - get_v3_ds_connect =NULL ; - } -} - static int _nfs4_pnfs_v3_ds_connect(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds, unsigned int timeo,
@@ -881,9 +854,6 @@ static int _nfs4_pnfs_v3_ds_connect(struct nfs_server *mds_srv,dprintk ("--> %s DS %s\n" , __func__, ds->ds_remotestr); -if (!load_v3_ds_connect ()) -return -EPROTONOSUPPORT ; -list_for_each_entry (da, &ds->ds_addrs, da_node) {dprintk ("%s: DS %s: trying address %s\n" , __func__, ds->ds_remotestr, da->da_remotestr);
@@ -920,8 +890,8 @@ static int _nfs4_pnfs_v3_ds_connect(struct nfs_server *mds_srv, xprtsec_policy != RPC_XPRTSEC_NONE) ds_proto =XPRT_TRANSPORT_TCP_TLS ; - clp =get_v3_ds_connect (mds_srv, &da->da_addr, da->da_addrlen, - ds_proto, timeo, retrans, nconnect); + clp =nfs3_set_ds_client (mds_srv, &da->da_addr, da->da_addrlen, + ds_proto, timeo, retrans, nconnect);if (IS_ERR (clp))continue ; clp->cl_rpcclient->cl_softerr =0 ;
Signature · 1 line
2.55.0
----- Original Message -----
Quoted 50 lines
From: "Roberto Bergantinos Corpas" <[email protected]>
To: "Trond Myklebust" <[email protected]>, "Anna Schumaker" <[email protected]>
Cc: "linux-nfs" <[email protected]>, "Mike Snitzer" <[email protected]>, "Benjamin Coddington" <[email protected]>, "Antonio Alvarez Feijoo" <[email protected]>, "Tigran Mkrtchyan" <[email protected]>
Sent: Wednesday, 4 November, 2026 12:25:05
Subject: [PATCH] NFSv4/flexfiles: couple back with NFSv3Commit
7a375cafc14e("NFSv4/flexfiles: honorFF_FLAGS_NO_IO_THRU_MDSon fatal DS connect errors") uncovered an unexpected issue, EPROTONOSUPPORT from a missing nfsv3 module during pNFS flexfiles I/O operation turned a harmless WARN + fallback to MDS into a forever retry op.Flexfiles is decoupled from NFSv3 after commit
a68c6fbb638a("nfs41:
drop dependency between flexfiles layout driver and NFSv3 modules"), so we trusted on legacysymbol_request(nfs3_set_ds_client)->request_moduleat runtime to load NFSv3 module in case it's not loaded.However this approach has some problematic scenarios, an unprivileged container may be denied by SELinux policy to load nfsv3 module, leading to writeback hang, other scenario is boot hang on NFSv4 root mounted hosts, where we get deadlocked trying to fetch from the filesystem the usermode helpers necessary for
request_moduleto proceed.So, couple back NFSv3 with flexfiles to make sure both are loaded on i.e. mount time, and remove the scaffolding associated with
symbol_request()mechanism now that we have a hard dependency on the code withnfs3_set_ds_client.Fixes 7a375cafc14e ("NFSv4/flexfiles: honor FF_FLAGS_NO_IO_THRU_MDS on fatal DSconnect errors")
Based-on-patch-by Antonio Alvarez Feijoo <[email protected]>Suggested-by Benjamin Coddington <[email protected]>Assisted-by Claude Opus 4.6 <[email protected]>Signed-off-by Roberto Bergantinos Corpas <[email protected]>---
fs/nfs/Kconfig | 2 +- fs/nfs/nfs4super.c | 3 --- fs/nfs/pnfs.h | 5 ----- fs/nfs/pnfs_nfs.c | 34 ++-------------------------------- 4 files changed, 3 insertions(+), 41 deletions(-)fs/nfs/Kconfig +0
-0@@ -143,7 +143,7 @@ config PNFS_SCSI_LAYOUTconfig
PNFS_FLEXFILE_LAYOUT
tristate
fs/nfs/Kconfig config PNFS_SCSI_LAYOUT · line 146
Quoted 2 lines
fs/nfs/Kconfig +1
-1- depends on NFS_V4 + depends on NFS_V4 && NFS_V3
or maybe
select NFS_V3
To enforce nfs3 to be built, if flexfiles layout type is selected.
Tigran.
Quoted 104 lines
default
NFS_V4config
NFS_V4_1_IMPLEMENTATION_ID_DOMAINfs/nfs/nfs4super.c +0
-3@@ -297,9 +297,6 @@ static int __init init_nfs_v4(void) static void __exit exit_nfs_v4(void) { -/* Not called in the _init(), conditionally loaded */ -nfs4_pnfs_v3_ds_connect_unload (); -unregister_nfs_version (&nfs_v4);#ifdef CONFIG_NFS_V4_2 nfs4_xattr_cache_exit ();fs/nfs/pnfs.h +0
-5@@ -504,7 +504,6 @@ void nfs4_pnfs_ds_put(struct nfs4_pnfs_ds *ds);struct nfs4_pnfs_ds *nfs4_pnfs_ds_add (const struct net *net,struct list_head *dsaddrs,u32 version,gfp_t gfp_flags); -void nfs4_pnfs_v3_ds_connect_unload (void ); int nfs4_pnfs_ds_connect(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds, struct nfs4_deviceid_node *devid, unsigned int timeo, unsigned int retrans, unsigned int nconnect,@@ -972,10 +971,6 @@ static inline struct nfs4_threshold *pnfs_mdsthreshold_alloc(void)return NULL ; } -static inline void nfs4_pnfs_v3_ds_connect_unload (void ) -{ -} - static inline bool nfs4_layout_refresh_old_stateid(nfs4_stateid *dst, struct pnfs_layout_range *dst_range,struct inode *inode)
fs/nfs/pnfs_nfs.c +0
-30@@ -838,33 +838,6 @@ static void nfs4_clear_ds_conn_bit(struct nfs4_pnfs_ds *ds)clear_and_wake_up_bit (NFS4DS_CONNECTING , &ds->ds_state); } -static struct nfs_client *(*get_v3_ds_connect)( -struct nfs_server *mds_srv, -const struct sockaddr_storage *ds_addr, -int ds_addrlen, -int ds_proto, -unsigned int ds_timeo, -unsigned int ds_retrans, -unsigned int ds_nconnect); - -static bool load_v3_ds_connect (void ) -{ -if (!get_v3_ds_connect) { - get_v3_ds_connect =symbol_request (nfs3_set_ds_client); -WARN_ON_ONCE (!get_v3_ds_connect); - } - -return (get_v3_ds_connect !=NULL ); -} - -void nfs4_pnfs_v3_ds_connect_unload (void ) -{ -if (get_v3_ds_connect) { -symbol_put (nfs3_set_ds_client); - get_v3_ds_connect =NULL ; - } -} - static int _nfs4_pnfs_v3_ds_connect(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds, unsigned int timeo,@@ -881,9 +854,6 @@ static int _nfs4_pnfs_v3_ds_connect(struct nfs_server *mds_srv,dprintk ("--> %s DS %s\n" , __func__, ds->ds_remotestr); -if (!load_v3_ds_connect ()) -return -EPROTONOSUPPORT ; -list_for_each_entry (da, &ds->ds_addrs, da_node) { dprintk("%s: DS %s: trying address %s\n",__func__, ds->ds_remotestr, da->da_remotestr);fs/nfs/pnfs_nfs.c +2
-2@@ -920,8 +890,8 @@ static int _nfs4_pnfs_v3_ds_connect(struct nfs_server *mds_srv, xprtsec_policy != RPC_XPRTSEC_NONE) ds_proto =XPRT_TRANSPORT_TCP_TLS ; - clp =get_v3_ds_connect (mds_srv, &da->da_addr, da->da_addrlen, - ds_proto, timeo, retrans, nconnect); + clp =nfs3_set_ds_client (mds_srv, &da->da_addr, da->da_addrlen, + ds_proto, timeo, retrans, nconnect);if (IS_ERR (clp))continue ;clp->cl_rpcclient->cl_softerr = 0;--
2.55.0