Re: [PATCH] nfsd: don't offer flexfiles layouts when NFSv3 isn't being served

From: Rick Macklem

Date: Fri Sep 04 2026 - 15:59:31 EST


On Fri, Sep 4, 2026 at 9:50 AM Jeff Layton <jlayton@xxxxxxxxxx> wrote:
>
> 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.
>
> Reported-by: Benji Wiebe <itsme@xxxxxxxxxxxxxx>
> Closes: https://lore.kernel.org/linux-nfs/c734eeb8-8486-4491-bb4d-b9656cbaffbe@xxxxxxxxxxxxxxxx/
> Fixes: 9b9960a0ca47 ("nfsd: Add a super simple flex file server")
> Assisted-by: LLM
> Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
> ---
> fs/nfsd/nfs4layouts.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/nfsd/nfs4layouts.c b/fs/nfsd/nfs4layouts.c
> index 22bcb6d09f70..cef4d40c89a2 100644
> --- a/fs/nfsd/nfs4layouts.c
> +++ b/fs/nfsd/nfs4layouts.c
> @@ -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))
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?)

>
> ---
> base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
> change-id: 20260904-pnfs-ff-485ac21042a6
>
> Best regards,
> --
> Jeff Layton <jlayton@xxxxxxxxxx>
>
>