Blame SOURCES/0037-libmultipath-make-helper-function-to-trigger-path-ue.patch

da32ae
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
da32ae
From: Benjamin Marzinski <bmarzins@redhat.com>
da32ae
Date: Mon, 17 Jan 2022 14:45:38 -0600
da32ae
Subject: [PATCH] libmultipath: make helper function to trigger path uevents
da32ae
da32ae
Pull the code that checks if a path needs to trigger a uevent, and
da32ae
triggers, out of trigger_paths_udev_change() and into a new function,
da32ae
trigger_path_udev_change(). This function will be used separately by
da32ae
a future patch. No functional changes.
da32ae
da32ae
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
da32ae
---
da32ae
 libmultipath/configure.c | 79 +++++++++++++++++++++-------------------
da32ae
 libmultipath/configure.h |  1 +
da32ae
 2 files changed, 43 insertions(+), 37 deletions(-)
da32ae
da32ae
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
da32ae
index 7edb355b..043e4232 100644
da32ae
--- a/libmultipath/configure.c
da32ae
+++ b/libmultipath/configure.c
da32ae
@@ -565,11 +565,8 @@ unref:
da32ae
 }
da32ae
 
da32ae
 void
da32ae
-trigger_paths_udev_change(struct multipath *mpp, bool is_mpath)
da32ae
+trigger_path_udev_change(struct path *pp, bool is_mpath)
da32ae
 {
da32ae
-	struct pathgroup *pgp;
da32ae
-	struct path *pp;
da32ae
-	int i, j;
da32ae
 	/*
da32ae
 	 * If a path changes from multipath to non-multipath, we must
da32ae
 	 * synthesize an artificial "add" event, otherwise the LVM2 rules
da32ae
@@ -577,6 +574,45 @@ trigger_paths_udev_change(struct multipath *mpp, bool is_mpath)
da32ae
 	 * irritate ourselves with an "add", so use "change".
da32ae
 	 */
da32ae
 	const char *action = is_mpath ? "change" : "add";
da32ae
+	const char *env;
da32ae
+
da32ae
+	if (!pp->udev)
da32ae
+		return;
da32ae
+	/*
da32ae
+	 * Paths that are already classified as multipath
da32ae
+	 * members don't need another uevent.
da32ae
+	 */
da32ae
+	env = udev_device_get_property_value(
da32ae
+		pp->udev, "DM_MULTIPATH_DEVICE_PATH");
da32ae
+
da32ae
+	if (is_mpath && env != NULL && !strcmp(env, "1")) {
da32ae
+		/*
da32ae
+		 * If FIND_MULTIPATHS_WAIT_UNTIL is not "0",
da32ae
+		 * path is in "maybe" state and timer is running
da32ae
+		 * Send uevent now (see multipath.rules).
da32ae
+		 */
da32ae
+		env = udev_device_get_property_value(
da32ae
+			pp->udev, "FIND_MULTIPATHS_WAIT_UNTIL");
da32ae
+		if (env == NULL || !strcmp(env, "0"))
da32ae
+			return;
da32ae
+	} else if (!is_mpath &&
da32ae
+		   (env == NULL || !strcmp(env, "0")))
da32ae
+		return;
da32ae
+
da32ae
+	condlog(3, "triggering %s uevent for %s (is %smultipath member)",
da32ae
+		action, pp->dev, is_mpath ? "" : "no ");
da32ae
+	sysfs_attr_set_value(pp->udev, "uevent",
da32ae
+			     action, strlen(action));
da32ae
+	trigger_partitions_udev_change(pp->udev, action,
da32ae
+				       strlen(action));
da32ae
+}
da32ae
+
da32ae
+void
da32ae
+trigger_paths_udev_change(struct multipath *mpp, bool is_mpath)
da32ae
+{
da32ae
+	struct pathgroup *pgp;
da32ae
+	struct path *pp;
da32ae
+	int i, j;
da32ae
 
da32ae
 	if (!mpp || !mpp->pg)
da32ae
 		return;
da32ae
@@ -584,39 +620,8 @@ trigger_paths_udev_change(struct multipath *mpp, bool is_mpath)
da32ae
 	vector_foreach_slot (mpp->pg, pgp, i) {
da32ae
 		if (!pgp->paths)
da32ae
 			continue;
da32ae
-		vector_foreach_slot(pgp->paths, pp, j) {
da32ae
-			const char *env;
da32ae
-
da32ae
-			if (!pp->udev)
da32ae
-				continue;
da32ae
-			/*
da32ae
-			 * Paths that are already classified as multipath
da32ae
-			 * members don't need another uevent.
da32ae
-			 */
da32ae
-			env = udev_device_get_property_value(
da32ae
-				pp->udev, "DM_MULTIPATH_DEVICE_PATH");
da32ae
-
da32ae
-			if (is_mpath && env != NULL && !strcmp(env, "1")) {
da32ae
-				/*
da32ae
-				 * If FIND_MULTIPATHS_WAIT_UNTIL is not "0",
da32ae
-				 * path is in "maybe" state and timer is running
da32ae
-				 * Send uevent now (see multipath.rules).
da32ae
-				 */
da32ae
-				env = udev_device_get_property_value(
da32ae
-					pp->udev, "FIND_MULTIPATHS_WAIT_UNTIL");
da32ae
-				if (env == NULL || !strcmp(env, "0"))
da32ae
-					continue;
da32ae
-			} else if (!is_mpath &&
da32ae
-				   (env == NULL || !strcmp(env, "0")))
da32ae
-				continue;
da32ae
-
da32ae
-			condlog(3, "triggering %s uevent for %s (is %smultipath member)",
da32ae
-				action, pp->dev, is_mpath ? "" : "no ");
da32ae
-			sysfs_attr_set_value(pp->udev, "uevent",
da32ae
-					     action, strlen(action));
da32ae
-			trigger_partitions_udev_change(pp->udev, action,
da32ae
-						       strlen(action));
da32ae
-		}
da32ae
+		vector_foreach_slot(pgp->paths, pp, j)
da32ae
+			trigger_path_udev_change(pp, is_mpath);
da32ae
 	}
da32ae
 
da32ae
 	mpp->needs_paths_uevent = 0;
da32ae
diff --git a/libmultipath/configure.h b/libmultipath/configure.h
da32ae
index efe18b7d..2bf73e65 100644
da32ae
--- a/libmultipath/configure.h
da32ae
+++ b/libmultipath/configure.h
da32ae
@@ -56,6 +56,7 @@ int coalesce_paths (struct vectors *vecs, vector curmp, char * refwwid, int forc
da32ae
 int get_refwwid (enum mpath_cmds cmd, const char *dev, enum devtypes dev_type,
da32ae
 		 vector pathvec, char **wwid);
da32ae
 struct udev_device *get_udev_device(const char *dev, enum devtypes dev_type);
da32ae
+void trigger_path_udev_change(struct path *pp, bool is_mpath);
da32ae
 void trigger_paths_udev_change(struct multipath *mpp, bool is_mpath);
da32ae
 void trigger_partitions_udev_change(struct udev_device *dev, const char *action,
da32ae
 				    int len);