How opensvc/multipath-tools works
Project Type and Purpose
• This project is a set of system-level tools for Linux that work with the device mapper multipathing driver.
• Its purpose is to provide several command‐line utilities and daemons (e.g., multipath, multipathd, multipathc, mpathpersist, and kpartx) to automate device mapper configuration, manage persistent SCSI reservations, and create device maps from partition tables.
• The README confirms that these tools interact directly with kernel subsystems (device mapper, SCSI, NVMe) and relies on a variety of system-level libraries.
Analyzing the File Structure
• The project is organized into several top-level directories and files:
– .github directory: Contains CI/CD configuration (actions, workflows) that automate building, unit tests, and ABI checks.
– Individual directories for each of the binaries: “multipath”, “multipathd”, “mpathpersist”, “kpartx”, with their source files in subdirectories.
– Several libraries or “lib” directories (libdmmp, libmpathcmd, libmpathpersist, libmpathutil, libmpathvalid, libmultipath) that encapsulate common functionality: interacting with device mapper, persistent reservations, configuration parsing, logging, etc.
– The tests directory includes unit tests that validate behaviors.
• The Makefiles and build scripts (e.g., create-config.mk, Makefile.inc) provide insight into the build process and the specific configurable paths, linking with external libraries (libdevmapper, libsystemd, etc.).
Key Components and Their Relationships
• Main Binaries and Daemons:
• multipath: Performs automatic configuration for device mapper multipathing.
• multipathd: Acts as a persistent daemon, coordinating with the kernel’s device mapper and handling dynamic events.
• multipathc: An interactive client for communicating with multipathd.
• mpathpersist: Manages SCSI persistent reservations on multipath devices.
• kpartx: Creates device maps from partition tables.
• Core Libraries:
• libmultipath and the other libmpath* directories: Provide the underlying functionality (e.g., configuration parsing, logging, device scanning, and error handling) that are shared across multiple binaries.
• libdmmp: Offers abstractions and interfaces for interacting with the device mapper multipathing components.
• External Dependencies:
• The build depends on libraries such as libdevmapper, libaio, libudev, libjson-c, liburcu, and libsystemd.
• There is support for command line editing via libedit or libreadline (conditional upon build settings).
• Build and Continuous Integration:
• GitHub workflows in the .github directory define various CI steps (building on different architectures, unit testing, and ABI verification).