Re: [PATCH 4/4] exportfs,nfsd: rework checking for layout-based block device access support

Chuck Lever
2026-03-31T18:00:48Z

On Tue, Mar 31, 2026, at 11:33 AM, Christoph Hellwig wrote:

> diff --git a/fs/nfsd/nfs4layouts.c b/fs/nfsd/nfs4layouts.c
> index c53eb67969eb..7b849b637b5e 100644
> --- a/fs/nfsd/nfs4layouts.c
> +++ b/fs/nfsd/nfs4layouts.c
> @@ -2,7 +2,6 @@
> /*
> * Copyright (c) 2014 Christoph Hellwig.
> */
> -#include <linux/blkdev.h>
> #include <linux/exportfs_block.h>
> #include <linux/kmod.h>
> #include <linux/file.h>
> @@ -126,28 +125,17 @@ nfsd4_set_deviceid(struct nfsd4_deviceid *id,
> const struct svc_fh *fhp,
>
> void nfsd4_setup_layout_type(struct svc_export *exp)
> {
> -#if defined(CONFIG_NFSD_BLOCKLAYOUT) || defined(CONFIG_NFSD_SCSILAYOUT)
> struct super_block *sb = exp->ex_path.mnt->mnt_sb;
> - struct exportfs_block_ops *bops = sb->s_export_op->block_ops;
> -#endif
> -
> - if (!(exp->ex_flags & NFSEXP_PNFS))
> - return;
> + expfs_block_layouts_t block_supported = exporfs_layouts_supported(sb);

^exporfs^exportfs

throughout the patch.

> -#ifdef CONFIG_NFSD_FLEXFILELAYOUT
> - exp->ex_layout_types |= 1 << LAYOUT_FLEX_FILES;
> -#endif
> -#ifdef CONFIG_NFSD_BLOCKLAYOUT
> - if (bops && bops->get_uuid && bops->map_blocks && bops->commit_blocks)
> + if (IS_ENABLED(CONFIG_NFSD_FLEXFILELAYOUT))
> + exp->ex_layout_types |= 1 << LAYOUT_FLEX_FILES;
> + if (IS_ENABLED(CONFIG_NFSD_BLOCKLAYOUT) &&
> + (block_supported & EXPFS_BLOCK_IN_BAND_ID))
> exp->ex_layout_types |= 1 << LAYOUT_BLOCK_VOLUME;
> -#endif
> -#ifdef CONFIG_NFSD_SCSILAYOUT
> - if (bops && bops->map_blocks && bops->commit_blocks &&
> - sb->s_bdev &&
> - sb->s_bdev->bd_disk->fops->pr_ops &&
> - sb->s_bdev->bd_disk->fops->get_unique_id)
> + if (IS_ENABLED(CONFIG_NFSD_SCSILAYOUT) &&
> + (block_supported & EXPFS_BLOCK_OUT_OF_BAND_ID))
> exp->ex_layout_types |= 1 << LAYOUT_SCSI;
> -#endif
> }
>
> void nfsd4_close_layout(struct nfs4_layout_stateid *ls)

--
Chuck Lever