Skip to contentSkip to conversation

nfsd: don't offer flexfiles layouts when NFSv3 isn't being served

PATCH In review Jeff Layton 4 participants 4 messages Sep 4 – Sep 5

Subsystems (2)
lore
Share & tools
lore

Jeff Layton

author maintainer
#0 lore raw

PATCH 1/1 nfsd: don't offer flexfiles layouts when NFSv3 isn't being served

The flexfiles layout driver hands out a deviceinfo that names this server as an NFSv3 DS (flexfilelayout.c hardcodes da->version = 3). With v3 disabled, the client can't talk to the DS: it loops on v3 NULL calls that the server answers with PROG_MISMATCH, and I/O hangs in D state.

Skip LAYOUT_FLEX_FILES in nfsd4_setup_layout_type() unless v3 is enabled.

Fixes 9b9960a0ca47 ("nfsd: Add a super simple flex file server")
Assisted-by LLM
---
 fs/nfsd/nfs4layouts.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/nfsd/nfs4layouts.c +3 -1
index 22bcb6d09f70..cef4d40c89a2 100644
@@ -127,10 +127,12 @@ nfsd4_set_deviceid(struct nfsd4_deviceid *id, const struct svc_fh *fhp,
 
 void nfsd4_setup_layout_type(struct svc_export *exp)
 {
+	struct nfsd_net *nn = net_generic(exp->cd->net, nfsd_net_id);
 	struct super_block *sb = exp->ex_path.mnt->mnt_sb;
 	expfs_block_layouts_t block_supported = exportfs_layouts_supported(sb);
 
-	if (IS_ENABLED(CONFIG_NFSD_FLEXFILELAYOUT))
+	if (IS_ENABLED(CONFIG_NFSD_FLEXFILELAYOUT) &&
+	    nfsd_vers(nn, 3, NFSD_TEST))
 		exp->ex_layout_types |= 1 << LAYOUT_FLEX_FILES;
 	if (IS_ENABLED(CONFIG_NFSD_BLOCKLAYOUT) &&
 	    (block_supported & EXPFS_BLOCK_IN_BAND_ID))

---
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260904-pnfs-ff-485ac21042a6

Best regards,

Signature · 1 line
Jeff Layton <[email protected]>
maintainer
#1 lore raw
Quoted 8 lines · Jeff Layton

The flexfiles layout driver hands out a deviceinfo that names this server as an NFSv3 DS (flexfilelayout.c hardcodes da->version = 3). With v3 disabled, the client can't talk to the DS: it loops on v3 NULL calls that the server answers with PROG_MISMATCH, and I/O hangs in D state.

Skip LAYOUT_FLEX_FILES in nfsd4_setup_layout_type() unless v3 is enabled.

[...]

Applied to nfsd-testing, thanks! I can drop this one if you find a better solution.

[1/1] nfsd: don't offer flexfiles layouts when NFSv3 isn't being served

      commit: c1efd0d304fb61af95f4919936dc11a94845532d

--
Chuck Lever

#2 lore raw
In reply to Jeff Layton
Quoted 25 lines · Jeff Layton

The flexfiles layout driver hands out a deviceinfo that names this server as an NFSv3 DS (flexfilelayout.c hardcodes da->version = 3). With v3 disabled, the client can't talk to the DS: it loops on v3 NULL calls that the server answers with PROG_MISMATCH, and I/O hangs in D state.

Skip LAYOUT_FLEX_FILES in nfsd4_setup_layout_type() unless v3 is enabled.

Fixes 9b9960a0ca47 ("nfsd: Add a super simple flex file server")
Assisted-by LLM
---
 fs/nfsd/nfs4layouts.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/nfsd/nfs4layouts.c +0 -0
index 22bcb6d09f70..cef4d40c89a2 100644
@@ -127,10 +127,12 @@ nfsd4_set_deviceid(struct nfsd4_deviceid *id, const struct svc_fh *fhp,
 
 void nfsd4_setup_layout_type(struct svc_export *exp)
 {

fs/nfsd/nfs4layouts.c nfsd4_set_deviceid(struct nfsd4_deviceid *id, const struct svc_fh *fhp, · line 138

Quoted 10 lines
fs/nfsd/nfs4layouts.c +3 -1
+       struct nfsd_net *nn = net_generic(exp->cd->net, nfsd_net_id);
        struct super_block *sb = exp->ex_path.mnt->mnt_sb;
        expfs_block_layouts_t block_supported = exportfs_layouts_supported(sb);
 
-       if (IS_ENABLED(CONFIG_NFSD_FLEXFILELAYOUT))
+       if (IS_ENABLED(CONFIG_NFSD_FLEXFILELAYOUT) &&
+           nfsd_vers(nn, 3, NFSD_TEST))
                exp->ex_layout_types |= 1 << LAYOUT_FLEX_FILES;
        if (IS_ENABLED(CONFIG_NFSD_BLOCKLAYOUT) &&
            (block_supported & EXPFS_BLOCK_IN_BAND_ID))

Although most ffv1 servers use NFSv3 DSs, it is possible for an ffv1 layout to specify NFSv4.

rick
ps: I don't know how you'd check to see if the layout will be an
NFSv3 one. (If the server only does NFSv3 layouts, then I'd guess this patch is ok?)

Quoted 10 lines

---
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260904-pnfs-ff-485ac21042a6

Best regards,
--
Jeff Layton <[email protected]>

#3 lore raw

Hi Rick,

our server runs with v4.1 DSes whenissues FF layouts. The patch is touching server side only, so I hope the client side still works as expected. For quite some time I had submitted a patch[0] that decomples ff layout driver from v3 client so that client still can use v4.1 DSes ever if v3 client in not compiled.

[0]: a68c6fbb638a "nfs41: drop dependency between flexfiles layout driver and NFSv3 modules"

Best regards,
Tigran.

----- Original Message -----

Quoted 63 lines

From: "Rick Macklem" <[email protected]>
To: "Jeff Layton" <[email protected]>
Cc: "Chuck Lever" <[email protected]>, "NeilBrown" <[email protected]>, "Olga Kornievskaia" <[email protected]>, "Dai Ngo" <[email protected]>, "Tom Talpey" <[email protected]>, "Tom Haynes" <[email protected]>, "linux-nfs" <[email protected]>, "linux-kernel" <[email protected]>, "Benji Wiebe" <[email protected]>
Sent: Friday, 4 September, 2026 21:04:18
Subject: Re: [PATCH] nfsd: don't offer flexfiles layouts when NFSv3 isn't being served

Quoted 36 lines · Jeff Layton

The flexfiles layout driver hands out a deviceinfo that names this server as an NFSv3 DS (flexfilelayout.c hardcodes da->version = 3). With v3 disabled, the client can't talk to the DS: it loops on v3 NULL calls that the server answers with PROG_MISMATCH, and I/O hangs in D state.

Skip LAYOUT_FLEX_FILES in nfsd4_setup_layout_type() unless v3 is enabled.

Closes:
https://lore.kernel.org/linux-nfs/[email protected]/

Fixes 9b9960a0ca47 ("nfsd: Add a super simple flex file server")
Assisted-by LLM
---
 fs/nfsd/nfs4layouts.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/nfsd/nfs4layouts.c +3 -1
index 22bcb6d09f70..cef4d40c89a2 100644
@@ -127,10 +127,12 @@ nfsd4_set_deviceid(struct nfsd4_deviceid *id, const struct
 svc_fh *fhp,
 
 void nfsd4_setup_layout_type(struct svc_export *exp)
 {
+       struct nfsd_net *nn = net_generic(exp->cd->net, nfsd_net_id);
        struct super_block *sb = exp->ex_path.mnt->mnt_sb;
        expfs_block_layouts_t block_supported = exportfs_layouts_supported(sb);
 
-       if (IS_ENABLED(CONFIG_NFSD_FLEXFILELAYOUT))
+       if (IS_ENABLED(CONFIG_NFSD_FLEXFILELAYOUT) &&
+           nfsd_vers(nn, 3, NFSD_TEST))
                exp->ex_layout_types |= 1 << LAYOUT_FLEX_FILES;
        if (IS_ENABLED(CONFIG_NFSD_BLOCKLAYOUT) &&
Quoted 1 line

(block_supported & EXPFS_BLOCK_IN_BAND_ID))

Although most ffv1 servers use NFSv3 DSs, it is possible for an ffv1 layout to specify NFSv4.

rick
ps: I don't know how you'd check to see if the layout will be an
NFSv3 one. (If the server only does NFSv3 layouts, then I'd guess this patch is ok?)

Quoted 9 lines

---
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260904-pnfs-ff-485ac21042a6

Best regards,
--
Jeff Layton <[email protected]>