diff --git a/.gitignore b/.gitignore index c297b30..03e544c 100644 --- a/.gitignore +++ b/.gitignore @@ -23,15 +23,3 @@ multipath-tools-091027.tar.gz /multipath-tools-0.8.5.tgz /multipath-tools-0.8.6.tgz /multipath-tools-0.8.7.tgz -/multipath-tools-0.8.9.tgz -/multipath-tools-0.9.0.tgz -/multipath-tools-0.9.3.tgz -/multipath-tools-0.9.4.tgz -/multipath-tools-0.9.5.tgz -/multipath-tools-0.9.6.tgz -/multipath-tools-0.9.7.tgz -/multipath-tools-0.9.8.tgz -/multipath-tools-0.9.9.tgz -/multipath-tools-0.10.0.tgz -/multipath-tools-0.11.1.tgz -/multipath-tools-0.13.0.tgz diff --git a/0001-RH-fixup-udev-rules-for-redhat.patch b/0001-RH-fixup-udev-rules-for-redhat.patch deleted file mode 100644 index ed5b7e9..0000000 --- a/0001-RH-fixup-udev-rules-for-redhat.patch +++ /dev/null @@ -1,63 +0,0 @@ -From 64a07df23affd21842fdc604887276e62e5b41de Mon Sep 17 00:00:00 2001 -From: Benjamin Marzinski -Date: Thu, 13 Apr 2017 07:22:23 -0500 -Subject: [PATCH] RH: fixup udev rules for redhat - -The multipath rules need to run after scsi_id is run. This means moving -them after 60-persistent-storage.rules for redhat. Redhat also uses a -different naming scheme for partitions than SuSE. - -Signed-off-by: Benjamin Marzinski ---- - Makefile.inc | 2 +- - kpartx/kpartx.rules.in | 2 +- - multipath/Makefile | 4 ++-- - 3 files changed, 4 insertions(+), 4 deletions(-) - -diff --git a/Makefile.inc b/Makefile.inc -index 9e3dc466..ead89030 100644 ---- a/Makefile.inc -+++ b/Makefile.inc -@@ -34,7 +34,7 @@ endif - # Paths. All these can be overridden on the "make" command line. - prefix := - # Prefix for binaries --exec_prefix := $(prefix) -+exec_prefix := $(prefix)/usr - # Prefix for non-essential libraries (libdmmp) - usr_prefix := $(if $(prefix),$(prefix),/usr) - # Prefix for configuration files (multipath.conf) -diff --git a/kpartx/kpartx.rules.in b/kpartx/kpartx.rules.in -index 9d879609..2049eb8f 100644 ---- a/kpartx/kpartx.rules.in -+++ b/kpartx/kpartx.rules.in -@@ -39,6 +39,6 @@ LABEL="mpath_kpartx_end" - GOTO="kpartx_end" - - LABEL="run_kpartx" --RUN+="@BINDIR@/kpartx -un -p -part /dev/$name" -+RUN+="@BINDIR@/kpartx -un /dev/$name" - - LABEL="kpartx_end" -diff --git a/multipath/Makefile b/multipath/Makefile -index 67fb5e62..2ea9e528 100644 ---- a/multipath/Makefile -+++ b/multipath/Makefile -@@ -27,7 +27,7 @@ install: - $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(udevrulesdir) - $(Q)$(INSTALL_PROGRAM) -m 644 11-dm-mpath.rules $(DESTDIR)$(udevrulesdir) - $(Q)$(INSTALL_PROGRAM) -m 644 99-z-dm-mpath-late.rules $(DESTDIR)$(udevrulesdir) -- $(Q)$(INSTALL_PROGRAM) -m 644 multipath.rules $(DESTDIR)$(udevrulesdir)/56-multipath.rules -+ $(Q)$(INSTALL_PROGRAM) -m 644 multipath.rules $(DESTDIR)$(udevrulesdir)/62-multipath.rules - $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(tmpfilesdir) - $(Q)$(INSTALL_PROGRAM) -m 644 tmpfiles.conf $(DESTDIR)$(tmpfilesdir)/multipath.conf - $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(mandir)/man8 -@@ -50,7 +50,7 @@ uninstall: - $(Q)$(RM) $(DESTDIR)$(udevrulesdir)/99-z-dm-mpath-late.rules - $(Q)$(RM) $(DESTDIR)$(modulesloaddir)/multipath.conf - $(Q)$(RM) $(DESTDIR)$(modulesloaddir)/scsi_dh.conf -- $(Q)$(RM) $(DESTDIR)$(libudevdir)/rules.d/56-multipath.rules -+ $(Q)$(RM) $(DESTDIR)$(libudevdir)/rules.d/62-multipath.rules - $(Q)$(RM) $(DESTDIR)$(mandir)/man8/$(EXEC).8 - $(Q)$(RM) $(DESTDIR)$(mandir)/man5/$(EXEC).conf.5 - $(Q)$(RM) $(DESTDIR)$(tmpfilesdir)/multipath.conf diff --git a/0001-multipath-tools-add-info-about-IO-affinity-path-sele.patch b/0001-multipath-tools-add-info-about-IO-affinity-path-sele.patch new file mode 100644 index 0000000..559d5a5 --- /dev/null +++ b/0001-multipath-tools-add-info-about-IO-affinity-path-sele.patch @@ -0,0 +1,45 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Xose Vazquez Perez +Date: Wed, 8 Sep 2021 22:33:54 +0200 +Subject: [PATCH] multipath-tools: add info about IO affinity path selector to + manpage + +Added in 5.11: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e4d2e82b2300b03f66b3ca8417590c86e661fab1 + +Cc: Mike Christie +Cc: Martin Wilck +Cc: Benjamin Marzinski +Cc: Christophe Varoqui +Cc: DM-DEVEL ML +Signed-off-by: Xose Vazquez Perez + +Reviewed-by: Martin Wilck +Signed-off-by: Benjamin Marzinski +--- + multipath/multipath.conf.5 | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5 +index d6b8c7f6..42a15ffd 100644 +--- a/multipath/multipath.conf.5 ++++ b/multipath/multipath.conf.5 +@@ -6,7 +6,7 @@ + .\" + .\" ---------------------------------------------------------------------------- + . +-.TH MULTIPATH.CONF 5 2018-05-21 Linux ++.TH MULTIPATH.CONF 5 2021-09-08 Linux + . + . + .\" ---------------------------------------------------------------------------- +@@ -210,6 +210,10 @@ of outstanding I/O to the path and its relative throughput. + estimation of future service time based on the history of previous I/O submitted + to each path. + .TP ++.I "io-affinity 0" ++(Since 5.11 kernel) Choose the path for the next bunch of I/O based on a CPU to ++path mapping the user passes in and what CPU we are executing on. ++.TP + The default is: \fBservice-time 0\fR + .RE + . diff --git a/0002-multipathd-fix-missing-persistent-reseravtion-for-ac.patch b/0002-multipathd-fix-missing-persistent-reseravtion-for-ac.patch new file mode 100644 index 0000000..5312160 --- /dev/null +++ b/0002-multipathd-fix-missing-persistent-reseravtion-for-ac.patch @@ -0,0 +1,52 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: lixiaokeng +Date: Mon, 13 Sep 2021 10:43:14 +0800 +Subject: [PATCH] multipathd: fix missing persistent reseravtion for active + path + +There are two paths(sucu as sda and adb) for one LUN. The two +paths log in, but before the two uevents have been processed +(for example there are many uevent), users use multipathd add +path /dev/sda to cause mpatha and use mpathpersist -o -I to +register prkey for mpatha. The add map uevent is after add path +uevent, the the uevent(add sdb) will delay and missing persistent +reseravtion check. + +Here, we add persistent reseravtion check in update_map() which +is called ev_add_map(). + +Signed-off-by: Lixiaokeng +Signed-off-by: Benjamin Marzinski +--- + multipathd/main.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/multipathd/main.c b/multipathd/main.c +index 3aff241d..1defeaf1 100644 +--- a/multipathd/main.c ++++ b/multipathd/main.c +@@ -490,6 +490,8 @@ update_map (struct multipath *mpp, struct vectors *vecs, int new_map) + { + int retries = 3; + char *params __attribute__((cleanup(cleanup_charp))) = NULL; ++ struct path *pp; ++ int i; + + retry: + condlog(4, "%s: updating new map", mpp->alias); +@@ -502,6 +504,15 @@ retry: + verify_paths(mpp); + mpp->action = ACT_RELOAD; + ++ if (mpp->prflag) { ++ vector_foreach_slot(mpp->paths, pp, i) { ++ if ((pp->state == PATH_UP) || (pp->state == PATH_GHOST)) { ++ /* persistent reseravtion check*/ ++ mpath_pr_event_handle(pp); ++ } ++ } ++ } ++ + if (setup_map(mpp, ¶ms, vecs)) { + condlog(0, "%s: failed to setup new map in update", mpp->alias); + retries = -1; diff --git a/0003-RH-don-t-start-without-a-config-file.patch b/0003-RH-don-t-start-without-a-config-file.patch deleted file mode 100644 index 05d4e7a..0000000 --- a/0003-RH-don-t-start-without-a-config-file.patch +++ /dev/null @@ -1,137 +0,0 @@ -From 5613e07ce9cabf2fdc402f6f102cc54bd1059800 Mon Sep 17 00:00:00 2001 -From: Benjamin Marzinski -Date: Wed, 15 Oct 2014 10:39:30 -0500 -Subject: [PATCH] RH: don't start without a config file - -If /etc/multipath.conf doesn't exist, don't start multipathd and blacklist -all devices when running multipath. A completely blank configuration file -is almost never what users want. Also, people may have the multipath -packages installed but don't want to use them. This patch provides a -simple way to disable multipath. Simply removing or renaming -/etc/multipath.conf will keep multipath from doing anything. - -Signed-off-by: Benjamin Marzinski ---- - libmultipath/config.c | 13 +++++++++++++ - libmultipath/config.h | 1 + - multipath/main.c | 6 ++++++ - multipath/multipath.rules.in | 1 + - multipathd/multipathd.8.in | 2 ++ - multipathd/multipathd.service.in | 1 + - multipathd/multipathd.socket.in | 1 + - 7 files changed, 25 insertions(+) - -diff --git a/libmultipath/config.c b/libmultipath/config.c -index 8b424d18..b8317f4d 100644 ---- a/libmultipath/config.c -+++ b/libmultipath/config.c -@@ -937,6 +937,19 @@ int init_config__ (const char *file, struct config *conf) - } - factorize_hwtable(conf->hwtable, builtin_hwtable_size, file); - validate_pctable(conf->overrides, 0, file); -+ } else { -+ condlog(0, "/etc/multipath.conf does not exist, blacklisting all devices."); -+ if (conf->blist_devnode == NULL) { -+ conf->blist_devnode = vector_alloc(); -+ if (!conf->blist_devnode) { -+ condlog(0, "cannot allocate blacklist\n"); -+ goto out; -+ } -+ } -+ if (store_ble(conf->blist_devnode, ".*", ORIGIN_NO_CONFIG)) { -+ condlog(0, "cannot store default no-config blacklist\n"); -+ goto out; -+ } - } - - conf->processed_main_config = 1; -diff --git a/libmultipath/config.h b/libmultipath/config.h -index 5b4ebf8c..2302eacc 100644 ---- a/libmultipath/config.h -+++ b/libmultipath/config.h -@@ -10,6 +10,7 @@ - - #define ORIGIN_DEFAULT 0 - #define ORIGIN_CONFIG 1 -+#define ORIGIN_NO_CONFIG 2 - - enum devtypes { - DEV_NONE, -diff --git a/multipath/main.c b/multipath/main.c -index f2adcdeb..31012874 100644 ---- a/multipath/main.c -+++ b/multipath/main.c -@@ -834,11 +834,14 @@ main (int argc, char *argv[]) - char *dev = NULL; - struct config *conf; - bool enable_foreign = false; -+ bool have_config; -+ struct stat buf; - - libmultipath_init(); - if (atexit(dm_lib_exit) || atexit(libmultipath_exit)) - condlog(1, "failed to register cleanup handler for libmultipath: %m"); - logsink = LOGSINK_STDERR_WITH_TIME; -+ have_config = (stat(DEFAULT_CONFIGFILE, &buf) == 0); - if (init_config(DEFAULT_CONFIGFILE)) - exit(RTVL_FAIL); - if (atexit(uninit_config)) -@@ -1092,6 +1095,9 @@ main (int argc, char *argv[]) - while ((r = configure(conf, cmd, dev_type, dev)) == RTVL_RETRY) - condlog(3, "restart multipath configuration process"); - -+ if (!have_config && r == RTVL_OK && -+ (cmd == CMD_LIST_SHORT || cmd == CMD_LIST_LONG)) -+ r = RTVL_FAIL; - out: - put_multipath_config(conf); - if (dev) -diff --git a/multipath/multipath.rules.in b/multipath/multipath.rules.in -index 2ac1972f..cc248231 100644 ---- a/multipath/multipath.rules.in -+++ b/multipath/multipath.rules.in -@@ -9,6 +9,7 @@ IMPORT{cmdline}="nompath" - ENV{nompath}=="?*", GOTO="end_mpath" - IMPORT{cmdline}="multipath" - ENV{multipath}=="off", GOTO="end_mpath" -+TEST!="/etc/multipath.conf", GOTO="end_mpath" - - ENV{DEVTYPE}!="partition", GOTO="test_dev" - IMPORT{parent}="DM_MULTIPATH_DEVICE_PATH" -diff --git a/multipathd/multipathd.8.in b/multipathd/multipathd.8.in -index 8815e099..342e363e 100644 ---- a/multipathd/multipathd.8.in -+++ b/multipathd/multipathd.8.in -@@ -49,6 +49,8 @@ map regains its maximum performance and redundancy. - With the \fB-k\fR option, \fBmultipathd\fR acts as a client utility that - sends commands to a running instance of the multipathd daemon (see - \fBCOMMANDS\fR below). -+ -+In this Linux distribution, multipathd does not run unless a /etc/multipath.conf file exists. - . - . - .\" ---------------------------------------------------------------------------- -diff --git a/multipathd/multipathd.service.in b/multipathd/multipathd.service.in -index eb58943c..ab166435 100644 ---- a/multipathd/multipathd.service.in -+++ b/multipathd/multipathd.service.in -@@ -6,6 +6,7 @@ Wants=systemd-udevd-kernel.socket multipathd-queueing.service @MODPROBE_UNIT@ - After=systemd-udevd-kernel.socket @MODPROBE_UNIT@ - After=multipathd.socket systemd-remount-fs.service - Before=initrd-cleanup.service -+ConditionPathExists=/etc/multipath.conf - DefaultDependencies=no - Conflicts=shutdown.target - Conflicts=initrd-cleanup.service -diff --git a/multipathd/multipathd.socket.in b/multipathd/multipathd.socket.in -index 11002fce..5ed24757 100644 ---- a/multipathd/multipathd.socket.in -+++ b/multipathd/multipathd.socket.in -@@ -1,6 +1,7 @@ - [Unit] - Description=multipathd control socket - DefaultDependencies=no -+ConditionPathExists=/etc/multipath.conf - ConditionKernelCommandLine=!nompath - ConditionKernelCommandLine=!multipath=off - ConditionVirtualization=!container diff --git a/0003-multipath-tools-minor-fixes-to-multipath.conf.5-man-.patch b/0003-multipath-tools-minor-fixes-to-multipath.conf.5-man-.patch new file mode 100644 index 0000000..ddad7b0 --- /dev/null +++ b/0003-multipath-tools-minor-fixes-to-multipath.conf.5-man-.patch @@ -0,0 +1,48 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Xose Vazquez Perez +Date: Thu, 16 Sep 2021 00:44:49 +0200 +Subject: [PATCH] multipath-tools: minor fixes to multipath.conf.5 man page + +Cc: Martin Wilck +Cc: Benjamin Marzinski +Cc: Christophe Varoqui +Cc: DM-DEVEL ML +Signed-off-by: Xose Vazquez Perez +Signed-off-by: Benjamin Marzinski +--- + multipath/multipath.conf.5 | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5 +index 42a15ffd..c74129bd 100644 +--- a/multipath/multipath.conf.5 ++++ b/multipath/multipath.conf.5 +@@ -1,9 +1,9 @@ + .\" ---------------------------------------------------------------------------- +-.\" Update the date below if you make any significant change. + .\" Make sure there are no errors with: + .\" groff -z -wall -b -e -t multipath/multipath.conf.5 + .\" man --warnings -E UTF-8 -l -Tutf8 -Z multipath/multipath.conf.5 >/dev/null + .\" ++.\" Update the date below if you make any significant change. + .\" ---------------------------------------------------------------------------- + . + .TH MULTIPATH.CONF 5 2021-09-08 Linux +@@ -189,7 +189,7 @@ The default is: \fB\fR + .TP + .B path_selector + The default path selector algorithm to use; they are offered by the +-kernel multipath target. There are three selector algorithms: ++kernel multipath target: + .RS + .TP 12 + .I "round-robin 0" +@@ -206,7 +206,7 @@ of outstanding I/O to the path. + of outstanding I/O to the path and its relative throughput. + .TP + .I "historical-service-time 0" +-(Since 5.8 kernel) Choose the path for the next bunch of IOs based on the ++(Since 5.8 kernel) Choose the path for the next bunch of I/O based on the + estimation of future service time based on the history of previous I/O submitted + to each path. + .TP diff --git a/0004-multipath-tools-make-IBM-XIV-config-work-with-alua-a.patch b/0004-multipath-tools-make-IBM-XIV-config-work-with-alua-a.patch new file mode 100644 index 0000000..da06d58 --- /dev/null +++ b/0004-multipath-tools-make-IBM-XIV-config-work-with-alua-a.patch @@ -0,0 +1,39 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Xose Vazquez Perez +Date: Sat, 25 Sep 2021 00:27:36 +0200 +Subject: [PATCH] multipath-tools: make IBM/XIV config work with alua and + multibus + +And add recommended pgfailback value. + +ALUA is supported since XIV_Gen2 and microcode 10.2.1 +(All ports across all controllers in single Target Port Group) + +https://www.ibm.com/support/pages/ibm-flashsystem%C2%AE-a9000-and-a9000r-hyperswap-solution-deployment-linux%C2%AE-ibm-z-systems%C2%AE +https://www.google.com/search?q=%222810XIV%22+%22path_grouping_policy%22+site%3Aibm.com + +Cc: Martin Wilck +Cc: Benjamin Marzinski +Cc: Christophe Varoqui +Cc: DM-DEVEL ML +Signed-off-by: Xose Vazquez Perez +Reviewed-by: Martin Wilck +Signed-off-by: Benjamin Marzinski +--- + libmultipath/hwtable.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/libmultipath/hwtable.c b/libmultipath/hwtable.c +index 0caac0da..72f81c60 100644 +--- a/libmultipath/hwtable.c ++++ b/libmultipath/hwtable.c +@@ -712,7 +712,8 @@ static struct hwentry default_hw[] = { + .vendor = "(XIV|IBM)", + .product = "(NEXTRA|2810XIV)", + .no_path_retry = NO_PATH_RETRY_QUEUE, +- .pgpolicy = MULTIBUS, ++ .pgpolicy = GROUP_BY_PRIO, ++ .pgfailback = 15, + }, + { + /* TMS RamSan / FlashSystem 710/720/810/820/840/900 */ diff --git a/0005-RH-use-rpm-optflags-if-present.patch b/0005-RH-use-rpm-optflags-if-present.patch deleted file mode 100644 index 7a6f57f..0000000 --- a/0005-RH-use-rpm-optflags-if-present.patch +++ /dev/null @@ -1,67 +0,0 @@ -From bf46f8029998498045bb055415ba3ff515c79eaa Mon Sep 17 00:00:00 2001 -From: Benjamin Marzinski -Date: Wed, 19 Apr 2017 06:10:01 -0500 -Subject: [PATCH] RH: use rpm optflags if present - -Use the passed in optflags when compiling as an RPM, and keep the -default flags as close as possible to the current fedora flags, while -still being generic. - -Signed-off-by: Benjamin Marzinski ---- - Makefile.inc | 25 ++++++++++++++++++------- - 1 file changed, 18 insertions(+), 7 deletions(-) - -diff --git a/Makefile.inc b/Makefile.inc -index ead89030..03aee175 100644 ---- a/Makefile.inc -+++ b/Makefile.inc -@@ -102,17 +102,29 @@ SYSTEMD_LIBDEPS := $(if $(SYSTEMD),$(if $(shell test $(SYSTEMD) -gt 209 && echo - MODPROBE_UNIT := $(shell test "0$(SYSTEMD)" -lt 245 2>/dev/null || \ - echo "modprobe@dm_multipath.service") - --OPTFLAGS := -O2 -g $(STACKPROT) --param=ssp-buffer-size=4 -+ifndef RPM_OPT_FLAGS -+ OPTFLAGS := -O2 -g $(STACKPROT) --param=ssp-buffer-size=4 \ -+ -Wall $(FORTIFY_OPT) -fexceptions -grecord-gcc-switches \ -+ -fasynchronous-unwind-tables -+ ifeq ($(shell test -f /usr/lib/rpm/redhat/redhat-hardened-cc1 && echo 1),1) -+ OPTFLAGS += -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -+ endif -+ ifeq ($(shell test -f /usr/lib/rpm/redhat/redhat-annobin-cc1 && echo 1),1) -+ OPTFLAGS += -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -+ endif -+else -+ OPTFLAGS := $(RPM_OPT_FLAGS) --param=ssp-buffer-size=4 -+endif - - # Set WARN_ONLY=1 to avoid compilation erroring out due to warnings. Useful during development. - WARN_ONLY := - ERROR := $(if $(WARN_ONLY),,error=) - WERROR := $(if $(WARN_ONLY),,-Werror) --WARNFLAGS := $(WERROR) -Wall -Wextra -Wformat=2 $(WFORMATOVERFLOW) -W$(ERROR)implicit-int \ -+WARNFLAGS := $(WERROR) -Wextra -Wformat=2 $(WFORMATOVERFLOW) -W$(ERROR)implicit-int \ - -W$(ERROR)implicit-function-declaration -W$(ERROR)format-security \ -- $(WNOCLOBBERED) -W$(ERROR)cast-qual $(ERROR_DISCARDED_QUALIFIERS) $(W_URCU_TYPE_LIMITS) -+ $(WNOCLOBBERED) -W$(ERROR)cast-qual $(ERROR_DISCARDED_QUALIFIERS) $(W_URCU_TYPE_LIMITS) -Wstrict-prototypes - --CPPFLAGS := $(FORTIFY_OPT) $(CPPFLAGS) $(D_URCU_VERSION) \ -+CPPFLAGS := $(CPPFLAGS) $(D_URCU_VERSION) \ - -D_FILE_OFFSET_BITS=64 \ - -DBIN_DIR=\"$(bindir)\" -DMULTIPATH_DIR=\"$(TGTDIR)$(plugindir)\" \ - -DRUNTIME_DIR=\"$(runtimedir)\" -DCONFIG_DIR=\"$(TGTDIR)$(configdir)\" \ -@@ -121,12 +133,11 @@ CPPFLAGS := $(FORTIFY_OPT) $(CPPFLAGS) $(D_URCU_VERSION) \ - -DABSTRACT_SOCKET=\"$(abstract_socket)\" -DPATHNAME_SOCKET=\"$(pathname_socket)\" \ - -DWSTRINGOP_TRUNCATION=$(if $(WSTRINGOP_TRUNCATION),1,0) \ - -MMD -MP --CFLAGS := -std=$(C_STD) $(CFLAGS) $(OPTFLAGS) $(WARNFLAGS) -pipe \ -- -fexceptions -+CFLAGS := -std=$(C_STD) $(CFLAGS) $(OPTFLAGS) $(WARNFLAGS) -pipe - BIN_CFLAGS := -fPIE -DPIE - LIB_CFLAGS := -fPIC - SHARED_FLAGS := -shared --LDFLAGS := $(LDFLAGS) -Wl,-z,relro -Wl,-z,now -Wl,-z,defs -+LDFLAGS := $(LDFLAGS) $(RPM_LD_FLAGS) -Wl,-z,relro -Wl,-z,now -Wl,-z,defs - BIN_LDFLAGS := -pie - - # Source code directories. Don't modify. diff --git a/0005-multipathd.socket-add-missing-conditions-from-servic.patch b/0005-multipathd.socket-add-missing-conditions-from-servic.patch new file mode 100644 index 0000000..e6b34a2 --- /dev/null +++ b/0005-multipathd.socket-add-missing-conditions-from-servic.patch @@ -0,0 +1,32 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Luca BRUNO +Date: Fri, 24 Sep 2021 09:34:01 +0000 +Subject: [PATCH] multipathd.socket: add missing conditions from service unit + +This aligns 'multipathd' socket and service units, by adding the +start conditions that are set on the service but not on the socket. +It should help avoiding situations where the socket unit ends up +marked as failed after hitting its retry-limit. + +Fixes: https://github.com/opensvc/multipath-tools/issues/15 +Signed-off-by: Luca BRUNO +Reviewed-by: Martin Wilck +Signed-off-by: Benjamin Marzinski +--- + multipathd/multipathd.socket | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/multipathd/multipathd.socket b/multipathd/multipathd.socket +index 0ed4a1f7..c777e5e3 100644 +--- a/multipathd/multipathd.socket ++++ b/multipathd/multipathd.socket +@@ -1,6 +1,9 @@ + [Unit] + Description=multipathd control socket + DefaultDependencies=no ++ConditionKernelCommandLine=!nompath ++ConditionKernelCommandLine=!multipath=off ++ConditionVirtualization=!container + Before=sockets.target + + [Socket] diff --git a/0006-multipath-tools-make-IBM-2107900-DS8000-config-work-.patch b/0006-multipath-tools-make-IBM-2107900-DS8000-config-work-.patch new file mode 100644 index 0000000..97cc8ef --- /dev/null +++ b/0006-multipath-tools-make-IBM-2107900-DS8000-config-work-.patch @@ -0,0 +1,40 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Xose Vazquez Perez +Date: Tue, 28 Sep 2021 18:52:10 +0200 +Subject: [PATCH] multipath-tools: make IBM/2107900 (DS8000) config work with + alua and multibus + +ALUA is supported since the beginning: +https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/scsi/device_handler/scsi_dh_alua.c?id=057ea7c9683c3d684128cced796f03c179ecf1c2#n683 + +... the DS8000 is an Asymmetric Logical Unit Access (ALUA) capable storage array, +pag#160(144): https://www.redbooks.ibm.com/redbooks/pdfs/sg248887.pdf + +kernel log: +https://marc.info/?l=linux-scsi&m=156407413807511&q=mbox + +Cc: Martin Wilck +Cc: Benjamin Marzinski +Cc: Christophe Varoqui +Cc: DM-DEVEL ML +Signed-off-by: Xose Vazquez Perez +Reviewed-by: Martin Wilck +Signed-off-by: Benjamin Marzinski +--- + libmultipath/hwtable.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/libmultipath/hwtable.c b/libmultipath/hwtable.c +index 72f81c60..f115c4f9 100644 +--- a/libmultipath/hwtable.c ++++ b/libmultipath/hwtable.c +@@ -656,7 +656,8 @@ static struct hwentry default_hw[] = { + .vendor = "IBM", + .product = "^2107900", + .no_path_retry = NO_PATH_RETRY_QUEUE, +- .pgpolicy = MULTIBUS, ++ .pgpolicy = GROUP_BY_PRIO, ++ .pgfailback = -FAILBACK_IMMEDIATE, + }, + { + // Storwize V5000 and V7000 lines / SAN Volume Controller (SVC) / Flex System V7000 / diff --git a/0007-multipath-tools-make-EMC-SYMMETRIX-config-work-with-.patch b/0007-multipath-tools-make-EMC-SYMMETRIX-config-work-with-.patch new file mode 100644 index 0000000..201232a --- /dev/null +++ b/0007-multipath-tools-make-EMC-SYMMETRIX-config-work-with-.patch @@ -0,0 +1,35 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Xose Vazquez Perez +Date: Tue, 28 Sep 2021 19:20:59 +0200 +Subject: [PATCH] multipath-tools: make EMC/SYMMETRIX config work with alua and + multibus + +ALUA is supported since VMAX3 and HYPERMAX OS 5977.811.784, pag#113: +https://www.delltechnologies.com/en-us/collaterals/unauth/technical-guides-support-information/products/storage-2/docu5128.pdf + +Cc: Martin Wilck +Cc: Benjamin Marzinski +Cc: Christophe Varoqui +Cc: DM-DEVEL ML +Signed-off-by: Xose Vazquez Perez +Reviewed-by: Martin Wilck +Signed-off-by: Benjamin Marzinski +--- + libmultipath/hwtable.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/libmultipath/hwtable.c b/libmultipath/hwtable.c +index f115c4f9..7095aaf1 100644 +--- a/libmultipath/hwtable.c ++++ b/libmultipath/hwtable.c +@@ -329,8 +329,9 @@ static struct hwentry default_hw[] = { + /* Symmetrix / DMX / VMAX / PowerMax */ + .vendor = "EMC", + .product = "SYMMETRIX", +- .pgpolicy = MULTIBUS, ++ .pgpolicy = GROUP_BY_PRIO, + .no_path_retry = 6, ++ .pgfailback = -FAILBACK_IMMEDIATE, + }, + { + /* DGC CLARiiON CX/AX / VNX and Unity */ diff --git a/0008-multipath-tools-make-EMC-Invista-config-work-with-al.patch b/0008-multipath-tools-make-EMC-Invista-config-work-with-al.patch new file mode 100644 index 0000000..723f023 --- /dev/null +++ b/0008-multipath-tools-make-EMC-Invista-config-work-with-al.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Xose Vazquez Perez +Date: Tue, 28 Sep 2021 19:31:21 +0200 +Subject: [PATCH] multipath-tools: make EMC/Invista config work with alua and + multibus + +Optimal Path Management (OPM) was introduced with VPLEX 5.5 to improve VPLEX +performance. OPM uses the ALUA mechanism to spread the I/O load across VPLEX directors +while gaining cache locality, pag #187: +https://www.delltechnologies.com/en-us/collaterals/unauth/technical-guides-support-information/products/storage-2/docu5128.pdf + +Cc: Martin Wilck +Cc: Benjamin Marzinski +Cc: Christophe Varoqui +Cc: DM-DEVEL ML +Signed-off-by: Xose Vazquez Perez +Reviewed-by: Martin Wilck +Signed-off-by: Benjamin Marzinski +--- + libmultipath/hwtable.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/libmultipath/hwtable.c b/libmultipath/hwtable.c +index 7095aaf1..4e8b52ff 100644 +--- a/libmultipath/hwtable.c ++++ b/libmultipath/hwtable.c +@@ -350,8 +350,9 @@ static struct hwentry default_hw[] = { + .vendor = "EMC", + .product = "Invista", + .bl_product = "LUNZ", +- .pgpolicy = MULTIBUS, ++ .pgpolicy = GROUP_BY_PRIO, + .no_path_retry = 5, ++ .pgfailback = -FAILBACK_IMMEDIATE, + }, + { + /* XtremIO */ diff --git a/0009-multipath-tools-make-COMPELNT-Compellent-Vol-config-.patch b/0009-multipath-tools-make-COMPELNT-Compellent-Vol-config-.patch new file mode 100644 index 0000000..e2a93ee --- /dev/null +++ b/0009-multipath-tools-make-COMPELNT-Compellent-Vol-config-.patch @@ -0,0 +1,35 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Xose Vazquez Perez +Date: Tue, 28 Sep 2021 22:15:56 +0200 +Subject: [PATCH] multipath-tools: make "COMPELNT/Compellent Vol" config work + with alua and multibus + +ALUA is needed by SAS arrays, pag#124: +https://downloads.dell.com/manuals/all-products/esuprt_solutions_int/esuprt_solutions_int_solutions_resources/general-solution-resources_white-papers2_en-us.pdf + +Cc: Sean McGinnis +Cc: Martin Wilck +Cc: Benjamin Marzinski +Cc: Christophe Varoqui +Cc: DM-DEVEL ML +Signed-off-by: Xose Vazquez Perez +Reviewed-by: Martin Wilck +Signed-off-by: Benjamin Marzinski +--- + libmultipath/hwtable.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/libmultipath/hwtable.c b/libmultipath/hwtable.c +index 4e8b52ff..7fc5bc04 100644 +--- a/libmultipath/hwtable.c ++++ b/libmultipath/hwtable.c +@@ -368,7 +368,8 @@ static struct hwentry default_hw[] = { + */ + .vendor = "COMPELNT", + .product = "Compellent Vol", +- .pgpolicy = MULTIBUS, ++ .pgpolicy = GROUP_BY_PRIO, ++ .pgfailback = -FAILBACK_IMMEDIATE, + .no_path_retry = NO_PATH_RETRY_QUEUE, + }, + { diff --git a/0010-multipath-tools-remove-Compellent-maintainer.patch b/0010-multipath-tools-remove-Compellent-maintainer.patch new file mode 100644 index 0000000..f8e9cc0 --- /dev/null +++ b/0010-multipath-tools-remove-Compellent-maintainer.patch @@ -0,0 +1,35 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Xose Vazquez Perez +Date: Tue, 28 Sep 2021 22:39:17 +0200 +Subject: [PATCH] multipath-tools: remove Compellent maintainer + +e-mail was bounced: 550 5.1.1 User Unknown + +Cc: Martin Wilck +Cc: Benjamin Marzinski +Cc: Christophe Varoqui +Cc: DM-DEVEL ML +Signed-off-by: Xose Vazquez Perez +Reviewed-by: Martin Wilck +Signed-off-by: Benjamin Marzinski +--- + libmultipath/hwtable.c | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +diff --git a/libmultipath/hwtable.c b/libmultipath/hwtable.c +index 7fc5bc04..763982cd 100644 +--- a/libmultipath/hwtable.c ++++ b/libmultipath/hwtable.c +@@ -361,11 +361,7 @@ static struct hwentry default_hw[] = { + .pgpolicy = MULTIBUS, + }, + { +- /* +- * SC Series, formerly Compellent +- * +- * Maintainer: Sean McGinnis +- */ ++ /* SC Series, formerly Compellent */ + .vendor = "COMPELNT", + .product = "Compellent Vol", + .pgpolicy = GROUP_BY_PRIO, diff --git a/0011-RH-add-scsi-device-handlers-to-modules-load.d.patch b/0011-RH-add-scsi-device-handlers-to-modules-load.d.patch deleted file mode 100644 index 3fe7c25..0000000 --- a/0011-RH-add-scsi-device-handlers-to-modules-load.d.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 374755791536be4870ab2e93ae36549cbaaeb800 Mon Sep 17 00:00:00 2001 -From: Benjamin Marzinski -Date: Fri, 25 Mar 2022 18:12:06 -0500 -Subject: [PATCH] RH: add scsi device handlers to modules-load.d - -Make scsi_dh_alua scsi_dh_emc and scsi_dh_rdac get loaded in early boot. - -Signed-off-by: Benjamin Marzinski ---- - Makefile.inc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Makefile.inc b/Makefile.inc -index 03aee175..936a622f 100644 ---- a/Makefile.inc -+++ b/Makefile.inc -@@ -16,7 +16,7 @@ READLINE := - - # List of scsi device handler modules to load on boot, e.g. - # SCSI_DH_MODULES_PRELOAD := scsi_dh_alua scsi_dh_rdac --SCSI_DH_MODULES_PRELOAD := -+SCSI_DH_MODULES_PRELOAD := scsi_dh_alua scsi_dh_emc scsi_dh_rdac - - EXTRAVERSION := $(shell rev=$$(git rev-parse --short=7 HEAD 2>/dev/null); echo $${rev:+-g$$rev}) - diff --git a/0011-Revert-multipath-tools-make-EMC-Invista-config-work-.patch b/0011-Revert-multipath-tools-make-EMC-Invista-config-work-.patch new file mode 100644 index 0000000..1912f80 --- /dev/null +++ b/0011-Revert-multipath-tools-make-EMC-Invista-config-work-.patch @@ -0,0 +1,35 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martin Wilck +Date: Wed, 20 Oct 2021 20:44:54 +0200 +Subject: [PATCH] Revert "multipath-tools: make EMC/Invista config work with + alua and multibus" + +This reverts commit 309ff281aaa07e862540d3d645a8263f3e9baaed. + +Mail from , 20210930: + +"OPM is no longer supported in the Dell VPLEX product. If we at Dell had +wished to change the default device stanzas for any of our products they +would have been done when the product and/or feature is released. +Please remove this patch as well. It is not needed." + +Signed-off-by: Benjamin Marzinski +--- + libmultipath/hwtable.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/libmultipath/hwtable.c b/libmultipath/hwtable.c +index 763982cd..211087ad 100644 +--- a/libmultipath/hwtable.c ++++ b/libmultipath/hwtable.c +@@ -350,9 +350,8 @@ static struct hwentry default_hw[] = { + .vendor = "EMC", + .product = "Invista", + .bl_product = "LUNZ", +- .pgpolicy = GROUP_BY_PRIO, ++ .pgpolicy = MULTIBUS, + .no_path_retry = 5, +- .pgfailback = -FAILBACK_IMMEDIATE, + }, + { + /* XtremIO */ diff --git a/0012-RH-compile-with-libreadline-support.patch b/0012-RH-compile-with-libreadline-support.patch deleted file mode 100644 index 0964c42..0000000 --- a/0012-RH-compile-with-libreadline-support.patch +++ /dev/null @@ -1,26 +0,0 @@ -From cc15379130e8aa068e97c64afd46be212b456d4f Mon Sep 17 00:00:00 2001 -From: Benjamin Marzinski -Date: Tue, 15 Nov 2022 18:03:33 -0600 -Subject: [PATCH] RH: compile with libreadline support - -Since the license issue has been resolved, and there are problems with -the command completion with libedit, use libreadline. - -Signed-off-by: Benjamin Marzinski ---- - Makefile.inc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Makefile.inc b/Makefile.inc -index 936a622f..f475f70f 100644 ---- a/Makefile.inc -+++ b/Makefile.inc -@@ -12,7 +12,7 @@ - # Readline library to use, libedit, libreadline, or empty - # Caution: Using libreadline may make the multipathd binary undistributable, - # see https://github.com/opensvc/multipath-tools/issues/36 --READLINE := -+READLINE := libreadline - - # List of scsi device handler modules to load on boot, e.g. - # SCSI_DH_MODULES_PRELOAD := scsi_dh_alua scsi_dh_rdac diff --git a/0012-Revert-multipath-tools-make-EMC-SYMMETRIX-config-wor.patch b/0012-Revert-multipath-tools-make-EMC-SYMMETRIX-config-wor.patch new file mode 100644 index 0000000..b889ea8 --- /dev/null +++ b/0012-Revert-multipath-tools-make-EMC-SYMMETRIX-config-wor.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martin Wilck +Date: Wed, 20 Oct 2021 20:46:09 +0200 +Subject: [PATCH] Revert "multipath-tools: make EMC/SYMMETRIX config work with + alua and multibus" + +This reverts commit 831af0dbfa171cd39d968ba6174669f11a278be9. + +Mail from "berthiaume, wayne" , 210930: + +"As a representative of Dell I request this patch be withdrawn. If we had +wanted the default stanza changed we would have already implemented it. +Also for your information we only advertise the entire enterprise storage +product line (DMX, VMAX, VMAX AFA, PowerMax) as SYMMETRIX in the VPD page. +The ALUA capability is only used for mobility devices in an SRDF/Metro +configuration and the current device stanza still works well in all of our +testing." + +Signed-off-by: Benjamin Marzinski +--- + libmultipath/hwtable.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/libmultipath/hwtable.c b/libmultipath/hwtable.c +index 211087ad..a8ba28e3 100644 +--- a/libmultipath/hwtable.c ++++ b/libmultipath/hwtable.c +@@ -329,9 +329,8 @@ static struct hwentry default_hw[] = { + /* Symmetrix / DMX / VMAX / PowerMax */ + .vendor = "EMC", + .product = "SYMMETRIX", +- .pgpolicy = GROUP_BY_PRIO, ++ .pgpolicy = MULTIBUS, + .no_path_retry = 6, +- .pgfailback = -FAILBACK_IMMEDIATE, + }, + { + /* DGC CLARiiON CX/AX / VNX and Unity */ diff --git a/0013-RH-Add-mpathcleanup.patch b/0013-RH-Add-mpathcleanup.patch deleted file mode 100644 index d1a8e84..0000000 --- a/0013-RH-Add-mpathcleanup.patch +++ /dev/null @@ -1,186 +0,0 @@ -From 2ef5bd86052ba0b22f4d3a16e69cdf268d90a53a Mon Sep 17 00:00:00 2001 -From: Benjamin Marzinski -Date: Fri, 7 Jul 2023 15:25:59 -0500 -Subject: [PATCH] RH: Add mpathcleanup - -mpathcleanup is a program that will remove a multipath device as well as -all of the scsi path devices that make it up. - -Signed-off-by: Benjamin Marzinski ---- - multipath/Makefile | 2 + - multipath/mpathcleanup | 145 +++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 147 insertions(+) - create mode 100755 multipath/mpathcleanup - -diff --git a/multipath/Makefile b/multipath/Makefile -index 3dc241cc..47e82234 100644 ---- a/multipath/Makefile -+++ b/multipath/Makefile -@@ -25,6 +25,7 @@ install: - $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir) - $(Q)$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)/ - $(Q)$(INSTALL_PROGRAM) -m 755 mpathconf $(DESTDIR)$(bindir)/ -+ $(Q)$(INSTALL_PROGRAM) -m 755 mpathcleanup $(DESTDIR)$(bindir)/ - $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(udevrulesdir) - $(Q)$(INSTALL_PROGRAM) -m 644 11-dm-mpath.rules $(DESTDIR)$(udevrulesdir) - $(Q)$(INSTALL_PROGRAM) -m 644 99-z-dm-mpath-late.rules $(DESTDIR)$(udevrulesdir) -@@ -49,6 +50,7 @@ endif - uninstall: - $(Q)$(RM) $(DESTDIR)$(bindir)/$(EXEC) - $(Q)$(RM) $(DESTDIR)$(bindir)/mpathconf -+ $(Q)$(RM) $(DESTDIR)$(bindir)/mpathcleanup - $(Q)$(RM) $(DESTDIR)$(udevrulesdir)/11-dm-mpath.rules - $(Q)$(RM) $(DESTDIR)$(udevrulesdir)/99-z-dm-mpath-late.rules - $(Q)$(RM) $(DESTDIR)$(modulesloaddir)/multipath.conf -diff --git a/multipath/mpathcleanup b/multipath/mpathcleanup -new file mode 100755 -index 00000000..6fd921e4 ---- /dev/null -+++ b/multipath/mpathcleanup -@@ -0,0 +1,145 @@ -+#!/bin/bash -+# -+# Copyright (C) 2023 Red Hat, Inc. All rights reserved. -+# -+# This file is part of the device-mapper-multipath package. -+# -+# This copyrighted material is made available to anyone wishing to use, -+# modify, copy, or redistribute it subject to the terms and conditions -+# of the GNU General Public License v.2. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program; if not, write to the Free Software Foundation, -+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ -+unset PROGRAM FLUSH DEVICE DEVNAME MAJOR MINOR PATHDEVS PATHDEV HAVE_MULTIPATHD QUEUEING -+ -+function usage -+{ -+ echo "usage: $PROGRAM [-h] [--flush] " -+ echo "" -+ echo "remove a multipath device and its scsi path devices" -+ echo "" -+ echo "options:" -+ echo " -h, --help show this help message and exit" -+ echo " --flush disable queuing on the multipath device and" -+ echo " flush the path devices before removing" -+} -+ -+function parse_args -+{ -+ while [ -n "$1" ]; do -+ case $1 in -+ --flush) -+ FLUSH=1 -+ shift -+ ;; -+ --help | -h) -+ usage -+ exit 1 -+ ;; -+ *) -+ if [ -n "$DEVICE" ]; then -+ usage -+ exit 1 -+ fi -+ DEVICE=$1 -+ shift -+ ;; -+ esac -+ done -+} -+ -+function validate_device -+{ -+ if [ -z "$DEVICE" ]; then -+ usage -+ exit 1 -+ fi -+ if [[ "$DEVICE" =~ ^[[:digit:]]+:[[:digit:]]+$ ]]; then -+ MAJOR=${DEVICE%%:*} -+ MINOR=${DEVICE##*:} -+ DEVNAME=`dmsetup ls --target multipath | grep "($MAJOR, $MINOR)$" | awk '{print $1}'` -+ else -+ DEVNAME=`dmsetup ls --target multipath | awk '{print $1}' | grep "^$DEVICE$"` -+ fi -+ if [ -z "$DEVNAME" ]; then -+ DEVNAME=`multipath -v 1 -l $DEVICE 2>/dev/null` -+ if [ -z "$DEVNAME" ]; then -+ echo "$DEVICE is not a multipath device" -+ exit 1 -+ fi -+ # verify that this is not a native nvme multipath device -+ dmsetup ls --target multipath | awk '{print $1}' | grep -q "^$DEVNAME$" -+ if test $? -eq 1; then -+ echo "$DEVICE is not a device-mapper multipath device" -+ exit 1 -+ fi -+ fi -+ if [ -z "$MINOR" ]; then -+ MINOR=`dmsetup info -c --noheadings -o minor $DEVNAME` -+ fi -+} -+ -+function get_paths -+{ -+ PATHDEVS=`ls /sys/block/dm-$MINOR/slaves` -+ for PATHDEV in $PATHDEVS; do -+ if [[ ! "$PATHDEV" =~ ^sd[a-z]+$ ]]; then -+ echo "$PATHDEV is not a scsi device. $PROGRAM only works with scsi devices" -+ exit 1 -+ fi -+ done -+} -+ -+function remove_devs -+{ -+ pidof multipathd > /dev/null -+ HAVE_MULTIPATHD=$? -+ multipath -v2 -l "$DEVNAME" | grep features | grep -q queue_if_no_path -+ QUEUEING=$? -+ if [ -n "$FLUSH" ] && [ "$QUEUEING" -eq 0 ]; then -+ if test $HAVE_MULTIPATHD -eq 0; then -+ multipathd disablequeueing map "$DEVNAME" > /dev/null -+ else -+ dmsetup message "$DEVNAME" 0 fail_if_no_path -+ fi -+ sleep 1 -+ fi -+ if test $HAVE_MULTIPATHD -eq 0; then -+ multipath -f "$DEVNAME" -+ else -+ multipathd -Df "$DEVNAME" -+ fi -+ if test $? -eq 1; then -+ echo "$DEVICE cannot be removed" -+ exit 1 -+ fi -+ for PATHDEV in $PATHDEVS; do -+ if [ -n "$FLUSH" ]; then -+ blockdev --flushbufs /dev/"$PATHDEV" -+ fi -+ echo 1 > /sys/block/"$PATHDEV"/device/delete -+ done -+} -+ -+function verify_removal -+{ -+ multipath -v 1 -d $DEVNAME | grep -q "^$DEVNAME$" -+ if test $? -eq 0; then -+ echo "$DEVICE removed but path devices still exist" -+ exit 1 -+ fi -+ multipath -v 1 -l $DEVNAME | grep -q "^$DEVNAME$" -+ if test $? -eq 0; then -+ echo "$DEVICE removal succeeded, but device still exists" -+ exit 1 -+ fi -+} -+ -+PROGRAM="$0" -+parse_args "$@" -+validate_device -+get_paths -+remove_devs -+verify_removal diff --git a/0013-multipath-fix-exit-status-of-multipath-T.patch b/0013-multipath-fix-exit-status-of-multipath-T.patch new file mode 100644 index 0000000..783e95e --- /dev/null +++ b/0013-multipath-fix-exit-status-of-multipath-T.patch @@ -0,0 +1,26 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martin Wilck +Date: Fri, 22 Oct 2021 12:58:11 +0200 +Subject: [PATCH] multipath: fix exit status of multipath -T + +We must set the return value in configure(). + +Signed-off-by: Martin Wilck +Reviewed-by: Benjamin Marzinski +Signed-off-by: Benjamin Marzinski +--- + multipath/main.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/multipath/main.c b/multipath/main.c +index 65ece830..b2d300e5 100644 +--- a/multipath/main.c ++++ b/multipath/main.c +@@ -560,6 +560,7 @@ configure (struct config *conf, enum mpath_cmds cmd, + + dump_config(conf, hwes, curmp); + vector_free(hwes); ++ r = RTVL_OK; + goto out; + } + diff --git a/0014-libmultipath-add-section-name-to-invalid-keyword-out.patch b/0014-libmultipath-add-section-name-to-invalid-keyword-out.patch new file mode 100644 index 0000000..f4fce9f --- /dev/null +++ b/0014-libmultipath-add-section-name-to-invalid-keyword-out.patch @@ -0,0 +1,70 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Thu, 11 Nov 2021 12:53:44 -0600 +Subject: [PATCH] libmultipath: add section name to invalid keyword output + +If users forget the closing brace for a section in multipath.conf, +multipath has no way to detect that. When it sees the keyword at the +start of the next section, it will complain that there is an invalid +keyword, because that keyword doesn't belong in previous section (which +was never ended with a closing brace). This can confuse users. To make +this easier to understand, when multipath prints an invalid keyword +message, it now also prints the current section name, which can give +users a hint that they didn't end the previous section. + +Signed-off-by: Benjamin Marzinski +Reviewed-by: Martin Wilck +--- + libmultipath/parser.c | 20 +++++++++++++------- + 1 file changed, 13 insertions(+), 7 deletions(-) + +diff --git a/libmultipath/parser.c b/libmultipath/parser.c +index 8ca91bf2..611054f7 100644 +--- a/libmultipath/parser.c ++++ b/libmultipath/parser.c +@@ -504,7 +504,7 @@ validate_config_strvec(vector strvec, const char *file) + + static int + process_stream(struct config *conf, FILE *stream, vector keywords, +- const char *file) ++ const char *section, const char *file) + { + int i; + int r = 0, t; +@@ -568,16 +568,22 @@ process_stream(struct config *conf, FILE *stream, vector keywords, + if (keyword->sub) { + kw_level++; + r += process_stream(conf, stream, +- keyword->sub, file); ++ keyword->sub, ++ keyword->string, ++ file); + kw_level--; + } + break; + } + } +- if (i >= VECTOR_SIZE(keywords)) +- condlog(1, "%s line %d, invalid keyword: %s", +- file, line_nr, str); +- ++ if (i >= VECTOR_SIZE(keywords)) { ++ if (section) ++ condlog(1, "%s line %d, invalid keyword in the %s section: %s", ++ file, line_nr, section, str); ++ else ++ condlog(1, "%s line %d, invalid keyword: %s", ++ file, line_nr, str); ++ } + free_strvec(strvec); + } + if (kw_level == 1) +@@ -608,7 +614,7 @@ process_file(struct config *conf, const char *file) + + /* Stream handling */ + line_nr = 0; +- r = process_stream(conf, stream, conf->keywords, file); ++ r = process_stream(conf, stream, conf->keywords, NULL, file); + fclose(stream); + //free_keywords(keywords); + diff --git a/0015-libmultipath-use-typedef-for-keyword-handler-functio.patch b/0015-libmultipath-use-typedef-for-keyword-handler-functio.patch new file mode 100644 index 0000000..c3a41d2 --- /dev/null +++ b/0015-libmultipath-use-typedef-for-keyword-handler-functio.patch @@ -0,0 +1,85 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Thu, 11 Nov 2021 12:53:45 -0600 +Subject: [PATCH] libmultipath: use typedef for keyword handler function + +Don't keep writing out the function type. + +Signed-off-by: Benjamin Marzinski +Reviewed-by: Martin Wilck +--- + libmultipath/parser.c | 6 +++--- + libmultipath/parser.h | 15 ++++++--------- + 2 files changed, 9 insertions(+), 12 deletions(-) + +diff --git a/libmultipath/parser.c b/libmultipath/parser.c +index 611054f7..ebe1cbd9 100644 +--- a/libmultipath/parser.c ++++ b/libmultipath/parser.c +@@ -33,7 +33,7 @@ static int line_nr; + + int + keyword_alloc(vector keywords, char *string, +- int (*handler) (struct config *, vector), ++ handler_fn *handler, + print_fn *print, + int unique) + { +@@ -72,7 +72,7 @@ install_sublevel_end(void) + + int + _install_keyword(vector keywords, char *string, +- int (*handler) (struct config *, vector), ++ handler_fn *handler, + print_fn *print, + int unique) + { +@@ -558,7 +558,7 @@ process_stream(struct config *conf, FILE *stream, vector keywords, + goto out; + } + if (keyword->handler) { +- t = (*keyword->handler) (conf, strvec); ++ t = keyword->handler(conf, strvec); + r += t; + if (t) + condlog(1, "multipath.conf +%d, parsing failed: %s", +diff --git a/libmultipath/parser.h b/libmultipath/parser.h +index b43d46f8..3452bde1 100644 +--- a/libmultipath/parser.h ++++ b/libmultipath/parser.h +@@ -43,10 +43,11 @@ struct strbuf; + + /* keyword definition */ + typedef int print_fn(struct config *, struct strbuf *, const void *); ++typedef int handler_fn(struct config *, vector); + + struct keyword { + char *string; +- int (*handler) (struct config *, vector); ++ handler_fn *handler; + print_fn *print; + vector sub; + int unique; +@@ -62,18 +63,14 @@ struct keyword { + for (i = 0; i < (k)->sub->allocated && ((p) = (k)->sub->slot[i]); i++) + + /* Prototypes */ +-extern int keyword_alloc(vector keywords, char *string, +- int (*handler) (struct config *, vector), +- print_fn *print, +- int unique); ++extern int keyword_alloc(vector keywords, char *string, handler_fn *handler, ++ print_fn *print, int unique); + #define install_keyword_root(str, h) keyword_alloc(keywords, str, h, NULL, 1) + extern void install_sublevel(void); + extern void install_sublevel_end(void); + +-extern int _install_keyword(vector keywords, char *string, +- int (*handler) (struct config *, vector), +- print_fn *print, +- int unique); ++extern int _install_keyword(vector keywords, char *string, handler_fn *handler, ++ print_fn *print, int unique); + #define install_keyword(str, vec, pri) _install_keyword(keywords, str, vec, pri, 1) + #define install_keyword_multi(str, vec, pri) _install_keyword(keywords, str, vec, pri, 0) + extern void dump_keywords(vector keydump, int level); diff --git a/0016-libmultipath-print-the-correct-file-when-parsing-fai.patch b/0016-libmultipath-print-the-correct-file-when-parsing-fai.patch new file mode 100644 index 0000000..5d9f2f4 --- /dev/null +++ b/0016-libmultipath-print-the-correct-file-when-parsing-fai.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Thu, 11 Nov 2021 12:53:46 -0600 +Subject: [PATCH] libmultipath: print the correct file when parsing fails + +Don't assume that parsing failed on multipath.conf + +Signed-off-by: Benjamin Marzinski +Reviewed-by: Martin Wilck +--- + libmultipath/parser.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/libmultipath/parser.c b/libmultipath/parser.c +index ebe1cbd9..d5595fb0 100644 +--- a/libmultipath/parser.c ++++ b/libmultipath/parser.c +@@ -561,8 +561,8 @@ process_stream(struct config *conf, FILE *stream, vector keywords, + t = keyword->handler(conf, strvec); + r += t; + if (t) +- condlog(1, "multipath.conf +%d, parsing failed: %s", +- line_nr, buf); ++ condlog(1, "%s line %d, parsing failed: %s", ++ file, line_nr, buf); + } + + if (keyword->sub) { diff --git a/0017-libmultipath-pass-file-and-line-number-to-keyword-ha.patch b/0017-libmultipath-pass-file-and-line-number-to-keyword-ha.patch new file mode 100644 index 0000000..50f9184 --- /dev/null +++ b/0017-libmultipath-pass-file-and-line-number-to-keyword-ha.patch @@ -0,0 +1,528 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Thu, 11 Nov 2021 12:53:47 -0600 +Subject: [PATCH] libmultipath: pass file and line number to keyword handlers + +This will make it possible for the keyword handlers to print more useful +warning messages. It will be used by future patches. + +Signed-off-by: Benjamin Marzinski +Reviewed-by: Martin Wilck +--- + libmultipath/dict.c | 143 +++++++++++++++++++++++++----------------- + libmultipath/parser.c | 3 +- + libmultipath/parser.h | 2 +- + 3 files changed, 90 insertions(+), 58 deletions(-) + +diff --git a/libmultipath/dict.c b/libmultipath/dict.c +index 7a727389..eb2c44c0 100644 +--- a/libmultipath/dict.c ++++ b/libmultipath/dict.c +@@ -29,7 +29,7 @@ + #include "strbuf.h" + + static int +-set_int(vector strvec, void *ptr) ++set_int(vector strvec, void *ptr, const char *file, int line_nr) + { + int *int_ptr = (int *)ptr; + char *buff, *eptr; +@@ -58,7 +58,7 @@ set_int(vector strvec, void *ptr) + } + + static int +-set_uint(vector strvec, void *ptr) ++set_uint(vector strvec, void *ptr, const char *file, int line_nr) + { + unsigned int *uint_ptr = (unsigned int *)ptr; + char *buff, *eptr, *p; +@@ -90,7 +90,7 @@ set_uint(vector strvec, void *ptr) + } + + static int +-set_str(vector strvec, void *ptr) ++set_str(vector strvec, void *ptr, const char *file, int line_nr) + { + char **str_ptr = (char **)ptr; + +@@ -105,7 +105,7 @@ set_str(vector strvec, void *ptr) + } + + static int +-set_yes_no(vector strvec, void *ptr) ++set_yes_no(vector strvec, void *ptr, const char *file, int line_nr) + { + char * buff; + int *int_ptr = (int *)ptr; +@@ -124,7 +124,7 @@ set_yes_no(vector strvec, void *ptr) + } + + static int +-set_yes_no_undef(vector strvec, void *ptr) ++set_yes_no_undef(vector strvec, void *ptr, const char *file, int line_nr) + { + char * buff; + int *int_ptr = (int *)ptr; +@@ -187,9 +187,10 @@ static int print_yes_no_undef(struct strbuf *buff, long v) + + #define declare_def_handler(option, function) \ + static int \ +-def_ ## option ## _handler (struct config *conf, vector strvec) \ ++def_ ## option ## _handler (struct config *conf, vector strvec, \ ++ const char *file, int line_nr) \ + { \ +- return function (strvec, &conf->option); \ ++ return function (strvec, &conf->option, file, line_nr); \ + } + + #define declare_def_snprint(option, function) \ +@@ -224,12 +225,13 @@ snprint_def_ ## option (struct config *conf, struct strbuf *buff, \ + + #define declare_hw_handler(option, function) \ + static int \ +-hw_ ## option ## _handler (struct config *conf, vector strvec) \ ++hw_ ## option ## _handler (struct config *conf, vector strvec, \ ++ const char *file, int line_nr) \ + { \ + struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable); \ + if (!hwe) \ + return 1; \ +- return function (strvec, &hwe->option); \ ++ return function (strvec, &hwe->option, file, line_nr); \ + } + + #define declare_hw_snprint(option, function) \ +@@ -243,11 +245,12 @@ snprint_hw_ ## option (struct config *conf, struct strbuf *buff, \ + + #define declare_ovr_handler(option, function) \ + static int \ +-ovr_ ## option ## _handler (struct config *conf, vector strvec) \ ++ovr_ ## option ## _handler (struct config *conf, vector strvec, \ ++ const char *file, int line_nr) \ + { \ + if (!conf->overrides) \ + return 1; \ +- return function (strvec, &conf->overrides->option); \ ++ return function (strvec, &conf->overrides->option, file, line_nr); \ + } + + #define declare_ovr_snprint(option, function) \ +@@ -260,12 +263,13 @@ snprint_ovr_ ## option (struct config *conf, struct strbuf *buff, \ + + #define declare_mp_handler(option, function) \ + static int \ +-mp_ ## option ## _handler (struct config *conf, vector strvec) \ ++mp_ ## option ## _handler (struct config *conf, vector strvec, \ ++ const char *file, int line_nr) \ + { \ + struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable); \ + if (!mpe) \ + return 1; \ +- return function (strvec, &mpe->option); \ ++ return function (strvec, &mpe->option, file, line_nr); \ + } + + #define declare_mp_snprint(option, function) \ +@@ -277,9 +281,10 @@ snprint_mp_ ## option (struct config *conf, struct strbuf *buff, \ + return function(buff, mpe->option); \ + } + +-static int checkint_handler(struct config *conf, vector strvec) ++static int checkint_handler(struct config *conf, vector strvec, ++ const char *file, int line_nr) + { +- int rc = set_uint(strvec, &conf->checkint); ++ int rc = set_uint(strvec, &conf->checkint, file, line_nr); + + if (rc) + return rc; +@@ -302,9 +307,10 @@ declare_def_snprint(reassign_maps, print_yes_no) + declare_def_handler(multipath_dir, set_str) + declare_def_snprint(multipath_dir, print_str) + +-static int def_partition_delim_handler(struct config *conf, vector strvec) ++static int def_partition_delim_handler(struct config *conf, vector strvec, ++ const char *file, int line_nr) + { +- int rc = set_str(strvec, &conf->partition_delim); ++ int rc = set_str(strvec, &conf->partition_delim, file, line_nr); + + if (rc != 0) + return rc; +@@ -334,13 +340,13 @@ static const char * const find_multipaths_optvals[] = { + }; + + static int +-def_find_multipaths_handler(struct config *conf, vector strvec) ++def_find_multipaths_handler(struct config *conf, vector strvec, ++ const char *file, int line_nr) + { + char *buff; + int i; + +- if (set_yes_no_undef(strvec, &conf->find_multipaths) == 0 && +- conf->find_multipaths != FIND_MULTIPATHS_UNDEF) ++ if (set_yes_no_undef(strvec, &conf->find_multipaths, file, line_nr) == 0 && conf->find_multipaths != FIND_MULTIPATHS_UNDEF) + return 0; + + buff = set_value(strvec); +@@ -396,7 +402,8 @@ static int snprint_uid_attrs(struct config *conf, struct strbuf *buff, + return total; + } + +-static int uid_attrs_handler(struct config *conf, vector strvec) ++static int uid_attrs_handler(struct config *conf, vector strvec, ++ const char *file, int line_nr) + { + char *val; + +@@ -597,7 +604,8 @@ declare_hw_handler(skip_kpartx, set_yes_no_undef) + declare_hw_snprint(skip_kpartx, print_yes_no_undef) + declare_mp_handler(skip_kpartx, set_yes_no_undef) + declare_mp_snprint(skip_kpartx, print_yes_no_undef) +-static int def_disable_changed_wwids_handler(struct config *conf, vector strvec) ++static int def_disable_changed_wwids_handler(struct config *conf, vector strvec, ++ const char *file, int line_nr) + { + return 0; + } +@@ -629,20 +637,23 @@ declare_def_snprint_defstr(enable_foreign, print_str, + DEFAULT_ENABLE_FOREIGN) + + static int +-def_config_dir_handler(struct config *conf, vector strvec) ++def_config_dir_handler(struct config *conf, vector strvec, const char *file, ++ int line_nr) + { + /* this is only valid in the main config file */ + if (conf->processed_main_config) + return 0; +- return set_str(strvec, &conf->config_dir); ++ return set_str(strvec, &conf->config_dir, file, line_nr); + } + declare_def_snprint(config_dir, print_str) + + #define declare_def_attr_handler(option, function) \ + static int \ +-def_ ## option ## _handler (struct config *conf, vector strvec) \ ++def_ ## option ## _handler (struct config *conf, vector strvec, \ ++ const char *file, int line_nr) \ + { \ +- return function (strvec, &conf->option, &conf->attribute_flags);\ ++ return function (strvec, &conf->option, &conf->attribute_flags, \ ++ file, line_nr); \ + } + + #define declare_def_attr_snprint(option, function) \ +@@ -655,12 +666,14 @@ snprint_def_ ## option (struct config *conf, struct strbuf *buff, \ + + #define declare_mp_attr_handler(option, function) \ + static int \ +-mp_ ## option ## _handler (struct config *conf, vector strvec) \ ++mp_ ## option ## _handler (struct config *conf, vector strvec, \ ++ const char *file, int line_nr) \ + { \ + struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable); \ + if (!mpe) \ + return 1; \ +- return function (strvec, &mpe->option, &mpe->attribute_flags); \ ++ return function (strvec, &mpe->option, &mpe->attribute_flags, \ ++ file, line_nr); \ + } + + #define declare_mp_attr_snprint(option, function) \ +@@ -673,7 +686,7 @@ snprint_mp_ ## option (struct config *conf, struct strbuf *buff, \ + } + + static int +-set_mode(vector strvec, void *ptr, int *flags) ++set_mode(vector strvec, void *ptr, int *flags, const char *file, int line_nr) + { + mode_t mode; + mode_t *mode_ptr = (mode_t *)ptr; +@@ -694,7 +707,7 @@ set_mode(vector strvec, void *ptr, int *flags) + } + + static int +-set_uid(vector strvec, void *ptr, int *flags) ++set_uid(vector strvec, void *ptr, int *flags, const char *file, int line_nr) + { + uid_t uid; + uid_t *uid_ptr = (uid_t *)ptr; +@@ -719,7 +732,7 @@ set_uid(vector strvec, void *ptr, int *flags) + } + + static int +-set_gid(vector strvec, void *ptr, int *flags) ++set_gid(vector strvec, void *ptr, int *flags, const char *file, int line_nr) + { + gid_t gid; + gid_t *gid_ptr = (gid_t *)ptr; +@@ -786,7 +799,7 @@ declare_mp_attr_handler(gid, set_gid) + declare_mp_attr_snprint(gid, print_gid) + + static int +-set_undef_off_zero(vector strvec, void *ptr) ++set_undef_off_zero(vector strvec, void *ptr, const char *file, int line_nr) + { + char * buff; + int *int_ptr = (int *)ptr; +@@ -827,7 +840,7 @@ declare_hw_handler(fast_io_fail, set_undef_off_zero) + declare_hw_snprint(fast_io_fail, print_undef_off_zero) + + static int +-set_dev_loss(vector strvec, void *ptr) ++set_dev_loss(vector strvec, void *ptr, const char *file, int line_nr) + { + char * buff; + unsigned int *uint_ptr = (unsigned int *)ptr; +@@ -870,7 +883,7 @@ declare_hw_handler(eh_deadline, set_undef_off_zero) + declare_hw_snprint(eh_deadline, print_undef_off_zero) + + static int +-set_pgpolicy(vector strvec, void *ptr) ++set_pgpolicy(vector strvec, void *ptr, const char *file, int line_nr) + { + char * buff; + int *int_ptr = (int *)ptr; +@@ -936,7 +949,8 @@ get_sys_max_fds(int *max_fds) + + + static int +-max_fds_handler(struct config *conf, vector strvec) ++max_fds_handler(struct config *conf, vector strvec, const char *file, ++ int line_nr) + { + char * buff; + int r = 0, max_fds; +@@ -981,7 +995,7 @@ snprint_max_fds (struct config *conf, struct strbuf *buff, const void *data) + } + + static int +-set_rr_weight(vector strvec, void *ptr) ++set_rr_weight(vector strvec, void *ptr, const char *file, int line_nr) + { + int *int_ptr = (int *)ptr; + char * buff; +@@ -1025,7 +1039,7 @@ declare_mp_handler(rr_weight, set_rr_weight) + declare_mp_snprint(rr_weight, print_rr_weight) + + static int +-set_pgfailback(vector strvec, void *ptr) ++set_pgfailback(vector strvec, void *ptr, const char *file, int line_nr) + { + int *int_ptr = (int *)ptr; + char * buff; +@@ -1075,7 +1089,7 @@ declare_mp_handler(pgfailback, set_pgfailback) + declare_mp_snprint(pgfailback, print_pgfailback) + + static int +-no_path_retry_helper(vector strvec, void *ptr) ++no_path_retry_helper(vector strvec, void *ptr, const char *file, int line_nr) + { + int *int_ptr = (int *)ptr; + char * buff; +@@ -1120,7 +1134,8 @@ declare_mp_handler(no_path_retry, no_path_retry_helper) + declare_mp_snprint(no_path_retry, print_no_path_retry) + + static int +-def_log_checker_err_handler(struct config *conf, vector strvec) ++def_log_checker_err_handler(struct config *conf, vector strvec, ++ const char *file, int line_nr) + { + char * buff; + +@@ -1193,7 +1208,8 @@ print_reservation_key(struct strbuf *buff, + } + + static int +-def_reservation_key_handler(struct config *conf, vector strvec) ++def_reservation_key_handler(struct config *conf, vector strvec, ++ const char *file, int line_nr) + { + return set_reservation_key(strvec, &conf->reservation_key, + &conf->sa_flags, +@@ -1209,7 +1225,8 @@ snprint_def_reservation_key (struct config *conf, struct strbuf *buff, + } + + static int +-mp_reservation_key_handler(struct config *conf, vector strvec) ++mp_reservation_key_handler(struct config *conf, vector strvec, const char *file, ++ int line_nr) + { + struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable); + if (!mpe) +@@ -1229,7 +1246,7 @@ snprint_mp_reservation_key (struct config *conf, struct strbuf *buff, + } + + static int +-set_off_int_undef(vector strvec, void *ptr) ++set_off_int_undef(vector strvec, void *ptr, const char *file, int line_nr) + { + int *int_ptr = (int *)ptr; + char * buff; +@@ -1370,7 +1387,8 @@ declare_hw_snprint(recheck_wwid, print_yes_no_undef) + + + static int +-def_uxsock_timeout_handler(struct config *conf, vector strvec) ++def_uxsock_timeout_handler(struct config *conf, vector strvec, const char *file, ++ int line_nr) + { + unsigned int uxsock_timeout; + char *buff; +@@ -1390,7 +1408,8 @@ def_uxsock_timeout_handler(struct config *conf, vector strvec) + } + + static int +-hw_vpd_vendor_handler(struct config *conf, vector strvec) ++hw_vpd_vendor_handler(struct config *conf, vector strvec, const char *file, ++ int line_nr) + { + int i; + char *buff; +@@ -1430,7 +1449,8 @@ snprint_hw_vpd_vendor(struct config *conf, struct strbuf *buff, + * blacklist block handlers + */ + static int +-blacklist_handler(struct config *conf, vector strvec) ++blacklist_handler(struct config *conf, vector strvec, const char*file, ++ int line_nr) + { + if (!conf->blist_devnode) + conf->blist_devnode = vector_alloc(); +@@ -1452,7 +1472,8 @@ blacklist_handler(struct config *conf, vector strvec) + } + + static int +-blacklist_exceptions_handler(struct config *conf, vector strvec) ++blacklist_exceptions_handler(struct config *conf, vector strvec, ++ const char *file, int line_nr) + { + if (!conf->elist_devnode) + conf->elist_devnode = vector_alloc(); +@@ -1475,7 +1496,8 @@ blacklist_exceptions_handler(struct config *conf, vector strvec) + + #define declare_ble_handler(option) \ + static int \ +-ble_ ## option ## _handler (struct config *conf, vector strvec) \ ++ble_ ## option ## _handler (struct config *conf, vector strvec, \ ++ const char *file, int line_nr) \ + { \ + char *buff; \ + int rc; \ +@@ -1494,7 +1516,8 @@ ble_ ## option ## _handler (struct config *conf, vector strvec) \ + + #define declare_ble_device_handler(name, option, vend, prod) \ + static int \ +-ble_ ## option ## _ ## name ## _handler (struct config *conf, vector strvec) \ ++ble_ ## option ## _ ## name ## _handler (struct config *conf, vector strvec, \ ++ const char *file, int line_nr) \ + { \ + char * buff; \ + int rc; \ +@@ -1536,13 +1559,15 @@ snprint_ble_simple (struct config *conf, struct strbuf *buff, const void *data) + } + + static int +-ble_device_handler(struct config *conf, vector strvec) ++ble_device_handler(struct config *conf, vector strvec, const char *file, ++ int line_nr) + { + return alloc_ble_device(conf->blist_device); + } + + static int +-ble_except_device_handler(struct config *conf, vector strvec) ++ble_except_device_handler(struct config *conf, vector strvec, const char *file, ++ int line_nr) + { + return alloc_ble_device(conf->elist_device); + } +@@ -1574,7 +1599,8 @@ static int snprint_bled_product(struct config *conf, struct strbuf *buff, + * devices block handlers + */ + static int +-devices_handler(struct config *conf, vector strvec) ++devices_handler(struct config *conf, vector strvec, const char *file, ++ int line_nr) + { + if (!conf->hwtable) + conf->hwtable = vector_alloc(); +@@ -1586,7 +1612,8 @@ devices_handler(struct config *conf, vector strvec) + } + + static int +-device_handler(struct config *conf, vector strvec) ++device_handler(struct config *conf, vector strvec, const char *file, ++ int line_nr) + { + struct hwentry * hwe; + +@@ -1623,7 +1650,8 @@ declare_hw_snprint(hwhandler, print_str) + * overrides handlers + */ + static int +-overrides_handler(struct config *conf, vector strvec) ++overrides_handler(struct config *conf, vector strvec, const char *file, ++ int line_nr) + { + if (!conf->overrides) + conf->overrides = alloc_hwe(); +@@ -1640,7 +1668,8 @@ overrides_handler(struct config *conf, vector strvec) + * multipaths block handlers + */ + static int +-multipaths_handler(struct config *conf, vector strvec) ++multipaths_handler(struct config *conf, vector strvec, const char *file, ++ int line_nr) + { + if (!conf->mptable) + conf->mptable = vector_alloc(); +@@ -1652,7 +1681,8 @@ multipaths_handler(struct config *conf, vector strvec) + } + + static int +-multipath_handler(struct config *conf, vector strvec) ++multipath_handler(struct config *conf, vector strvec, const char *file, ++ int line_nr) + { + struct mpentry * mpe; + +@@ -1681,7 +1711,8 @@ declare_mp_snprint(alias, print_str) + */ + + static int +-deprecated_handler(struct config *conf, vector strvec) ++deprecated_handler(struct config *conf, vector strvec, const char *file, ++ int line_nr) + { + char * buff; + +diff --git a/libmultipath/parser.c b/libmultipath/parser.c +index d5595fb0..68262d0e 100644 +--- a/libmultipath/parser.c ++++ b/libmultipath/parser.c +@@ -558,7 +558,8 @@ process_stream(struct config *conf, FILE *stream, vector keywords, + goto out; + } + if (keyword->handler) { +- t = keyword->handler(conf, strvec); ++ t = keyword->handler(conf, strvec, file, ++ line_nr); + r += t; + if (t) + condlog(1, "%s line %d, parsing failed: %s", +diff --git a/libmultipath/parser.h b/libmultipath/parser.h +index 3452bde1..11ea2278 100644 +--- a/libmultipath/parser.h ++++ b/libmultipath/parser.h +@@ -43,7 +43,7 @@ struct strbuf; + + /* keyword definition */ + typedef int print_fn(struct config *, struct strbuf *, const void *); +-typedef int handler_fn(struct config *, vector); ++typedef int handler_fn(struct config *, vector, const char *file, int line_nr); + + struct keyword { + char *string; diff --git a/0018-libmultipath-make-set_int-take-a-range-for-valid-val.patch b/0018-libmultipath-make-set_int-take-a-range-for-valid-val.patch new file mode 100644 index 0000000..21969af --- /dev/null +++ b/0018-libmultipath-make-set_int-take-a-range-for-valid-val.patch @@ -0,0 +1,251 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Thu, 11 Nov 2021 12:53:48 -0600 +Subject: [PATCH] libmultipath: make set_int take a range for valid values + +If a value outside of the valid range is passed to set_int, it caps the +value at appropriate limit, and issues a warning. + +Signed-off-by: Benjamin Marzinski +Reviewed-by: Martin Wilck +--- + libmultipath/dict.c | 121 +++++++++++++++++++++++++++----------------- + 1 file changed, 75 insertions(+), 46 deletions(-) + +diff --git a/libmultipath/dict.c b/libmultipath/dict.c +index eb2c44c0..57b6a7b6 100644 +--- a/libmultipath/dict.c ++++ b/libmultipath/dict.c +@@ -29,7 +29,8 @@ + #include "strbuf.h" + + static int +-set_int(vector strvec, void *ptr, const char *file, int line_nr) ++set_int(vector strvec, void *ptr, int min, int max, const char *file, ++ int line_nr) + { + int *int_ptr = (int *)ptr; + char *buff, *eptr; +@@ -44,11 +45,17 @@ set_int(vector strvec, void *ptr, const char *file, int line_nr) + if (eptr > buff) + while (isspace(*eptr)) + eptr++; +- if (*buff == '\0' || *eptr != '\0' || res > INT_MAX || res < INT_MIN) { +- condlog(1, "%s: invalid value for %s: \"%s\"", +- __func__, (char*)VECTOR_SLOT(strvec, 0), buff); ++ if (*buff == '\0' || *eptr != '\0') { ++ condlog(1, "%s line %d, invalid value for %s: \"%s\"", ++ file, line_nr, (char*)VECTOR_SLOT(strvec, 0), buff); + rc = 1; + } else { ++ if (res > max || res < min) { ++ res = (res > max) ? max : min; ++ condlog(1, "%s line %d, value for %s too %s, capping at %ld", ++ file, line_nr, (char*)VECTOR_SLOT(strvec, 0), ++ (res == max)? "large" : "small", res); ++ } + rc = 0; + *int_ptr = res; + } +@@ -77,8 +84,8 @@ set_uint(vector strvec, void *ptr, const char *file, int line_nr) + while (isspace(*eptr)) + eptr++; + if (*buff == '\0' || *eptr != '\0' || !isdigit(*p) || res > UINT_MAX) { +- condlog(1, "%s: invalid value for %s: \"%s\"", +- __func__, (char*)VECTOR_SLOT(strvec, 0), buff); ++ condlog(1, "%s line %d, invalid value for %s: \"%s\"", ++ file, line_nr, (char*)VECTOR_SLOT(strvec, 0), buff); + rc = 1; + } else { + rc = 0; +@@ -193,6 +200,14 @@ def_ ## option ## _handler (struct config *conf, vector strvec, \ + return function (strvec, &conf->option, file, line_nr); \ + } + ++#define declare_def_range_handler(option, minval, maxval) \ ++static int \ ++def_ ## option ## _handler (struct config *conf, vector strvec, \ ++ const char *file, int line_nr) \ ++{ \ ++ return set_int(strvec, &conf->option, minval, maxval, file, line_nr); \ ++} ++ + #define declare_def_snprint(option, function) \ + static int \ + snprint_def_ ## option (struct config *conf, struct strbuf *buff, \ +@@ -234,6 +249,18 @@ hw_ ## option ## _handler (struct config *conf, vector strvec, \ + return function (strvec, &hwe->option, file, line_nr); \ + } + ++#define declare_hw_range_handler(option, minval, maxval) \ ++static int \ ++hw_ ## option ## _handler (struct config *conf, vector strvec, \ ++ const char *file, int line_nr) \ ++{ \ ++ struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable); \ ++ if (!hwe) \ ++ return 1; \ ++ return set_int(strvec, &hwe->option, minval, maxval, file, line_nr); \ ++} ++ ++ + #define declare_hw_snprint(option, function) \ + static int \ + snprint_hw_ ## option (struct config *conf, struct strbuf *buff, \ +@@ -253,6 +280,17 @@ ovr_ ## option ## _handler (struct config *conf, vector strvec, \ + return function (strvec, &conf->overrides->option, file, line_nr); \ + } + ++#define declare_ovr_range_handler(option, minval, maxval) \ ++static int \ ++ovr_ ## option ## _handler (struct config *conf, vector strvec, \ ++ const char *file, int line_nr) \ ++{ \ ++ if (!conf->overrides) \ ++ return 1; \ ++ return set_int(strvec, &conf->overrides->option, minval, maxval, \ ++ file, line_nr); \ ++} ++ + #define declare_ovr_snprint(option, function) \ + static int \ + snprint_ovr_ ## option (struct config *conf, struct strbuf *buff, \ +@@ -272,6 +310,17 @@ mp_ ## option ## _handler (struct config *conf, vector strvec, \ + return function (strvec, &mpe->option, file, line_nr); \ + } + ++#define declare_mp_range_handler(option, minval, maxval) \ ++static int \ ++mp_ ## option ## _handler (struct config *conf, vector strvec, \ ++ const char *file, int line_nr) \ ++{ \ ++ struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable); \ ++ if (!mpe) \ ++ return 1; \ ++ return set_int(strvec, &mpe->option, minval, maxval, file, line_nr); \ ++} ++ + #define declare_mp_snprint(option, function) \ + static int \ + snprint_mp_ ## option (struct config *conf, struct strbuf *buff, \ +@@ -298,7 +347,7 @@ declare_def_snprint(checkint, print_int) + declare_def_handler(max_checkint, set_uint) + declare_def_snprint(max_checkint, print_int) + +-declare_def_handler(verbosity, set_int) ++declare_def_range_handler(verbosity, 0, MAX_VERBOSITY) + declare_def_snprint(verbosity, print_int) + + declare_def_handler(reassign_maps, set_yes_no) +@@ -473,22 +522,22 @@ declare_ovr_snprint(checker_name, print_str) + declare_hw_handler(checker_name, set_str) + declare_hw_snprint(checker_name, print_str) + +-declare_def_handler(minio, set_int) ++declare_def_range_handler(minio, 0, INT_MAX) + declare_def_snprint_defint(minio, print_int, DEFAULT_MINIO) +-declare_ovr_handler(minio, set_int) ++declare_ovr_range_handler(minio, 0, INT_MAX) + declare_ovr_snprint(minio, print_nonzero) +-declare_hw_handler(minio, set_int) ++declare_hw_range_handler(minio, 0, INT_MAX) + declare_hw_snprint(minio, print_nonzero) +-declare_mp_handler(minio, set_int) ++declare_mp_range_handler(minio, 0, INT_MAX) + declare_mp_snprint(minio, print_nonzero) + +-declare_def_handler(minio_rq, set_int) ++declare_def_range_handler(minio_rq, 0, INT_MAX) + declare_def_snprint_defint(minio_rq, print_int, DEFAULT_MINIO_RQ) +-declare_ovr_handler(minio_rq, set_int) ++declare_ovr_range_handler(minio_rq, 0, INT_MAX) + declare_ovr_snprint(minio_rq, print_nonzero) +-declare_hw_handler(minio_rq, set_int) ++declare_hw_range_handler(minio_rq, 0, INT_MAX) + declare_hw_snprint(minio_rq, print_nonzero) +-declare_mp_handler(minio_rq, set_int) ++declare_mp_range_handler(minio_rq, 0, INT_MAX) + declare_mp_snprint(minio_rq, print_nonzero) + + declare_def_handler(queue_without_daemon, set_yes_no) +@@ -512,7 +561,7 @@ snprint_def_queue_without_daemon(struct config *conf, struct strbuf *buff, + return append_strbuf_quoted(buff, qwd); + } + +-declare_def_handler(checker_timeout, set_int) ++declare_def_range_handler(checker_timeout, 0, INT_MAX) + declare_def_snprint(checker_timeout, print_nonzero) + + declare_def_handler(allow_usb_devices, set_yes_no) +@@ -583,13 +632,13 @@ declare_hw_snprint(deferred_remove, print_yes_no_undef) + declare_mp_handler(deferred_remove, set_yes_no_undef) + declare_mp_snprint(deferred_remove, print_yes_no_undef) + +-declare_def_handler(retrigger_tries, set_int) ++declare_def_range_handler(retrigger_tries, 0, INT_MAX) + declare_def_snprint(retrigger_tries, print_int) + +-declare_def_handler(retrigger_delay, set_int) ++declare_def_range_handler(retrigger_delay, 0, INT_MAX) + declare_def_snprint(retrigger_delay, print_int) + +-declare_def_handler(uev_wait_timeout, set_int) ++declare_def_range_handler(uev_wait_timeout, 0, INT_MAX) + declare_def_snprint(uev_wait_timeout, print_int) + + declare_def_handler(strict_timing, set_yes_no) +@@ -616,19 +665,19 @@ static int snprint_def_disable_changed_wwids(struct config *conf, + return print_ignored(buff); + } + +-declare_def_handler(remove_retries, set_int) ++declare_def_range_handler(remove_retries, 0, INT_MAX) + declare_def_snprint(remove_retries, print_int) + +-declare_def_handler(max_sectors_kb, set_int) ++declare_def_range_handler(max_sectors_kb, 0, INT_MAX) + declare_def_snprint(max_sectors_kb, print_nonzero) +-declare_ovr_handler(max_sectors_kb, set_int) ++declare_ovr_range_handler(max_sectors_kb, 0, INT_MAX) + declare_ovr_snprint(max_sectors_kb, print_nonzero) +-declare_hw_handler(max_sectors_kb, set_int) ++declare_hw_range_handler(max_sectors_kb, 0, INT_MAX) + declare_hw_snprint(max_sectors_kb, print_nonzero) +-declare_mp_handler(max_sectors_kb, set_int) ++declare_mp_range_handler(max_sectors_kb, 0, INT_MAX) + declare_mp_snprint(max_sectors_kb, print_nonzero) + +-declare_def_handler(find_multipaths_timeout, set_int) ++declare_def_range_handler(find_multipaths_timeout, INT_MIN, INT_MAX) + declare_def_snprint_defint(find_multipaths_timeout, print_int, + DEFAULT_FIND_MULTIPATHS_TIMEOUT) + +@@ -1385,27 +1434,7 @@ declare_ovr_snprint(recheck_wwid, print_yes_no_undef) + declare_hw_handler(recheck_wwid, set_yes_no_undef) + declare_hw_snprint(recheck_wwid, print_yes_no_undef) + +- +-static int +-def_uxsock_timeout_handler(struct config *conf, vector strvec, const char *file, +- int line_nr) +-{ +- unsigned int uxsock_timeout; +- char *buff; +- +- buff = set_value(strvec); +- if (!buff) +- return 1; +- +- if (sscanf(buff, "%u", &uxsock_timeout) == 1 && +- uxsock_timeout > DEFAULT_REPLY_TIMEOUT) +- conf->uxsock_timeout = uxsock_timeout; +- else +- conf->uxsock_timeout = DEFAULT_REPLY_TIMEOUT; +- +- free(buff); +- return 0; +-} ++declare_def_range_handler(uxsock_timeout, DEFAULT_REPLY_TIMEOUT, INT_MAX) + + static int + hw_vpd_vendor_handler(struct config *conf, vector strvec, const char *file, diff --git a/0019-libmultipath-improve-checks-for-set_str.patch b/0019-libmultipath-improve-checks-for-set_str.patch new file mode 100644 index 0000000..0cd8627 --- /dev/null +++ b/0019-libmultipath-improve-checks-for-set_str.patch @@ -0,0 +1,171 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Thu, 11 Nov 2021 12:53:49 -0600 +Subject: [PATCH] libmultipath: improve checks for set_str + +multipath always requires absolute pathnames, so make sure all file and +directory names start with a slash. Also check that the directories +exist. Finally, some strings, like the alias, will be used in paths. +These must not contain the slash character '/', since it is a forbidden +character in file/directory names. This patch adds seperate handlers for +these three cases. If a config line is invalid, these handlers retain +the existing config string, if any. + +Signed-off-by: Benjamin Marzinski +Reviewed-by: Martin Wilck +--- + libmultipath/dict.c | 88 +++++++++++++++++++++++++++++++++++++++------ + 1 file changed, 78 insertions(+), 10 deletions(-) + +diff --git a/libmultipath/dict.c b/libmultipath/dict.c +index 57b6a7b6..149d3348 100644 +--- a/libmultipath/dict.c ++++ b/libmultipath/dict.c +@@ -5,6 +5,8 @@ + * Copyright (c) 2005 Kiyoshi Ueda, NEC + */ + #include ++#include ++#include + #include + #include + #include "checkers.h" +@@ -111,6 +113,72 @@ set_str(vector strvec, void *ptr, const char *file, int line_nr) + return 0; + } + ++static int ++set_dir(vector strvec, void *ptr, const char *file, int line_nr) ++{ ++ char **str_ptr = (char **)ptr; ++ char *old_str = *str_ptr; ++ struct stat sb; ++ ++ *str_ptr = set_value(strvec); ++ if (!*str_ptr) { ++ free(old_str); ++ return 1; ++ } ++ if ((*str_ptr)[0] != '/'){ ++ condlog(1, "%s line %d, %s is not an absolute directory path. Ignoring", file, line_nr, *str_ptr); ++ *str_ptr = old_str; ++ } else { ++ if (stat(*str_ptr, &sb) == 0 && S_ISDIR(sb.st_mode)) ++ free(old_str); ++ else { ++ condlog(1, "%s line %d, %s is not an existing directory. Ignoring", file, line_nr, *str_ptr); ++ *str_ptr = old_str; ++ } ++ } ++ return 0; ++} ++ ++static int ++set_path(vector strvec, void *ptr, const char *file, int line_nr) ++{ ++ char **str_ptr = (char **)ptr; ++ char *old_str = *str_ptr; ++ ++ *str_ptr = set_value(strvec); ++ if (!*str_ptr) { ++ free(old_str); ++ return 1; ++ } ++ if ((*str_ptr)[0] != '/'){ ++ condlog(1, "%s line %d, %s is not an absolute path. Ignoring", ++ file, line_nr, *str_ptr); ++ *str_ptr = old_str; ++ } else ++ free(old_str); ++ return 0; ++} ++ ++static int ++set_str_noslash(vector strvec, void *ptr, const char *file, int line_nr) ++{ ++ char **str_ptr = (char **)ptr; ++ char *old_str = *str_ptr; ++ ++ *str_ptr = set_value(strvec); ++ if (!*str_ptr) { ++ free(old_str); ++ return 1; ++ } ++ if (strchr(*str_ptr, '/')) { ++ condlog(1, "%s line %d, %s cannot contain a slash. Ignoring", ++ file, line_nr, *str_ptr); ++ *str_ptr = old_str; ++ } else ++ free(old_str); ++ return 0; ++} ++ + static int + set_yes_no(vector strvec, void *ptr, const char *file, int line_nr) + { +@@ -353,13 +421,13 @@ declare_def_snprint(verbosity, print_int) + declare_def_handler(reassign_maps, set_yes_no) + declare_def_snprint(reassign_maps, print_yes_no) + +-declare_def_handler(multipath_dir, set_str) ++declare_def_handler(multipath_dir, set_dir) + declare_def_snprint(multipath_dir, print_str) + + static int def_partition_delim_handler(struct config *conf, vector strvec, + const char *file, int line_nr) + { +- int rc = set_str(strvec, &conf->partition_delim, file, line_nr); ++ int rc = set_str_noslash(strvec, &conf->partition_delim, file, line_nr); + + if (rc != 0) + return rc; +@@ -490,11 +558,11 @@ declare_hw_snprint(prio_name, print_str) + declare_mp_handler(prio_name, set_str) + declare_mp_snprint(prio_name, print_str) + +-declare_def_handler(alias_prefix, set_str) ++declare_def_handler(alias_prefix, set_str_noslash) + declare_def_snprint_defstr(alias_prefix, print_str, DEFAULT_ALIAS_PREFIX) +-declare_ovr_handler(alias_prefix, set_str) ++declare_ovr_handler(alias_prefix, set_str_noslash) + declare_ovr_snprint(alias_prefix, print_str) +-declare_hw_handler(alias_prefix, set_str) ++declare_hw_handler(alias_prefix, set_str_noslash) + declare_hw_snprint(alias_prefix, print_str) + + declare_def_handler(prio_args, set_str) +@@ -586,13 +654,13 @@ declare_hw_snprint(user_friendly_names, print_yes_no_undef) + declare_mp_handler(user_friendly_names, set_yes_no_undef) + declare_mp_snprint(user_friendly_names, print_yes_no_undef) + +-declare_def_handler(bindings_file, set_str) ++declare_def_handler(bindings_file, set_path) + declare_def_snprint(bindings_file, print_str) + +-declare_def_handler(wwids_file, set_str) ++declare_def_handler(wwids_file, set_path) + declare_def_snprint(wwids_file, print_str) + +-declare_def_handler(prkeys_file, set_str) ++declare_def_handler(prkeys_file, set_path) + declare_def_snprint(prkeys_file, print_str) + + declare_def_handler(retain_hwhandler, set_yes_no_undef) +@@ -692,7 +760,7 @@ def_config_dir_handler(struct config *conf, vector strvec, const char *file, + /* this is only valid in the main config file */ + if (conf->processed_main_config) + return 0; +- return set_str(strvec, &conf->config_dir, file, line_nr); ++ return set_path(strvec, &conf->config_dir, file, line_nr); + } + declare_def_snprint(config_dir, print_str) + +@@ -1732,7 +1800,7 @@ multipath_handler(struct config *conf, vector strvec, const char *file, + declare_mp_handler(wwid, set_str) + declare_mp_snprint(wwid, print_str) + +-declare_mp_handler(alias, set_str) ++declare_mp_handler(alias, set_str_noslash) + declare_mp_snprint(alias, print_str) + + /* diff --git a/0020-libmultipath-deprecate-file-and-directory-config-opt.patch b/0020-libmultipath-deprecate-file-and-directory-config-opt.patch new file mode 100644 index 0000000..32e1b23 --- /dev/null +++ b/0020-libmultipath-deprecate-file-and-directory-config-opt.patch @@ -0,0 +1,115 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Thu, 11 Nov 2021 12:53:50 -0600 +Subject: [PATCH] libmultipath: deprecate file and directory config options + +Having multipath able to select pathnames for the files and directories +it needs causes unnecessary maintainer headaches. Mark these as +deprecated, but still support them for now. + +Signed-off-by: Benjamin Marzinski +Reviewed-by: Martin Wilck +--- + libmultipath/dict.c | 19 +++++++++++++++---- + multipath/multipath.conf.5 | 5 +++++ + 2 files changed, 20 insertions(+), 4 deletions(-) + +diff --git a/libmultipath/dict.c b/libmultipath/dict.c +index 149d3348..d14be340 100644 +--- a/libmultipath/dict.c ++++ b/libmultipath/dict.c +@@ -268,6 +268,15 @@ def_ ## option ## _handler (struct config *conf, vector strvec, \ + return function (strvec, &conf->option, file, line_nr); \ + } + ++#define declare_def_warn_handler(option, function) \ ++static int \ ++def_ ## option ## _handler (struct config *conf, vector strvec, \ ++ const char *file, int line_nr) \ ++{ \ ++ condlog(2, "%s line %d, \"" #option "\" is deprecated and will be disabled in a future release", file, line_nr); \ ++ return function (strvec, &conf->option, file, line_nr); \ ++} ++ + #define declare_def_range_handler(option, minval, maxval) \ + static int \ + def_ ## option ## _handler (struct config *conf, vector strvec, \ +@@ -421,7 +430,7 @@ declare_def_snprint(verbosity, print_int) + declare_def_handler(reassign_maps, set_yes_no) + declare_def_snprint(reassign_maps, print_yes_no) + +-declare_def_handler(multipath_dir, set_dir) ++declare_def_warn_handler(multipath_dir, set_dir) + declare_def_snprint(multipath_dir, print_str) + + static int def_partition_delim_handler(struct config *conf, vector strvec, +@@ -654,13 +663,13 @@ declare_hw_snprint(user_friendly_names, print_yes_no_undef) + declare_mp_handler(user_friendly_names, set_yes_no_undef) + declare_mp_snprint(user_friendly_names, print_yes_no_undef) + +-declare_def_handler(bindings_file, set_path) ++declare_def_warn_handler(bindings_file, set_path) + declare_def_snprint(bindings_file, print_str) + +-declare_def_handler(wwids_file, set_path) ++declare_def_warn_handler(wwids_file, set_path) + declare_def_snprint(wwids_file, print_str) + +-declare_def_handler(prkeys_file, set_path) ++declare_def_warn_handler(prkeys_file, set_path) + declare_def_snprint(prkeys_file, print_str) + + declare_def_handler(retain_hwhandler, set_yes_no_undef) +@@ -760,6 +769,8 @@ def_config_dir_handler(struct config *conf, vector strvec, const char *file, + /* this is only valid in the main config file */ + if (conf->processed_main_config) + return 0; ++ condlog(2, "%s line %d, \"config_dir\" is deprecated and will be disabled in a future release", ++ file, line_nr); + return set_path(strvec, &conf->config_dir, file, line_nr); + } + declare_def_snprint(config_dir, print_str) +diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5 +index c74129bd..88d2a1df 100644 +--- a/multipath/multipath.conf.5 ++++ b/multipath/multipath.conf.5 +@@ -178,6 +178,7 @@ The default is: \fBno\fR + . + .TP + .B multipath_dir ++This option is deprecated, and will be removed in a future release. + Directory where the dynamic shared objects are stored. Defined at compile time, + commonly \fI/lib64/multipath/\fR or \fI/lib/multipath/\fR. + .RS +@@ -742,6 +743,7 @@ The default is: \fB\fR + . + .TP + .B bindings_file ++This option is deprecated, and will be removed in a future release. + The full pathname of the binding file to be used when the user_friendly_names + option is set. + .RS +@@ -752,6 +754,7 @@ The default is: \fB/etc/multipath/bindings\fR + . + .TP + .B wwids_file ++This option is deprecated, and will be removed in a future release. + The full pathname of the WWIDs file, which is used by multipath to keep track + of the WWIDs for LUNs it has created multipath devices on in the past. + .RS +@@ -762,6 +765,7 @@ The default is: \fB/etc/multipath/wwids\fR + . + .TP + .B prkeys_file ++This option is deprecated, and will be removed in a future release. + The full pathname of the prkeys file, which is used by multipathd to keep + track of the persistent reservation key used for a specific WWID, when + \fIreservation_key\fR is set to \fBfile\fR. +@@ -933,6 +937,7 @@ The default is: \fB\fR + . + .TP + .B config_dir ++This option is deprecated, and will be removed in a future release. + If set to anything other than "", multipath will search this directory + alphabetically for file ending in ".conf" and it will read configuration + information from them, just as if it was in \fI/etc/multipath.conf\fR. diff --git a/0021-libmultipath-split-set_int-to-enable-reuse.patch b/0021-libmultipath-split-set_int-to-enable-reuse.patch new file mode 100644 index 0000000..4f4b09a --- /dev/null +++ b/0021-libmultipath-split-set_int-to-enable-reuse.patch @@ -0,0 +1,192 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Thu, 11 Nov 2021 12:53:51 -0600 +Subject: [PATCH] libmultipath: split set_int to enable reuse + +Split the code that does the actual value parsing out of set_int(), into +a helper function, do_set_int(), so that it can be used by other +handlers. These functions no longer set the config value at all, when +they have invalid input. + +Signed-off-by: Benjamin Marzinski +Reviewed-by: Martin Wilck +--- + libmultipath/dict.c | 82 +++++++++++++++++++++++++-------------------- + 1 file changed, 46 insertions(+), 36 deletions(-) + +diff --git a/libmultipath/dict.c b/libmultipath/dict.c +index d14be340..68647061 100644 +--- a/libmultipath/dict.c ++++ b/libmultipath/dict.c +@@ -31,17 +31,12 @@ + #include "strbuf.h" + + static int +-set_int(vector strvec, void *ptr, int min, int max, const char *file, +- int line_nr) ++do_set_int(vector strvec, void *ptr, int min, int max, const char *file, ++ int line_nr, char *buff) + { + int *int_ptr = (int *)ptr; +- char *buff, *eptr; ++ char *eptr; + long res; +- int rc; +- +- buff = set_value(strvec); +- if (!buff) +- return 1; + + res = strtol(buff, &eptr, 10); + if (eptr > buff) +@@ -50,17 +45,30 @@ set_int(vector strvec, void *ptr, int min, int max, const char *file, + if (*buff == '\0' || *eptr != '\0') { + condlog(1, "%s line %d, invalid value for %s: \"%s\"", + file, line_nr, (char*)VECTOR_SLOT(strvec, 0), buff); +- rc = 1; +- } else { +- if (res > max || res < min) { +- res = (res > max) ? max : min; +- condlog(1, "%s line %d, value for %s too %s, capping at %ld", ++ return 1; ++ } ++ if (res > max || res < min) { ++ res = (res > max) ? max : min; ++ condlog(1, "%s line %d, value for %s too %s, capping at %ld", + file, line_nr, (char*)VECTOR_SLOT(strvec, 0), +- (res == max)? "large" : "small", res); +- } +- rc = 0; +- *int_ptr = res; ++ (res == max)? "large" : "small", res); + } ++ *int_ptr = res; ++ return 0; ++} ++ ++static int ++set_int(vector strvec, void *ptr, int min, int max, const char *file, ++ int line_nr) ++{ ++ char *buff; ++ int rc; ++ ++ buff = set_value(strvec); ++ if (!buff) ++ return 1; ++ ++ rc = do_set_int(strvec, ptr, min, max, file, line_nr, buff); + + FREE(buff); + return rc; +@@ -929,6 +937,7 @@ declare_mp_attr_snprint(gid, print_gid) + static int + set_undef_off_zero(vector strvec, void *ptr, const char *file, int line_nr) + { ++ int rc = 0; + char * buff; + int *int_ptr = (int *)ptr; + +@@ -938,10 +947,10 @@ set_undef_off_zero(vector strvec, void *ptr, const char *file, int line_nr) + + if (strcmp(buff, "off") == 0) + *int_ptr = UOZ_OFF; +- else if (sscanf(buff, "%d", int_ptr) != 1 || +- *int_ptr < UOZ_ZERO) +- *int_ptr = UOZ_UNDEF; +- else if (*int_ptr == 0) ++ else ++ rc = do_set_int(strvec, int_ptr, 0, INT_MAX, file, line_nr, ++ buff); ++ if (rc == 0 && *int_ptr == 0) + *int_ptr = UOZ_ZERO; + + FREE(buff); +@@ -1093,14 +1102,12 @@ max_fds_handler(struct config *conf, vector strvec, const char *file, + /* Assume safe limit */ + max_fds = 4096; + } +- if (strlen(buff) == 3 && +- !strcmp(buff, "max")) +- conf->max_fds = max_fds; +- else +- conf->max_fds = atoi(buff); +- +- if (conf->max_fds > max_fds) ++ if (!strcmp(buff, "max")) { + conf->max_fds = max_fds; ++ r = 0; ++ } else ++ r = do_set_int(strvec, &conf->max_fds, 0, max_fds, file, ++ line_nr, buff); + + FREE(buff); + +@@ -1169,6 +1176,7 @@ declare_mp_snprint(rr_weight, print_rr_weight) + static int + set_pgfailback(vector strvec, void *ptr, const char *file, int line_nr) + { ++ int rc = 0; + int *int_ptr = (int *)ptr; + char * buff; + +@@ -1183,11 +1191,11 @@ set_pgfailback(vector strvec, void *ptr, const char *file, int line_nr) + else if (strlen(buff) == 10 && !strcmp(buff, "followover")) + *int_ptr = -FAILBACK_FOLLOWOVER; + else +- *int_ptr = atoi(buff); ++ rc = do_set_int(strvec, ptr, 0, INT_MAX, file, line_nr, buff); + + FREE(buff); + +- return 0; ++ return rc; + } + + int +@@ -1219,6 +1227,7 @@ declare_mp_snprint(pgfailback, print_pgfailback) + static int + no_path_retry_helper(vector strvec, void *ptr, const char *file, int line_nr) + { ++ int rc = 0; + int *int_ptr = (int *)ptr; + char * buff; + +@@ -1230,11 +1239,11 @@ no_path_retry_helper(vector strvec, void *ptr, const char *file, int line_nr) + *int_ptr = NO_PATH_RETRY_FAIL; + else if (!strcmp(buff, "queue")) + *int_ptr = NO_PATH_RETRY_QUEUE; +- else if ((*int_ptr = atoi(buff)) < 1) +- *int_ptr = NO_PATH_RETRY_UNDEF; ++ else ++ rc = do_set_int(strvec, ptr, 1, INT_MAX, file, line_nr, buff); + + FREE(buff); +- return 0; ++ return rc; + } + + int +@@ -1376,6 +1385,7 @@ snprint_mp_reservation_key (struct config *conf, struct strbuf *buff, + static int + set_off_int_undef(vector strvec, void *ptr, const char *file, int line_nr) + { ++ int rc =0; + int *int_ptr = (int *)ptr; + char * buff; + +@@ -1385,11 +1395,11 @@ set_off_int_undef(vector strvec, void *ptr, const char *file, int line_nr) + + if (!strcmp(buff, "no") || !strcmp(buff, "0")) + *int_ptr = NU_NO; +- else if ((*int_ptr = atoi(buff)) < 1) +- *int_ptr = NU_UNDEF; ++ else ++ rc = do_set_int(strvec, ptr, 1, INT_MAX, file, line_nr, buff); + + FREE(buff); +- return 0; ++ return rc; + } + + int diff --git a/0022-libmultipath-cleanup-invalid-config-handling.patch b/0022-libmultipath-cleanup-invalid-config-handling.patch new file mode 100644 index 0000000..fcdca11 --- /dev/null +++ b/0022-libmultipath-cleanup-invalid-config-handling.patch @@ -0,0 +1,202 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Thu, 11 Nov 2021 12:53:52 -0600 +Subject: [PATCH] libmultipath: cleanup invalid config handling + +Add error reporting to the remaining config handlers. If the value is +invalid, do not change the existing config option's value. Also print +an error whenever 0 is returned for an invalid value. When the handler +returns 1, config processing already fails with an error message. + +Signed-off-by: Benjamin Marzinski +Reviewed-by: Martin Wilck +--- + libmultipath/dict.c | 73 +++++++++++++++++++++++++++++++-------------- + 1 file changed, 51 insertions(+), 22 deletions(-) + +diff --git a/libmultipath/dict.c b/libmultipath/dict.c +index 68647061..c534d703 100644 +--- a/libmultipath/dict.c ++++ b/libmultipath/dict.c +@@ -199,8 +199,11 @@ set_yes_no(vector strvec, void *ptr, const char *file, int line_nr) + + if (strcmp(buff, "yes") == 0 || strcmp(buff, "1") == 0) + *int_ptr = YN_YES; +- else ++ else if (strcmp(buff, "no") == 0 || strcmp(buff, "0") == 0) + *int_ptr = YN_NO; ++ else ++ condlog(1, "%s line %d, invalid value for %s: \"%s\"", ++ file, line_nr, (char*)VECTOR_SLOT(strvec, 0), buff); + + FREE(buff); + return 0; +@@ -221,7 +224,8 @@ set_yes_no_undef(vector strvec, void *ptr, const char *file, int line_nr) + else if (strcmp(buff, "yes") == 0 || strcmp(buff, "1") == 0) + *int_ptr = YNU_YES; + else +- *int_ptr = YNU_UNDEF; ++ condlog(1, "%s line %d, invalid value for %s: \"%s\"", ++ file, line_nr, (char*)VECTOR_SLOT(strvec, 0), buff); + + FREE(buff); + return 0; +@@ -480,9 +484,6 @@ def_find_multipaths_handler(struct config *conf, vector strvec, + char *buff; + int i; + +- if (set_yes_no_undef(strvec, &conf->find_multipaths, file, line_nr) == 0 && conf->find_multipaths != FIND_MULTIPATHS_UNDEF) +- return 0; +- + buff = set_value(strvec); + if (!buff) + return 1; +@@ -495,9 +496,14 @@ def_find_multipaths_handler(struct config *conf, vector strvec, + } + } + +- if (conf->find_multipaths == YNU_UNDEF) { +- condlog(0, "illegal value for find_multipaths: %s", buff); +- conf->find_multipaths = DEFAULT_FIND_MULTIPATHS; ++ if (i >= __FIND_MULTIPATHS_LAST) { ++ if (strcmp(buff, "no") == 0 || strcmp(buff, "0") == 0) ++ conf->find_multipaths = FIND_MULTIPATHS_OFF; ++ else if (strcmp(buff, "yes") == 0 || strcmp(buff, "1") == 0) ++ conf->find_multipaths = FIND_MULTIPATHS_ON; ++ else ++ condlog(1, "%s line %d, invalid value for find_multipaths: \"%s\"", ++ file, line_nr, buff); + } + + FREE(buff); +@@ -546,8 +552,10 @@ static int uid_attrs_handler(struct config *conf, vector strvec, + if (!val) + return 1; + if (parse_uid_attrs(val, conf)) +- condlog(1, "error parsing uid_attrs: \"%s\"", val); +- condlog(3, "parsed %d uid_attrs", VECTOR_SIZE(&conf->uid_attrs)); ++ condlog(1, "%s line %d,error parsing uid_attrs: \"%s\"", file, ++ line_nr, val); ++ else ++ condlog(4, "parsed %d uid_attrs", VECTOR_SIZE(&conf->uid_attrs)); + FREE(val); + return 0; + } +@@ -775,8 +783,11 @@ def_config_dir_handler(struct config *conf, vector strvec, const char *file, + int line_nr) + { + /* this is only valid in the main config file */ +- if (conf->processed_main_config) ++ if (conf->processed_main_config) { ++ condlog(1, "%s line %d, config_dir option only valid in /etc/multipath.conf", ++ file, line_nr); + return 0; ++ } + condlog(2, "%s line %d, \"config_dir\" is deprecated and will be disabled in a future release", + file, line_nr); + return set_path(strvec, &conf->config_dir, file, line_nr); +@@ -836,7 +847,9 @@ set_mode(vector strvec, void *ptr, int *flags, const char *file, int line_nr) + if (sscanf(buff, "%o", &mode) == 1 && mode <= 0777) { + *flags |= (1 << ATTR_MODE); + *mode_ptr = mode; +- } ++ } else ++ condlog(1, "%s line %d, invalid value for mode: \"%s\"", ++ file, line_nr, buff); + + FREE(buff); + return 0; +@@ -861,7 +874,9 @@ set_uid(vector strvec, void *ptr, int *flags, const char *file, int line_nr) + else if (sscanf(buff, "%u", &uid) == 1){ + *flags |= (1 << ATTR_UID); + *uid_ptr = uid; +- } ++ } else ++ condlog(1, "%s line %d, invalid value for uid: \"%s\"", ++ file, line_nr, buff); + + FREE(buff); + return 0; +@@ -887,7 +902,9 @@ set_gid(vector strvec, void *ptr, int *flags, const char *file, int line_nr) + else if (sscanf(buff, "%u", &gid) == 1){ + *flags |= (1 << ATTR_GID); + *gid_ptr = gid; +- } ++ } else ++ condlog(1, "%s line %d, invalid value for gid: \"%s\"", ++ file, line_nr, buff); + FREE(buff); + return 0; + } +@@ -989,7 +1006,8 @@ set_dev_loss(vector strvec, void *ptr, const char *file, int line_nr) + if (!strcmp(buff, "infinity")) + *uint_ptr = MAX_DEV_LOSS_TMO; + else if (sscanf(buff, "%u", uint_ptr) != 1) +- *uint_ptr = DEV_LOSS_TMO_UNSET; ++ condlog(1, "%s line %d, invalid value for dev_loss_tmo: \"%s\"", ++ file, line_nr, buff); + + FREE(buff); + return 0; +@@ -1023,13 +1041,19 @@ static int + set_pgpolicy(vector strvec, void *ptr, const char *file, int line_nr) + { + char * buff; ++ int policy; + int *int_ptr = (int *)ptr; + + buff = set_value(strvec); + if (!buff) + return 1; + +- *int_ptr = get_pgpolicy_id(buff); ++ policy = get_pgpolicy_id(buff); ++ if (policy != IOPOLICY_UNDEF) ++ *int_ptr = policy; ++ else ++ condlog(1, "%s line %d, invalid value for path_grouping_policy: \"%s\"", ++ file, line_nr, buff); + FREE(buff); + + return 0; +@@ -1142,10 +1166,11 @@ set_rr_weight(vector strvec, void *ptr, const char *file, int line_nr) + + if (!strcmp(buff, "priorities")) + *int_ptr = RR_WEIGHT_PRIO; +- +- if (!strcmp(buff, "uniform")) ++ else if (!strcmp(buff, "uniform")) + *int_ptr = RR_WEIGHT_NONE; +- ++ else ++ condlog(1, "%s line %d, invalid value for rr_weight: \"%s\"", ++ file, line_nr, buff); + FREE(buff); + + return 0; +@@ -1281,10 +1306,13 @@ def_log_checker_err_handler(struct config *conf, vector strvec, + if (!buff) + return 1; + +- if (strlen(buff) == 4 && !strcmp(buff, "once")) ++ if (!strcmp(buff, "once")) + conf->log_checker_err = LOG_CHKR_ERR_ONCE; +- else if (strlen(buff) == 6 && !strcmp(buff, "always")) ++ else if (!strcmp(buff, "always")) + conf->log_checker_err = LOG_CHKR_ERR_ALWAYS; ++ else ++ condlog(1, "%s line %d, invalid value for log_checker_err: \"%s\"", ++ file, line_nr, buff); + + free(buff); + return 0; +@@ -1545,7 +1573,8 @@ hw_vpd_vendor_handler(struct config *conf, vector strvec, const char *file, + goto out; + } + } +- hwe->vpd_vendor_id = 0; ++ condlog(1, "%s line %d, invalid value for vpd_vendor: \"%s\"", ++ file, line_nr, buff); + out: + FREE(buff); + return 0; diff --git a/0023-libmultipath-don-t-return-error-on-invalid-values.patch b/0023-libmultipath-don-t-return-error-on-invalid-values.patch new file mode 100644 index 0000000..2d651e2 --- /dev/null +++ b/0023-libmultipath-don-t-return-error-on-invalid-values.patch @@ -0,0 +1,219 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Thu, 11 Nov 2021 19:24:31 -0600 +Subject: [PATCH] libmultipath: don't return error on invalid values + +do_set_int and set_uint return 1 for invalid values. This can cause +multipath to fail completely, while reading the config. The config +handlers should only return a non-zero value if there is an internal +error, not if there is just an invalid value. + +Signed-off-by: Benjamin Marzinski +Reviewed-by: Martin Wilck +--- + libmultipath/dict.c | 64 ++++++++++++++++++--------------------------- + 1 file changed, 25 insertions(+), 39 deletions(-) + +diff --git a/libmultipath/dict.c b/libmultipath/dict.c +index c534d703..1b75be47 100644 +--- a/libmultipath/dict.c ++++ b/libmultipath/dict.c +@@ -30,7 +30,7 @@ + #include "dict.h" + #include "strbuf.h" + +-static int ++static void + do_set_int(vector strvec, void *ptr, int min, int max, const char *file, + int line_nr, char *buff) + { +@@ -45,7 +45,7 @@ do_set_int(vector strvec, void *ptr, int min, int max, const char *file, + if (*buff == '\0' || *eptr != '\0') { + condlog(1, "%s line %d, invalid value for %s: \"%s\"", + file, line_nr, (char*)VECTOR_SLOT(strvec, 0), buff); +- return 1; ++ return; + } + if (res > max || res < min) { + res = (res > max) ? max : min; +@@ -54,7 +54,7 @@ do_set_int(vector strvec, void *ptr, int min, int max, const char *file, + (res == max)? "large" : "small", res); + } + *int_ptr = res; +- return 0; ++ return; + } + + static int +@@ -62,16 +62,15 @@ set_int(vector strvec, void *ptr, int min, int max, const char *file, + int line_nr) + { + char *buff; +- int rc; + + buff = set_value(strvec); + if (!buff) + return 1; + +- rc = do_set_int(strvec, ptr, min, max, file, line_nr, buff); ++ do_set_int(strvec, ptr, min, max, file, line_nr, buff); + + FREE(buff); +- return rc; ++ return 0; + } + + static int +@@ -80,7 +79,6 @@ set_uint(vector strvec, void *ptr, const char *file, int line_nr) + unsigned int *uint_ptr = (unsigned int *)ptr; + char *buff, *eptr, *p; + unsigned long res; +- int rc; + + buff = set_value(strvec); + if (!buff) +@@ -93,17 +91,14 @@ set_uint(vector strvec, void *ptr, const char *file, int line_nr) + if (eptr > buff) + while (isspace(*eptr)) + eptr++; +- if (*buff == '\0' || *eptr != '\0' || !isdigit(*p) || res > UINT_MAX) { ++ if (*buff == '\0' || *eptr != '\0' || !isdigit(*p) || res > UINT_MAX) + condlog(1, "%s line %d, invalid value for %s: \"%s\"", + file, line_nr, (char*)VECTOR_SLOT(strvec, 0), buff); +- rc = 1; +- } else { +- rc = 0; ++ else + *uint_ptr = res; +- } + + FREE(buff); +- return rc; ++ return 0; + } + + static int +@@ -954,7 +949,6 @@ declare_mp_attr_snprint(gid, print_gid) + static int + set_undef_off_zero(vector strvec, void *ptr, const char *file, int line_nr) + { +- int rc = 0; + char * buff; + int *int_ptr = (int *)ptr; + +@@ -964,11 +958,10 @@ set_undef_off_zero(vector strvec, void *ptr, const char *file, int line_nr) + + if (strcmp(buff, "off") == 0) + *int_ptr = UOZ_OFF; +- else +- rc = do_set_int(strvec, int_ptr, 0, INT_MAX, file, line_nr, +- buff); +- if (rc == 0 && *int_ptr == 0) ++ else if (strcmp(buff, "0") == 0) + *int_ptr = UOZ_ZERO; ++ else ++ do_set_int(strvec, int_ptr, 1, INT_MAX, file, line_nr, buff); + + FREE(buff); + return 0; +@@ -1114,28 +1107,24 @@ max_fds_handler(struct config *conf, vector strvec, const char *file, + int line_nr) + { + char * buff; +- int r = 0, max_fds; ++ int max_fds; + + buff = set_value(strvec); + + if (!buff) + return 1; + +- r = get_sys_max_fds(&max_fds); +- if (r) { +- /* Assume safe limit */ +- max_fds = 4096; +- } +- if (!strcmp(buff, "max")) { ++ if (get_sys_max_fds(&max_fds) != 0) ++ max_fds = 4096; /* Assume safe limit */ ++ if (!strcmp(buff, "max")) + conf->max_fds = max_fds; +- r = 0; +- } else +- r = do_set_int(strvec, &conf->max_fds, 0, max_fds, file, +- line_nr, buff); ++ else ++ do_set_int(strvec, &conf->max_fds, 0, max_fds, file, line_nr, ++ buff); + + FREE(buff); + +- return r; ++ return 0; + } + + static int +@@ -1201,7 +1190,6 @@ declare_mp_snprint(rr_weight, print_rr_weight) + static int + set_pgfailback(vector strvec, void *ptr, const char *file, int line_nr) + { +- int rc = 0; + int *int_ptr = (int *)ptr; + char * buff; + +@@ -1216,11 +1204,11 @@ set_pgfailback(vector strvec, void *ptr, const char *file, int line_nr) + else if (strlen(buff) == 10 && !strcmp(buff, "followover")) + *int_ptr = -FAILBACK_FOLLOWOVER; + else +- rc = do_set_int(strvec, ptr, 0, INT_MAX, file, line_nr, buff); ++ do_set_int(strvec, ptr, 0, INT_MAX, file, line_nr, buff); + + FREE(buff); + +- return rc; ++ return 0; + } + + int +@@ -1252,7 +1240,6 @@ declare_mp_snprint(pgfailback, print_pgfailback) + static int + no_path_retry_helper(vector strvec, void *ptr, const char *file, int line_nr) + { +- int rc = 0; + int *int_ptr = (int *)ptr; + char * buff; + +@@ -1265,10 +1252,10 @@ no_path_retry_helper(vector strvec, void *ptr, const char *file, int line_nr) + else if (!strcmp(buff, "queue")) + *int_ptr = NO_PATH_RETRY_QUEUE; + else +- rc = do_set_int(strvec, ptr, 1, INT_MAX, file, line_nr, buff); ++ do_set_int(strvec, ptr, 1, INT_MAX, file, line_nr, buff); + + FREE(buff); +- return rc; ++ return 0; + } + + int +@@ -1413,7 +1400,6 @@ snprint_mp_reservation_key (struct config *conf, struct strbuf *buff, + static int + set_off_int_undef(vector strvec, void *ptr, const char *file, int line_nr) + { +- int rc =0; + int *int_ptr = (int *)ptr; + char * buff; + +@@ -1424,10 +1410,10 @@ set_off_int_undef(vector strvec, void *ptr, const char *file, int line_nr) + if (!strcmp(buff, "no") || !strcmp(buff, "0")) + *int_ptr = NU_NO; + else +- rc = do_set_int(strvec, ptr, 1, INT_MAX, file, line_nr, buff); ++ do_set_int(strvec, ptr, 1, INT_MAX, file, line_nr, buff); + + FREE(buff); +- return rc; ++ return 0; + } + + int diff --git a/0024-multipathd-avoid-unnecessary-path-read-only-reloads.patch b/0024-multipathd-avoid-unnecessary-path-read-only-reloads.patch new file mode 100644 index 0000000..7bbe406 --- /dev/null +++ b/0024-multipathd-avoid-unnecessary-path-read-only-reloads.patch @@ -0,0 +1,129 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Mon, 15 Nov 2021 10:54:35 -0600 +Subject: [PATCH] multipathd: avoid unnecessary path read-only reloads + +A mulitpath device can only be reloaded read/write when all paths are +read/write. Also, whenever a read-only device is rescanned, the scsi +subsystem will first unconditionally issue a uevent with DISK_RO=0 +before checking the read-only status, and if it the device is still +read-only, issuing another uevent with DISK_RO=1. These uevents cause +pointless reloads when read-only paths are rescanned. To avoid this, +check to see if all paths are read/write before changing a multipath +device from read-only to read/write. + +Signed-off-by: Benjamin Marzinski +--- + libmultipath/libmultipath.version | 5 +++++ + libmultipath/sysfs.c | 22 ++++++++++++++++++++++ + libmultipath/sysfs.h | 1 + + multipathd/main.c | 31 ++++++++++++++++++++++++++++++- + 4 files changed, 58 insertions(+), 1 deletion(-) + +diff --git a/libmultipath/libmultipath.version b/libmultipath/libmultipath.version +index eb5b5b55..dd1b4122 100644 +--- a/libmultipath/libmultipath.version ++++ b/libmultipath/libmultipath.version +@@ -287,3 +287,8 @@ global: + local: + *; + }; ++ ++LIBMULTIPATH_9.1.0 { ++global: ++ sysfs_get_ro; ++} LIBMULTIPATH_9.0.0; +diff --git a/libmultipath/sysfs.c b/libmultipath/sysfs.c +index 9ff145f2..24c12b6a 100644 +--- a/libmultipath/sysfs.c ++++ b/libmultipath/sysfs.c +@@ -236,6 +236,28 @@ sysfs_get_size (struct path *pp, unsigned long long * size) + return 0; + } + ++int ++sysfs_get_ro (struct path *pp) ++{ ++ int ro; ++ char buff[3]; /* Either "0\n\0" or "1\n\0" */ ++ ++ if (!pp->udev) ++ return -1; ++ ++ if (sysfs_attr_get_value(pp->udev, "ro", buff, sizeof(buff)) <= 0) { ++ condlog(3, "%s: Cannot read ro attribute in sysfs", pp->dev); ++ return -1; ++ } ++ ++ if (sscanf(buff, "%d\n", &ro) != 1 || ro < 0 || ro > 1) { ++ condlog(3, "%s: Cannot parse ro attribute", pp->dev); ++ return -1; ++ } ++ ++ return ro; ++} ++ + int sysfs_check_holders(char * check_devt, char * new_devt) + { + unsigned int major, new_minor, table_minor; +diff --git a/libmultipath/sysfs.h b/libmultipath/sysfs.h +index 72b39ab2..c948c467 100644 +--- a/libmultipath/sysfs.h ++++ b/libmultipath/sysfs.h +@@ -13,6 +13,7 @@ ssize_t sysfs_attr_get_value(struct udev_device *dev, const char *attr_name, + ssize_t sysfs_bin_attr_get_value(struct udev_device *dev, const char *attr_name, + unsigned char * value, size_t value_len); + int sysfs_get_size (struct path *pp, unsigned long long * size); ++int sysfs_get_ro(struct path *pp); + int sysfs_check_holders(char * check_devt, char * new_devt); + bool sysfs_is_multipathed(struct path *pp, bool set_wwid); + #endif +diff --git a/multipathd/main.c b/multipathd/main.c +index 1defeaf1..6145e512 100644 +--- a/multipathd/main.c ++++ b/multipathd/main.c +@@ -1324,6 +1324,35 @@ fail: + return REMOVE_PATH_MAP_ERROR; + } + ++static bool ++needs_ro_update(struct multipath *mpp, int ro) ++{ ++ struct pathgroup * pgp; ++ struct path * pp; ++ unsigned int i, j; ++ struct dm_info *dmi = NULL; ++ ++ if (!mpp || ro < 0) ++ return false; ++ dm_get_info(mpp->alias, &dmi); ++ if (!dmi) /* assume we do need to reload the device */ ++ return true; ++ if (dmi->read_only == ro) { ++ free(dmi); ++ return false; ++ } ++ free(dmi); ++ if (ro == 1) ++ return true; ++ vector_foreach_slot (mpp->pg, pgp, i) { ++ vector_foreach_slot (pgp->paths, pp, j) { ++ if (sysfs_get_ro(pp) == 1) ++ return false; ++ } ++ } ++ return true; ++} ++ + static int + uev_update_path (struct uevent *uev, struct vectors * vecs) + { +@@ -1388,7 +1417,7 @@ uev_update_path (struct uevent *uev, struct vectors * vecs) + } + + ro = uevent_get_disk_ro(uev); +- if (mpp && ro >= 0) { ++ if (needs_ro_update(mpp, ro)) { + condlog(2, "%s: update path write_protect to '%d' (uevent)", uev->kernel, ro); + + if (mpp->wait_for_udev) diff --git a/0025-RH-fixup-udev-rules-for-redhat.patch b/0025-RH-fixup-udev-rules-for-redhat.patch new file mode 100644 index 0000000..df4455e --- /dev/null +++ b/0025-RH-fixup-udev-rules-for-redhat.patch @@ -0,0 +1,63 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Thu, 13 Apr 2017 07:22:23 -0500 +Subject: [PATCH] RH: fixup udev rules for redhat + +The multipath rules need to run after scsi_id is run. This means moving +them after 60-persistent-storage.rules for redhat. Redhat also uses a +different naming scheme for partitions than SuSE. + +Signed-off-by: Benjamin Marzinski +--- + Makefile.inc | 2 +- + kpartx/kpartx.rules | 2 +- + multipath/Makefile | 4 ++-- + 3 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/Makefile.inc b/Makefile.inc +index d0ec9b44..2a75dc9c 100644 +--- a/Makefile.inc ++++ b/Makefile.inc +@@ -55,7 +55,7 @@ endif + prefix = + exec_prefix = $(prefix) + usr_prefix = $(prefix) +-bindir = $(exec_prefix)/sbin ++bindir = $(exec_prefix)/usr/sbin + libudevdir = $(prefix)/$(SYSTEMDPATH)/udev + udevrulesdir = $(libudevdir)/rules.d + multipathdir = $(TOPDIR)/libmultipath +diff --git a/kpartx/kpartx.rules b/kpartx/kpartx.rules +index d7527d7d..0e0d70d5 100644 +--- a/kpartx/kpartx.rules ++++ b/kpartx/kpartx.rules +@@ -36,6 +36,6 @@ LABEL="mpath_kpartx_end" + GOTO="kpartx_end" + + LABEL="run_kpartx" +-RUN+="/sbin/kpartx -un -p -part /dev/$name" ++RUN+="/sbin/kpartx -un /dev/$name" + + LABEL="kpartx_end" +diff --git a/multipath/Makefile b/multipath/Makefile +index 0828a8f7..b9bbb3cf 100644 +--- a/multipath/Makefile ++++ b/multipath/Makefile +@@ -24,7 +24,7 @@ install: + $(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)/ + $(INSTALL_PROGRAM) -d $(DESTDIR)$(udevrulesdir) + $(INSTALL_PROGRAM) -m 644 11-dm-mpath.rules $(DESTDIR)$(udevrulesdir) +- $(INSTALL_PROGRAM) -m 644 $(EXEC).rules $(DESTDIR)$(libudevdir)/rules.d/56-multipath.rules ++ $(INSTALL_PROGRAM) -m 644 $(EXEC).rules $(DESTDIR)$(libudevdir)/rules.d/62-multipath.rules + $(INSTALL_PROGRAM) -d $(DESTDIR)$(man8dir) + $(INSTALL_PROGRAM) -m 644 $(EXEC).8.gz $(DESTDIR)$(man8dir) + $(INSTALL_PROGRAM) -d $(DESTDIR)$(man5dir) +@@ -33,7 +33,7 @@ install: + uninstall: + $(RM) $(DESTDIR)$(bindir)/$(EXEC) + $(RM) $(DESTDIR)$(udevrulesdir)/11-dm-mpath.rules +- $(RM) $(DESTDIR)$(libudevdir)/rules.d/56-multipath.rules ++ $(RM) $(DESTDIR)$(libudevdir)/rules.d/62-multipath.rules + $(RM) $(DESTDIR)$(man8dir)/$(EXEC).8.gz + $(RM) $(DESTDIR)$(man5dir)/$(EXEC).conf.5.gz + diff --git a/0002-RH-Remove-the-property-blacklist-exception-builtin.patch b/0026-RH-Remove-the-property-blacklist-exception-builtin.patch similarity index 77% rename from 0002-RH-Remove-the-property-blacklist-exception-builtin.patch rename to 0026-RH-Remove-the-property-blacklist-exception-builtin.patch index b8e580a..3bb4786 100644 --- a/0002-RH-Remove-the-property-blacklist-exception-builtin.patch +++ b/0026-RH-Remove-the-property-blacklist-exception-builtin.patch @@ -1,4 +1,4 @@ -From f7be16ac9fce97585a4552d49f3d3c54a93c9c17 Mon Sep 17 00:00:00 2001 +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Benjamin Marzinski Date: Wed, 2 Jul 2014 12:49:53 -0500 Subject: [PATCH] RH: Remove the property blacklist exception builtin @@ -13,25 +13,26 @@ it. Signed-off-by: Benjamin Marzinski --- - libmultipath/blacklist.c | 5 ++--- - multipath/multipath.conf.5.in | 11 ++++++----- - tests/blacklist.c | 7 ++----- - 3 files changed, 10 insertions(+), 13 deletions(-) + libmultipath/blacklist.c | 6 ++---- + multipath/multipath.conf.5 | 11 ++++++----- + tests/blacklist.c | 7 ++----- + 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/libmultipath/blacklist.c b/libmultipath/blacklist.c -index 17e1b54a..10d13e98 100644 +index 4e315c97..1e463ef6 100644 --- a/libmultipath/blacklist.c +++ b/libmultipath/blacklist.c -@@ -230,8 +230,6 @@ setup_default_blist (struct config * conf) - ORIGIN_DEFAULT)) - return 1; - } +@@ -202,9 +202,6 @@ setup_default_blist (struct config * conf) + if (store_ble(conf->blist_devnode, "!^(sd[a-z]|dasd[a-z]|nvme[0-9])", ORIGIN_DEFAULT)) + return 1; + - if (store_ble(conf->elist_property, "(SCSI_IDENT_|ID_WWN)", ORIGIN_DEFAULT)) - return 1; - +- vector_foreach_slot (conf->hwtable, hwe, i) { if (hwe->bl_product) { -@@ -438,7 +436,8 @@ filter_property(const struct config *conf, struct udev_device *udev, + if (find_blacklist_device(conf->blist_device, +@@ -410,7 +407,8 @@ filter_property(const struct config *conf, struct udev_device *udev, *uid_attribute != '\0'; bool uid_attr_seen = false; @@ -41,11 +42,11 @@ index 17e1b54a..10d13e98 100644 udev_list_entry_foreach(list_entry, udev_device_get_properties_list_entry(udev)) { -diff --git a/multipath/multipath.conf.5.in b/multipath/multipath.conf.5.in -index 3c9ae097..ba291e11 100644 ---- a/multipath/multipath.conf.5.in -+++ b/multipath/multipath.conf.5.in -@@ -1470,9 +1470,14 @@ keywords. Both are regular expressions. For a full description of these keywords +diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5 +index 88d2a1df..7f85f766 100644 +--- a/multipath/multipath.conf.5 ++++ b/multipath/multipath.conf.5 +@@ -1356,9 +1356,14 @@ keywords. Both are regular expressions. For a full description of these keywords Regular expression for an udev property. All devices that have matching udev properties will be excluded/included. The handling of the \fIproperty\fR keyword is special, @@ -61,7 +62,7 @@ index 3c9ae097..ba291e11 100644 . .RS .PP -@@ -1483,10 +1488,6 @@ Blacklisting by missing properties is only applied to devices which do have the +@@ -1369,10 +1374,6 @@ Blacklisting by missing properties is only applied to devices which do have the property specified by \fIuid_attribute\fR (e.g. \fIID_SERIAL\fR) set. Previously, it was applied to every device, possibly causing devices to be blacklisted because of temporary I/O error conditions. @@ -73,10 +74,10 @@ index 3c9ae097..ba291e11 100644 .TP .B protocol diff --git a/tests/blacklist.c b/tests/blacklist.c -index ab3da619..52ae03e0 100644 +index 882aa3a1..6a22b660 100644 --- a/tests/blacklist.c +++ b/tests/blacklist.c -@@ -371,9 +371,8 @@ static void test_property_missing(void **state) +@@ -375,9 +375,8 @@ static void test_property_missing(void **state) { static struct udev_device udev = { "sdb", { "ID_FOO", "ID_BAZ", "ID_BAR", "ID_SERIAL", NULL } }; conf.blist_property = blist_property_wwn; @@ -87,7 +88,7 @@ index ab3da619..52ae03e0 100644 assert_int_equal(filter_property(&conf, &udev, 3, "ID_BLAH"), MATCH_NOTHING); assert_int_equal(filter_property(&conf, &udev, 3, ""), -@@ -465,9 +464,7 @@ static void test_filter_path_missing1(void **state) +@@ -469,9 +468,7 @@ static void test_filter_path_missing1(void **state) conf.blist_device = blist_device_foo_bar; conf.blist_protocol = blist_protocol_fcp; conf.blist_wwid = blist_wwid_xyzzy; diff --git a/0027-RH-don-t-start-without-a-config-file.patch b/0027-RH-don-t-start-without-a-config-file.patch new file mode 100644 index 0000000..8061a99 --- /dev/null +++ b/0027-RH-don-t-start-without-a-config-file.patch @@ -0,0 +1,107 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Wed, 15 Oct 2014 10:39:30 -0500 +Subject: [PATCH] RH: don't start without a config file + +If /etc/multipath.conf doesn't exist, don't start multipathd and blacklist +all devices when running multipath. A completely blank configuration file +is almost never what users want. Also, people may have the multipath +packages installed but don't want to use them. This patch provides a +simple way to disable multipath. Simply removing or renaming +/etc/multipath.conf will keep multipath from doing anything. + +Signed-off-by: Benjamin Marzinski +--- + libmultipath/config.c | 13 +++++++++++++ + libmultipath/config.h | 1 + + multipath/multipath.rules | 1 + + multipathd/multipathd.8 | 2 ++ + multipathd/multipathd.service | 1 + + multipathd/multipathd.socket | 1 + + 6 files changed, 19 insertions(+) + +diff --git a/libmultipath/config.c b/libmultipath/config.c +index 30046a17..5f35c3d3 100644 +--- a/libmultipath/config.c ++++ b/libmultipath/config.c +@@ -895,6 +895,19 @@ int _init_config (const char *file, struct config *conf) + goto out; + } + factorize_hwtable(conf->hwtable, builtin_hwtable_size, file); ++ } else { ++ condlog(0, "/etc/multipath.conf does not exist, blacklisting all devices."); ++ if (conf->blist_devnode == NULL) { ++ conf->blist_devnode = vector_alloc(); ++ if (!conf->blist_devnode) { ++ condlog(0, "cannot allocate blacklist\n"); ++ goto out; ++ } ++ } ++ if (store_ble(conf->blist_devnode, ".*", ORIGIN_NO_CONFIG)) { ++ condlog(0, "cannot store default no-config blacklist\n"); ++ goto out; ++ } + } + + conf->processed_main_config = 1; +diff --git a/libmultipath/config.h b/libmultipath/config.h +index 933fe0d1..5f01c1fc 100644 +--- a/libmultipath/config.h ++++ b/libmultipath/config.h +@@ -9,6 +9,7 @@ + + #define ORIGIN_DEFAULT 0 + #define ORIGIN_CONFIG 1 ++#define ORIGIN_NO_CONFIG 2 + + enum devtypes { + DEV_NONE, +diff --git a/multipath/multipath.rules b/multipath/multipath.rules +index 9df11a95..0486bf70 100644 +--- a/multipath/multipath.rules ++++ b/multipath/multipath.rules +@@ -9,6 +9,7 @@ IMPORT{cmdline}="nompath" + ENV{nompath}=="?*", GOTO="end_mpath" + IMPORT{cmdline}="multipath" + ENV{multipath}=="off", GOTO="end_mpath" ++TEST!="/etc/multipath.conf", GOTO="end_mpath" + + ENV{DEVTYPE}!="partition", GOTO="test_dev" + IMPORT{parent}="DM_MULTIPATH_DEVICE_PATH" +diff --git a/multipathd/multipathd.8 b/multipathd/multipathd.8 +index 048a838d..8bd47a80 100644 +--- a/multipathd/multipathd.8 ++++ b/multipathd/multipathd.8 +@@ -39,6 +39,8 @@ map regains its maximum performance and redundancy. + This daemon executes the external \fBmultipath\fR tool when events occur. + In turn, the multipath tool signals the multipathd daemon when it is done with + devmap reconfiguration, so that it can refresh its failed path list. ++ ++In this Linux distribution, multipathd does not run unless a /etc/multipath.conf file exists. + . + . + .\" ---------------------------------------------------------------------------- +diff --git a/multipathd/multipathd.service b/multipathd/multipathd.service +index 0b2ac814..6d57c7e8 100644 +--- a/multipathd/multipathd.service ++++ b/multipathd/multipathd.service +@@ -4,6 +4,7 @@ Wants=systemd-udev-trigger.service systemd-udev-settle.service + Before=iscsi.service iscsid.service lvm2-activation-early.service + Before=local-fs-pre.target blk-availability.service shutdown.target + After=multipathd.socket systemd-udev-trigger.service systemd-udev-settle.service ++ConditionPathExists=/etc/multipath.conf + DefaultDependencies=no + Conflicts=shutdown.target + ConditionKernelCommandLine=!nompath +diff --git a/multipathd/multipathd.socket b/multipathd/multipathd.socket +index c777e5e3..3c20a2ff 100644 +--- a/multipathd/multipathd.socket ++++ b/multipathd/multipathd.socket +@@ -1,6 +1,7 @@ + [Unit] + Description=multipathd control socket + DefaultDependencies=no ++ConditionPathExists=/etc/multipath.conf + ConditionKernelCommandLine=!nompath + ConditionKernelCommandLine=!multipath=off + ConditionVirtualization=!container diff --git a/0004-RH-Fix-nvme-function-missing-argument.patch b/0028-RH-Fix-nvme-function-missing-argument.patch similarity index 84% rename from 0004-RH-Fix-nvme-function-missing-argument.patch rename to 0028-RH-Fix-nvme-function-missing-argument.patch index 33a8d5f..ced7159 100644 --- a/0004-RH-Fix-nvme-function-missing-argument.patch +++ b/0028-RH-Fix-nvme-function-missing-argument.patch @@ -1,4 +1,4 @@ -From 283b5dd645663a2cf16f2813581772d7a84db6ad Mon Sep 17 00:00:00 2001 +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Benjamin Marzinski Date: Fri, 25 Jan 2019 14:54:56 -0600 Subject: [PATCH] RH: Fix nvme function missing argument @@ -12,10 +12,10 @@ Signed-off-by: Benjamin Marzinski 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmultipath/nvme/argconfig.h b/libmultipath/nvme/argconfig.h -index b3caa7be..f91504c9 100644 +index adb192b6..bfd10ef8 100644 --- a/libmultipath/nvme/argconfig.h +++ b/libmultipath/nvme/argconfig.h -@@ -63,7 +63,7 @@ struct argconfig_commandline_options { +@@ -76,7 +76,7 @@ struct argconfig_commandline_options { extern "C" { #endif diff --git a/0029-RH-use-rpm-optflags-if-present.patch b/0029-RH-use-rpm-optflags-if-present.patch new file mode 100644 index 0000000..a1c081c --- /dev/null +++ b/0029-RH-use-rpm-optflags-if-present.patch @@ -0,0 +1,66 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Wed, 19 Apr 2017 06:10:01 -0500 +Subject: [PATCH] RH: use rpm optflags if present + +Use the passed in optflags when compiling as an RPM, and keep the +default flags as close as possible to the current fedora flags, while +still being generic. + +Signed-off-by: Benjamin Marzinski +--- + Makefile.inc | 26 +++++++++++++++++++------- + 1 file changed, 19 insertions(+), 7 deletions(-) + +diff --git a/Makefile.inc b/Makefile.inc +index 2a75dc9c..5ac660de 100644 +--- a/Makefile.inc ++++ b/Makefile.inc +@@ -92,23 +92,35 @@ TEST_CC_OPTION = $(shell \ + echo "$(2)"; \ + fi) + +-STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector) + ERROR_DISCARDED_QUALIFIERS := $(call TEST_CC_OPTION,-Werror=discarded-qualifiers,) + WNOCLOBBERED := $(call TEST_CC_OPTION,-Wno-clobbered -Wno-error=clobbered,) + WFORMATOVERFLOW := $(call TEST_CC_OPTION,-Wformat-overflow=2,) + +-OPTFLAGS := -O2 -g $(STACKPROT) --param=ssp-buffer-size=4 +-WARNFLAGS := -Werror -Wall -Wextra -Wformat=2 $(WFORMATOVERFLOW) -Werror=implicit-int \ ++ifndef RPM_OPT_FLAGS ++ STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector) ++ OPTFLAGS := -O2 -g -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions \ ++ $(STACKPROT) -grecord-gcc-switches \ ++ -fasynchronous-unwind-tables --param=ssp-buffer-size=4 ++ ifeq ($(shell test -f /usr/lib/rpm/redhat/redhat-hardened-cc1 && echo 1),1) ++ OPTFLAGS += -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 ++ endif ++ ifeq ($(shell test -f /usr/lib/rpm/redhat/redhat-annobin-cc1 && echo 1),1) ++ OPTFLAGS += -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 ++ endif ++else ++ OPTFLAGS := $(RPM_OPT_FLAGS) --param=ssp-buffer-size=4 ++endif ++WARNFLAGS := -Werror -Wextra -Wformat=2 $(WFORMATOVERFLOW) -Werror=implicit-int \ + -Werror=implicit-function-declaration -Werror=format-security \ +- $(WNOCLOBBERED) -Werror=cast-qual $(ERROR_DISCARDED_QUALIFIERS) +-CPPFLAGS := -Wp,-D_FORTIFY_SOURCE=2 ++ $(WNOCLOBBERED) -Werror=cast-qual $(ERROR_DISCARDED_QUALIFIERS) \ ++ -Wstrict-prototypes + CFLAGS := --std=gnu99 $(CFLAGS) $(OPTFLAGS) $(WARNFLAGS) -pipe \ + -DBIN_DIR=\"$(bindir)\" -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" \ + -MMD -MP + BIN_CFLAGS = -fPIE -DPIE + LIB_CFLAGS = -fPIC + SHARED_FLAGS = -shared +-LDFLAGS := $(LDFLAGS) -Wl,-z,relro -Wl,-z,now -Wl,-z,defs ++LDFLAGS := $(LDFLAGS) $(RPM_LD_FLAGS) -Wl,-z,relro -Wl,-z,now -Wl,-z,defs + BIN_LDFLAGS = -pie + + # Check whether a function with name $1 has been declared in header file $2. +@@ -139,4 +151,4 @@ check_file = $(shell \ + + %.o: %.c + @echo building $@ because of $? +- $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< ++ $(CC) $(CFLAGS) -c -o $@ $< diff --git a/0006-RH-add-mpathconf.patch b/0030-RH-add-mpathconf.patch similarity index 73% rename from 0006-RH-add-mpathconf.patch rename to 0030-RH-add-mpathconf.patch index 46f1126..aaa4150 100644 --- a/0006-RH-add-mpathconf.patch +++ b/0030-RH-add-mpathconf.patch @@ -1,4 +1,4 @@ -From 29e5c6d6e2177e73d1be2ed2af66c1007487bf60 Mon Sep 17 00:00:00 2001 +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Benjamin Marzinski Date: Thu, 16 Oct 2014 15:49:01 -0500 Subject: [PATCH] RH: add mpathconf @@ -10,48 +10,22 @@ command line. But, mostly it is used to get a multipath.conf file with the OS defaults, and to enable and disable multipathing via a single command. -Co-authored-by: Paul Donohue Signed-off-by: Benjamin Marzinski --- - .github/actions/spelling/expect.txt | 3 + - libmultipath/config.c | 2 + - multipath/Makefile | 4 + - multipath/mpathconf | 658 ++++++++++++++++++++++++++++ - multipath/mpathconf.8 | 151 +++++++ - 5 files changed, 818 insertions(+) + libmultipath/config.c | 2 + + multipath/Makefile | 5 + + multipath/mpathconf | 564 ++++++++++++++++++++++++++++++++++++++++++ + multipath/mpathconf.8 | 135 ++++++++++ + 4 files changed, 706 insertions(+) create mode 100644 multipath/mpathconf create mode 100644 multipath/mpathconf.8 -diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt -index a5856bcc..5c9113ba 100644 ---- a/.github/actions/spelling/expect.txt -+++ b/.github/actions/spelling/expect.txt -@@ -131,9 +131,11 @@ Marzinski - misdetection - mpath - mpathb -+mpathconf - mpathpersist - mpathvalid - msecs -+multipathable - multipathc - multipathd - multipathed -@@ -154,6 +156,7 @@ ontap - OOM - opensvc - OPTFLAGS -+outfile - paramp - partx - pathgroup diff --git a/libmultipath/config.c b/libmultipath/config.c -index b8317f4d..0bbaa981 100644 +index 5f35c3d3..cee3bbb7 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c -@@ -939,6 +939,8 @@ int init_config__ (const char *file, struct config *conf) - validate_pctable(conf->overrides, 0, file); +@@ -897,6 +897,8 @@ int _init_config (const char *file, struct config *conf) + factorize_hwtable(conf->hwtable, builtin_hwtable_size, file); } else { condlog(0, "/etc/multipath.conf does not exist, blacklisting all devices."); + condlog(0, "You can run \"/sbin/mpathconf --enable\" to create"); @@ -60,46 +34,45 @@ index b8317f4d..0bbaa981 100644 conf->blist_devnode = vector_alloc(); if (!conf->blist_devnode) { diff --git a/multipath/Makefile b/multipath/Makefile -index 2ea9e528..3dc241cc 100644 +index b9bbb3cf..e720c7f6 100644 --- a/multipath/Makefile +++ b/multipath/Makefile -@@ -24,6 +24,7 @@ $(EXEC): $(OBJS) $(multipathdir)/libmultipath.so $(mpathcmddir)/libmpathcmd.so +@@ -18,10 +18,12 @@ $(EXEC): $(OBJS) $(multipathdir)/libmultipath.so $(mpathcmddir)/libmpathcmd.so + $(CC) $(CFLAGS) $(OBJS) -o $(EXEC) $(LDFLAGS) $(LIBDEPS) + $(GZIP) $(EXEC).8 > $(EXEC).8.gz + $(GZIP) $(EXEC).conf.5 > $(EXEC).conf.5.gz ++ $(GZIP) mpathconf.8 > mpathconf.8.gz + install: - $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir) - $(Q)$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)/ -+ $(Q)$(INSTALL_PROGRAM) -m 755 mpathconf $(DESTDIR)$(bindir)/ - $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(udevrulesdir) - $(Q)$(INSTALL_PROGRAM) -m 644 11-dm-mpath.rules $(DESTDIR)$(udevrulesdir) - $(Q)$(INSTALL_PROGRAM) -m 644 99-z-dm-mpath-late.rules $(DESTDIR)$(udevrulesdir) -@@ -32,6 +33,7 @@ install: - $(Q)$(INSTALL_PROGRAM) -m 644 tmpfiles.conf $(DESTDIR)$(tmpfilesdir)/multipath.conf - $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(mandir)/man8 - $(Q)$(INSTALL_PROGRAM) -m 644 $(EXEC).8 $(DESTDIR)$(mandir)/man8 -+ $(Q)$(INSTALL_PROGRAM) -m 644 mpathconf.8 $(DESTDIR)$(mandir)/man8 - $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(mandir)/man5 - $(Q)$(INSTALL_PROGRAM) -m 644 $(EXEC).conf.5 $(DESTDIR)$(mandir)/man5 - $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(modulesloaddir) -@@ -46,12 +48,14 @@ endif + $(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir) + $(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)/ ++ $(INSTALL_PROGRAM) -m 755 mpathconf $(DESTDIR)$(bindir)/ + $(INSTALL_PROGRAM) -d $(DESTDIR)$(udevrulesdir) + $(INSTALL_PROGRAM) -m 644 11-dm-mpath.rules $(DESTDIR)$(udevrulesdir) + $(INSTALL_PROGRAM) -m 644 $(EXEC).rules $(DESTDIR)$(libudevdir)/rules.d/62-multipath.rules +@@ -29,13 +31,16 @@ install: + $(INSTALL_PROGRAM) -m 644 $(EXEC).8.gz $(DESTDIR)$(man8dir) + $(INSTALL_PROGRAM) -d $(DESTDIR)$(man5dir) + $(INSTALL_PROGRAM) -m 644 $(EXEC).conf.5.gz $(DESTDIR)$(man5dir) ++ $(INSTALL_PROGRAM) -m 644 mpathconf.8.gz $(DESTDIR)$(man8dir) uninstall: - $(Q)$(RM) $(DESTDIR)$(bindir)/$(EXEC) -+ $(Q)$(RM) $(DESTDIR)$(bindir)/mpathconf - $(Q)$(RM) $(DESTDIR)$(udevrulesdir)/11-dm-mpath.rules - $(Q)$(RM) $(DESTDIR)$(udevrulesdir)/99-z-dm-mpath-late.rules - $(Q)$(RM) $(DESTDIR)$(modulesloaddir)/multipath.conf - $(Q)$(RM) $(DESTDIR)$(modulesloaddir)/scsi_dh.conf - $(Q)$(RM) $(DESTDIR)$(libudevdir)/rules.d/62-multipath.rules - $(Q)$(RM) $(DESTDIR)$(mandir)/man8/$(EXEC).8 -+ $(Q)$(RM) $(DESTDIR)$(mandir)/man8/mpathconf.8 - $(Q)$(RM) $(DESTDIR)$(mandir)/man5/$(EXEC).conf.5 - $(Q)$(RM) $(DESTDIR)$(tmpfilesdir)/multipath.conf + $(RM) $(DESTDIR)$(bindir)/$(EXEC) + $(RM) $(DESTDIR)$(udevrulesdir)/11-dm-mpath.rules + $(RM) $(DESTDIR)$(libudevdir)/rules.d/62-multipath.rules ++ $(RM) $(DESTDIR)$(bindir)/mpathconf + $(RM) $(DESTDIR)$(man8dir)/$(EXEC).8.gz + $(RM) $(DESTDIR)$(man5dir)/$(EXEC).conf.5.gz ++ $(RM) $(DESTDIR)$(man8dir)/mpathconf.8.gz + clean: dep_clean + $(RM) core *.o $(EXEC) *.gz diff --git a/multipath/mpathconf b/multipath/mpathconf new file mode 100644 -index 00000000..ce430075 +index 00000000..0de6b121 --- /dev/null +++ b/multipath/mpathconf -@@ -0,0 +1,658 @@ +@@ -0,0 +1,564 @@ +#!/bin/bash +# +# Copyright (C) 2010 Red Hat, Inc. All rights reserved. @@ -119,7 +92,7 @@ index 00000000..ce430075 +# This program was largely ripped off from lvmconf +# + -+unset ENABLE FIND FRIENDLY PROPERTY FOREIGN MODULE MULTIPATHD HAVE_DISABLE HAVE_WWID_DISABLE HAVE_FIND HAVE_BLACKLIST HAVE_EXCEPTIONS HAVE_DEFAULTS HAVE_FRIENDLY HAVE_PROPERTY HAVE_FOREIGN HAVE_MULTIPATHD HAVE_MODULE HAVE_OUTFILE SHOW_STATUS CHANGED_CONFIG WWID_LIST HAVE_OPTION OPTION_NAME OPTION_VALUE HAVE_RECHECK_WWID RECHECK_WWID ++unset ENABLE FIND FRIENDLY PROPERTY FOREIGN MODULE MULTIPATHD HAVE_DISABLE HAVE_WWID_DISABLE HAVE_FIND HAVE_BLACKLIST HAVE_EXCEPTIONS HAVE_DEFAULTS HAVE_FRIENDLY HAVE_PROPERTY HAVE_FOREIGN HAVE_MULTIPATHD HAVE_MODULE HAVE_OUTFILE SHOW_STATUS CHANGED_CONFIG WWID_LIST + +DEFAULT_CONFIG="# device-mapper-multipath configuration file + @@ -133,7 +106,7 @@ index 00000000..ce430075 + +defaults { + user_friendly_names yes -+ find_multipaths on ++ find_multipaths yes +}" + +CONFIGFILE="/etc/multipath.conf" @@ -151,11 +124,9 @@ index 00000000..ce430075 + echo "Disable: --disable" + echo "Only allow certain wwids (instead of enable): --allow " + echo "Set user_friendly_names (Default y): --user_friendly_names " -+ echo "Set find_multipaths (Default on): --find_multipaths " ++ echo "Set find_multipaths (Default y): --find_multipaths " + echo "Set default property blacklist (Default n): --property_blacklist " + echo "Set enable_foreign to show foreign devices (Default n): --enable_foreign " -+ echo "Set recheck_wwid (Defaut n): --recheck_wwid " -+ echo "Add/Change/Remove option in defaults section: --option :" + echo "Load the dm-multipath modules on enable (Default y): --with_module " + echo "start/stop/reload multipathd (Default n): --with_multipathd " + echo "select output file (Default /etc/multipath.conf): --outfile " @@ -248,15 +219,6 @@ index 00000000..ce430075 + exit 1 + fi + ;; -+ --recheck_wwid) -+ if [ -n "$2" ]; then -+ RECHECK_WWID=$2 -+ shift 2 -+ else -+ usage -+ exit 1 -+ fi -+ ;; + --find_multipaths) + if [ -n "$2" ]; then + FIND=$2 @@ -275,20 +237,6 @@ index 00000000..ce430075 + exit 1 + fi + ;; -+ --option) -+ if [ -n "$2" ]; then -+ OPTION_NAME=$(echo $2 | cut -s -f1 -d:) -+ OPTION_VALUE=$(echo $2 | cut -s -f2 -d:) -+ if [ -z "$OPTION_NAME" ]; then -+ usage -+ exit 1 -+ fi -+ shift 2 -+ else -+ usage -+ exit 1 -+ fi -+ ;; + --enable_foreign) + if [ -n "$2" ]; then + FOREIGN=$2 @@ -335,31 +283,23 @@ index 00000000..ce430075 + +function validate_args +{ -+ if [ "$ENABLE" = "0" ] && [ -n "$FRIENDLY" -o -n "$FIND" -o -n "$PROPERTY" -o -n "$MODULE" -o -n "$FOREIGN" -o -n "$OPTION_NAME" -o -n "$RECHECK_WWID" ]; then ++ if [ "$ENABLE" = "0" ] && [ -n "$FRIENDLY" -o -n "$FIND" -o -n "$PROPERTY" -o -n "$MODULE" ]; then + echo "ignoring extra parameters on disable" + FRIENDLY="" + FIND="" + PROPERTY="" + MODULE="" -+ FOREIGN="" -+ OPTION_NAME="" -+ OPTION_VALUE="" -+ RECHECK_WWID="" + fi + if [ -n "$FRIENDLY" ] && [ "$FRIENDLY" != "y" -a "$FRIENDLY" != "n" ]; then + echo "--user_friendly_names must be either 'y' or 'n'" + exit 1 + fi -+ if [ -n "$RECHECK_WWID" ] && [ "$RECHECK_WWID" != "y" -a "$RECHECK_WWID" != "n" ]; then -+ echo "--recheck_wwid must be either 'y' or 'n'" -+ exit 1 -+ fi + if [ "$FIND" = "y" ]; then -+ FIND="on" ++ FIND="yes" + elif [ "$FIND" = "n" ]; then -+ FIND="off" -+ elif [ -n "$FIND" ] && [ "$FIND" != "on" -a "$FIND" != "yes" -a "$FIND" != "off" -a "$FIND" != "no" -a "$FIND" != "strict" -a "$FIND" != "greedy" -a "$FIND" != "smart" ]; then -+ echo "--find_multipaths must be one of 'on' 'yes' 'y' 'off' 'no' 'n' 'strict' 'greedy' or 'smart'" ++ FIND="no" ++ elif [ -n "$FIND" ] && [ "$FIND" != "yes" -a "$FIND" != "no" -a "$FIND" != "strict" -a "$FIND" != "greedy" -a "$FIND" != "smart" ]; then ++ echo "--find_multipaths must be one of 'yes' 'no' 'strict' 'greedy' or 'smart'" + exit 1 + fi + if [ -n "$PROPERTY" ] && [ "$PROPERTY" != "y" -a "$PROPERTY" != "n" ]; then @@ -370,19 +310,7 @@ index 00000000..ce430075 + echo "--enable_foreign must be either 'y' or 'n'" + exit 1 + fi -+ if [ -n "$OPTION_NAME" ]; then -+ if [[ $OPTION_NAME =~ [[:space:]]|#|\"|!|\{|\} ]]; then -+ echo "--option name \"$OPTION_NAME\" is invalid" -+ exit 1 -+ elif [[ $OPTION_VALUE =~ \"|#|!|\{|\} ]]; then -+ echo "--option value \"$OPTION_VALUE\" is invalid" -+ exit 1 -+ fi -+ if [[ $OPTION_VALUE =~ [[:space:]] ]]; then -+ OPTION_VALUE=\"$OPTION_VALUE\" -+ fi -+ fi -+ if [ -z "$ENABLE" -a -z "$FIND" -a -z "$FRIENDLY" -a -z "$PROPERTY" -a -z "$FOREIGN" -a -z "$OPTION_NAME" -a -z "$RECHECK_WWID" ]; then ++ if [ -z "$ENABLE" -a -z "$FIND" -a -z "$FRIENDLY" -a -z "$PROPERTY" -a -z "$FOREIGN" ]; then + SHOW_STATUS=1 + fi + if [ -n "$MODULE" ] && [ "$MODULE" != "y" -a "$MODULE" != "n" ]; then @@ -484,11 +412,6 @@ index 00000000..ce430075 + elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*user_friendly_names[[:space:]][[:space:]]*\(no\|0\)" ; then + HAVE_FRIENDLY=0 + fi -+ if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*recheck_wwid[[:space:]][[:space:]]*\(yes\|1\)" ; then -+ HAVE_RECHECK_WWID=1 -+ elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*recheck_wwid[[:space:]][[:space:]]*\(no\|0\)" ; then -+ HAVE_RECHECK_WWID=0 -+ fi + if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[[:space:]]*enable_foreign" ; then + HAVE_FOREIGN=0 + elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*enable_foreign[[:space:]][[:space:]]*\"\.\*\"" ; then @@ -500,13 +423,6 @@ index 00000000..ce430075 + elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*enable_foreign" ; then + HAVE_FOREIGN=3 + fi -+ if [ -n "$OPTION_NAME" ]; then -+ if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q '^[[:space:]]*'"$OPTION_NAME"'[[:space:]][[:space:]]*'"$OPTION_VALUE" ; then -+ HAVE_OPTION=1 -+ elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q '^[[:space:]]*'"$OPTION_NAME"'\([[:space:]].*\)\?$' ; then -+ HAVE_OPTION=0 -+ fi -+ fi +fi + +if [ "$HAVE_EXCEPTIONS" = "1" ]; then @@ -524,7 +440,7 @@ index 00000000..ce430075 + echo "multipath is disabled" + fi + if [ -z "$HAVE_FIND" ]; then -+ echo "find_multipaths is off" ++ echo "find_multipaths is no" + else + echo "find_multipaths is $HAVE_FIND" + fi @@ -533,11 +449,6 @@ index 00000000..ce430075 + else + echo "user_friendly_names is enabled" + fi -+ if [ -z "$HAVE_RECHECK_WWID" -o "$HAVE_RECHECK_WWID" = 0 ]; then -+ echo "recheck_wwid is disabled" -+ else -+ echo "recheck_wwid is enabled" -+ fi + if [ -z "$HAVE_PROPERTY" -o "$HAVE_PROPERTY" = 0 ]; then + echo "default property blacklist is disabled" + else @@ -654,23 +565,6 @@ index 00000000..ce430075 + fi +fi + -+if [ "$RECHECK_WWID" = "n" ]; then -+ if [ "$HAVE_RECHECK_WWID" = 1 ]; then -+ sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*recheck_wwid[[:space:]][[:space:]]*\(yes\|1\)/ recheck_wwid no/' $TMPFILE -+ CHANGED_CONFIG=1 -+ fi -+elif [ "$RECHECK_WWID" = "y" ]; then -+ if [ -z "$HAVE_RECHECK_WWID" ]; then -+ sed -i '/^defaults[[:space:]]*{/ a\ -+ recheck_wwid yes -+' $TMPFILE -+ CHANGED_CONFIG=1 -+ elif [ "$HAVE_RECHECK_WWID" = 0 ]; then -+ sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*recheck_wwid[[:space:]][[:space:]]*\(no\|0\)/ recheck_wwid yes/' $TMPFILE -+ CHANGED_CONFIG=1 -+ fi -+fi -+ +if [ "$PROPERTY" = "n" ]; then + if [ "$HAVE_PROPERTY" = 1 ]; then + sed -i '/^blacklist_exceptions[[:space:]]*{/,/^}/ s/^[[:space:]]*property[[:space:]][[:space:]]*\"(SCSI_IDENT_|ID_WWN)\"/# property \"(SCSI_IDENT_|ID_WWN)\"/' $TMPFILE @@ -713,21 +607,6 @@ index 00000000..ce430075 + fi +fi + -+if [ -n "$OPTION_NAME" -a -n "$OPTION_VALUE" ]; then -+ if [ -z "$HAVE_OPTION" ]; then -+ sed -i '/^defaults[[:space:]]*{/ a\ -+ '"$OPTION_NAME"' '"$OPTION_VALUE"' -+' $TMPFILE -+ CHANGED_CONFIG=1 -+ elif [ "$HAVE_OPTION" = 0 ]; then -+ sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*'"$OPTION_NAME"'\([[:space:]].*\)\?$/ '"$OPTION_NAME"' '"$OPTION_VALUE"'/' $TMPFILE -+ CHANGED_CONFIG=1 -+ fi -+elif [ -n "$OPTION_NAME" -a -n "$HAVE_OPTION" ]; then -+ sed -i '/^defaults[[:space:]]*{/,/^}/{/^[[:space:]]*'"$OPTION_NAME"'\([[:space:]].*\)\?$/d}' $TMPFILE -+ CHANGED_CONFIG=1 -+fi -+ +if [ -f "$OUTPUTFILE" ]; then + cp $OUTPUTFILE $OUTPUTFILE.old + if [ $? != 0 ]; then @@ -760,10 +639,10 @@ index 00000000..ce430075 +fi diff --git a/multipath/mpathconf.8 b/multipath/mpathconf.8 new file mode 100644 -index 00000000..ec4e5c56 +index 00000000..a14d831e --- /dev/null +++ b/multipath/mpathconf.8 -@@ -0,0 +1,151 @@ +@@ -0,0 +1,135 @@ +.TH MPATHCONF 8 "June 2010" "" "Linux Administrator's Manual" +.SH NAME +mpathconf - A tool for configuring device-mapper-multipath @@ -806,10 +685,10 @@ index 00000000..ec4e5c56 +.B user_friendly_names +set and +.B find_multipaths -+set to \fBon\fP. To disable these, use the ++set to \fByes\fP. To disable these, use the +.B --user_friendly_names n +and -+.B --find_multipaths off ++.B --find_multipaths n +options +.SH COMMANDS +.TP @@ -843,16 +722,7 @@ index 00000000..ec4e5c56 +defaults section. If set to \fBn\fP, this removes the line, if present. This +command can be used along with any other command. +.TP -+.B --recheck_wwid \fP { \fBy\fP | \fBn\fP } -+If set to \fBy\fP, this adds the line -+.B recheck_wwid yes -+to the -+.B /etc/multipath.conf -+defaults section, or sets an existing line to \fByes\fP. If set to \fBn\fP, this -+sets an existing \fBrecheck_wwid\fP line to \fBno\fP. This command can be used -+along with any other command. -+.TP -+.B --find_multipaths\fP { \fBon\fP | \fByes\fP | \fBy\fP | \fBoff\fP | \fBno\fP | \fBn\fP | \fBstrict\fP | \fBgreedy\fP | \fBsmart\fP } ++.B --find_multipaths\fP { \fByes\fP | \fBno\fP | \fBstrict\fP | \fBgreedy\fP | \fBsmart\fP } +If set to \fB\fP, this adds the line +.B find_multipaths +to the @@ -876,13 +746,6 @@ index 00000000..ec4e5c56 +defaults section. if set to \fBn\fP, this removes the line, if present. This +command can be used along with any other command. +.TP -+.B --option \fB:[]\fP -+Sets the defaults section option \fB\fP to \fB\fP. If the -+option was not previously set in the defaults section, it is added. If it was -+set, its value is changed to \fB\fP. If \fB\fP is left blank, -+then the option is removed from the defaults section, if was set there. This -+command can be used along with any other command. -+.TP +.B --outfile \fB\fP +Write the resulting multipath configuration to \fB\fP instead of +\fB/etc/multipath.conf\fP. @@ -902,7 +765,7 @@ index 00000000..ec4e5c56 +.B service multipathd stop +to stop the multipathd daemon on \fB--disable\fP, and +.B service multipathd reload -+to reconfigure multipathd on \fB--user_friendly_names\fP and ++to reconfigure multipathd on \fB--user_frindly_names\fP and +\fB--find_multipaths\fP. +This option is set to \fBn\fP by default. +.SH FILES diff --git a/0007-RH-add-wwids-from-kernel-cmdline-mpath.wwids-with-A.patch b/0031-RH-add-wwids-from-kernel-cmdline-mpath.wwids-with-A.patch similarity index 72% rename from 0007-RH-add-wwids-from-kernel-cmdline-mpath.wwids-with-A.patch rename to 0031-RH-add-wwids-from-kernel-cmdline-mpath.wwids-with-A.patch index cef8b56..3ce47ac 100644 --- a/0007-RH-add-wwids-from-kernel-cmdline-mpath.wwids-with-A.patch +++ b/0031-RH-add-wwids-from-kernel-cmdline-mpath.wwids-with-A.patch @@ -1,4 +1,4 @@ -From d6ad888bad3850bb0a342ebcdc9fd78773eb3b2a Mon Sep 17 00:00:00 2001 +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Benjamin Marzinski Date: Fri, 17 Oct 2014 11:20:34 -0500 Subject: [PATCH] RH: add wwids from kernel cmdline mpath.wwids with -A @@ -14,16 +14,16 @@ multipathd.service Signed-off-by: Benjamin Marzinski --- - multipath/main.c | 54 ++++++++++++++++++++++++++++++-- - multipath/multipath.8.in | 7 ++++- - multipathd/multipathd.service.in | 1 + + multipath/main.c | 54 +++++++++++++++++++++++++++++++++-- + multipath/multipath.8 | 7 ++++- + multipathd/multipathd.service | 1 + 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/multipath/main.c b/multipath/main.c -index 31012874..a667c2ee 100644 +index b2d300e5..80fa68e5 100644 --- a/multipath/main.c +++ b/multipath/main.c -@@ -111,7 +111,7 @@ usage (char * progname) +@@ -122,7 +122,7 @@ usage (char * progname) fprintf (stderr, " %s [-v level] [-R retries] -F\n", progname); fprintf (stderr, " %s [-v level] [-l|-ll] [device]\n", progname); fprintf (stderr, " %s [-v level] [-a|-w] device\n", progname); @@ -32,7 +32,7 @@ index 31012874..a667c2ee 100644 fprintf (stderr, " %s [-v level] [-i] [-c|-C] device\n", progname); fprintf (stderr, " %s [-v level] [-i] [-u|-U]\n", progname); fprintf (stderr, " %s [-h|-t|-T]\n", progname); -@@ -125,6 +125,8 @@ usage (char * progname) +@@ -136,6 +136,8 @@ usage (char * progname) " -f flush a multipath device map\n" " -F flush all multipath device maps\n" " -a add a device wwid to the wwids file\n" @@ -41,7 +41,7 @@ index 31012874..a667c2ee 100644 " -c check if a device should be a path in a multipath device\n" " -C check if a multipath device has usable paths\n" " -q allow queue_if_no_path when multipathd is not running\n" -@@ -440,6 +442,50 @@ static void cleanup_vecs(void) +@@ -450,6 +452,50 @@ static void cleanup_vecs(void) free_pathvec(vecs.pathvec, FREE_PATHS); } @@ -92,16 +92,16 @@ index 31012874..a667c2ee 100644 static int configure (struct config *conf, enum mpath_cmds cmd, enum devtypes dev_type, char *devpath) -@@ -851,7 +897,7 @@ main (int argc, char *argv[]) - condlog(1, "failed to register cleanup handler for vecs: %m"); - if (atexit(cleanup_bindings)) - condlog(1, "failed to register cleanup handler for bindings: %m"); +@@ -839,7 +885,7 @@ main (int argc, char *argv[]) + conf->retrigger_tries = 0; + conf->force_sync = 1; + atexit(cleanup_vecs); - while ((arg = getopt(argc, argv, ":adDcChl::eFfM:v:p:b:BrR:itTquUwW")) != EOF ) { + while ((arg = getopt(argc, argv, ":aAdDcChl::eFfM:v:p:b:BrR:itTquUwW")) != EOF ) { switch(arg) { - case 'v': - if (!isdigit(optarg[0])) { -@@ -922,6 +968,10 @@ main (int argc, char *argv[]) + case 1: printf("optarg : %s\n",optarg); + break; +@@ -916,6 +962,10 @@ main (int argc, char *argv[]) case 'T': cmd = CMD_DUMP_CONFIG; break; @@ -112,11 +112,11 @@ index 31012874..a667c2ee 100644 case 'h': usage(argv[0]); exit(RTVL_OK); -diff --git a/multipath/multipath.8.in b/multipath/multipath.8.in -index b88e9a4c..edd742aa 100644 ---- a/multipath/multipath.8.in -+++ b/multipath/multipath.8.in -@@ -64,7 +64,7 @@ multipath \- Device mapper target autoconfig. +diff --git a/multipath/multipath.8 b/multipath/multipath.8 +index 17df59f5..5ca75359 100644 +--- a/multipath/multipath.8 ++++ b/multipath/multipath.8 +@@ -63,7 +63,7 @@ multipath \- Device mapper target autoconfig. .B multipath .RB [\| \-v\ \c .IR level \|] @@ -125,7 +125,7 @@ index b88e9a4c..edd742aa 100644 . .LP .B multipath -@@ -146,6 +146,11 @@ device mapper, path checkers ...). +@@ -145,6 +145,11 @@ device mapper, path checkers ...). Add the WWID for the specified device to the WWIDs file. . .TP @@ -137,15 +137,15 @@ index b88e9a4c..edd742aa 100644 .B \-w Remove the WWID for the specified device from the WWIDs file. . -diff --git a/multipathd/multipathd.service.in b/multipathd/multipathd.service.in -index ab166435..1ec08c6e 100644 ---- a/multipathd/multipathd.service.in -+++ b/multipathd/multipathd.service.in -@@ -19,6 +19,7 @@ StartLimitBurst=3 - [Service] - Type=notify +diff --git a/multipathd/multipathd.service b/multipathd/multipathd.service +index 6d57c7e8..dfc1e962 100644 +--- a/multipathd/multipathd.service ++++ b/multipathd/multipathd.service +@@ -16,6 +16,7 @@ Type=notify NotifyAccess=main -+ExecStartPre=-@BINDIR@/multipath -A - ExecStart=@BINDIR@/multipathd -d -s - ExecReload=@BINDIR@/multipathd reconfigure - Restart=on-failure + LimitCORE=infinity + ExecStartPre=-/sbin/modprobe -a scsi_dh_alua scsi_dh_emc scsi_dh_rdac dm-multipath ++ExecStartPre=-/sbin/multipath -A + ExecStart=/sbin/multipathd -d -s + ExecReload=/sbin/multipathd reconfigure + TasksMax=infinity diff --git a/0008-RH-reset-default-find_mutipaths-value-to-off.patch b/0032-RH-reset-default-find_mutipaths-value-to-off.patch similarity index 52% rename from 0008-RH-reset-default-find_mutipaths-value-to-off.patch rename to 0032-RH-reset-default-find_mutipaths-value-to-off.patch index fdc90d4..d5b5601 100644 --- a/0008-RH-reset-default-find_mutipaths-value-to-off.patch +++ b/0032-RH-reset-default-find_mutipaths-value-to-off.patch @@ -1,4 +1,4 @@ -From 064d761121e7e2c7b63ab280e341d8010a413119 Mon Sep 17 00:00:00 2001 +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Benjamin Marzinski Date: Thu, 7 Jun 2018 17:43:52 -0500 Subject: [PATCH] RH: reset default find_mutipaths value to off @@ -6,18 +6,16 @@ Subject: [PATCH] RH: reset default find_mutipaths value to off Upstream has changed to default find_multipaths to "strict". For now Redhat will retain the previous default of "off". -Co-authored-by: Paul Donohue Signed-off-by: Benjamin Marzinski --- - libmultipath/defaults.h | 2 +- - multipath/multipath.conf.5.in | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) + libmultipath/defaults.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmultipath/defaults.h b/libmultipath/defaults.h -index 134b690a..e2fe7ac4 100644 +index c27946c7..e0dd32ad 100644 --- a/libmultipath/defaults.h +++ b/libmultipath/defaults.h -@@ -24,7 +24,7 @@ +@@ -23,7 +23,7 @@ #define DEFAULT_NO_PATH_RETRY NO_PATH_RETRY_UNDEF #define DEFAULT_VERBOSITY 2 #define DEFAULT_REASSIGN_MAPS 0 @@ -26,16 +24,3 @@ index 134b690a..e2fe7ac4 100644 #define DEFAULT_FAST_IO_FAIL 5 #define DEFAULT_DEV_LOSS_TMO 600 #define DEFAULT_RETAIN_HWHANDLER RETAIN_HWHANDLER_ON -diff --git a/multipath/multipath.conf.5.in b/multipath/multipath.conf.5.in -index ba291e11..b8389db3 100644 ---- a/multipath/multipath.conf.5.in -+++ b/multipath/multipath.conf.5.in -@@ -1227,7 +1227,7 @@ as non-multipath and passed on to upper layers. - \fBNote:\fR this may cause delays during device detection if - there are single-path devices which aren\'t blacklisted. - .TP --The default is: \fBstrict\fR -+The default is: \fBoff\fR - .RE - . - . diff --git a/0009-RH-attempt-to-get-ANA-info-via-sysfs-first.patch b/0033-RH-attempt-to-get-ANA-info-via-sysfs-first.patch similarity index 86% rename from 0009-RH-attempt-to-get-ANA-info-via-sysfs-first.patch rename to 0033-RH-attempt-to-get-ANA-info-via-sysfs-first.patch index 8065e9f..06233ff 100644 --- a/0009-RH-attempt-to-get-ANA-info-via-sysfs-first.patch +++ b/0033-RH-attempt-to-get-ANA-info-via-sysfs-first.patch @@ -1,4 +1,4 @@ -From 335b8eb2773b07a602e84e14c1f3e289a9b25b5a Mon Sep 17 00:00:00 2001 +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Benjamin Marzinski Date: Thu, 11 Apr 2019 13:25:42 -0500 Subject: [PATCH] RH: attempt to get ANA info via sysfs first @@ -13,10 +13,10 @@ Signed-off-by: Benjamin Marzinski 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/libmultipath/prioritizers/ana.c b/libmultipath/prioritizers/ana.c -index 34527b22..4eaa3cc3 100644 +index b5c7873d..e139360c 100644 --- a/libmultipath/prioritizers/ana.c +++ b/libmultipath/prioritizers/ana.c -@@ -23,6 +23,7 @@ +@@ -24,6 +24,7 @@ #include "prio.h" #include "util.h" #include "structs.h" @@ -24,7 +24,7 @@ index 34527b22..4eaa3cc3 100644 enum { ANA_ERR_GETCTRL_FAILED = 1, -@@ -35,6 +36,7 @@ enum { +@@ -36,6 +37,7 @@ enum { ANA_ERR_GETNS_FAILED, ANA_ERR_NO_MEMORY, ANA_ERR_NO_INFORMATION, @@ -32,7 +32,7 @@ index 34527b22..4eaa3cc3 100644 }; static const char *ana_errmsg[] = { -@@ -48,6 +50,7 @@ static const char *ana_errmsg[] = { +@@ -49,6 +51,7 @@ static const char *ana_errmsg[] = { [ANA_ERR_GETNS_FAILED] = "couldn't get namespace info", [ANA_ERR_NO_MEMORY] = "out of memory", [ANA_ERR_NO_INFORMATION] = "invalid fd", @@ -40,7 +40,7 @@ index 34527b22..4eaa3cc3 100644 }; static const char *anas_string[] = { -@@ -106,6 +109,27 @@ static int get_ana_state(__u32 nsid, __u32 anagrpid, void *ana_log, +@@ -107,6 +110,27 @@ static int get_ana_state(__u32 nsid, __u32 anagrpid, void *ana_log, return -ANA_ERR_GETANAS_NOTFOUND; } @@ -68,7 +68,7 @@ index 34527b22..4eaa3cc3 100644 static int get_ana_info(struct path * pp) { int rc; -@@ -208,8 +232,11 @@ int getprio(struct path *pp, __attribute__((unused)) char *args) +@@ -210,8 +234,11 @@ int getprio(struct path *pp, __attribute__((unused)) char *args, if (pp->fd < 0) rc = -ANA_ERR_NO_INFORMATION; diff --git a/0010-RH-make-parse_vpd_pg83-match-scsi_id-output.patch b/0034-RH-make-parse_vpd_pg83-match-scsi_id-output.patch similarity index 65% rename from 0010-RH-make-parse_vpd_pg83-match-scsi_id-output.patch rename to 0034-RH-make-parse_vpd_pg83-match-scsi_id-output.patch index f7bca92..1d10c09 100644 --- a/0010-RH-make-parse_vpd_pg83-match-scsi_id-output.patch +++ b/0034-RH-make-parse_vpd_pg83-match-scsi_id-output.patch @@ -1,4 +1,4 @@ -From 137c96d16b6bb03d8a52854e152db4ee36b7d9e4 Mon Sep 17 00:00:00 2001 +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Benjamin Marzinski Date: Thu, 25 Mar 2021 13:05:10 -0500 Subject: [PATCH] RH: make parse_vpd_pg83 match scsi_id output @@ -9,46 +9,52 @@ that. Signed-off-by: Benjamin Marzinski --- - libmultipath/discovery.c | 12 ++---------- + libmultipath/discovery.c | 18 ++---------------- tests/vpd.c | 6 ++++++ - 2 files changed, 8 insertions(+), 10 deletions(-) + 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c -index 31db8758..21cfcc73 100644 +index f25fe9e3..6fb81c28 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c -@@ -1225,13 +1225,9 @@ parse_vpd_pg83(const unsigned char *in, size_t in_len, - good_len = 8; +@@ -1136,12 +1136,9 @@ parse_vpd_pg83(const unsigned char *in, size_t in_len, + naa_prio = 7; break; case 2: - /* IEEE Extended: Prio 6 */ -- new_prio = 6; -- good_len = 8; +- naa_prio = 6; - break; case 3: - /* IEEE Locally assigned: Prio 1 */ -- new_prio = 1; +- naa_prio = 1; + /* IEEE Extended or Locally assigned: Prio 6 */ -+ new_prio = 6; - good_len = 8; ++ naa_prio = 6; break; default: -@@ -1249,10 +1245,6 @@ parse_vpd_pg83(const unsigned char *in, size_t in_len, - break; - case 0x8: - /* SCSI Name: Prio 3 */ -- invalid = (d[3] < 4 || (memcmp(d + 4, "eui.", 4) && -- memcmp(d + 4, "naa.", 4) && -- memcmp(d + 4, "iqn.", 4))); -- new_prio = 3; + /* Default: no priority */ +@@ -1160,17 +1157,6 @@ parse_vpd_pg83(const unsigned char *in, size_t in_len, + vpd = d; + } break; +- case 0x8: +- /* SCSI Name: Prio 3 */ +- if (memcmp(d + 4, "eui.", 4) && +- memcmp(d + 4, "naa.", 4) && +- memcmp(d + 4, "iqn.", 4)) +- break; +- if (prio < 3) { +- prio = 3; +- vpd = d; +- } +- break; case 0x1: /* T-10 Vendor ID: Prio 2 */ + if (prio < 2) { diff --git a/tests/vpd.c b/tests/vpd.c -index e3212e61..cdb111bb 100644 +index 8e730d37..7bf7990f 100644 --- a/tests/vpd.c +++ b/tests/vpd.c -@@ -232,11 +232,13 @@ static const char * const str_prefix[] = { +@@ -230,11 +230,13 @@ static const char * const str_prefix[] = { [STR_IQN] = "iqn.", }; @@ -62,7 +68,7 @@ index e3212e61..cdb111bb 100644 /** * create_scsi_string_desc() - create a SCSI name string descriptor. -@@ -767,6 +769,7 @@ make_test_vpd_naa(2, 18); +@@ -659,6 +661,7 @@ make_test_vpd_naa(2, 18); make_test_vpd_naa(2, 17); make_test_vpd_naa(2, 16); @@ -70,7 +76,7 @@ index e3212e61..cdb111bb 100644 /* SCSI Name string: EUI64, WWID size: 17 */ make_test_vpd_str(0, 20, 18) make_test_vpd_str(0, 20, 17) -@@ -802,6 +805,7 @@ make_test_vpd_str(18, 20, 18) +@@ -694,6 +697,7 @@ make_test_vpd_str(18, 20, 18) make_test_vpd_str(18, 20, 17) make_test_vpd_str(18, 20, 16) make_test_vpd_str(18, 20, 15) @@ -78,7 +84,7 @@ index e3212e61..cdb111bb 100644 static int test_vpd(void) { -@@ -910,6 +914,7 @@ static int test_vpd(void) +@@ -767,6 +771,7 @@ static int test_vpd(void) cmocka_unit_test(test_vpd_naa_2_18), cmocka_unit_test(test_vpd_naa_2_17), cmocka_unit_test(test_vpd_naa_2_16), @@ -86,7 +92,7 @@ index e3212e61..cdb111bb 100644 cmocka_unit_test(test_vpd_str_0_20_18), cmocka_unit_test(test_vpd_str_0_20_17), cmocka_unit_test(test_vpd_str_0_20_16), -@@ -934,6 +939,7 @@ static int test_vpd(void) +@@ -791,6 +796,7 @@ static int test_vpd(void) cmocka_unit_test(test_vpd_str_18_20_17), cmocka_unit_test(test_vpd_str_18_20_16), cmocka_unit_test(test_vpd_str_18_20_15), diff --git a/0035-libmultipath-use-asprintf-to-allocate-prefixed_uuid.patch b/0035-libmultipath-use-asprintf-to-allocate-prefixed_uuid.patch new file mode 100644 index 0000000..6e60d4a --- /dev/null +++ b/0035-libmultipath-use-asprintf-to-allocate-prefixed_uuid.patch @@ -0,0 +1,59 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Tue, 25 Jan 2022 23:02:33 -0600 +Subject: [PATCH] libmultipath: use asprintf() to allocate prefixed_uuid + +gcc 12.0.1 failed building libmultipath due to a format-overflow false +positive on 32-bit architectures. This isn't so surprising as +format-overflow=2 is very aggressive in the assumptions it makes about +the arguments. Here, it assumes that mpp->wwid could take up all the +space that a pointer could point to, even if I add code to this function +to explicitly null terminate mpp->wwid to fit in WWID_SIZE. + +To avoid this and simplify the function, switch from using calloc() and +sprintf() to just using asprintf(). + +For reference, the gcc build error that this fixes is: + +devmapper.c: In function 'dm_addmap.constprop.0': +devmapper.h:27:21: error: '%s' directive writing up to 2147483644 bytes into a region of size 2147483641 [-Werror=format-overflow=] + 27 | #define UUID_PREFIX "mpath-" + | ^~~~~~~~ +devmapper.c:484:53: note: format string is defined here + 484 | sprintf(prefixed_uuid, UUID_PREFIX "%s", mpp->wwid); + | ^~ + +Signed-off-by: Benjamin Marzinski +--- + libmultipath/devmapper.c | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) + +diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c +index c05dc201..bae07125 100644 +--- a/libmultipath/devmapper.c ++++ b/libmultipath/devmapper.c +@@ -474,14 +474,11 @@ dm_addmap (int task, const char *target, struct multipath *mpp, + dm_task_set_ro(dmt); + + if (task == DM_DEVICE_CREATE) { +- prefixed_uuid = MALLOC(UUID_PREFIX_LEN + +- strlen(mpp->wwid) + 1); +- if (!prefixed_uuid) { ++ if (asprintf(&prefixed_uuid, UUID_PREFIX "%s", mpp->wwid) < 0) { + condlog(0, "cannot create prefixed uuid : %s", + strerror(errno)); + goto addout; + } +- sprintf(prefixed_uuid, UUID_PREFIX "%s", mpp->wwid); + if (!dm_task_set_uuid(dmt, prefixed_uuid)) + goto freeout; + dm_task_skip_lockfs(dmt); +@@ -517,7 +514,7 @@ dm_addmap (int task, const char *target, struct multipath *mpp, + libmp_udev_wait(cookie); + freeout: + if (prefixed_uuid) +- FREE(prefixed_uuid); ++ free(prefixed_uuid); + + addout: + dm_task_destroy (dmt); diff --git a/0036-RH-add-support-to-mpathconf-for-setting-arbitrary-de.patch b/0036-RH-add-support-to-mpathconf-for-setting-arbitrary-de.patch new file mode 100644 index 0000000..dff41f8 --- /dev/null +++ b/0036-RH-add-support-to-mpathconf-for-setting-arbitrary-de.patch @@ -0,0 +1,149 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Wed, 2 Feb 2022 17:00:21 -0600 +Subject: [PATCH] RH: add support to mpathconf for setting arbitrary default + options + +mpathconf now supports --option :[] for setting, changing, +or removing options from the defaults section of multipath.conf. + +Signed-off-by: Benjamin Marzinski +--- + multipath/mpathconf | 58 ++++++++++++++++++++++++++++++++++++++++--- + multipath/mpathconf.8 | 7 ++++++ + 2 files changed, 62 insertions(+), 3 deletions(-) + +diff --git a/multipath/mpathconf b/multipath/mpathconf +index 0de6b121..6e33fb99 100644 +--- a/multipath/mpathconf ++++ b/multipath/mpathconf +@@ -17,7 +17,7 @@ + # This program was largely ripped off from lvmconf + # + +-unset ENABLE FIND FRIENDLY PROPERTY FOREIGN MODULE MULTIPATHD HAVE_DISABLE HAVE_WWID_DISABLE HAVE_FIND HAVE_BLACKLIST HAVE_EXCEPTIONS HAVE_DEFAULTS HAVE_FRIENDLY HAVE_PROPERTY HAVE_FOREIGN HAVE_MULTIPATHD HAVE_MODULE HAVE_OUTFILE SHOW_STATUS CHANGED_CONFIG WWID_LIST ++unset ENABLE FIND FRIENDLY PROPERTY FOREIGN MODULE MULTIPATHD HAVE_DISABLE HAVE_WWID_DISABLE HAVE_FIND HAVE_BLACKLIST HAVE_EXCEPTIONS HAVE_DEFAULTS HAVE_FRIENDLY HAVE_PROPERTY HAVE_FOREIGN HAVE_MULTIPATHD HAVE_MODULE HAVE_OUTFILE SHOW_STATUS CHANGED_CONFIG WWID_LIST HAVE_OPTION OPTION_NAME OPTION_VALUE + + DEFAULT_CONFIG="# device-mapper-multipath configuration file + +@@ -52,6 +52,7 @@ function usage + echo "Set find_multipaths (Default y): --find_multipaths " + echo "Set default property blacklist (Default n): --property_blacklist " + echo "Set enable_foreign to show foreign devices (Default n): --enable_foreign " ++ echo "Add/Change/Remove option in defaults section: --option :" + echo "Load the dm-multipath modules on enable (Default y): --with_module " + echo "start/stop/reload multipathd (Default n): --with_multipathd " + echo "select output file (Default /etc/multipath.conf): --outfile " +@@ -162,6 +163,20 @@ function parse_args + exit 1 + fi + ;; ++ --option) ++ if [ -n "$2" ]; then ++ OPTION_NAME=$(echo $2 | cut -s -f1 -d:) ++ OPTION_VALUE=$(echo $2 | cut -s -f2 -d:) ++ if [ -z "$OPTION_NAME" ]; then ++ usage ++ exit 1 ++ fi ++ shift 2 ++ else ++ usage ++ exit 1 ++ fi ++ ;; + --enable_foreign) + if [ -n "$2" ]; then + FOREIGN=$2 +@@ -208,12 +223,15 @@ function parse_args + + function validate_args + { +- if [ "$ENABLE" = "0" ] && [ -n "$FRIENDLY" -o -n "$FIND" -o -n "$PROPERTY" -o -n "$MODULE" ]; then ++ if [ "$ENABLE" = "0" ] && [ -n "$FRIENDLY" -o -n "$FIND" -o -n "$PROPERTY" -o -n "$MODULE" -o -n "$FOREIGN" -o -n "$OPTION_NAME" ]; then + echo "ignoring extra parameters on disable" + FRIENDLY="" + FIND="" + PROPERTY="" + MODULE="" ++ FOREIGN="" ++ OPTION_NAME="" ++ OPTION_VALUE="" + fi + if [ -n "$FRIENDLY" ] && [ "$FRIENDLY" != "y" -a "$FRIENDLY" != "n" ]; then + echo "--user_friendly_names must be either 'y' or 'n'" +@@ -235,7 +253,19 @@ function validate_args + echo "--enable_foreign must be either 'y' or 'n'" + exit 1 + fi +- if [ -z "$ENABLE" -a -z "$FIND" -a -z "$FRIENDLY" -a -z "$PROPERTY" -a -z "$FOREIGN" ]; then ++ if [ -n "$OPTION_NAME" ]; then ++ if [[ $OPTION_NAME =~ [[:space:]]|#|\"|!|\{|\} ]]; then ++ echo "--option name \"$OPTION_NAME\" is invalid" ++ exit 1 ++ elif [[ $OPTION_VALUE =~ \"|#|!|\{|\} ]]; then ++ echo "--option value \"$OPTION_VALUE\" is invalid" ++ exit 1 ++ fi ++ if [[ $OPTION_VALUE =~ [[:space:]] ]]; then ++ OPTION_VALUE=\"$OPTION_VALUE\" ++ fi ++ fi ++ if [ -z "$ENABLE" -a -z "$FIND" -a -z "$FRIENDLY" -a -z "$PROPERTY" -a -z "$FOREIGN" -a -z "$OPTION_NAME" ]; then + SHOW_STATUS=1 + fi + if [ -n "$MODULE" ] && [ "$MODULE" != "y" -a "$MODULE" != "n" ]; then +@@ -348,6 +378,13 @@ if [ "$HAVE_DEFAULTS" = "1" ]; then + elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*enable_foreign" ; then + HAVE_FOREIGN=3 + fi ++ if [ -n "$OPTION_NAME" ]; then ++ if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q '^[[:space:]]*'"$OPTION_NAME"'[[:space:]][[:space:]]*'"$OPTION_VALUE" ; then ++ HAVE_OPTION=1 ++ elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q '^[[:space:]]*'"$OPTION_NAME"'\([[:space:]].*\)\?$' ; then ++ HAVE_OPTION=0 ++ fi ++ fi + fi + + if [ "$HAVE_EXCEPTIONS" = "1" ]; then +@@ -532,6 +569,21 @@ elif [ "$FOREIGN" = "y" ]; then + fi + fi + ++if [ -n "$OPTION_NAME" -a -n "$OPTION_VALUE" ]; then ++ if [ -z "$HAVE_OPTION" ]; then ++ sed -i '/^defaults[[:space:]]*{/ a\ ++ '"$OPTION_NAME"' '"$OPTION_VALUE"' ++' $TMPFILE ++ CHANGED_CONFIG=1 ++ elif [ "$HAVE_OPTION" = 0 ]; then ++ sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*'"$OPTION_NAME"'\([[:space:]].*\)\?$/ '"$OPTION_NAME"' '"$OPTION_VALUE"'/' $TMPFILE ++ CHANGED_CONFIG=1 ++ fi ++elif [ -n "$OPTION_NAME" -a -n "$HAVE_OPTION" ]; then ++ sed -i '/^defaults[[:space:]]*{/,/^}/{/^[[:space:]]*'"$OPTION_NAME"'\([[:space:]].*\)\?$/d}' $TMPFILE ++ CHANGED_CONFIG=1 ++fi ++ + if [ -f "$OUTPUTFILE" ]; then + cp $OUTPUTFILE $OUTPUTFILE.old + if [ $? != 0 ]; then +diff --git a/multipath/mpathconf.8 b/multipath/mpathconf.8 +index a14d831e..496383b7 100644 +--- a/multipath/mpathconf.8 ++++ b/multipath/mpathconf.8 +@@ -101,6 +101,13 @@ to the + defaults section. if set to \fBn\fP, this removes the line, if present. This + command can be used along with any other command. + .TP ++.B --option \fB:[]\fP ++Sets the defaults section option \fB\fP to \fB\fP. If the ++option was not previously set in the defaults section, it is added. If it was ++set, its value is changed to \fB\fP. If \fB\fP is left blank, ++then the option is removed from the defaults section, if was set there. This ++command can be used along with any other command. ++.TP + .B --outfile \fB\fP + Write the resulting multipath configuration to \fB\fP instead of + \fB/etc/multipath.conf\fP. diff --git a/0037-RH-add-support-to-mpathconf-for-setting-recheck_wwid.patch b/0037-RH-add-support-to-mpathconf-for-setting-recheck_wwid.patch new file mode 100644 index 0000000..5330d38 --- /dev/null +++ b/0037-RH-add-support-to-mpathconf-for-setting-recheck_wwid.patch @@ -0,0 +1,154 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Thu, 3 Feb 2022 13:26:18 -0600 +Subject: [PATCH] RH: add support to mpathconf for setting recheck_wwid + +mpathconf now supports --recheck_wwid for setthing the +recheck_wwid option + +Signed-off-by: Benjamin Marzinski +--- + multipath/mpathconf | 48 ++++++++++++++++++++++++++++++++++++++++--- + multipath/mpathconf.8 | 9 ++++++++ + 2 files changed, 54 insertions(+), 3 deletions(-) + +diff --git a/multipath/mpathconf b/multipath/mpathconf +index 6e33fb99..319664b1 100644 +--- a/multipath/mpathconf ++++ b/multipath/mpathconf +@@ -17,7 +17,7 @@ + # This program was largely ripped off from lvmconf + # + +-unset ENABLE FIND FRIENDLY PROPERTY FOREIGN MODULE MULTIPATHD HAVE_DISABLE HAVE_WWID_DISABLE HAVE_FIND HAVE_BLACKLIST HAVE_EXCEPTIONS HAVE_DEFAULTS HAVE_FRIENDLY HAVE_PROPERTY HAVE_FOREIGN HAVE_MULTIPATHD HAVE_MODULE HAVE_OUTFILE SHOW_STATUS CHANGED_CONFIG WWID_LIST HAVE_OPTION OPTION_NAME OPTION_VALUE ++unset ENABLE FIND FRIENDLY PROPERTY FOREIGN MODULE MULTIPATHD HAVE_DISABLE HAVE_WWID_DISABLE HAVE_FIND HAVE_BLACKLIST HAVE_EXCEPTIONS HAVE_DEFAULTS HAVE_FRIENDLY HAVE_PROPERTY HAVE_FOREIGN HAVE_MULTIPATHD HAVE_MODULE HAVE_OUTFILE SHOW_STATUS CHANGED_CONFIG WWID_LIST HAVE_OPTION OPTION_NAME OPTION_VALUE HAVE_RECHECK_WWID RECHECK_WWID + + DEFAULT_CONFIG="# device-mapper-multipath configuration file + +@@ -52,6 +52,7 @@ function usage + echo "Set find_multipaths (Default y): --find_multipaths " + echo "Set default property blacklist (Default n): --property_blacklist " + echo "Set enable_foreign to show foreign devices (Default n): --enable_foreign " ++ echo "Set recheck_wwid (Defaut n): --recheck_wwid " + echo "Add/Change/Remove option in defaults section: --option :" + echo "Load the dm-multipath modules on enable (Default y): --with_module " + echo "start/stop/reload multipathd (Default n): --with_multipathd " +@@ -145,6 +146,15 @@ function parse_args + exit 1 + fi + ;; ++ --recheck_wwid) ++ if [ -n "$2" ]; then ++ RECHECK_WWID=$2 ++ shift 2 ++ else ++ usage ++ exit 1 ++ fi ++ ;; + --find_multipaths) + if [ -n "$2" ]; then + FIND=$2 +@@ -223,7 +233,7 @@ function parse_args + + function validate_args + { +- if [ "$ENABLE" = "0" ] && [ -n "$FRIENDLY" -o -n "$FIND" -o -n "$PROPERTY" -o -n "$MODULE" -o -n "$FOREIGN" -o -n "$OPTION_NAME" ]; then ++ if [ "$ENABLE" = "0" ] && [ -n "$FRIENDLY" -o -n "$FIND" -o -n "$PROPERTY" -o -n "$MODULE" -o -n "$FOREIGN" -o -n "$OPTION_NAME" -o -n "$RECHECK_WWID" ]; then + echo "ignoring extra parameters on disable" + FRIENDLY="" + FIND="" +@@ -232,11 +242,16 @@ function validate_args + FOREIGN="" + OPTION_NAME="" + OPTION_VALUE="" ++ RECHECK_WWID="" + fi + if [ -n "$FRIENDLY" ] && [ "$FRIENDLY" != "y" -a "$FRIENDLY" != "n" ]; then + echo "--user_friendly_names must be either 'y' or 'n'" + exit 1 + fi ++ if [ -n "$RECHECK_WWID" ] && [ "$RECHECK_WWID" != "y" -a "$RECHECK_WWID" != "n" ]; then ++ echo "--recheck_wwid must be either 'y' or 'n'" ++ exit 1 ++ fi + if [ "$FIND" = "y" ]; then + FIND="yes" + elif [ "$FIND" = "n" ]; then +@@ -265,7 +280,7 @@ function validate_args + OPTION_VALUE=\"$OPTION_VALUE\" + fi + fi +- if [ -z "$ENABLE" -a -z "$FIND" -a -z "$FRIENDLY" -a -z "$PROPERTY" -a -z "$FOREIGN" -a -z "$OPTION_NAME" ]; then ++ if [ -z "$ENABLE" -a -z "$FIND" -a -z "$FRIENDLY" -a -z "$PROPERTY" -a -z "$FOREIGN" -a -z "$OPTION_NAME" -a -z "$RECHECK_WWID" ]; then + SHOW_STATUS=1 + fi + if [ -n "$MODULE" ] && [ "$MODULE" != "y" -a "$MODULE" != "n" ]; then +@@ -367,6 +382,11 @@ if [ "$HAVE_DEFAULTS" = "1" ]; then + elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*user_friendly_names[[:space:]][[:space:]]*\(no\|0\)" ; then + HAVE_FRIENDLY=0 + fi ++ if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*recheck_wwid[[:space:]][[:space:]]*\(yes\|1\)" ; then ++ HAVE_RECHECK_WWID=1 ++ elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*recheck_wwid[[:space:]][[:space:]]*\(no\|0\)" ; then ++ HAVE_RECHECK_WWID=0 ++ fi + if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[[:space:]]*enable_foreign" ; then + HAVE_FOREIGN=0 + elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*enable_foreign[[:space:]][[:space:]]*\"\.\*\"" ; then +@@ -411,6 +431,11 @@ if [ -n "$SHOW_STATUS" ]; then + else + echo "user_friendly_names is enabled" + fi ++ if [ -z "$HAVE_RECHECK_WWID" -o "$HAVE_RECHECK_WWID" = 0 ]; then ++ echo "recheck_wwid is disabled" ++ else ++ echo "recheck_wwid is enabled" ++ fi + if [ -z "$HAVE_PROPERTY" -o "$HAVE_PROPERTY" = 0 ]; then + echo "default property blacklist is disabled" + else +@@ -527,6 +552,23 @@ elif [ "$FRIENDLY" = "y" ]; then + fi + fi + ++if [ "$RECHECK_WWID" = "n" ]; then ++ if [ "$HAVE_RECHECK_WWID" = 1 ]; then ++ sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*recheck_wwid[[:space:]][[:space:]]*\(yes\|1\)/ recheck_wwid no/' $TMPFILE ++ CHANGED_CONFIG=1 ++ fi ++elif [ "$RECHECK_WWID" = "y" ]; then ++ if [ -z "$HAVE_RECHECK_WWID" ]; then ++ sed -i '/^defaults[[:space:]]*{/ a\ ++ recheck_wwid yes ++' $TMPFILE ++ CHANGED_CONFIG=1 ++ elif [ "$HAVE_RECHECK_WWID" = 0 ]; then ++ sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*recheck_wwid[[:space:]][[:space:]]*\(no\|0\)/ recheck_wwid yes/' $TMPFILE ++ CHANGED_CONFIG=1 ++ fi ++fi ++ + if [ "$PROPERTY" = "n" ]; then + if [ "$HAVE_PROPERTY" = 1 ]; then + sed -i '/^blacklist_exceptions[[:space:]]*{/,/^}/ s/^[[:space:]]*property[[:space:]][[:space:]]*\"(SCSI_IDENT_|ID_WWN)\"/# property \"(SCSI_IDENT_|ID_WWN)\"/' $TMPFILE +diff --git a/multipath/mpathconf.8 b/multipath/mpathconf.8 +index 496383b7..9c2fb835 100644 +--- a/multipath/mpathconf.8 ++++ b/multipath/mpathconf.8 +@@ -77,6 +77,15 @@ to the + defaults section. If set to \fBn\fP, this removes the line, if present. This + command can be used along with any other command. + .TP ++.B --recheck_wwid \fP { \fBy\fP | \fBn\fP } ++If set to \fBy\fP, this adds the line ++.B recheck_wwid yes ++to the ++.B /etc/multipath.conf ++defaults section, or sets an existing line to \fByes\fP. If set to \fBn\fP, this ++sets an existing \fBrecheck_wwid\fP line to \fBno\fP. This command can be used ++along with any other command. ++.TP + .B --find_multipaths\fP { \fByes\fP | \fBno\fP | \fBstrict\fP | \fBgreedy\fP | \fBsmart\fP } + If set to \fB\fP, this adds the line + .B find_multipaths diff --git a/0038-multipathd-Add-missing-ctype-include.patch b/0038-multipathd-Add-missing-ctype-include.patch new file mode 100644 index 0000000..7e2d464 --- /dev/null +++ b/0038-multipathd-Add-missing-ctype-include.patch @@ -0,0 +1,26 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Bastian Germann +Date: Thu, 14 Oct 2021 00:34:33 +0200 +Subject: [PATCH] multipathd: Add missing ctype include + +In uxclnt.c, there are isspace calls. Add an explicit include. + +Signed-off-by: Bastian Germann +Reviewed-by: Martin Wilck +Signed-off-by: Benjamin Marzinski +--- + multipathd/uxclnt.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/multipathd/uxclnt.c b/multipathd/uxclnt.c +index a76f8e29..f16a7309 100644 +--- a/multipathd/uxclnt.c ++++ b/multipathd/uxclnt.c +@@ -8,6 +8,7 @@ + #include + #include + #include ++#include + #include + #include + #include diff --git a/0039-multipathd-replace-libreadline-with-libedit.patch b/0039-multipathd-replace-libreadline-with-libedit.patch new file mode 100644 index 0000000..0f3bee1 --- /dev/null +++ b/0039-multipathd-replace-libreadline-with-libedit.patch @@ -0,0 +1,103 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martin Wilck +Date: Fri, 12 Aug 2022 18:58:15 +0200 +Subject: [PATCH] multipathd: replace libreadline with libedit + +Linking multipathd with libreadline may cause a license conflict, +because libreadline is licensed under GPL-3.0-or-later, and +libmultipath contains several files under GPL-2.0. + +See: + https://github.com/opensvc/multipath-tools/issues/36 + https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=979095 + https://www.gnu.org/licenses/gpl-faq.html#AllCompatibility + +Replace the readline functionality with libedit, which comes under +a BSD license. The readline library can still be enabled (e.g. for +binaries not intended to be distributed) by running +"make READLINE=libreadline". + +Signed-off-by: Martin Wilck +Signed-off-by: Benjamin Marzinski +--- + Makefile.inc | 5 +++++ + multipathd/Makefile | 12 +++++++++++- + multipathd/cli.c | 5 +++++ + multipathd/uxclnt.c | 6 ++++++ + 4 files changed, 27 insertions(+), 1 deletion(-) + +diff --git a/Makefile.inc b/Makefile.inc +index 5ac660de..4502e2b2 100644 +--- a/Makefile.inc ++++ b/Makefile.inc +@@ -14,6 +14,11 @@ + # + # Uncomment to disable dmevents polling support + # ENABLE_DMEVENTS_POLL = 0 ++# ++# Readline library to use, libedit or libreadline ++# Caution: Using libreadline may make the multipathd binary undistributable, ++# see https://github.com/opensvc/multipath-tools/issues/36 ++READLINE = libedit + + PKGCONFIG ?= pkg-config + +diff --git a/multipathd/Makefile b/multipathd/Makefile +index 393b6cbb..abd9ef6f 100644 +--- a/multipathd/Makefile ++++ b/multipathd/Makefile +@@ -15,7 +15,17 @@ CFLAGS += $(BIN_CFLAGS) -I$(multipathdir) -I$(mpathpersistdir) \ + LDFLAGS += $(BIN_LDFLAGS) + LIBDEPS += -L$(multipathdir) -lmultipath -L$(mpathpersistdir) -lmpathpersist \ + -L$(mpathcmddir) -lmpathcmd -ludev -ldl -lurcu -lpthread \ +- -ldevmapper -lreadline ++ -ldevmapper ++ ++ifeq ($(READLINE),libedit) ++CFLAGS += -DUSE_LIBEDIT ++LIBDEPS += -ledit ++endif ++ifeq ($(READLINE),libreadline) ++CFLAGS += -DUSE_LIBREADLINE ++LIBDEPS += -lreadline ++endif ++ + CFLAGS += $(shell $(PKGCONFIG) --modversion liburcu 2>/dev/null | \ + awk -F. '{ printf("-DURCU_VERSION=0x%06x", 256 * ( 256 * $$1 + $$2) + $$3); }') + +diff --git a/multipathd/cli.c b/multipathd/cli.c +index 4d6c37c9..cc547e67 100644 +--- a/multipathd/cli.c ++++ b/multipathd/cli.c +@@ -11,7 +11,12 @@ + #include "parser.h" + #include "util.h" + #include "version.h" ++#ifdef USE_LIBEDIT ++#include ++#endif ++#ifdef USE_LIBREADLINE + #include ++#endif + + #include "mpath_cmd.h" + #include "cli.h" +diff --git a/multipathd/uxclnt.c b/multipathd/uxclnt.c +index f16a7309..2c17d8fc 100644 +--- a/multipathd/uxclnt.c ++++ b/multipathd/uxclnt.c +@@ -16,8 +16,14 @@ + #include + #include + #include ++ ++#ifdef USE_LIBEDIT ++#include ++#endif ++#ifdef USE_LIBREADLINE + #include + #include ++#endif + + #include "mpath_cmd.h" + #include "uxsock.h" diff --git a/0040-multipathd-ignore-duplicated-multipathd-command-keys.patch b/0040-multipathd-ignore-duplicated-multipathd-command-keys.patch new file mode 100644 index 0000000..c2665cc --- /dev/null +++ b/0040-multipathd-ignore-duplicated-multipathd-command-keys.patch @@ -0,0 +1,153 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Thu, 8 Sep 2022 11:54:49 -0500 +Subject: [PATCH] multipathd: ignore duplicated multipathd command keys + +multipath adds rather than or-s the values of command keys. Fix this. +Also, return an invalid fingerprint if a key is used more than once. + +Signed-off-by: Benjamin Marzinski +--- + multipathd/cli.c | 8 ++-- + multipathd/main.c | 106 +++++++++++++++++++++++----------------------- + 2 files changed, 58 insertions(+), 56 deletions(-) + +diff --git a/multipathd/cli.c b/multipathd/cli.c +index cc547e67..eb2e8c1d 100644 +--- a/multipathd/cli.c ++++ b/multipathd/cli.c +@@ -342,9 +342,11 @@ fingerprint(vector vec) + if (!vec) + return 0; + +- vector_foreach_slot(vec, kw, i) +- fp += kw->code; +- ++ vector_foreach_slot(vec, kw, i) { ++ if (fp & kw->code) ++ return (uint64_t)-1; ++ fp |= kw->code; ++ } + return fp; + } + +diff --git a/multipathd/main.c b/multipathd/main.c +index 6145e512..2db2994b 100644 +--- a/multipathd/main.c ++++ b/multipathd/main.c +@@ -1683,62 +1683,62 @@ uxlsnrloop (void * ap) + /* Tell main thread that thread has started */ + post_config_state(DAEMON_CONFIGURE); + +- set_handler_callback(LIST+PATHS, cli_list_paths); +- set_handler_callback(LIST+PATHS+FMT, cli_list_paths_fmt); +- set_handler_callback(LIST+PATHS+RAW+FMT, cli_list_paths_raw); +- set_handler_callback(LIST+PATH, cli_list_path); +- set_handler_callback(LIST+MAPS, cli_list_maps); +- set_handler_callback(LIST+STATUS, cli_list_status); +- set_unlocked_handler_callback(LIST+DAEMON, cli_list_daemon); +- set_handler_callback(LIST+MAPS+STATUS, cli_list_maps_status); +- set_handler_callback(LIST+MAPS+STATS, cli_list_maps_stats); +- set_handler_callback(LIST+MAPS+FMT, cli_list_maps_fmt); +- set_handler_callback(LIST+MAPS+RAW+FMT, cli_list_maps_raw); +- set_handler_callback(LIST+MAPS+TOPOLOGY, cli_list_maps_topology); +- set_handler_callback(LIST+TOPOLOGY, cli_list_maps_topology); +- set_handler_callback(LIST+MAPS+JSON, cli_list_maps_json); +- set_handler_callback(LIST+MAP+TOPOLOGY, cli_list_map_topology); +- set_handler_callback(LIST+MAP+FMT, cli_list_map_fmt); +- set_handler_callback(LIST+MAP+RAW+FMT, cli_list_map_fmt); +- set_handler_callback(LIST+MAP+JSON, cli_list_map_json); +- set_handler_callback(LIST+CONFIG+LOCAL, cli_list_config_local); +- set_handler_callback(LIST+CONFIG, cli_list_config); +- set_handler_callback(LIST+BLACKLIST, cli_list_blacklist); +- set_handler_callback(LIST+DEVICES, cli_list_devices); +- set_handler_callback(LIST+WILDCARDS, cli_list_wildcards); +- set_handler_callback(RESET+MAPS+STATS, cli_reset_maps_stats); +- set_handler_callback(RESET+MAP+STATS, cli_reset_map_stats); +- set_handler_callback(ADD+PATH, cli_add_path); +- set_handler_callback(DEL+PATH, cli_del_path); +- set_handler_callback(ADD+MAP, cli_add_map); +- set_handler_callback(DEL+MAP, cli_del_map); +- set_handler_callback(DEL+MAPS, cli_del_maps); +- set_handler_callback(SWITCH+MAP+GROUP, cli_switch_group); ++ set_handler_callback(LIST|PATHS, cli_list_paths); ++ set_handler_callback(LIST|PATHS|FMT, cli_list_paths_fmt); ++ set_handler_callback(LIST|PATHS|RAW|FMT, cli_list_paths_raw); ++ set_handler_callback(LIST|PATH, cli_list_path); ++ set_handler_callback(LIST|MAPS, cli_list_maps); ++ set_handler_callback(LIST|STATUS, cli_list_status); ++ set_unlocked_handler_callback(LIST|DAEMON, cli_list_daemon); ++ set_handler_callback(LIST|MAPS|STATUS, cli_list_maps_status); ++ set_handler_callback(LIST|MAPS|STATS, cli_list_maps_stats); ++ set_handler_callback(LIST|MAPS|FMT, cli_list_maps_fmt); ++ set_handler_callback(LIST|MAPS|RAW|FMT, cli_list_maps_raw); ++ set_handler_callback(LIST|MAPS|TOPOLOGY, cli_list_maps_topology); ++ set_handler_callback(LIST|TOPOLOGY, cli_list_maps_topology); ++ set_handler_callback(LIST|MAPS|JSON, cli_list_maps_json); ++ set_handler_callback(LIST|MAP|TOPOLOGY, cli_list_map_topology); ++ set_handler_callback(LIST|MAP|FMT, cli_list_map_fmt); ++ set_handler_callback(LIST|MAP|RAW|FMT, cli_list_map_fmt); ++ set_handler_callback(LIST|MAP|JSON, cli_list_map_json); ++ set_handler_callback(LIST|CONFIG|LOCAL, cli_list_config_local); ++ set_handler_callback(LIST|CONFIG, cli_list_config); ++ set_handler_callback(LIST|BLACKLIST, cli_list_blacklist); ++ set_handler_callback(LIST|DEVICES, cli_list_devices); ++ set_handler_callback(LIST|WILDCARDS, cli_list_wildcards); ++ set_handler_callback(RESET|MAPS|STATS, cli_reset_maps_stats); ++ set_handler_callback(RESET|MAP|STATS, cli_reset_map_stats); ++ set_handler_callback(ADD|PATH, cli_add_path); ++ set_handler_callback(DEL|PATH, cli_del_path); ++ set_handler_callback(ADD|MAP, cli_add_map); ++ set_handler_callback(DEL|MAP, cli_del_map); ++ set_handler_callback(DEL|MAPS, cli_del_maps); ++ set_handler_callback(SWITCH|MAP|GROUP, cli_switch_group); + set_unlocked_handler_callback(RECONFIGURE, cli_reconfigure); +- set_handler_callback(SUSPEND+MAP, cli_suspend); +- set_handler_callback(RESUME+MAP, cli_resume); +- set_handler_callback(RESIZE+MAP, cli_resize); +- set_handler_callback(RELOAD+MAP, cli_reload); +- set_handler_callback(RESET+MAP, cli_reassign); +- set_handler_callback(REINSTATE+PATH, cli_reinstate); +- set_handler_callback(FAIL+PATH, cli_fail); +- set_handler_callback(DISABLEQ+MAP, cli_disable_queueing); +- set_handler_callback(RESTOREQ+MAP, cli_restore_queueing); +- set_handler_callback(DISABLEQ+MAPS, cli_disable_all_queueing); +- set_handler_callback(RESTOREQ+MAPS, cli_restore_all_queueing); ++ set_handler_callback(SUSPEND|MAP, cli_suspend); ++ set_handler_callback(RESUME|MAP, cli_resume); ++ set_handler_callback(RESIZE|MAP, cli_resize); ++ set_handler_callback(RELOAD|MAP, cli_reload); ++ set_handler_callback(RESET|MAP, cli_reassign); ++ set_handler_callback(REINSTATE|PATH, cli_reinstate); ++ set_handler_callback(FAIL|PATH, cli_fail); ++ set_handler_callback(DISABLEQ|MAP, cli_disable_queueing); ++ set_handler_callback(RESTOREQ|MAP, cli_restore_queueing); ++ set_handler_callback(DISABLEQ|MAPS, cli_disable_all_queueing); ++ set_handler_callback(RESTOREQ|MAPS, cli_restore_all_queueing); + set_unlocked_handler_callback(QUIT, cli_quit); + set_unlocked_handler_callback(SHUTDOWN, cli_shutdown); +- set_handler_callback(GETPRSTATUS+MAP, cli_getprstatus); +- set_handler_callback(SETPRSTATUS+MAP, cli_setprstatus); +- set_handler_callback(UNSETPRSTATUS+MAP, cli_unsetprstatus); +- set_handler_callback(FORCEQ+DAEMON, cli_force_no_daemon_q); +- set_handler_callback(RESTOREQ+DAEMON, cli_restore_no_daemon_q); +- set_handler_callback(GETPRKEY+MAP, cli_getprkey); +- set_handler_callback(SETPRKEY+MAP+KEY, cli_setprkey); +- set_handler_callback(UNSETPRKEY+MAP, cli_unsetprkey); +- set_handler_callback(SETMARGINAL+PATH, cli_set_marginal); +- set_handler_callback(UNSETMARGINAL+PATH, cli_unset_marginal); +- set_handler_callback(UNSETMARGINAL+MAP, cli_unset_all_marginal); ++ set_handler_callback(GETPRSTATUS|MAP, cli_getprstatus); ++ set_handler_callback(SETPRSTATUS|MAP, cli_setprstatus); ++ set_handler_callback(UNSETPRSTATUS|MAP, cli_unsetprstatus); ++ set_handler_callback(FORCEQ|DAEMON, cli_force_no_daemon_q); ++ set_handler_callback(RESTOREQ|DAEMON, cli_restore_no_daemon_q); ++ set_handler_callback(GETPRKEY|MAP, cli_getprkey); ++ set_handler_callback(SETPRKEY|MAP|KEY, cli_setprkey); ++ set_handler_callback(UNSETPRKEY|MAP, cli_unsetprkey); ++ set_handler_callback(SETMARGINAL|PATH, cli_set_marginal); ++ set_handler_callback(UNSETMARGINAL|PATH, cli_unset_marginal); ++ set_handler_callback(UNSETMARGINAL|MAP, cli_unset_all_marginal); + + umask(077); + uxsock_listen(&uxsock_trigger, ux_sock, ap); diff --git a/0041-multipath-tools-use-run-instead-of-dev-shm.patch b/0041-multipath-tools-use-run-instead-of-dev-shm.patch new file mode 100644 index 0000000..64eb30a --- /dev/null +++ b/0041-multipath-tools-use-run-instead-of-dev-shm.patch @@ -0,0 +1,141 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martin Wilck +Date: Thu, 1 Sep 2022 19:21:30 +0200 +Subject: [PATCH] multipath-tools: use /run instead of /dev/shm + +/dev/shm may have unsafe permissions. Use /run instead. +Use systemd's tmpfiles.d mechanism to create /run/multipath +early during boot. + +For backward compatibilty, make the runtime directory configurable +via the "runtimedir" make variable. + +Signed-off-by: Martin Wilck +Signed-off-by: Benjamin Marzinski +--- + .gitignore | 2 ++ + Makefile.inc | 4 +++- + libmultipath/defaults.h | 2 +- + multipath/Makefile | 9 +++++++-- + multipath/{multipath.rules => multipath.rules.in} | 4 ++-- + multipath/tmpfiles.conf.in | 1 + + 6 files changed, 16 insertions(+), 6 deletions(-) + rename multipath/{multipath.rules => multipath.rules.in} (95%) + create mode 100644 multipath/tmpfiles.conf.in + +diff --git a/.gitignore b/.gitignore +index 087dffc2..6ee4fa09 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -11,6 +11,8 @@ cscope.files + cscope.out + kpartx/kpartx + multipath/multipath ++multipath/multipath.rules ++multipath/tmpfiles.conf + multipathd/multipathd + mpathpersist/mpathpersist + .nfs* +diff --git a/Makefile.inc b/Makefile.inc +index 4502e2b2..b2d082f2 100644 +--- a/Makefile.inc ++++ b/Makefile.inc +@@ -62,6 +62,7 @@ exec_prefix = $(prefix) + usr_prefix = $(prefix) + bindir = $(exec_prefix)/usr/sbin + libudevdir = $(prefix)/$(SYSTEMDPATH)/udev ++tmpfilesdir = $(prefix)/$(SYSTEMDPATH)/tmpfiles.d + udevrulesdir = $(libudevdir)/rules.d + multipathdir = $(TOPDIR)/libmultipath + man8dir = $(prefix)/usr/share/man/man8 +@@ -79,6 +80,7 @@ libdmmpdir = $(TOPDIR)/libdmmp + nvmedir = $(TOPDIR)/libmultipath/nvme + includedir = $(prefix)/usr/include + pkgconfdir = $(usrlibdir)/pkgconfig ++runtimedir = /$(RUN) + + GZIP = gzip -9 -c + RM = rm -f +@@ -120,7 +122,7 @@ WARNFLAGS := -Werror -Wextra -Wformat=2 $(WFORMATOVERFLOW) -Werror=implicit-int + $(WNOCLOBBERED) -Werror=cast-qual $(ERROR_DISCARDED_QUALIFIERS) \ + -Wstrict-prototypes + CFLAGS := --std=gnu99 $(CFLAGS) $(OPTFLAGS) $(WARNFLAGS) -pipe \ +- -DBIN_DIR=\"$(bindir)\" -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" \ ++ -DBIN_DIR=\"$(bindir)\" -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" -DRUNTIME_DIR=\"$(runtimedir)\" \ + -MMD -MP + BIN_CFLAGS = -fPIE -DPIE + LIB_CFLAGS = -fPIC +diff --git a/libmultipath/defaults.h b/libmultipath/defaults.h +index e0dd32ad..cec82f07 100644 +--- a/libmultipath/defaults.h ++++ b/libmultipath/defaults.h +@@ -69,7 +69,7 @@ + #define DEFAULT_WWIDS_FILE "/etc/multipath/wwids" + #define DEFAULT_PRKEYS_FILE "/etc/multipath/prkeys" + #define DEFAULT_CONFIG_DIR "/etc/multipath/conf.d" +-#define MULTIPATH_SHM_BASE "/dev/shm/multipath/" ++#define MULTIPATH_SHM_BASE RUNTIME_DIR "/multipath/" + + + static inline char *set_default(char *str) +diff --git a/multipath/Makefile b/multipath/Makefile +index e720c7f6..f3d98012 100644 +--- a/multipath/Makefile ++++ b/multipath/Makefile +@@ -12,7 +12,7 @@ EXEC = multipath + + OBJS = main.o + +-all: $(EXEC) ++all: $(EXEC) multipath.rules tmpfiles.conf + + $(EXEC): $(OBJS) $(multipathdir)/libmultipath.so $(mpathcmddir)/libmpathcmd.so + $(CC) $(CFLAGS) $(OBJS) -o $(EXEC) $(LDFLAGS) $(LIBDEPS) +@@ -27,6 +27,8 @@ install: + $(INSTALL_PROGRAM) -d $(DESTDIR)$(udevrulesdir) + $(INSTALL_PROGRAM) -m 644 11-dm-mpath.rules $(DESTDIR)$(udevrulesdir) + $(INSTALL_PROGRAM) -m 644 $(EXEC).rules $(DESTDIR)$(libudevdir)/rules.d/62-multipath.rules ++ $(INSTALL_PROGRAM) -d $(DESTDIR)$(tmpfilesdir) ++ $(INSTALL_PROGRAM) -m 644 tmpfiles.conf $(DESTDIR)$(tmpfilesdir)/multipath.conf + $(INSTALL_PROGRAM) -d $(DESTDIR)$(man8dir) + $(INSTALL_PROGRAM) -m 644 $(EXEC).8.gz $(DESTDIR)$(man8dir) + $(INSTALL_PROGRAM) -d $(DESTDIR)$(man5dir) +@@ -43,9 +45,12 @@ uninstall: + $(RM) $(DESTDIR)$(man8dir)/mpathconf.8.gz + + clean: dep_clean +- $(RM) core *.o $(EXEC) *.gz ++ $(RM) core *.o $(EXEC) *.gz multipath.rules tmpfiles.conf + + include $(wildcard $(OBJS:.o=.d)) + + dep_clean: + $(RM) $(OBJS:.o=.d) ++ ++%: %.in ++ sed 's,@RUNTIME_DIR@,$(runtimedir),' $< >$@ +diff --git a/multipath/multipath.rules b/multipath/multipath.rules.in +similarity index 95% +rename from multipath/multipath.rules +rename to multipath/multipath.rules.in +index 0486bf70..5fb499e6 100644 +--- a/multipath/multipath.rules ++++ b/multipath/multipath.rules.in +@@ -1,8 +1,8 @@ + # Set DM_MULTIPATH_DEVICE_PATH if the device should be handled by multipath + SUBSYSTEM!="block", GOTO="end_mpath" + KERNEL!="sd*|dasd*|nvme*", GOTO="end_mpath" +-ACTION=="remove", TEST=="/dev/shm/multipath/find_multipaths/$major:$minor", \ +- RUN+="/usr/bin/rm -f /dev/shm/multipath/find_multipaths/$major:$minor" ++ACTION=="remove", TEST=="@RUNTIME_DIR@/multipath/find_multipaths/$major:$minor", \ ++ RUN+="/usr/bin/rm -f @RUNTIME_DIR@/multipath/find_multipaths/$major:$minor" + ACTION!="add|change", GOTO="end_mpath" + + IMPORT{cmdline}="nompath" +diff --git a/multipath/tmpfiles.conf.in b/multipath/tmpfiles.conf.in +new file mode 100644 +index 00000000..21be438a +--- /dev/null ++++ b/multipath/tmpfiles.conf.in +@@ -0,0 +1 @@ ++d @RUNTIME_DIR@/multipath 0700 root root - diff --git a/device-mapper-multipath.spec b/device-mapper-multipath.spec index 5d80d4e..92ff926 100644 --- a/device-mapper-multipath.spec +++ b/device-mapper-multipath.spec @@ -1,37 +1,63 @@ Name: device-mapper-multipath -Version: 0.13.0 -Release: 2%{?dist} +Version: 0.8.7 +Release: 9%{?dist} Summary: Tools to manage multipath devices using device-mapper -# readline uses GPL-3.0-only -License: GPL-2.0-only AND GPL-3.0-only +License: GPLv2 URL: http://christophe.varoqui.free.fr/ # The source for this package was pulled from upstream's git repo. Use the # following command to generate the tarball -# curl -L https://github.com/opensvc/multipath-tools/archive/0.13.0.tar.gz -o multipath-tools-0.13.0.tgz -Source0: multipath-tools-0.13.0.tgz +# curl -L https://github.com/opensvc/multipath-tools/archive/0.8.7.tar.gz -o multipath-tools-0.8.7.tgz +Source0: multipath-tools-0.8.7.tgz Source1: multipath.conf -Patch0001: 0001-RH-fixup-udev-rules-for-redhat.patch -Patch0002: 0002-RH-Remove-the-property-blacklist-exception-builtin.patch -Patch0003: 0003-RH-don-t-start-without-a-config-file.patch -Patch0004: 0004-RH-Fix-nvme-function-missing-argument.patch -Patch0005: 0005-RH-use-rpm-optflags-if-present.patch -Patch0006: 0006-RH-add-mpathconf.patch -Patch0007: 0007-RH-add-wwids-from-kernel-cmdline-mpath.wwids-with-A.patch -Patch0008: 0008-RH-reset-default-find_mutipaths-value-to-off.patch -Patch0009: 0009-RH-attempt-to-get-ANA-info-via-sysfs-first.patch -Patch0010: 0010-RH-make-parse_vpd_pg83-match-scsi_id-output.patch -Patch0011: 0011-RH-add-scsi-device-handlers-to-modules-load.d.patch -Patch0012: 0012-RH-compile-with-libreadline-support.patch -Patch0013: 0013-RH-Add-mpathcleanup.patch +Patch0001: 0001-multipath-tools-add-info-about-IO-affinity-path-sele.patch +Patch0002: 0002-multipathd-fix-missing-persistent-reseravtion-for-ac.patch +Patch0003: 0003-multipath-tools-minor-fixes-to-multipath.conf.5-man-.patch +Patch0004: 0004-multipath-tools-make-IBM-XIV-config-work-with-alua-a.patch +Patch0005: 0005-multipathd.socket-add-missing-conditions-from-servic.patch +Patch0006: 0006-multipath-tools-make-IBM-2107900-DS8000-config-work-.patch +Patch0007: 0007-multipath-tools-make-EMC-SYMMETRIX-config-work-with-.patch +Patch0008: 0008-multipath-tools-make-EMC-Invista-config-work-with-al.patch +Patch0009: 0009-multipath-tools-make-COMPELNT-Compellent-Vol-config-.patch +Patch0010: 0010-multipath-tools-remove-Compellent-maintainer.patch +Patch0011: 0011-Revert-multipath-tools-make-EMC-Invista-config-work-.patch +Patch0012: 0012-Revert-multipath-tools-make-EMC-SYMMETRIX-config-wor.patch +Patch0013: 0013-multipath-fix-exit-status-of-multipath-T.patch +Patch0014: 0014-libmultipath-add-section-name-to-invalid-keyword-out.patch +Patch0015: 0015-libmultipath-use-typedef-for-keyword-handler-functio.patch +Patch0016: 0016-libmultipath-print-the-correct-file-when-parsing-fai.patch +Patch0017: 0017-libmultipath-pass-file-and-line-number-to-keyword-ha.patch +Patch0018: 0018-libmultipath-make-set_int-take-a-range-for-valid-val.patch +Patch0019: 0019-libmultipath-improve-checks-for-set_str.patch +Patch0020: 0020-libmultipath-deprecate-file-and-directory-config-opt.patch +Patch0021: 0021-libmultipath-split-set_int-to-enable-reuse.patch +Patch0022: 0022-libmultipath-cleanup-invalid-config-handling.patch +Patch0023: 0023-libmultipath-don-t-return-error-on-invalid-values.patch +Patch0024: 0024-multipathd-avoid-unnecessary-path-read-only-reloads.patch +Patch0025: 0025-RH-fixup-udev-rules-for-redhat.patch +Patch0026: 0026-RH-Remove-the-property-blacklist-exception-builtin.patch +Patch0027: 0027-RH-don-t-start-without-a-config-file.patch +Patch0028: 0028-RH-Fix-nvme-function-missing-argument.patch +Patch0029: 0029-RH-use-rpm-optflags-if-present.patch +Patch0030: 0030-RH-add-mpathconf.patch +Patch0031: 0031-RH-add-wwids-from-kernel-cmdline-mpath.wwids-with-A.patch +Patch0032: 0032-RH-reset-default-find_mutipaths-value-to-off.patch +Patch0033: 0033-RH-attempt-to-get-ANA-info-via-sysfs-first.patch +Patch0034: 0034-RH-make-parse_vpd_pg83-match-scsi_id-output.patch +Patch0035: 0035-libmultipath-use-asprintf-to-allocate-prefixed_uuid.patch +Patch0036: 0036-RH-add-support-to-mpathconf-for-setting-arbitrary-de.patch +Patch0037: 0037-RH-add-support-to-mpathconf-for-setting-recheck_wwid.patch +Patch0038: 0038-multipathd-Add-missing-ctype-include.patch +Patch0039: 0039-multipathd-replace-libreadline-with-libedit.patch +Patch0040: 0040-multipathd-ignore-duplicated-multipathd-command-keys.patch +Patch0041: 0041-multipath-tools-use-run-instead-of-dev-shm.patch # runtime Requires: %{name}-libs = %{version}-%{release} Requires: kpartx = %{version}-%{release} Requires: device-mapper >= 1.02.96 Requires: userspace-rcu -Requires: readline -Requires: libmount +Requires: libedit Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units @@ -49,11 +75,10 @@ Conflicts: udisks2 < 2.8.0-2 # build/setup BuildRequires: libaio-devel, device-mapper-devel >= 1.02.89 BuildRequires: libselinux-devel, libsepol-devel -BuildRequires: readline-devel, ncurses-devel +BuildRequires: libedit-devel, ncurses-devel BuildRequires: systemd-units, systemd-devel BuildRequires: json-c-devel, perl-interpreter, pkgconfig, gcc BuildRequires: userspace-rcu-devel -BuildRequires: libmount-devel BuildRequires: make %description @@ -65,8 +90,8 @@ The tools are : %package libs Summary: The %{name} modules and shared library -# only libmpathcmd is LGPL-2.1-or-later AND LGPL-2.0-or-later -License: GPL-2.0-or-later AND LGPL-2.1-or-later AND LGPL-2.0-or-later +# only libmpathcmd is LGPLv2+ +License: GPLv2 and LGPLv2+ %description libs The %{name}-libs provides the path checker @@ -91,8 +116,7 @@ kpartx manages partition creation and removal for device-mapper devices. %package -n libdmmp Summary: device-mapper-multipath C API library -# Automatically converted from old format: GPLv3+ - review is highly recommended. -License: GPL-3.0-or-later +License: GPLv3+ Requires: json-c Requires: %{name} = %{version}-%{release} Requires: %{name}-libs = %{version}-%{release} @@ -111,10 +135,11 @@ This package contains the files needed to develop applications that use device-mapper-multipath's libdmmp C API library %prep -%autosetup -n multipath-tools-0.13.0 -p1 +%autosetup -n multipath-tools-0.8.7 -p1 cp %{SOURCE1} . %build +%define _sbindir /usr/sbin %define _libdir /usr/%{_lib} %define _libmpathdir %{_libdir}/multipath %define _pkgconfdir %{_libdir}/pkgconfig @@ -125,8 +150,8 @@ cp %{SOURCE1} . bindir=%{_sbindir} \ syslibdir=%{_libdir} \ usrlibdir=%{_libdir} \ - plugindir=%{_libmpathdir} \ - mandir=%{_mandir} \ + libdir=%{_libmpathdir} \ + rcdir=%{_initrddir} \ unitdir=%{_unitdir} \ includedir=%{_includedir} \ pkgconfdir=%{_pkgconfdir} \ @@ -145,7 +170,7 @@ rm -rf %{buildroot}/%{_initrddir} %postun if [ $1 -ge 1 ] ; then - multipathd forcequeueing daemon > /dev/null 2>&1 || : + /sbin/multipathd forcequeueing daemon > /dev/null 2>&1 || : fi %systemd_postun_with_restart multipathd.service @@ -155,39 +180,31 @@ fi /bin/systemctl --quiet is-enabled multipathd.service >/dev/null 2>&1 && /bin/systemctl reenable multipathd.service ||: %files -%license LICENSES/GPL-2.0 LICENSES/LGPL-2.0 LICENSES/GPL-3.0 +%license LICENSES/GPL-2.0 LICENSES/LGPL-2.0 %{_sbindir}/multipath %{_sbindir}/multipathd -%{_sbindir}/multipathc %{_sbindir}/mpathconf -%{_sbindir}/mpathcleanup %{_sbindir}/mpathpersist %{_unitdir}/multipathd.service -%{_unitdir}/multipathd-queueing.service %{_unitdir}/multipathd.socket -%{_mandir}/man5/multipath.conf.5* -%{_mandir}/man8/multipath.8* -%{_mandir}/man8/multipathd.8* -%{_mandir}/man8/multipathc.8* -%{_mandir}/man8/mpathconf.8* -%{_mandir}/man8/mpathpersist.8* +%{_mandir}/man5/multipath.conf.5.gz +%{_mandir}/man8/multipath.8.gz +%{_mandir}/man8/multipathd.8.gz +%{_mandir}/man8/mpathconf.8.gz +%{_mandir}/man8/mpathpersist.8.gz %config /usr/lib/udev/rules.d/62-multipath.rules %config /usr/lib/udev/rules.d/11-dm-mpath.rules -%config /usr/lib/udev/rules.d/99-z-dm-mpath-late.rules -%dir %{_modulesloaddir} -%{_modulesloaddir}/scsi_dh.conf %{_tmpfilesdir}/multipath.conf %doc README.md +%doc README.alua %doc multipath.conf %dir /etc/multipath %files libs -%license LICENSES/GPL-2.0 LICENSES/LGPL-2.0 LICENSES/LGPL-2.1 +%license LICENSES/GPL-2.0 LICENSES/LGPL-2.0 %doc README.md %{_libdir}/libmultipath.so %{_libdir}/libmultipath.so.* -%{_libdir}/libmpathutil.so -%{_libdir}/libmpathutil.so.* %{_libdir}/libmpathpersist.so.* %{_libdir}/libmpathcmd.so.* %{_libdir}/libmpathvalid.so.* @@ -204,15 +221,15 @@ fi %{_includedir}/mpath_cmd.h %{_includedir}/mpath_persist.h %{_includedir}/mpath_valid.h -%{_mandir}/man3/mpath_persistent_reserve_in.3* -%{_mandir}/man3/mpath_persistent_reserve_out.3* +%{_mandir}/man3/mpath_persistent_reserve_in.3.gz +%{_mandir}/man3/mpath_persistent_reserve_out.3.gz %files -n kpartx %license LICENSES/GPL-2.0 %doc README.md %{_sbindir}/kpartx /usr/lib/udev/kpartx_id -%{_mandir}/man8/kpartx.8* +%{_mandir}/man8/kpartx.8.gz %config /usr/lib/udev/rules.d/11-dm-parts.rules %config /usr/lib/udev/rules.d/66-kpartx.rules %config /usr/lib/udev/rules.d/68-del-part-nodes.rules @@ -230,197 +247,25 @@ fi %dir %{_includedir}/libdmmp %{_includedir}/libdmmp/* %{_mandir}/man3/dmmp_* -%{_mandir}/man3/libdmmp.h.3* +%{_mandir}/man3/libdmmp.h.3.gz %{_pkgconfdir}/libdmmp.pc %changelog -* Thu Nov 13 2025 Benjamin Marzinski - 0.13.0-2 -- Move STI tests to TMT +* Wed Oct 26 2022 Benjamin Marzinski - 0.8.7-9 +- Add 0040-multipathd-ignore-duplicated-multipathd-command-keys.patch + * Fixes bz #2137414 +- Add 0041-multipath-tools-use-run-instead-of-dev-shm.patch + * Fixes bz #2137416 +- Resolves: bz #2137414, #2137416 -* Tue Nov 4 2025 Benjamin Marzinski - 0.13.0-1 -- Update source to upstream release 0.13.0 - * Previous patches 0001-0004 are included in the tarball -- Install /lib/systemd/system/multipathd-queueing.service -- Rename redhat patches - * Previous patches 0005-0017 are now patches 0001-0013 +* Tue Aug 23 2022 Benjamin Marzinski - 0.8.7-8.1 +- Add 0038-multipathd-Add-missing-ctype-include.patch +- Add 0039-multipathd-replace-libreadline-with-libedit.patch + * replace readline with libedit, to avoid license conflicts. readline + is licensed GPL v3, and multipathd includes code licensed gpl v2 + only. +- Require libedit instead of readline -* Wed Jul 23 2025 Fedora Release Engineering - 0.11.1-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild - -* Thu Feb 27 2025 Benjamin Marzinski - 0.11.1-1 -- Update source to upstream staging branch for 0.11.1 plus additional - stable branch patches. - * Previous patches 0001-0032 are included in the tarball -- Rename redhat patches - * Previous patches 0033-0045 are now patches 0005-0017 - -* Sat Feb 1 2025 Benjamin Marzinski - 0.10.0-5 -- Update source to upstream staging branch for 0.10.y (will be 0.10.2 when - merged). -- Rebase redhat patches - -* Thu Jan 16 2025 Fedora Release Engineering - 0.10.0-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild - -* Sun Jan 12 2025 Zbigniew Jędrzejewski-Szmek - 0.10.0-3 -- Rebuilt for the bin-sbin merge (2nd attempt) - -* Thu Aug 29 2024 Benjamin Marzinski - 0.10.0-2 -- update CI tests. - -* Thu Aug 29 2024 Benjamin Marzinski - 0.10.0-1 -- Update source to upstream version 0.9.9 - * Previous patch 0014-multipathd-fix-flush-check-in-flush_map.patch is - included in the source tarball -- Rebase redhat patches - -* Fri Aug 9 2024 Benjamin Marzinski - 0.9.9-6 -- Add 0014-multipathd-fix-null-pointer-dereference-in-uev_updat.patch - * multipath features tracking on failed removes - -* Mon Jul 29 2024 Miroslav Suchý - 0.9.9-5 -- convert license to SPDX - -* Thu Jul 25 2024 Miroslav Suchý - 0.9.9-4 -- convert license to SPDX - -* Wed Jul 17 2024 Fedora Release Engineering - 0.9.9-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild - -* Tue Jul 09 2024 Zbigniew Jędrzejewski-Szmek - 0.9.9-2 -- Rebuilt for the bin-sbin merge - -* Thu Jun 13 2024 Benjamin Marzinski - 0.9.9-1 -- Update source to upstream version 0.9.9 - * Previous patches 0001-0044 are included in the source tarball -- Rename redhat patches - * Previous patches 0045-0057 are now patches 0001-0013 - -* Mon May 20 2024 Benjamin Marzinski - 0.9.8-1 -- Update source to upstream version 0.9.8 plus latest staging branch - * Previous patches 0014 & 0015 are included in the source tarball - * patches 0001-0044 are from the upstream staging branch -- Rename redhat patches - * Previous patches 0001-0013 are now patches 0045-0057 -- Install /lib/udev/rules.d/99-z-dm-mpath-late.rules - -* Wed Jan 24 2024 Fedora Release Engineering - 0.9.7-7 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild - -* Fri Jan 19 2024 Fedora Release Engineering - 0.9.7-6 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild - -* Tue Jan 16 2024 Benjamin Marzinski - 0.9.7-5 -- Add 0014-multipathd-fix-null-pointer-dereference-in-uev_updat.patch - * Fix auto_resize code to avoid a segfault -- Add 0015-multipathd-fix-auto-resize-configuration.patch - * Fix auto_resize default value - -* Thu Nov 30 2023 Benjamin Marzinski - 0.9.7-4 -- Use modulesloaddir macro for installing scsi_dh.conf - -* Wed Nov 29 2023 Benjamin Marzinski - 0.9.7-3 -- Fix multipath_conf_syntax test -- Fix restate_module test - -* Tue Nov 28 2023 Paul Donohue - 0.9.7-2 -- Modify 0006-RH-add-mpathconf.patch -- Modify 0008-RH-reset-default-find_mutipaths-value-to-off.patch - * Fix find_multipaths values in docs and mpathconf - -* Tue Nov 21 2023 Benjamin Marzinski - 0.9.7-1 -- Update source to upstream version 0.9.7 - * Previous patches 0001-0040 are included in the source tarball -- Rename redhat patches - * Previous patches 0041-0053 are now patches 0001-0013 -- Remove /usr/lib/modules-load.d/multipath.conf - * has been replaced with modprobe@dm_multipath.service unit Wants. - -* Fri Sep 22 2023 Benjamin Marzinski - 0.9.6-1 -- Update to the head of the upstream staging branch -- Rename redhat patches - * Previous patches 0001-0012 are now patches 0041-0052 -- Add 0053-RH-Add-mpathcleanup.patch - * add mpathcleanup program - -* Wed Jul 19 2023 Fedora Release Engineering - 0.9.5-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild - -* Tue May 16 2023 Benjamin Marzinski - 0.9.5-1 -- Update to the latest upstream release - * Previous patches 0001-0015 are included in the source tarball -- Rename redhat patches - * Previous patches 0016-0027 are now patches 0001-0012 - -* Thu Feb 2 2023 Benjamin Marzinski - 0.9.4-2 -- Update to the head of the upstream staging branch - * Patches 0011-0015 are from the upstream staging branch -- Rename redhat patches - * Previous patches 0011-0022 are now patches 0016-0027 - -* Thu Jan 26 2023 Benjamin Marzinski - 0.9.4-1 -- Update to the head of the upstream staging branch - * Previous patches 0001-0032 are included in the source tarball - * Patches 0001-0010 are from the upstream staging branch -- Rename redhat patches - * Previous patches 0033-0044 are now patches 0011-0022 -- Add dependency on libmount - -* Thu Jan 19 2023 Fedora Release Engineering - 0.9.3-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild - -* Tue Nov 15 2022 Benjamin Marzinski - 0.9.3-1 -- Update to the head of the upstream staging branch - * Previous patches 0001-0042 are included in the source tarball - * Patches 0001-0032 are from the upstream staging branch -- Rename redhat patches - * Previous patches 0043-0053 are now patches 0033-0043 -- Change back to using readline instead of libedit - * The code the uses readline has been isolated from the code that - is licensed gpl v2 only. -- Add libmpathutil libraries to spec file -- Add multipathc program to spec file -- Add multipath.conf systemd tempfile configuration to spec file -- Misc spec file cleanups - -* Fri Aug 19 2022 Benjamin Marzinski - 0.9.0-3 -- Update to the head of the upstream staging branch - * Patches 0005-0042 are from the upstream staging branch - * Previous patches 0005 & 0006 are now patches 0023 & 0005 -- Rename redhat patches - * Previous patches 0007-0017 are now patches 0043-0053 -- Change from using readline to libedit - * readline is licensed GPL v3, and multipathd includes code - licensed gpl v2. -- Remove README.alua - * information moved to README.md - -* Thu Jul 21 2022 Fedora Release Engineering - 0.9.0-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild - -* Wed Jul 13 2022 Benjamin Marzinski - 0.9.0-1 -- Update source to upstream version 0.9.0 - * Previous patches 0001-0005 are included in the commit. - * This version deprecates multiple options: mutlipath_dir, config_dir, and - getuid_callout, along with the "default_" prefixed alternate names for the - default section parameters. -- Add patches from upstream staging branch - * Patches 0001-0006 are from the upstream staging branch -- Rename redhat patches - * Previous patches 0006-0016 are now patches 0007-0017 - -* Mon Mar 28 2022 Benjamin Marzinski - 0.8.9-1 -- Update source to upstream version 0.8.9 - * Previous patches 0001-0024 & 0035 are included in the commit. -- Add patches from upstream staging branch - * Patches 0001-0005 are from the upstream staging branch -- Rename redhat patches - * Previous patches 0025-0034 are now patches 0006-0015 -- Combine redhat patches - * Previous patches 0036 & 0037 are now part of patch 0011 -- Add 0016-RH-add-scsi-device-handlers-to-modules-load.d.patch -- Spec file changes - * Install multipath.conf and scsi_dh.conf to /usr/lib/modules-load.d * Mon Feb 7 2022 Benjamin Marzinski - 0.8.7-8 - Add 0036-RH-add-support-to-mpathconf-for-setting-arbitrary-de.patch diff --git a/plans/multipath.fmf b/plans/multipath.fmf deleted file mode 100644 index 876c77a..0000000 --- a/plans/multipath.fmf +++ /dev/null @@ -1,58 +0,0 @@ -summary: basic functionality tests - -provision: - hardware: - memory: ">= 2 GB" - -prepare: - how: install - package: - - device-mapper-multipath - - perl - -discover: - how: shell - tests: - - name: medium_error_scsi_debug - path: /tests/medium_error_scsi_debug - test: ./main.sh - duration: 15m - - name: squelch_scsi_id - path: /tests/squelch_scsi_id - test: ./main.sh - duration: 15m - - name: multipathd_oom - path: /tests/multipathd_oom - test: ./main.sh - duration: 15m - - name: user_friendly_names - path: /tests/user_friendly_names - test: ./main.sh - duration: 15m - - name: kpartx_4k_aligned - path: /tests/kpartx_4k_aligned - test: ./main.sh - duration: 15m - - name: bindings - path: /tests/bindings - test: ./main.sh - duration: 15m - - name: restate_module - path: /tests/restate_module - test: ./main.sh - duration: 15m - - name: find_multipaths - path: /tests/find_multipaths - test: ./main.sh - duration: 15m - - name: multipath_conf_syntax - path: /tests/multipath_conf_syntax - test: ./main.sh - duration: 15m - - name: alias_clash - path: /tests/alias_clash - test: ./main.sh - duration: 15m - -execute: - how: tmt diff --git a/sources b/sources index 233c4ea..ba0504a 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (multipath-tools-0.13.0.tgz) = 75c84524ee27590b8b751ea500898a44e5ac3d58d55be6bcab919d0d423049db3a4466fcb9135705cf63ba074416973bb651255063269e9f682f11d21ba57e59 +SHA512 (multipath-tools-0.8.7.tgz) = c01aea837b13429d17688455b813947342ca1cabba19b22e13ce640c77e68335a6d410280a8298595e239131e6fcbb655fa6de5ff9857eac99aa175046a450cd SHA512 (multipath.conf) = 71953dce5a68adcf60a942305f5a66023e6f4c4baf53b1bfdb4edf65ed5b8e03db804363c36d1dcfd85591f4766f52b515269904c53b84d7b076da0b80b09942 diff --git a/.fmf/version b/tests/.fmf/version similarity index 100% rename from .fmf/version rename to tests/.fmf/version diff --git a/tests/bindings/main.sh b/tests/bindings/main.sh index 76292e4..2d6f284 100755 --- a/tests/bindings/main.sh +++ b/tests/bindings/main.sh @@ -18,110 +18,40 @@ # Author: Lin Li #set -x -source ../include/tc.sh || exit 200 +source ../include/ec.sh || exit 200 + tlog "running $0" -cleanup () -{ - local retries - if pidof multipathd; then - tlog "stopping multipathd" - trun "systemctl stop multipathd.service || pkill multipathd" - sleep 1 - fi - retries=10 - while pidof multipathd; do - ((retries--)) - if [[ $retries -le 0 ]]; then - tfail_ "failed to stop multipath" - tend - fi - tlog "waiting for multipathd to stop" - sleep 2 - pidof multipathd && pkill multipathd - done - trun "multipath -l -v1" - retries=10 - while [[ -n `multipath -l -v1` ]]; do - ((retries--)) - if [[ $retries -le 0 ]]; then - tfail_ "failed to remove deviece" - tend - fi - tlog "removing multipath device" - trun "udevadm settle" - trun "multipath -DF" - sleep 2 - done - if lsmod | grep -q "^scsi_debug"; then - tlog "removing scsi_debug module" - tok "rmmod scsi_debug" - fi - trun "rm -f /etc/multipath.conf" -} - -assert () -{ - local cmd="$*" - _trun_ "$cmd" 0 - if test $? -eq 0; then - tpass_ "$cmd" ; - else - tfail_ "$cmd" ; - cleanup ; - tend ; - fi -} - -setup_config () -{ - trun "mpathconf --enable --user_friendly_names y" - sed -i '/^blacklist[[:space:]]*{/ a\ - device {\ - vendor ".*"\ - product ".*"\ - } -' /etc/multipath.conf - cat << _EOF_ >> /etc/multipath.conf - -blacklist_exceptions { - device { - vendor Linux - product scsi_debug - } -} -_EOF_ - trun "cat /etc/multipath.conf" -} - -do_reconfigure () -{ - tok "multipathd reconfigure" - sleep 5 -} - -rpm -q device-mapper-multipath || dnf install -y device-mapper-multipath -cleanup -setup_config -trun "rm -r /etc/multipath/bindings" -trun "modprobe scsi_debug vpd_use_hostno=0 add_host=2" +trun "service multipathd stop" +rpm -q device-mapper-multipath || yum install -y device-mapper-multipath +trun "mpathconf --enable --with_multipathd y --user_friendly_names y" +trun "service multipathd status" sleep 5 -trun "systemctl start multipathd.service" -while multipathd show daemon | grep -qv idle; do - tlog "waiting for multipathd to start" - sleep 1 -done -trun 'multipathd show maps raw format "%n"' -mpath_name=`multipathd show maps raw format "%n" | head -1` -assert "[[ -n $mpath_name ]] && [[ $mpath_name != ok ]]" +trun "multipath -F" +sleep 5 +terr "modprobe -r scsi_debug" +terr "modprobe scsi_debug num_tgts=1 vpd_use_hostno=0 add_host=2 delay=20 \ +max_luns=2 no_lun_0=1" +sleep 60 + +disk_path=$(get_scsi_debug_devices) +disk=$(basename $disk_path) +mpath_name=$(get_mpath_disk_by_scsi_device $disk) new_alias="mpath_test_$$" trun "sed -i 's/$mpath_name/$new_alias/' /etc/multipath/bindings" -do_reconfigure -trun 'multipathd show maps raw format "%n"' -mpath_name=`multipathd show maps raw format "%n" | head -1` -assert "[[ $mpath_name = $new_alias ]]" +trun "multipath -r" +sleep 5 +tok "[[ -b /dev/mapper/$new_alias ]]" +tok is_mpath $new_alias +sleep 5 -cleanup +trun "multipath -F" +sleep 5 +trun "modprobe -r scsi_debug" +trun "service multipathd stop" +sleep 3 +trun "multipath -W" +trun "rm /etc/multipath/bindings" tend diff --git a/tests/find_multipaths/Makefile b/tests/find_multipaths/Makefile new file mode 100644 index 0000000..b78dc57 --- /dev/null +++ b/tests/find_multipaths/Makefile @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2016 Red Hat, Inc. +# # +# # This program is free software: you can redistribute it and/or modify +# # it under the terms of the GNU General Public License as published by +# # the Free Software Foundation, either version 3 of the License, or +# # (at your option) any later version. +# # +# # This program is distributed in the hope that it will be useful, +# # but WITHOUT ANY WARRANTY; without even the implied warranty of +# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# # GNU General Public License for more details. +# # +# # You should have received a copy of the GNU General Public License +# # along with this program. If not, see . +# +# # Author: Lin Li + +.PHONY: all install download clean + +BUILT_FILES= + +FILES=$(METADATA) Makefile PURPOSE main.sh + +run: $(FILES) build + ./main.sh + +build: $(BUILT_FILES) + chmod a+x ./main.sh + +clean: + rm -f *~ *.rpm $(BUILT_FILES) + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @touch $(METADATA) + @echo "Owner: LiLin " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "License: GPLv3" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Description: find_multipaths" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: device-mapper-multipath" >> $(METADATA) + @echo "Requires: device-mapper-multipath" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/find_multipaths/main.sh b/tests/find_multipaths/main.sh index 28c325c..a39af79 100755 --- a/tests/find_multipaths/main.sh +++ b/tests/find_multipaths/main.sh @@ -18,92 +18,38 @@ # Author: Lin Li #set -x -source ../include/tc.sh || exit 200 -tlog "running $0" - -remove_devices () -{ - local retries - retries=10 - while [[ -n `multipath -l -v1` ]]; do - ((retries--)) - if [[ $retries -le 0 ]]; then - tfail_ "failed to remove devices" - cleanup - tend - fi - tlog "removing multipath devices" - trun "udevadm settle" - trun "multipath -F" - sleep 2 - done -} +source ../include/ec.sh || exit 200 cleanup () { - local retries - if pidof multipathd; then - tlog "stopping multipathd" - trun "systemctl stop multipathd.service || pkill multipathd" - sleep 1 - fi - retries=10 - while pidof multipathd; do - ((retries--)) - if [[ $retries -le 0 ]]; then - tfail_ "failed to stop multipath" - tend - fi - tlog "waiting for multipathd to stop" - sleep 2 - pidof multipathd && pkill multipathd - done - trun "multipath -l -v1" - retries=10 - while [[ -n `multipath -l -v1` ]]; do - ((retries--)) - if [[ $retries -le 0 ]]; then - tfail_ "failed to remove devices" - tend - fi - tlog "removing multipath devices" - trun "udevadm settle" - trun "multipath -DF" - sleep 2 - done - if lsmod | grep -q "^scsi_debug"; then - tlog "removing scsi_debug module" - tok "rmmod scsi_debug" - fi - trun "rm -f /etc/multipath.conf" - trun "rm -f /etc/multipath/wwids" - trun "rm -r /etc/multipath/bindings" + trun "multipathd disablequeueing maps" + trun "service multipathd stop" + sleep 5 + trun "udevadm settle" + trun "multipath -F" + sleep 5 + trun "modprobe -r scsi_debug" } -assert () -{ - local cmd="$*" - _trun_ "$cmd" 0 - if test $? -eq 0; then - tpass_ "$cmd" ; - else - tfail_ "$cmd" ; - cleanup ; - tend ; - fi -} +tlog "running $0" -setup_config () -{ - trun "mpathconf --enable --user_friendly_names y --find_multipaths y" - sed -i '/^blacklist[[:space:]]*{/ a\ - device {\ - vendor ".*"\ - product ".*"\ - } +# which not set find_multipaths yes, so multipath always create a multipath device for single device +# so stop service and reconfig with --find_multipaths y, and reload/start the service again. +rpm -q device-mapper-multipath || yum install -y device-mapper-multipath + +# test with find_multipath=y, will not multipath for the single device; reload/start the service to enable the config +cleanup +trun "rm -f /etc/multipath.conf" +trun "mpathconf --enable --user_friendly_names y --find_multipaths y --with_multipathd n" +sed -i '/^blacklist[[:space:]]*{/ a\ + device {\n vendor ".*"\n product ".*"\n } ' /etc/multipath.conf - cat << _EOF_ >> /etc/multipath.conf - +if grep -qw blacklist_exceptions /etc/multipath.conf ; then + sed -i '/^blacklist_exceptions[[:space:]]*{/ a\ + device {\n vendor Linux\n product scsi_debug\n } +' /etc/multipath.conf +else + cat << _EOF_ >> /etc/multipath.conf blacklist_exceptions { device { vendor Linux @@ -111,69 +57,56 @@ blacklist_exceptions { } } _EOF_ - trun "cat /etc/multipath.conf" -} - -do_reconfigure () -{ - trun "cat /etc/multipath.conf" - tok "multipathd reconfigure" - sleep 5 -} - -trun "rpm -q device-mapper-multipath || dnf install -y device-mapper-multipath" -cleanup -setup_config - -# test with find_multipath=y, will not multipath the single device +fi +trun "service multipathd start" trun "modprobe scsi_debug" sleep 5 -trun "systemctl start multipathd.service" -while multipathd show daemon | grep -qv idle; do - tlog "waiting for multipathd to start" - sleep 1 -done -trun 'multipathd show paths raw format "%d %m"' -trun 'cat /etc/multipath/wwids' -mpath_name=`multipathd show paths raw format "%m" | head -1` -tok "[[ $mpath_name = '[orphan]' ]]" -remove_devices - -# test with find_multipath=n, will multipath the single device -trun 'mpathconf --find_multipaths n' -do_reconfigure -trun 'multipathd show paths raw format "%d %m"' -trun 'cat /etc/multipath/wwids' -mpath_name=`multipathd show paths raw format "%m" | head -1` -tok "[[ -n $mpath_name ]] && [[ $mpath_name != '[orphan]' ]]" -remove_devices - -# test with find_multipath=y, with multipath single device with known WWID -trun 'mpathconf --find_multipaths y' -do_reconfigure -trun 'multipathd show paths raw format "%d %m"' -trun 'cat /etc/multipath/wwids' -mpath_name=`multipathd show paths raw format "%m" | head -1` -tok "[[ -n $mpath_name ]] && [[ $mpath_name != '[orphan]' ]]" -remove_devices - -# Clear WWID, test with find_multipath=y, will not multipath single device trun "multipath -W" -do_reconfigure -trun 'multipathd show paths raw format "%d %m"' -trun 'cat /etc/multipath/wwids' -mpath_name=`multipathd show paths raw format "%m" | head -1` -tok "[[ $mpath_name = '[orphan]' ]]" -remove_devices -assert 'rmmod scsi_debug' +cat /etc/multipath/wwids +trun "multipath" +disk_path=$(get_scsi_debug_devices) +disk_node=$(basename $disk_path) +mpath_name=$(get_mpath_disk_by_scsi_device $disk_node) +tok '[[ $mpath_name = "[orphan]" ]]' + +# test with find_multipath=n, will multipath for the single device +trun "mpathconf --user_friendly_names y --find_multipaths n --with_multipathd y" +sleep 5 +mpath_name=$(get_mpath_disk_by_scsi_device $disk_node) +tok "is_mpath $mpath_name" + +# flush new created path +trun "multipath -F" +sleep 1 + +# test with find_multipath=y, A path has the same WWID as a multipath device that was previously created +trun "mpathconf --user_friendly_names y --find_multipaths y --with_multipathd y" +sleep 5 +mpath_name=$(get_mpath_disk_by_scsi_device $disk_node) +tok "is_mpath $mpath_name" +trun "multipath -F" +sleep 1 + +# Clear wwid, test with find_multipath=y, will not multipath for the single device +trun "multipath -W" +trun "service multipathd reload" +sleep 5 +mpath_name=$(get_mpath_disk_by_scsi_device $disk_node) +tok '[[ $mpath_name = "[orphan]" ]]' + +trun "multipath -F" +sleep 5 +trun "modprobe -r scsi_debug" # test find_multipaths=y create device for paths have same wwid -trun "modprobe scsi_debug vpd_use_hostno=0 add_host=2" -sleep 5 -trun 'multipathd show paths raw format "%d %m"' -trun 'cat /etc/multipath/wwids' -mpath_name=`multipathd show paths raw format "%m" | head -1` -tok "[[ -n $mpath_name ]] && [[ $mpath_name != '[orphan]' ]]" +tok "modprobe scsi_debug num_tgts=1 vpd_use_hostno=0 add_host=2 delay=20 max_luns=2 no_lun_0=1" +sleep 10 +disk_paths=$(get_scsi_debug_devices) +disk_node=$(basename $disk_paths) +mpath_name=$(get_mpath_disk_by_scsi_device $disk_node) +tok "is_mpath $mpath_name" cleanup +trun "multipath -W" +cat /etc/multipath/wwids tend diff --git a/tests/include/ec.sh b/tests/include/ec.sh index 4b0aba9..22dfc40 100755 --- a/tests/include/ec.sh +++ b/tests/include/ec.sh @@ -44,12 +44,9 @@ function _init (){ } function _destroy (){ - Cmd "multipathd disablequeueing maps" + sleep 10 + Cmd "multipath -F" sleep 5 - Cmd "multipath -DF -R2" - Cmd "service multipathd stop" - sleep 5 - Cmd "udevadm settle" Cmd "modprobe -r scsi_debug" } @@ -177,7 +174,10 @@ AA fi #setup scsi_debug echo "INFO: Loading scsi_debug module for simulation of mpath" - modprobe scsi_debug vpd_use_hostno=0 add_host=2 + modprobe scsi_debug \ + num_tgts=1 vpd_use_hostno=0 \ + add_host=4 delay=20 \ + max_luns=2 no_lun_0=1 2>&1 1>/dev/null echo "INFO: Waiting for udev to create /dev/sdX" sleep 15s #wait for udev to create /dev/sdX @@ -189,6 +189,8 @@ AA #enable multipath for scsi_debug. cat << AA > /etc/multipath.conf defaults { +#Enable multibus is for mutlbus testing + path_grouping_policy multibus user_friendly_names yes } blacklist { diff --git a/tests/medium_error_scsi_debug/main.sh b/tests/medium_error_scsi_debug/main.sh index 35c6e6f..db2f008 100755 --- a/tests/medium_error_scsi_debug/main.sh +++ b/tests/medium_error_scsi_debug/main.sh @@ -16,51 +16,47 @@ # along with this program. If not, see . # Author: LiLin -source ../include/tc.sh || exit 200 -cleanup() +function cleanup() { sleep 5 udevadm settle - trun "multipath -DF" + multipath -F sleep 5 - trun "modprobe -r scsi_debug" + modprobe -r scsi_debug + + return 0 } -assert () -{ - local cmd="$*" - _trun_ "$cmd" 0 - if test $? -eq 0; then - tpass_ "$cmd" ; - else - tfail_ "$cmd" ; - cleanup ; - tend ; - fi -} - -tlog "running $0" -rpm -q device-mapper-multipath || dnf install -y device-mapper-multipath -trun "multipathd disablequeueing maps" -cleanup -trun "service multipathd stop" -trun "rm -f /etc/multipath.conf" -trun "mpathconf --enable" -trun "modprobe scsi_debug vpd_use_hostno=0 add_host=2 opts=2" +yum -y install device-mapper device-mapper-multipath +mpathconf --enable +service multipathd stop +modprobe scsi_debug num_tgts=1 vpd_use_hostno=0 add_host=2 delay=20 max_luns=2 no_lun_0=1 opts=2 sleep 5 -trun "multipath" +multipath > /dev/null sleep 5 -trun "multipath -l" mpathdev=`multipath -l | grep scsi_debug | awk '{print $1}' | head -1` -assert "[[ -n \"$mpathdev\" ]]" +if [ -z "$mpathdev" ]; then + echo "------- FAIL, no multipath device created -----" + cleanup + exit 1 +fi before_active=`multipath -l $mpathdev | grep "active undef" | wc -l` -tlog "before active = ${before_active}" IO_error=`dd if=/dev/zero of=/dev/mapper/$mpathdev bs=1024 seek=2330 count=10 2>&1 | grep -o "Input/output error" ` -assert "[[ -n \"$IO_error\" ]]" -after_active=`multipath -l $mpathdev | grep "active undef" | wc -l` -tlog "after active = ${after_active}" -assert "[[ \"$before_active\" -eq \"$after_active\" ]]" -cleanup -tend +if [ -n "$IO_error" ];then + after_active=`multipath -l $mpathdev | grep "active undef" | wc -l` + if [ "$before_active" -eq "$after_active" ]; then + echo "------- PASS, a medium error, correctly generated an I/O error and did not fail paths -----" + cleanup + exit 0 + else + echo "------- FAIL, paths failed -----" + cleanup + exit 1 + fi +else + echo "------- FAIL, did not generate an I/O error -----" + cleanup + exit 1 +fi diff --git a/tests/multipath_conf_syntax/main.sh b/tests/multipath_conf_syntax/main.sh index fb303c3..331d65e 100755 --- a/tests/multipath_conf_syntax/main.sh +++ b/tests/multipath_conf_syntax/main.sh @@ -119,7 +119,7 @@ tok "multipath -ll | grep mypath" # test wrong alias keyword trun "sed -i 's/alias.*$/alia mypath/g' /etc/multipath.conf" -tok "multipath 2>&1 | grep 'invalid keyword in the multipath section: alia'" +tok "multipath 2>&1 | grep 'invalid keyword: alia'" trun "multipath -r" tok "multipath -ll | grep mpath" trun "sed -i 's/alia.*$/alias mypath/g' /etc/multipath.conf" diff --git a/tests/provision.fmf b/tests/provision.fmf new file mode 100644 index 0000000..62a6eba --- /dev/null +++ b/tests/provision.fmf @@ -0,0 +1,5 @@ +--- + +standard-inventory-qcow2: + qemu: + m: 2G diff --git a/tests/restate_module/main.sh b/tests/restate_module/main.sh index be60eba..7f3279d 100755 --- a/tests/restate_module/main.sh +++ b/tests/restate_module/main.sh @@ -48,8 +48,10 @@ rpm -q device-mapper-multipath || yum install -y device-mapper-multipath tlog "device-mapper-multipath is installed" # cleanup existing devices trun "rm /etc/multipath.conf" -trun "mpathconf --enable --with_module y --option max_polling_interval:10" -trun "mpathconf --option detect_pgpolicy_use_tpg:yes" +trun "mpathconf --enable --with_module y" +sed -i '/^defaults[[:space:]]*{/ a\ + max_polling_interval 10 +' /etc/multipath.conf trun "service multipathd stop" trun "multipath -F" sleep 5 @@ -67,7 +69,7 @@ tlog "Checking if active path count equals 2" assert "[[ $pathcount -eq 2 ]]" tlog "offline one path device" -pathname=`multipathd show paths raw format "%d %m %p" | grep ${mpathdev} | sort -k 3n | head -1 | awk '{print $1}'` +pathname=`multipathd show paths raw format "%d %m" | grep ${mpathdev} | head -1 | awk '{print $1}'` tlog "path to offline: ${pathname}" trun "echo 'offline' > /sys/block/${pathname}/device/state" tlog "waiting for multipathd to fail path" diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..15f26d2 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,44 @@ +--- +# No tests suitable for atomic environment +# No tests suitable for container environment + +# Tests suitable for classic environment +- hosts: localhost + roles: + - role: standard-test-basic + tags: + - classic + tests: + - medium_error_scsi_debug: + run: ./main.sh + timeout: 15m + - squelch_scsi_id: + run: ./main.sh + timeout: 15m + - multipathd_oom: + run: ./main.sh + timeout: 15m + - user_friendly_names: + run: ./main.sh + timeout: 15m + - kpartx_4k_aligned: + run: ./main.sh + timeout: 15m + - bindings: + run: ./main.sh + timeout: 15m + - restate_module: + run: ./main.sh + timeout: 15m + - find_multipaths: + run: ./main.sh + timeout: 15m + - multipath_conf_syntax: + run: ./main.sh + timeout: 15m + - alias_clash: + run: ./main.sh + timeout: 15m + required_packages: + - device-mapper-multipath + - perl diff --git a/tests/user_friendly_names/main.sh b/tests/user_friendly_names/main.sh index 1d48801..56082fd 100755 --- a/tests/user_friendly_names/main.sh +++ b/tests/user_friendly_names/main.sh @@ -17,125 +17,50 @@ # Author: Lin Li -source ../include/tc.sh || exit 200 +source ../include/ec.sh || exit 200 + tlog "running $0" -cleanup () -{ - local retries - if pidof multipathd; then - tlog "stopping multipathd" - trun "systemctl stop multipathd.service || pkill multipathd" - sleep 1 - fi - retries=10 - while pidof multipathd; do - ((retries--)) - if [[ $retries -le 0 ]]; then - tfail_ "failed to stop multipath" - tend - fi - tlog "waiting for multipathd to stop" - sleep 2 - pidof multipathd && pkill multipathd - done - trun "multipath -l -v1" - retries=10 - while [[ -n `multipath -l -v1` ]]; do - ((retries--)) - if [[ $retries -le 0 ]]; then - tfail_ "failed to remove deviece" - tend - fi - tlog "removing multipath device" - trun "udevadm settle" - trun "multipath -DF" - sleep 2 - done - if lsmod | grep -q "^scsi_debug"; then - tlog "removing scsi_debug module" - tok "rmmod scsi_debug" - fi - trun "rm -f /etc/multipath.conf" -} +trun "rpm -q device-mapper-multipath || yum install -y device-mapper-multipath" +trun "mpathconf --enable --with_multipathd y --user_friendly_names y" -assert () -{ - local cmd="$*" - _trun_ "$cmd" 0 - if test $? -eq 0; then - tpass_ "$cmd" ; - else - tfail_ "$cmd" ; - cleanup ; - tend ; - fi -} +# backup the /etc/multipath.conf +trun "cp /etc/multipath.conf /etc/multipath.conf.$$" +trun "multipath -F" -setup_config () -{ - trun "mpathconf --enable --user_friendly_names y" - sed -i '/^blacklist[[:space:]]*{/ a\ - device {\ - vendor ".*"\ - product ".*"\ - } -' /etc/multipath.conf - cat << _EOF_ >> /etc/multipath.conf +trun "modprobe scsi_debug num_tgts=1 vpd_use_hostno=0 add_host=2 delay=20 \ +max_luns=2 no_lun_0=1" +trun "multipath" +# wwid shown slowly on s390x by the script framework, but normally when run by multipath command directly +# so extend sleep time +sleep 20 -blacklist_exceptions { - device { - vendor Linux - product scsi_debug - } -} +disk=$(get_scsi_debug_devices) +disk=$(basename $disk) +wwid=$(get_wwid_of_disk $disk) +mpath=$(get_mpath_disk_by_scsi_device $disk) -multipaths { - multipath { - wwid TEST_WWID - alias test - } -} -_EOF_ - trun "cat /etc/multipath.conf" -} +# user_friendly_names = yes and mpath=test +#cur_dir=/mnt/tests/kernel/storage/multipath/user_friendly_names/ +#cur_dir=/home/test/scratch/device-mapper-multipath/user_friendly_names +trun "cat multipath.conf.yes | sed "s/your_wwid/$wwid/g" > /etc/multipath.conf" +trun "cat -n /etc/multipath.conf" +trun "multipath -r" +echo ">>> Verify 'test ($wwid)' is present ..." +trun "multipath -ll" +tok "multipath -ll | egrep \"^test\"" -do_reconfigure () -{ - trun "cat /etc/multipath.conf" - tok "multipathd reconfigure" - sleep 5 -} +# user_friendly_names = no +trun "cat multipath.conf.no > /etc/multipath.conf" +trun "multipath -r" +echo ">>> Verify 'test' is gone but '$wwid' present ..." +trun "multipath -ll" +tok "multipath -ll | egrep \"^$wwid\"" +sleep 10 +tok "multipath -F $wwid" +sleep 10 +trun "modprobe -r scsi_debug" -trun "rpm -q device-mapper-multipath || dnf install -y device-mapper-multipath" -cleanup -setup_config -trun "rm -r /etc/multipath/bindings" -trun "modprobe scsi_debug vpd_use_hostno=0 add_host=2" -sleep 5 -trun "systemctl start multipathd.service" -while multipathd show daemon | grep -qv idle; do - tlog "waiting for multipathd to start" - sleep 1 -done -trun 'multipathd show maps raw format "%n %w"' -# verify user_friendly_name -tok 'multipathd show maps raw format "%n" | head -1 | grep -q mpath' -wwid=`multipathd show maps raw format "%w" | head -1` -assert "[[ -n $wwid ]] && [[ $wwid != ok ]]" -sed -i 's/TEST_WWID/'"$wwid"'/' /etc/multipath.conf -do_reconfigure -trun 'multipathd show maps raw format "%n %w"' -# verify configured alias takes precedence over user_friendly_name -tok 'multipathd show maps raw format "%n" | head -1 | grep -q test' -trun "mpathconf --user_friendly_names n" -do_reconfigure -trun 'multipathd show maps raw format "%n %w"' -# verify configured alias takes precedence over wwid name -tok 'multipathd show maps raw format "%n" | head -1 | grep -q test' -sed -i 's/'"$wwid"'/TEST_WWID/' /etc/multipath.conf -do_reconfigure -trun 'multipathd show maps raw format "%n %w"' -tok 'multipathd show maps raw format "%n" | head -1 | grep -q '"$wwid" -cleanup +trun "cp /etc/multipath.conf.$$ /etc/multipath.conf" +trun "multipath -F; multipath" tend diff --git a/tests/user_friendly_names/multipath.conf.no b/tests/user_friendly_names/multipath.conf.no new file mode 100644 index 0000000..b916bfb --- /dev/null +++ b/tests/user_friendly_names/multipath.conf.no @@ -0,0 +1,3 @@ +defaults { + user_friendly_names no +} diff --git a/tests/user_friendly_names/multipath.conf.yes b/tests/user_friendly_names/multipath.conf.yes new file mode 100644 index 0000000..ffc21bb --- /dev/null +++ b/tests/user_friendly_names/multipath.conf.yes @@ -0,0 +1,11 @@ +defaults { + user_friendly_names yes +} + +multipaths { + multipath { + wwid your_wwid + alias test + } +} +