nfs: split up block layout and SCSI layout support
Subsystems (2)
PATCH v2 1/1 nfs: split up block layout and SCSI layout support
Add two new config options PNFS_BLOCK_LAYOUT and PNFS_SCSI_LAYOUT so that SCSI layouts can be enabled without requiring block layouts. Since block layouts are considered deprecated, PNFS_BLOCK_LAYOUT defaults to n.
The original PNFS_BLOCK config is now invisible and gets set whenever either of PNFS_BLOCK_LAYOUT or PNFS_SCSI_LAYOUT are enabled.
--- fs/nfs/Kconfig | 13 +++++++++++++ fs/nfs/blocklayout/Makefile | 3 ++- fs/nfs/blocklayout/blocklayout.c | 30 ++++++++++++++++++++++++++++++ fs/nfs/blocklayout/blocklayout.h | 12 ++++++++++++ fs/nfs/blocklayout/dev.c | 18 ++++++++++++++++++ 5 files changed, 75 insertions(+), 1 deletion(-)
fs/nfs/Kconfig +13 -0
@@ -123,8 +123,21 @@ config PNFS_FILE_LAYOUT config PNFS_BLOCK tristate + default NFS_V4 if PNFS_BLOCK_LAYOUT || PNFS_SCSI_LAYOUT + +config PNFS_BLOCK_LAYOUT + bool "NFS client support for pNFS block layouts" depends on NFS_V4 && BLK_DEV_DM + default n + help + Enable support for the pNFS block-volume layout type (RFC 5663). + +config PNFS_SCSI_LAYOUT + bool "NFS client support for pNFS SCSI layouts" + depends on NFS_V4 default NFS_V4 + help + Enable suport for the pNFS SCSI layout type (RFC 8154). config PNFS_FLEXFILE_LAYOUT tristate
fs/nfs/blocklayout/Makefile +2 -1
@@ -4,4 +4,5 @@ # obj-$(CONFIG_PNFS_BLOCK) += blocklayoutdriver.o -blocklayoutdriver-y += blocklayout.o dev.o extent_tree.o rpc_pipefs.o +blocklayoutdriver-y += blocklayout.o dev.o extent_tree.o +blocklayoutdriver-$(CONFIG_PNFS_BLOCK_LAYOUT) += rpc_pipefs.o
fs/nfs/blocklayout/blocklayout.c +30 -0
@@ -470,17 +470,21 @@ static struct pnfs_layout_hdr *__bl_alloc_layout_hdr(struct inode *inode,return &bl->bl_layout; } +#ifdef CONFIG_PNFS_BLOCK_LAYOUT static struct pnfs_layout_hdr *bl_alloc_layout_hdr (struct inode *inode,gfp_t gfp_flags) {return __bl_alloc_layout_hdr (inode, gfp_flags, false); } +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ +#ifdef CONFIG_PNFS_SCSI_LAYOUT static struct pnfs_layout_hdr *sl_alloc_layout_hdr (struct inode *inode,gfp_t gfp_flags) {return __bl_alloc_layout_hdr (inode, gfp_flags, true); } +#endif /* CONFIG_PNFS_SCSI_LAYOUT */ static void bl_free_lseg (struct pnfs_layout_segment *lseg) {
@@ -954,6 +958,7 @@ static const struct nfs_pageio_ops bl_pg_write_ops = { .pg_cleanup = pnfs_generic_pg_cleanup, }; +#ifdef CONFIG_PNFS_BLOCK_LAYOUT static struct pnfs_layoutdriver_type blocklayout_type = { .id =LAYOUT_BLOCK_VOLUME , .name = "LAYOUT_BLOCK_VOLUME",
@@ -977,7 +982,9 @@ static struct pnfs_layoutdriver_type blocklayout_type = { .pg_write_ops = &bl_pg_write_ops, .sync = pnfs_generic_sync, }; +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ +#ifdef CONFIG_PNFS_SCSI_LAYOUT static struct pnfs_layoutdriver_type scsilayout_type = { .id =LAYOUT_SCSI , .name = "LAYOUT_SCSI",
@@ -1001,6 +1008,7 @@ static struct pnfs_layoutdriver_type scsilayout_type = { .pg_write_ops = &bl_pg_write_ops, .sync = pnfs_generic_sync, }; +#endif /* CONFIG_PNFS_SCSI_LAYOUT */ static int __init nfs4blocklayout_init (void )
@@ -1009,6 +1017,7 @@ static int __init nfs4blocklayout_init(void)dprintk ("%s: NFSv4 Block Layout Driver Registering...\n" , __func__); +#ifdef CONFIG_PNFS_BLOCK_LAYOUT ret =bl_init_pipefs ();if (ret) goto out;
@@ -1016,18 +1025,31 @@ static int __init nfs4blocklayout_init(void) ret =pnfs_register_layoutdriver (&blocklayout_type);if (ret) goto out_cleanup_pipe; +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ +#ifdef CONFIG_PNFS_SCSI_LAYOUT ret =pnfs_register_layoutdriver (&scsilayout_type); if (ret) +#ifdef CONFIG_PNFS_BLOCK_LAYOUT goto out_unregister_block; +#else +return ret; +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ +#endif /* CONFIG_PNFS_SCSI_LAYOUT */ return 0 ; +#ifdef CONFIG_PNFS_SCSI_LAYOUT +#ifdef CONFIG_PNFS_BLOCK_LAYOUT out_unregister_block:pnfs_unregister_layoutdriver (&blocklayout_type); +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ +#endif /* CONFIG_PNFS_SCSI_LAYOUT */ +#ifdef CONFIG_PNFS_BLOCK_LAYOUT out_cleanup_pipe:bl_cleanup_pipefs (); out:return ret; +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ } static void __exit nfs4blocklayout_exit(void)
@@ -1035,13 +1057,21 @@ static void __exit nfs4blocklayout_exit(void)dprintk ("%s: NFSv4 Block Layout Driver Unregistering...\n" , __func__); +#ifdef CONFIG_PNFS_SCSI_LAYOUT pnfs_unregister_layoutdriver (&scsilayout_type); +#endif /* CONFIG_PNFS_SCSI_LAYOUT */ +#ifdef CONFIG_PNFS_BLOCK_LAYOUT pnfs_unregister_layoutdriver (&blocklayout_type);bl_cleanup_pipefs (); +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ } +#ifdef CONFIG_PNFS_BLOCK_LAYOUT MODULE_ALIAS ("nfs-layouttype4-3" ); +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ +#ifdef CONFIG_PNFS_SCSI_LAYOUT MODULE_ALIAS ("nfs-layouttype4-5" ); +#endif /* CONFIG_PNFS_SCSI_LAYOUT */ module_init (nfs4blocklayout_init);module_exit (nfs4blocklayout_exit);
fs/nfs/blocklayout/blocklayout.h +12 -0
@@ -34,7 +34,9 @@#include <linux/device-mapper.h> #include <linux/nfs_fs.h> +#ifdef CONFIG_PNFS_BLOCK_LAYOUT #include <linux/sunrpc/rpc_pipe_fs.h> +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ #include "../nfs4_fs.h" #include "../pnfs.h"
@@ -46,7 +48,9 @@struct pnfs_block_dev ; +#ifdef CONFIG_PNFS_BLOCK_LAYOUT #define PNFS_BLOCK_MAX_UUIDS 4 +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ #define PNFS_BLOCK_MAX_DEVICES 64/*
@@ -58,6 +62,7 @@ struct pnfs_block_dev; struct pnfs_block_volume { enum pnfs_block_volume_type type; union { +#ifdef CONFIG_PNFS_BLOCK_LAYOUT struct { int len; int nr_sigs;
@@ -67,6 +72,7 @@ struct pnfs_block_volume { u8 sig[PNFS_BLOCK_UUID_LEN]; } sigs[PNFS_BLOCK_MAX_UUIDS ]; } simple; +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ struct {u64 start;u64 len;
@@ -81,6 +87,7 @@ struct pnfs_block_volume {u32 volumes_count;u32 volumes[PNFS_BLOCK_MAX_DEVICES ]; } stripe; +#ifdef CONFIG_PNFS_SCSI_LAYOUT struct { enum scsi_code_set code_set; enum scsi_designator_type designator_type;
@@ -88,6 +95,7 @@ struct pnfs_block_volume {u8 designator[256 ]; u64 pr_key; } scsi; +#endif /* CONFIG_PNFS_SCSI_LAYOUT */ }; };
@@ -161,6 +169,7 @@ BLK_LSEG2EXT(struct pnfs_layout_segment *lseg)return BLK_LO2EXT (lseg->pls_layout); } +#ifdef CONFIG_PNFS_BLOCK_LAYOUT struct bl_pipe_msg { struct rpc_pipe_msg msg; wait_queue_head_t *bl_wq;
@@ -176,6 +185,7 @@ struct bl_msg_hdr {#define BL_DEVICE_REQUEST_INIT 0x0/* Start request */ #define BL_DEVICE_REQUEST_PROC 0x1/* User level process succeeds */ #define BL_DEVICE_REQUEST_ERR 0x2/* User level process fails */ +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ /* dev.c */ bool bl_register_dev (struct pnfs_block_dev *d);
@@ -195,10 +205,12 @@ bool ext_tree_lookup(struct pnfs_block_layout *bl, sector_t isect,int ext_tree_prepare_commit (struct nfs4_layoutcommit_args *arg);void ext_tree_mark_committed (struct nfs4_layoutcommit_args *arg,int status); +#ifdef CONFIG_PNFS_BLOCK_LAYOUT /* rpc_pipefs.c */ dev_t bl_resolve_deviceid (struct nfs_server *server,struct pnfs_block_volume *b,gfp_t gfp_mask);int __init bl_init_pipefs (void );void bl_cleanup_pipefs (void ); +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ #endif /* FS_NFS_NFS4BLOCKLAYOUT_H */
fs/nfs/blocklayout/dev.c +18 -0
@@ -15,6 +15,7 @@#define NFSDBG_FACILITY NFSDBG_PNFS_LD +#ifdef CONFIG_PNFS_SCSI_LAYOUT static void bl_unregister_scsi (struct pnfs_block_dev *dev) {struct block_device *bdev =file_bdev (dev->bdev_file);
@@ -45,6 +46,7 @@ static bool bl_register_scsi(struct pnfs_block_dev *dev)trace_bl_pr_key_reg (bdev, dev->pr_key); return true; } +#endif /* CONFIG_PNFS_SCSI_LAYOUT */ static void bl_unregister_dev (struct pnfs_block_dev *dev) {
@@ -56,9 +58,11 @@ static void bl_unregister_dev(struct pnfs_block_dev *dev)return ; } +#ifdef CONFIG_PNFS_SCSI_LAYOUT if (dev->type ==PNFS_BLOCK_VOLUME_SCSI &&test_and_clear_bit (PNFS_BDEV_REGISTERED , &dev->flags))bl_unregister_scsi (dev); +#endif /* CONFIG_PNFS_SCSI_LAYOUT */ }bool bl_register_dev (struct pnfs_block_dev *dev)
@@ -76,8 +80,10 @@ bool bl_register_dev(struct pnfs_block_dev *dev)return true; } +#ifdef CONFIG_PNFS_SCSI_LAYOUT if (dev->type ==PNFS_BLOCK_VOLUME_SCSI )return bl_register_scsi (dev); +#endif /* CONFIG_PNFS_SCSI_LAYOUT */ return true; }
@@ -122,6 +128,7 @@ nfs4_block_decode_volume(struct xdr_stream *xdr, struct pnfs_block_volume *b) b->type =be32_to_cpup (p++);switch (b->type) { +#ifdef CONFIG_PNFS_BLOCK_LAYOUT case PNFS_BLOCK_VOLUME_SIMPLE : p =xdr_inline_decode (xdr,4 );if (!p)
@@ -155,6 +162,7 @@ nfs4_block_decode_volume(struct xdr_stream *xdr, struct pnfs_block_volume *b) (XDR_QUADLEN(b->simple.sigs[i].sig_len) << 2); }break ; +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ case PNFS_BLOCK_VOLUME_SLICE : p =xdr_inline_decode (xdr,8 +8 +4 );if (!p)
@@ -198,6 +206,7 @@ nfs4_block_decode_volume(struct xdr_stream *xdr, struct pnfs_block_volume *b)for (i =0 ; i < b->stripe.volumes_count; i++) b->stripe.volumes[i] =be32_to_cpup (p++);break ; +#ifdef CONFIG_PNFS_SCSI_LAYOUT case PNFS_BLOCK_VOLUME_SCSI : p =xdr_inline_decode (xdr,4 +4 +4 );if (!p)
@@ -216,6 +225,7 @@ nfs4_block_decode_volume(struct xdr_stream *xdr, struct pnfs_block_volume *b)return -EIO ; p =xdr_decode_hyper (p, &b->scsi.pr_key);break ; +#endif /* CONFIG_PNFS_SCSI_LAYOUT */ default :dprintk ("unknown volume type!\n" );return -EIO ;
@@ -293,6 +303,7 @@ bl_parse_deviceid(struct nfs_server *server, struct pnfs_block_dev *d, struct pnfs_block_volume *volumes, int idx, gfp_t gfp_mask); +#ifdef CONFIG_PNFS_BLOCK_LAYOUT static int bl_parse_simple (struct nfs_server *server,struct pnfs_block_dev *d,struct pnfs_block_volume *volumes,int idx,gfp_t gfp_mask)
@@ -320,7 +331,9 @@ bl_parse_simple(struct nfs_server *server, struct pnfs_block_dev *d, file_bdev(bdev_file)->bd_disk->disk_name);return 0 ; } +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ +#ifdef CONFIG_PNFS_SCSI_LAYOUT static bool bl_validate_designator (struct pnfs_block_volume *v) {
@@ -449,6 +462,7 @@ bl_parse_scsi(struct nfs_server *server, struct pnfs_block_dev *d, d->bdev_file =NULL ;return error; } +#endif /* CONFIG_PNFS_SCSI_LAYOUT */ static int bl_parse_slice(struct nfs_server *server, struct pnfs_block_dev *d,
@@ -537,16 +551,20 @@ bl_parse_deviceid(struct nfs_server *server, struct pnfs_block_dev *d, d->type = volumes[idx].type;switch (d->type) { +#ifdef CONFIG_PNFS_BLOCK_LAYOUT case PNFS_BLOCK_VOLUME_SIMPLE :return bl_parse_simple (server, d, volumes, idx, gfp_mask); +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ case PNFS_BLOCK_VOLUME_SLICE :return bl_parse_slice (server, d, volumes, idx, gfp_mask);case PNFS_BLOCK_VOLUME_CONCAT :return bl_parse_concat (server, d, volumes, idx, gfp_mask);case PNFS_BLOCK_VOLUME_STRIPE :return bl_parse_stripe (server, d, volumes, idx, gfp_mask); +#ifdef CONFIG_PNFS_SCSI_LAYOUT case PNFS_BLOCK_VOLUME_SCSI :return bl_parse_scsi (server, d, volumes, idx, gfp_mask); +#endif /* CONFIG_PNFS_SCSI_LAYOUT */ default :dprintk ("unsupported volume type: %d\n" , d->type);return -EIO ;
Signature · 1 line
2.55.0
Quoted 7 lines · Scott Mayhew
Add two new config options
PNFS_BLOCK_LAYOUTandPNFS_SCSI_LAYOUTso that SCSI layouts can be enabled without requiring block layouts. Since block layouts are considered deprecated,PNFS_BLOCK_LAYOUTdefaults to n.The original
PNFS_BLOCKconfig is now invisible and gets set whenever either ofPNFS_BLOCK_LAYOUTorPNFS_SCSI_LAYOUTare enabled.
Much better, thanks!
fs/nfs/Kconfig config PNFS_FILE_LAYOUT · line 126
Quoted 3 lines
config
PNFS_BLOCKfs/nfs/Kconfig +1
-0tristate + default NFS_V4 if PNFS_BLOCK_LAYOUT || PNFS_SCSI_LAYOUT
This is only used in the two Makefiles, where we could just build the objects for both symbols. But if you stick to the extra symbol, I'd not use default but instead select it from the other two options.
fs/nfs/Kconfig config PNFS_FILE_LAYOUT · line 131
Quoted 4 lines
fs/nfs/Kconfig +3
-0+config PNFS_BLOCK_LAYOUT + bool "NFS client support for pNFS block layouts" depends on NFS_V4 && BLK_DEV_DM + default n
n is the default default, so you can remove this line.
Quoted 9 lines
fs/nfs/blocklayout/blocklayout.c +1
-0@@ -470,17 +470,21 @@ static struct pnfs_layout_hdr *__bl_alloc_layout_hdr(struct inode *inode,return &bl->bl_layout; } +#ifdef CONFIG_PNFS_BLOCK_LAYOUT static struct pnfs_layout_hdr *bl_alloc_layout_hdr (struct inode *inode,gfp_t gfp_flags) {return __bl_alloc_layout_hdr (inode, gfp_flags, false);
fs/nfs/blocklayout/blocklayout.c static struct pnfs_layout_hdr *__bl_alloc_layout_hdr(struct inode *inode, · line 487
Quoted 10 lines
fs/nfs/blocklayout/blocklayout.c +3
-0} +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ +#ifdef CONFIG_PNFS_SCSI_LAYOUT static struct pnfs_layout_hdr *sl_alloc_layout_hdr (struct inode *inode,gfp_t gfp_flags) {return __bl_alloc_layout_hdr (inode, gfp_flags, true); } +#endif /* CONFIG_PNFS_SCSI_LAYOUT */
Let's move the alloc_layout_hdr helpers down next to the ops, to remove the number of ifdef blocks.
Quoted 24 lines
fs/nfs/blocklayout/blocklayout.c +10
-0+#ifdef CONFIG_PNFS_BLOCK_LAYOUT ret =bl_init_pipefs ();if (ret) goto out;@@ -1016,18 +1025,31 @@ static int __init nfs4blocklayout_init(void) ret =pnfs_register_layoutdriver (&blocklayout_type);if (ret) goto out_cleanup_pipe; +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ +#ifdef CONFIG_PNFS_SCSI_LAYOUT ret =pnfs_register_layoutdriver (&scsilayout_type); if (ret) +#ifdef CONFIG_PNFS_BLOCK_LAYOUT goto out_unregister_block; +#else +return ret; +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ +#endif /* CONFIG_PNFS_SCSI_LAYOUT */ return 0 ; +#ifdef CONFIG_PNFS_SCSI_LAYOUT +#ifdef CONFIG_PNFS_BLOCK_LAYOUT out_unregister_block:
fs/nfs/blocklayout/blocklayout.c static int __init nfs4blocklayout_init(void) · line 1053
Quoted 10 lines
fs/nfs/blocklayout/blocklayout.c +4
-0pnfs_unregister_layoutdriver (&blocklayout_type); +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ +#endif /* CONFIG_PNFS_SCSI_LAYOUT */ +#ifdef CONFIG_PNFS_BLOCK_LAYOUT out_cleanup_pipe:bl_cleanup_pipefs (); out:return ret; +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ }
This is a bit of a mess still. I think the best is to have separate init and exit helper for block vs scsi in the ifdef block above that have stubs and then call them here and in the exit handler without all the micro-ifdefs.
fs/nfs/blocklayout/blocklayout.c static void __exit nfs4blocklayout_exit(void) · line 1074
Quoted 6 lines
fs/nfs/blocklayout/blocklayout.c +4
-0+#ifdef CONFIG_PNFS_BLOCK_LAYOUT MODULE_ALIAS ("nfs-layouttype4-3" ); +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */ +#ifdef CONFIG_PNFS_SCSI_LAYOUT MODULE_ALIAS ("nfs-layouttype4-5" ); +#endif /* CONFIG_PNFS_SCSI_LAYOUT */
Please also move this into existing ifdef blocks.
fs/nfs/blocklayout/blocklayout.h line 39
Quoted 3 lines
fs/nfs/blocklayout/blocklayout.h +2
-0+#ifdef CONFIG_PNFS_BLOCK_LAYOUT #include <linux/sunrpc/rpc_pipe_fs.h> +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */
Extract unused includes are generall harmless and preferred over conditional ones.
fs/nfs/blocklayout/blocklayout.h line 53
Quoted 10 lines
#include "
../nfs4_fs.h"
#include "../pnfs.h"fs/nfs/blocklayout/blocklayout.h +2
-0@@ -46,7 +48,9 @@struct pnfs_block_dev ; +#ifdef CONFIG_PNFS_BLOCK_LAYOUT #define PNFS_BLOCK_MAX_UUIDS 4 +#endif /* CONFIG_PNFS_BLOCK_LAYOUT */
There is no point in hiding defines (or union arms below).
This still looks like overzealous agent work. Please try to use your own brain cells, the output tends to be much better than that from stupud machines.
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Scott,
kernel test robot noticed the following build errors:
[auto build test ERROR on trondmy-nfs/linux-next]
[also build test ERROR on linus/master v7.3-rc2 next-20260909] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Scott-Mayhew/nfs-split-up-block-layout-and-SCSI-layout-support/20260904-132627 base: git://git.linux-nfs.org/projects/trondmy/linux-nfs.git linux-next patch link: https://lore.kernel.org/r/20260904172627.1347637-1-smayhew%40redhat.com patch subject: [PATCH v2] nfs: split up block layout and SCSI layout support config: x86_64-randconfig-122-20260910 (https://download.01.org/0day-ci/archive/20260910/[email protected]/config) compiler: gcc-14 (Debian 14.2.0-19) 14.2.0 sparse: v0.6.5-rc1 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260910/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>, old ones prefixed by <<):
>> ERROR: modpost: fs/nfs/blocklayout/blocklayoutdriver.ko: symbol 'bdev_file_open_by_path' undefined! >> ERROR: modpost: fs/nfs/blocklayout/blocklayoutdriver.ko: symbol 'submit_bio' undefined! >> ERROR: modpost: fs/nfs/blocklayout/blocklayoutdriver.ko: symbol 'bio_put' undefined! >> ERROR: modpost: fs/nfs/blocklayout/blocklayoutdriver.ko: symbol 'bio_add_page' undefined! >> ERROR: modpost: fs/nfs/blocklayout/blocklayoutdriver.ko: symbol 'file_bdev' undefined! >> ERROR: modpost: fs/nfs/blocklayout/blocklayoutdriver.ko: symbol 'bio_alloc_bioset' undefined! >> ERROR: modpost: fs/nfs/blocklayout/blocklayoutdriver.ko: symbol 'fs_bio_set' undefined!
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki