nfs/blocklayout: allow pNFS SCSI layout without pNFS block layout
Subsystems (2)
PATCH 1/1 nfs/blocklayout: allow pNFS SCSI layout without pNFS block layout
The pNFS block-volume layout (LAYOUT_BLOCK_VOLUME, RFC 5663) and the pNFS SCSI layout (LAYOUT_SCSI, RFC 8154) are built from a single blocklayout driver. Until now CONFIG_PNFS_BLOCK was an unprompted symbol that pulled in both layout types whenever NFS_V4 and BLK_DEV_DM were enabled, so a kernel could not offer SCSI layout without also enabling block layout and device-mapper.
Split the two into separate, independently selectable options. Both types share almost the entire driver (read/write path, extent tree, and the device tree including the composite SLICE/CONCAT/STRIPE volume types), so keep a single blocklayoutdriver module and compile only the type-specific pieces in or out:
- block.c SIMPLE volume parsing, which resolves the device via the
userspace pipefs daemon (rpc_pipefs.c) - block only.
- scsi.c SCSI leaf volume parsing and persistent-reservation
register/unregister - SCSI only.
The remaining type-specific call sites in the shared core are guarded with IS_ENABLED() so the reference to a not-built symbol is eliminated, and the now cross-file helpers (bl_map_simple, bl_parse_simple, bl_parse_scsi, bl_register_scsi, bl_unregister_scsi) are made global with prototypes in blocklayout.h.
CONFIG_PNFS_BLOCK and CONFIG_PNFS_SCSI_LAYOUT are now prompted booleans that only select which volume types are compiled in. Module linkage is carried by a single internal tristate, CONFIG_PNFS_BLOCK_LAYOUT_DRIVER, which follows NFS_V4; making the two options booleans avoids a y/m mismatch where a built-in composite would silently drop a module-only object. SCSI layout defaults on and no longer depends on BLK_DEV_DM; block layout now defaults off.
blocklayout.h no longer includes device-mapper.h (it was unused); it includes blkdev.h for the block_device/sector_t/BLK_OPEN_* definitions used in the header.
--- fs/nfs/Kconfig | 20 ++- fs/nfs/Makefile | 2 +- fs/nfs/blocklayout/Makefile | 12 +- fs/nfs/blocklayout/block.c | 40 ++++++ fs/nfs/blocklayout/blocklayout.c | 43 ++++--- fs/nfs/blocklayout/blocklayout.h | 14 ++- fs/nfs/blocklayout/dev.c | 209 +++---------------------------- fs/nfs/blocklayout/scsi.c | 175 ++++++++++++++++++++++++++ 8 files changed, 300 insertions(+), 215 deletions(-) create mode 100644 fs/nfs/blocklayout/block.c create mode 100644 fs/nfs/blocklayout/scsi.c
fs/nfs/Kconfig +19 -1
@@ -122,9 +122,27 @@ config PNFS_FILE_LAYOUT default NFS_V4 config PNFS_BLOCK - tristate + bool "pNFS block layout support" 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 "pNFS SCSI layout support" + depends on NFS_V4 default NFS_V4 + help + Enable support for the pNFS SCSI layout type (RFC 8154). This does + not require device-mapper and can be enabled without PNFS_BLOCK. + +# Internal: the shared block/scsi layout driver module, built when either layout +# type is enabled. The two options above are booleans that only select which +# volume types are compiled in; this symbol is the single modularity knob and +# follows NFS_V4, so the composite module never lands in both obj-y and obj-m. +config PNFS_BLOCK_LAYOUT_DRIVER + tristate + default NFS_V4 if PNFS_BLOCK || PNFS_SCSI_LAYOUT config PNFS_FLEXFILE_LAYOUT tristate
fs/nfs/Makefile +1 -1
@@ -34,5 +34,5 @@ nfsv4-$(CONFIG_NFS_V4_0) += nfs40client.o nfs40proc.o nfsv4-$(CONFIG_NFS_V4_2) += nfs42proc.o nfs42xattr.o obj-$(CONFIG_PNFS_FILE_LAYOUT) += filelayout/ -obj-$(CONFIG_PNFS_BLOCK) += blocklayout/ +obj-$(CONFIG_PNFS_BLOCK_LAYOUT_DRIVER) += blocklayout/ obj-$(CONFIG_PNFS_FLEXFILE_LAYOUT) += flexfilelayout/
fs/nfs/blocklayout/Makefile +10 -2
@@ -2,6 +2,14 @@ # # Makefile for the pNFS block layout driver kernel module # -obj-$(CONFIG_PNFS_BLOCK) += blocklayoutdriver.o +obj-$(CONFIG_PNFS_BLOCK_LAYOUT_DRIVER) += blocklayoutdriver.o -blocklayoutdriver-y += blocklayout.o dev.o extent_tree.o rpc_pipefs.o +# Shared core: device tree incl. composite SLICE/CONCAT/STRIPE volumes (used by +# both layout types), extent tree, common layout ops, init/exit. +blocklayoutdriver-y += blocklayout.o dev.o extent_tree.o + +# Block-layout-specific: SIMPLE volumes resolved via the userspace pipefs daemon. +blocklayoutdriver-$(CONFIG_PNFS_BLOCK) += block.o rpc_pipefs.o + +# SCSI-layout-specific: SCSI leaf volume parse and PR register/unregister. +blocklayoutdriver-$(CONFIG_PNFS_SCSI_LAYOUT) += scsi.o
fs/nfs/blocklayout/block.c new file +40 -0
@@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2014-2016 Christoph Hellwig. +*/ +#include <linux/blkdev.h> +#include <linux/nfs4.h> +#include <linux/nfs_fs.h> +#include <linux/nfs_xdr.h> + +#include "blocklayout.h" + +#define NFSDBG_FACILITY NFSDBG_PNFS_LD + +int +bl_parse_simple (struct nfs_server *server,struct pnfs_block_dev *d, +struct pnfs_block_volume *volumes,int idx,gfp_t gfp_mask) +{ +struct pnfs_block_volume *v = &volumes[idx]; +struct file *bdev_file; +dev_t dev; + + dev =bl_resolve_deviceid (server, v, gfp_mask); +if (!dev) +return -EIO ; + + bdev_file =bdev_file_open_by_dev (dev,BLK_OPEN_READ |BLK_OPEN_WRITE , +NULL ,NULL ); +if (IS_ERR (bdev_file)) { +printk (KERN_WARNING "pNFS: failed to open device %d:%d (%ld)\n" , +MAJOR (dev),MINOR (dev),PTR_ERR (bdev_file)); +return PTR_ERR (bdev_file); + } + d->bdev_file = bdev_file; + d->len =bdev_nr_bytes (file_bdev (bdev_file)); + d->map = bl_map_simple; + +printk (KERN_INFO "pNFS: using block device %s\n" , +file_bdev (bdev_file)->bd_disk->disk_name); +return 0 ; +}
fs/nfs/blocklayout/blocklayout.c +28 -15
68 lines not on this page · raw message
fs/nfs/blocklayout/blocklayout.h +13 -1
@@ -32,7 +32,7 @@#ifndef FS_NFS_NFS4BLOCKLAYOUT_H #define FS_NFS_NFS4BLOCKLAYOUT_H -#include <linux/device-mapper.h> +#include <linux/blkdev.h> #include <linux/nfs_fs.h> #include <linux/sunrpc/rpc_pipe_fs.h>
@@ -182,6 +182,18 @@ bool bl_register_dev(struct pnfs_block_dev *d);struct nfs4_deviceid_node *bl_alloc_deviceid_node (struct nfs_server *server,struct pnfs_device *pdev,gfp_t gfp_mask);void bl_free_deviceid_node (struct nfs4_deviceid_node *d); +bool bl_map_simple (struct pnfs_block_dev *dev,u64 offset, +struct pnfs_block_dev_map *map); + +/* block.c */ +int bl_parse_simple (struct nfs_server *server,struct pnfs_block_dev *d, +struct pnfs_block_volume *volumes,int idx,gfp_t gfp_mask); + +/* scsi.c */ +int bl_parse_scsi (struct nfs_server *server,struct pnfs_block_dev *d, +struct pnfs_block_volume *volumes,int idx,gfp_t gfp_mask); +bool bl_register_scsi (struct pnfs_block_dev *dev); +void bl_unregister_scsi (struct pnfs_block_dev *dev);/* extent_tree.c */ int ext_tree_insert(struct pnfs_block_layout *bl,
fs/nfs/blocklayout/dev.c +14 -195
263 lines not on this page · raw message
fs/nfs/blocklayout/scsi.c new file +175 -0
175 lines not on this page · raw message
Signature · 1 line
2.55.0
Supporting SCSI layout with block layout makes totaly sense, but please do it without all the gracious renaming and annoying AI slop commit log. Take a look at show nfsd handled this with CONFIG_NFSD_BLOCKLAYOUT and CONFIG_NFSD_SCSILAYOUT as that is the model that applies here as well.