libmultipath: a generic multipath lib for block drivers This series introduces libmultipath. It is essentially a refactoring of NVME multipath support, so we can have a common library to also support native SCSI multipath.
Much of the code is taken directly from the NVMe multipath code. However, NVMe specifics are removed. A template structure is provided so the driver may provide callbacks for driver specifics, like ANA support for NVMe. Important new structures introduced include: - mpath_head These contain much of the multipath-specific functionality from nvme_ns_head, including a pointer to the gendisk structure and a path SRCU-based array. - mpath_device This is the per-path structure, and contains much the same multipath-specific functionality in nvme_ns libmultipath provides functionality for path management, path selection, data path, and failover handling. Since the NVMe driver has some code in the sysfs and ioctl handling which iterate all multipath NSes, functions like mpath_call_for_device() are added to do the same per-path iteration. Full series also available at https://github.com/johnpgarry/linux/commits/scsi-multipath-pre-7.1-upstream-v2/ Differences to v1: - put current_path[] at end of struct mpath_head (Nilay) - drop struct mpath_disk and keep nvme_remove_head() (Nilay) - don't pass iopolicy from mpath_find_path() (Benjamin) - change mpath_access_state names (Nilay) - fix for setting mpath_device.nr_active and .numa_node (Nilay) - fix uninit'ed pointers in __mpath_find_path() (Nilay) - simplify mpath_head_template.available_path (Nilay, Benjamin) - use DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE (Benjamin) - check mpath_bdev_submit_bio() -> .clone_bio() for errors (Benjamin) - drop struct mpath_pr_ops (Keith) - drop mpath_head_template.bdev_ioctl - drop mpath_head_template.get_unique_id - drop mpath_head_template.report_zones - drop mpath_head_template.get_access_state - add mpath_head_template.ioctl_{begin, finish} and drop mpath_head_read_unlock() - add mpath_device.access_state - add mpath_head_devices_empty() - make mpath_delete_device() return a bool John Garry (13): libmultipath: Add initial framework libmultipath: Add basic gendisk support libmultipath: Add path selection support libmultipath: Add bio handling libmultipath: Add support for mpath_device management libmultipath: Add cdev support libmultipath: Add delayed removal support libmultipath: Add sysfs helpers libmultipath: Add PR support libmultipath: Add mpath_bdev_report_zones() libmultipath: Add support for block device IOCTL libmultipath: Add mpath_bdev_getgeo() libmultipath: Add mpath_bdev_get_unique_id() include/linux/multipath.h | 181 ++++++ lib/Kconfig | 6 + lib/Makefile | 2 + lib/multipath.c | 1293 +++++++++++++++++++++++++++++++++++++ 4 files changed, 1482 insertions(+) create mode 100644 include/linux/multipath.h create mode 100644 lib/multipath.c -- 2.43.5

