Skip to contentSkip to conversation

Misc Multipath fixes

PATCH In review Benjamin Marzinski 2 participants 5 messages Jan 18, 2022 Device mapper

lore
Share & tools
lore

Benjamin Marzinski

author maintainer
#0 lore raw

cover Misc Multipath fixes

This patchset fixes two issues. First is that disassemble_status() was failing for the historical-service-time path selector, because it uses pathgroup status arguments, which were not handled correctly. Second is an issue with multipath not claiming paths that are added to multipath devices in a window right after the WWID has been added to the WWIDs file, if multipath is using a find_multipaths setting that relies on the wwid being in the WWIDs file (all settings but greedy or smart).

Benjamin Marzinski (3):
libmultipath: fix disassemble status for historical-service-time PS
libmultipath: make helper function to trigger path uevents
multipathd: trigger udev change on path addition

 libmultipath/configure.c          | 79 ++++++++++++++++---------------
 libmultipath/configure.h          |  1 +
 libmultipath/dmparser.c           | 14 +++++-
 libmultipath/libmultipath.version |  1 +
 multipathd/main.c                 |  2 +
 5 files changed, 58 insertions(+), 39 deletions(-)
Signature · 6 lines
2.17.2

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
author maintainer
#1 lore raw

PATCH 1/3 libmultipath: fix disassemble status for historical-service-time PS

The historical-service-time path selector prints out 2 path group status arguments. This is the only path selector that uses the group status arguments. All the others only have path status arguments. disassemble_status() was expecting the number of group status arguments to always be zero, causing it to fail at disassembling the status of devices that use historical-service-time path selector. Now multipath actually checks the number of group arguments, and skips them.

---
 libmultipath/dmparser.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
libmultipath/dmparser.c +12 -2
index 24ba4ac3..50d13c08 100644
@@ -436,9 +436,19 @@ int disassemble_status(const char *params, struct multipath *mpp)
 		free(word);
 
 		/*
-		 * PG Status (discarded, would be '0' anyway)
+		 * Path Selector Group Arguments
 		 */
-		p += get_word(p, NULL);
+		p += get_word(p, &word);
+
+		if (!word)
+			return 1;
+
+		num_pg_args = atoi(word);
+		free(word);
+
+		/* Ignore ps group arguments */
+		for (j = 0; j < num_pg_args; j++)
+			p += get_word(p, NULL);
 
 		p += get_word(p, &word);
 
Signature · 6 lines
2.17.2

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
author maintainer
#2 lore raw

PATCH 2/3 libmultipath: make helper function to trigger path uevents

In reply to Benjamin Marzinski

Pull the code that checks if a path needs to trigger a uevent, and triggers, out of trigger_paths_udev_change() and into a new function, trigger_path_udev_change(). This function will be used separately by a future patch. No functional changes.

---
 libmultipath/configure.c | 79 +++++++++++++++++++++-------------------
 libmultipath/configure.h |  1 +
 2 files changed, 43 insertions(+), 37 deletions(-)
libmultipath/configure.c +42 -37
index ec38f325..eca11ba0 100644
@@ -503,11 +503,8 @@ unref:
 }
 
 void
-trigger_paths_udev_change(struct multipath *mpp, bool is_mpath)
+trigger_path_udev_change(struct path *pp, bool is_mpath)
 {
-	struct pathgroup *pgp;
-	struct path *pp;
-	int i, j;
 	/*
 	 * If a path changes from multipath to non-multipath, we must
 	 * synthesize an artificial "add" event, otherwise the LVM2 rules
@@ -515,6 +512,45 @@ trigger_paths_udev_change(struct multipath *mpp, bool is_mpath)
 	 * irritate ourselves with an "add", so use "change".
 	 */
 	const char *action = is_mpath ? "change" : "add";
+	const char *env;
+
+	if (!pp->udev)
+		return;
+	/*
+	 * Paths that are already classified as multipath
+	 * members don't need another uevent.
+	 */
+	env = udev_device_get_property_value(
+		pp->udev, "DM_MULTIPATH_DEVICE_PATH");
+
+	if (is_mpath && env != NULL && !strcmp(env, "1")) {
+		/*
+		 * If FIND_MULTIPATHS_WAIT_UNTIL is not "0",
+		 * path is in "maybe" state and timer is running
+		 * Send uevent now (see multipath.rules).
+		 */
+		env = udev_device_get_property_value(
+			pp->udev, "FIND_MULTIPATHS_WAIT_UNTIL");
+		if (env == NULL || !strcmp(env, "0"))
+			return;
+	} else if (!is_mpath &&
+		   (env == NULL || !strcmp(env, "0")))
+		return;
+
+	condlog(3, "triggering %s uevent for %s (is %smultipath member)",
+		action, pp->dev, is_mpath ? "" : "no ");
+	sysfs_attr_set_value(pp->udev, "uevent",
+			     action, strlen(action));
+	trigger_partitions_udev_change(pp->udev, action,
+				       strlen(action));
+}
+
+void
+trigger_paths_udev_change(struct multipath *mpp, bool is_mpath)
+{
+	struct pathgroup *pgp;
+	struct path *pp;
+	int i, j;
 
 	if (!mpp || !mpp->pg)
 		return;
@@ -522,39 +558,8 @@ trigger_paths_udev_change(struct multipath *mpp, bool is_mpath)
 	vector_foreach_slot (mpp->pg, pgp, i) {
 		if (!pgp->paths)
 			continue;
-		vector_foreach_slot(pgp->paths, pp, j) {
-			const char *env;
-
-			if (!pp->udev)
-				continue;
-			/*
-			 * Paths that are already classified as multipath
-			 * members don't need another uevent.
-			 */
-			env = udev_device_get_property_value(
-				pp->udev, "DM_MULTIPATH_DEVICE_PATH");
-
-			if (is_mpath && env != NULL && !strcmp(env, "1")) {
-				/*
-				 * If FIND_MULTIPATHS_WAIT_UNTIL is not "0",
-				 * path is in "maybe" state and timer is running
-				 * Send uevent now (see multipath.rules).
-				 */
-				env = udev_device_get_property_value(
-					pp->udev, "FIND_MULTIPATHS_WAIT_UNTIL");
-				if (env == NULL || !strcmp(env, "0"))
-					continue;
-			} else if (!is_mpath &&
-				   (env == NULL || !strcmp(env, "0")))
-				continue;
-
-			condlog(3, "triggering %s uevent for %s (is %smultipath member)",
-				action, pp->dev, is_mpath ? "" : "no ");
-			sysfs_attr_set_value(pp->udev, "uevent",
-					     action, strlen(action));
-			trigger_partitions_udev_change(pp->udev, action,
-						       strlen(action));
-		}
+		vector_foreach_slot(pgp->paths, pp, j)
+			trigger_path_udev_change(pp, is_mpath);
 	}
 
 	mpp->needs_paths_uevent = 0;
libmultipath/configure.h +1 -0
index efe18b7d..2bf73e65 100644
@@ -56,6 +56,7 @@ int coalesce_paths (struct vectors *vecs, vector curmp, char * refwwid, int forc
 int get_refwwid (enum mpath_cmds cmd, const char *dev, enum devtypes dev_type,
 		 vector pathvec, char **wwid);
 struct udev_device *get_udev_device(const char *dev, enum devtypes dev_type);
+void trigger_path_udev_change(struct path *pp, bool is_mpath);
 void trigger_paths_udev_change(struct multipath *mpp, bool is_mpath);
 void trigger_partitions_udev_change(struct udev_device *dev, const char *action,
 				    int len);
Signature · 6 lines
2.17.2

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
author maintainer
#3 lore raw

PATCH 3/3 multipathd: trigger udev change on path addition

In reply to Benjamin Marzinski

When a multipath device is created for the first time, there is a window where some path devices way be added to the multipath device, but never claimed in udev. This can allow other device owners, like lvm, to think they can use the device.

When a multipath device is first created, all the existing paths that are not claimed by multipath have a uevent triggered so that they can get claimed. After that, multipath assumes all future paths added to the multipath device will have been claimed by multipath, since the device's WWID is now in the wwids file. This doesn't work for any paths that have already been processed by the multipath.rules udev rules before the multipath device was created.

To close this window, when path device is added, and a matching multipath device already exists, multipathd now checks if the device is claimed by multipath, and if not, triggers a uevent to claim it.

---
 libmultipath/libmultipath.version | 1 +
 multipathd/main.c                 | 2 ++
 2 files changed, 3 insertions(+)
libmultipath/libmultipath.version +1 -0
index d8cee0c3..b663cb29 100644
@@ -210,6 +210,7 @@ global:
 	sysfs_is_multipathed;
 	timespeccmp;
 	timespecsub;
+	trigger_path_udev_change;
 	trigger_paths_udev_change;
 	truncate_strbuf;
 	udev;
multipathd/main.c +2 -0
index c241dad5..44ca5b12 100644
@@ -1157,6 +1157,8 @@ ev_add_path (struct path * pp, struct vectors * vecs, int need_do_map)
 		free_path(pp);
 		return 1;
 	}
+	if (mpp)
+		trigger_path_udev_change(pp, true);
 	if (mpp && mpp->wait_for_udev &&
 	    (pathcount(mpp, PATH_UP) > 0 ||
 	     (pathcount(mpp, PATH_GHOST) > 0 &&
Signature · 6 lines
2.17.2

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
Reviewed-by on the v1 series
#4 lore raw
In reply to Benjamin Marzinski
Quoted 15 lines · Benjamin Marzinski

This patchset fixes two issues. First is that disassemble_status() was failing for the historical-service-time path selector, because it uses pathgroup status arguments, which were not handled correctly. Second is an issue with multipath not claiming paths that are added to
multipath devices in a window right after the WWID has been added to the WWIDs file, if multipath is using a find_multipaths setting that relies on the wwid being in the WWIDs file (all settings but greedy or smart).

Benjamin Marzinski (3):
  libmultipath: fix disassemble status for historical-service-time PS
  libmultipath: make helper function to trigger path uevents
  multipathd: trigger udev change on path addition

Quoted 8 lines

 libmultipath/configure.c          | 79 ++++++++++++++++------------- --
 libmultipath/configure.h          |  1 + libmultipath/dmparser.c           | 14 +++++- libmultipath/libmultipath.version |  1 + multipathd/main.c                 |  2 +

 5 files changed, 58 insertions(+), 39 deletions(-)

For the set:

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel