From 38f59abc6178a79a58c38eec88ab0ada4c8530e5 Mon Sep 17 00:00:00 2001 From: Benjamin Marzinski Date: Thu, 17 Apr 2025 19:19:47 -0400 Subject: [PATCH] device-mapper-multipath-0.8.7-38 Add 0142-multipathd-monitor-new-multipath-dev-even-if-we-can-.patch Add 0143-libmultipath-add-helper-function-check_path_wwid_cha.patch Add 0144-multipathd-re-add-paths-skipped-because-they-were-of.patch * Fixes RHEL-82534 ("multipathd does not monitor multipath devices created externally while there are offline paths.") Resolves: RHEL-82534 --- ...or-new-multipath-dev-even-if-we-can-.patch | 45 ++++ ...-helper-function-check_path_wwid_cha.patch | 75 +++++++ ...d-paths-skipped-because-they-were-of.patch | 201 ++++++++++++++++++ device-mapper-multipath.spec | 13 +- 4 files changed, 333 insertions(+), 1 deletion(-) create mode 100644 0142-multipathd-monitor-new-multipath-dev-even-if-we-can-.patch create mode 100644 0143-libmultipath-add-helper-function-check_path_wwid_cha.patch create mode 100644 0144-multipathd-re-add-paths-skipped-because-they-were-of.patch diff --git a/0142-multipathd-monitor-new-multipath-dev-even-if-we-can-.patch b/0142-multipathd-monitor-new-multipath-dev-even-if-we-can-.patch new file mode 100644 index 0000000..a240061 --- /dev/null +++ b/0142-multipathd-monitor-new-multipath-dev-even-if-we-can-.patch @@ -0,0 +1,45 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Wed, 2 Apr 2025 19:13:19 -0400 +Subject: [PATCH] multipathd: monitor new multipath dev even if we can't update + it + +If a multipath device was created by the multipath command, multipathd +might not agree with how the device was created. ev_add_map() can reload +the device with a different table by calling add_map_without_path() -> +update_map(). If this reloading of the map failed, multipathd was simply +ignoring the multipath device, even though it still existed. + +One way that reloading can fail is if a path that multipathd already has +initialized goes offline. If a multipath device is created by the +multipath command while the path is offline, it will not use the offline +path, since multipath won't be able to get the necessary pathinfo. +However, multipathd will already have the pathinfo for the path, and may +not even know that it's offline, since the path is an orphan. When it +tries to reload the device, it will include the offline path, and the +reload will fail. + +Instead of ignoring the device if it can't reload it, multipathd should +just montior it as it is. When the path device is no longer offline, it +can be added back to the multipath device by calling +"multipathd reconfigure" or "multipathd add path ". + +Signed-off-by: Benjamin Marzinski +Reviewed-by: Martin Wilck +--- + multipathd/main.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/multipathd/main.c b/multipathd/main.c +index 820d4e68..c5f458b9 100644 +--- a/multipathd/main.c ++++ b/multipathd/main.c +@@ -593,7 +593,7 @@ retry: + } + + fail: +- if (new_map && (retries < 0 || wait_for_events(mpp, vecs))) { ++ if (new_map && wait_for_events(mpp, vecs)) { + condlog(0, "%s: failed to create new map", mpp->alias); + remove_map(mpp, vecs->pathvec, vecs->mpvec); + return 1; diff --git a/0143-libmultipath-add-helper-function-check_path_wwid_cha.patch b/0143-libmultipath-add-helper-function-check_path_wwid_cha.patch new file mode 100644 index 0000000..4568393 --- /dev/null +++ b/0143-libmultipath-add-helper-function-check_path_wwid_cha.patch @@ -0,0 +1,75 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Wed, 2 Apr 2025 19:13:20 -0400 +Subject: [PATCH] libmultipath: add helper function check_path_wwid_change + +Wrap some code from select_recheck_wwid() in a helper function. A future +patch will call this code from a different function. + +Signed-off-by: Benjamin Marzinski +Reviewed-by: Martin Wilck +--- + libmultipath/discovery.c | 13 ++++++++++++- + libmultipath/discovery.h | 2 +- + libmultipath/propsel.c | 4 +--- + 3 files changed, 14 insertions(+), 5 deletions(-) + +diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c +index 672c783b..22d114b3 100644 +--- a/libmultipath/discovery.c ++++ b/libmultipath/discovery.c +@@ -2184,7 +2184,7 @@ static ssize_t uid_fallback(struct path *pp, int path_state, + return len; + } + +-bool has_uid_fallback(struct path *pp) ++static bool has_uid_fallback(const struct path *pp) + { + /* + * Falling back to direct WWID determination is dangerous +@@ -2205,6 +2205,17 @@ bool has_uid_fallback(struct path *pp) + !strcmp(pp->uid_attribute, "")))); + } + ++bool can_recheck_wwid(const struct path *pp) ++{ ++ /* ++ * check_path_wwid_change() only works for scsi devices, and it ++ * is only guaranteed to give the same WWID if the path uses ++ * the default uid_attribute ++ */ ++ return (pp->bus == SYSFS_BUS_SCSI && !pp->getuid && ++ has_uid_fallback(pp)); ++} ++ + int + get_uid (struct path * pp, int path_state, struct udev_device *udev, + int allow_fallback) +diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h +index c2a88686..c7f1becd 100644 +--- a/libmultipath/discovery.h ++++ b/libmultipath/discovery.h +@@ -54,7 +54,7 @@ ssize_t sysfs_get_inquiry(struct udev_device *udev, + unsigned char *buff, size_t len); + int sysfs_get_asymmetric_access_state(struct path *pp, + char *buff, int buflen); +-bool has_uid_fallback(struct path *pp); ++bool can_recheck_wwid(const struct path *pp); + int get_uid(struct path * pp, int path_state, struct udev_device *udev, + int allow_fallback); + bool is_vpd_page_supported(int fd, int pg); +diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c +index be781ff7..0b6e22c1 100644 +--- a/libmultipath/propsel.c ++++ b/libmultipath/propsel.c +@@ -672,9 +672,7 @@ int select_recheck_wwid(struct config *conf, struct path * pp) + pp_set_conf(recheck_wwid); + pp_set_default(recheck_wwid, DEFAULT_RECHECK_WWID); + out: +- if (pp->recheck_wwid == RECHECK_WWID_ON && +- (pp->bus != SYSFS_BUS_SCSI || pp->getuid != NULL || +- !has_uid_fallback(pp))) { ++ if (pp->recheck_wwid == RECHECK_WWID_ON && !can_recheck_wwid(pp)) { + pp->recheck_wwid = RECHECK_WWID_OFF; + origin = "(setting: unsupported by device type/config)"; + } diff --git a/0144-multipathd-re-add-paths-skipped-because-they-were-of.patch b/0144-multipathd-re-add-paths-skipped-because-they-were-of.patch new file mode 100644 index 0000000..0a04577 --- /dev/null +++ b/0144-multipathd-re-add-paths-skipped-because-they-were-of.patch @@ -0,0 +1,201 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Wed, 2 Apr 2025 19:13:21 -0400 +Subject: [PATCH] multipathd: re-add paths skipped because they were offline + +When a new device is added by the multipath command, multipathd may know +of other paths that cannot be added to the device because they are +currently offline. Instead of ignoring these paths, multipathd will now +re-add them when they come back online. To do this, it multipathd needs +a new path variable add_when_online, to track devices that could not be +added to an existing multipath device because they were offline. These +paths are handled along with the other uninitialized paths. + +Signed-off-by: Benjamin Marzinski +Reviewed-by: Martin Wilck +--- + libmultipath/libmultipath.version | 5 +++ + libmultipath/print.c | 5 ++- + libmultipath/structs.h | 1 + + libmultipath/structs_vec.c | 5 +++ + multipathd/main.c | 53 ++++++++++++++++++++++++++++++- + multipathd/multipathd.8 | 4 ++- + 6 files changed, 70 insertions(+), 3 deletions(-) + +diff --git a/libmultipath/libmultipath.version b/libmultipath/libmultipath.version +index e2cce8c7..46907278 100644 +--- a/libmultipath/libmultipath.version ++++ b/libmultipath/libmultipath.version +@@ -313,3 +313,8 @@ global: + cleanup_udev_enumerate_ptr; + cleanup_udev_device_ptr; + } LIBMULTIPATH_9.1.3; ++ ++LIBMULTIPATH_9.1.5 { ++global: ++ can_recheck_wwid; ++} LIBMULTIPATH_9.1.4; +diff --git a/libmultipath/print.c b/libmultipath/print.c +index 4552fd43..ff224bc4 100644 +--- a/libmultipath/print.c ++++ b/libmultipath/print.c +@@ -584,8 +584,11 @@ snprint_path_serial (struct strbuf *buff, const struct path * pp) + static int + snprint_path_mpp (struct strbuf *buff, const struct path * pp) + { +- if (!pp->mpp) ++ if (!pp->mpp) { ++ if (pp->add_when_online) ++ return append_strbuf_str(buff, "[offline]"); + return append_strbuf_str(buff, "[orphan]"); ++ } + if (!pp->mpp->alias) + return append_strbuf_str(buff, "[unknown]"); + return snprint_str(buff, pp->mpp->alias); +diff --git a/libmultipath/structs.h b/libmultipath/structs.h +index 4bf8c93a..0846e833 100644 +--- a/libmultipath/structs.h ++++ b/libmultipath/structs.h +@@ -374,6 +374,7 @@ struct path { + unsigned int dev_loss; + int eh_deadline; + bool can_use_env_uid; ++ bool add_when_online; + /* configlet pointers */ + vector hwe; + struct gen_path generic_path; +diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c +index b8e304e0..7086781a 100644 +--- a/libmultipath/structs_vec.c ++++ b/libmultipath/structs_vec.c +@@ -319,6 +319,9 @@ void orphan_paths(vector pathvec, struct multipath *mpp, const char *reason) + free_path(pp); + } else + orphan_path(pp, reason); ++ } else if (pp->add_when_online && ++ strncmp(mpp->wwid, pp->wwid, WWID_SIZE) == 0) { ++ pp->add_when_online = false; + } + } + } +@@ -496,6 +499,8 @@ void sync_paths(struct multipath *mpp, vector pathvec) + found = 0; + vector_foreach_slot(mpp->pg, pgp, j) { + if (find_slot(pgp->paths, (void *)pp) != -1) { ++ if (pp->add_when_online) ++ pp->add_when_online = false; + found = 1; + break; + } +diff --git a/multipathd/main.c b/multipathd/main.c +index c5f458b9..4119ad79 100644 +--- a/multipathd/main.c ++++ b/multipathd/main.c +@@ -558,11 +558,44 @@ pr_register_active_paths(struct multipath *mpp) + } + } + ++static void ++save_offline_paths(const struct multipath *mpp, vector offline_paths) ++{ ++ unsigned int i, j; ++ struct path *pp; ++ struct pathgroup *pgp; ++ ++ vector_foreach_slot (mpp->pg, pgp, i) ++ vector_foreach_slot (pgp->paths, pp, j) ++ if (pp->initialized == INIT_OK && pp->offline) ++ /* ignore failures storing the paths. */ ++ store_path(offline_paths, pp); ++} ++ ++static void ++handle_orphaned_offline_paths(vector offline_paths) ++{ ++ unsigned int i; ++ struct path *pp; ++ ++ vector_foreach_slot (offline_paths, pp, i) ++ if (pp->mpp == NULL) ++ pp->add_when_online = true; ++} ++ ++static void ++cleanup_reset_vec(struct _vector **v) ++{ ++ vector_reset(*v); ++} ++ + static int + update_map (struct multipath *mpp, struct vectors *vecs, int new_map) + { + int retries = 3; + char *params __attribute__((cleanup(cleanup_charp))) = NULL; ++ struct _vector offline_paths_vec = { .allocated = 0 }; ++ vector offline_paths __attribute__((cleanup(cleanup_reset_vec))) = &offline_paths_vec; + + retry: + condlog(4, "%s: updating new map", mpp->alias); +@@ -599,6 +632,9 @@ fail: + return 1; + } + ++ if (new_map && retries < 0) ++ save_offline_paths(mpp, offline_paths); ++ + if (setup_multipath(vecs, mpp)) + return 1; + +@@ -609,6 +645,9 @@ fail: + if (mpp->prflag == PRFLAG_SET) + pr_register_active_paths(mpp); + ++ if (VECTOR_SIZE(offline_paths) != 0) ++ handle_orphaned_offline_paths(offline_paths); ++ + if (retries < 0) + condlog(0, "%s: failed reload in new map update", mpp->alias); + return 0; +@@ -2253,7 +2292,8 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) + int ret; + + if (((pp->initialized == INIT_OK || +- pp->initialized == INIT_REQUESTED_UDEV) && !pp->mpp) || ++ pp->initialized == INIT_REQUESTED_UDEV) && !pp->mpp && ++ !pp->add_when_online) || + pp->initialized == INIT_REMOVED) + return 0; + +@@ -2367,6 +2407,17 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) + */ + pp->checkint = max_checkint; + } ++ } else if (pp->initialized == INIT_OK && pp->add_when_online && ++ (newstate == PATH_UP || newstate == PATH_GHOST)) { ++ pp->add_when_online = false; ++ if (can_recheck_wwid(pp) && ++ check_path_wwid_change(pp)) { ++ condlog(0, "%s: path wwid change detected. Removing", pp->dev); ++ handle_path_wwid_change(pp, vecs); ++ return 0; ++ } ++ ev_add_path(pp, vecs, 1); ++ pp->tick = 1; + } + return 0; + } +diff --git a/multipathd/multipathd.8 b/multipathd/multipathd.8 +index d3aa7a73..2ed036d4 100644 +--- a/multipathd/multipathd.8 ++++ b/multipathd/multipathd.8 +@@ -529,7 +529,9 @@ The device serial number. + The device marginal state, either \fImarginal\fR or \fInormal\fR. + .TP + .B %m +-The multipath device that this device is a path of. ++The multipath device that this device is a path of, or \fI[offline]\fR ++if this device could not be added to a device because it is offline or ++\fI[orphan]\fR if it is not part of any multipath device. + .TP + .B %N + The host World Wide Node Name (WWNN) of the device. diff --git a/device-mapper-multipath.spec b/device-mapper-multipath.spec index d5c2ad5..8cf0434 100644 --- a/device-mapper-multipath.spec +++ b/device-mapper-multipath.spec @@ -1,6 +1,6 @@ Name: device-mapper-multipath Version: 0.8.7 -Release: 37%{?dist} +Release: 38%{?dist} Summary: Tools to manage multipath devices using device-mapper License: GPLv2 URL: http://christophe.varoqui.free.fr/ @@ -151,6 +151,9 @@ Patch0138: 0138-libmpathcmd-honor-MULTIPATH_SOCKET_NAME-environment-.patch Patch0139: 0139-multipathd-honor-MULTIPATH_SOCKET_NAME-environment-v.patch Patch0140: 0140-multipath-clean-up-find_multipaths-value-names.patch Patch0141: 0141-multipathd-Add-multipathd-man-page-section-about-soc.patch +Patch0142: 0142-multipathd-monitor-new-multipath-dev-even-if-we-can-.patch +Patch0143: 0143-libmultipath-add-helper-function-check_path_wwid_cha.patch +Patch0144: 0144-multipathd-re-add-paths-skipped-because-they-were-of.patch # runtime @@ -354,6 +357,14 @@ fi %{_pkgconfdir}/libdmmp.pc %changelog +* Thu Apr 17 2025 Benjamin Marzinski - 0.8.7-38 +- Add 0142-multipathd-monitor-new-multipath-dev-even-if-we-can-.patch +- Add 0143-libmultipath-add-helper-function-check_path_wwid_cha.patch +- Add 0144-multipathd-re-add-paths-skipped-because-they-were-of.patch + * Fixes RHEL-82534 ("multipathd does not monitor multipath devices + created externally while there are offline paths.") +- Resolves: RHEL-82534 + * Thu Mar 13 2025 Benjamin Marzinski - 0.8.7-37 - Add 0140-multipath-clean-up-find_multipaths-value-names.patch - Add 0141-multipathd-Add-multipathd-man-page-section-about-soc.patch