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

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