Blame SOURCES/0135-RHBZ-1299600-path-dev-uevents.patch

4728c8
---
4728c8
 libmultipath/configure.c |   30 ++++++++++++++++++++++++++++--
4728c8
 libmultipath/configure.h |    1 +
4728c8
 libmultipath/wwids.c     |    4 ++--
4728c8
 multipath/main.c         |    2 +-
4728c8
 multipathd/main.c        |    3 ++-
4728c8
 5 files changed, 34 insertions(+), 6 deletions(-)
4728c8
4728c8
Index: multipath-tools-130222/libmultipath/configure.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/configure.c
4728c8
+++ multipath-tools-130222/libmultipath/configure.c
4728c8
@@ -38,6 +38,7 @@
4728c8
 #include "util.h"
4728c8
 #include "uxsock.h"
4728c8
 #include "wwids.h"
4728c8
+#include "sysfs.h"
4728c8
 
4728c8
 /* group paths in pg by host adapter
4728c8
  */
4728c8
@@ -569,6 +570,29 @@ fail:
4728c8
 	return 1;
4728c8
 }
4728c8
 
4728c8
+void
4728c8
+trigger_uevents (struct multipath *mpp)
4728c8
+{
4728c8
+	struct pathgroup * pgp;
4728c8
+	struct path * pp;
4728c8
+	int i, j;
4728c8
+
4728c8
+	if (!mpp || !mpp->pg)
4728c8
+		return;
4728c8
+
4728c8
+	vector_foreach_slot (mpp->pg, pgp, i) {
4728c8
+		if (!pgp->paths)
4728c8
+			continue;
4728c8
+		vector_foreach_slot(pgp->paths, pp, j) {
4728c8
+			if (!pp->udev)
4728c8
+				continue;
4728c8
+			sysfs_attr_set_value(pp->udev, "uevent", "change",
4728c8
+					     strlen("change"));
4728c8
+		}
4728c8
+	}
4728c8
+}
4728c8
+
4728c8
+
4728c8
 /*
4728c8
  * Return value:
4728c8
  */
4728c8
@@ -658,8 +682,10 @@ domap (struct multipath * mpp, char * pa
4728c8
 		 * DM_DEVICE_CREATE, DM_DEVICE_RENAME, or DM_DEVICE_RELOAD
4728c8
 		 * succeeded
4728c8
 		 */
4728c8
-		if (mpp->action == ACT_CREATE)
4728c8
-			remember_wwid(mpp->wwid);
4728c8
+		if (mpp->action == ACT_CREATE) {
4728c8
+			if (remember_wwid(mpp->wwid) == 1)
4728c8
+				trigger_uevents(mpp);
4728c8
+		}
4728c8
 		if (!conf->daemon) {
4728c8
 			/* multipath client mode */
4728c8
 			dm_switchgroup(mpp->alias, mpp->bestpg);
4728c8
Index: multipath-tools-130222/libmultipath/wwids.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/wwids.c
4728c8
+++ multipath-tools-130222/libmultipath/wwids.c
4728c8
@@ -310,7 +310,7 @@ remember_wwid(char *wwid)
4728c8
 	}
4728c8
 	else
4728c8
 		condlog(4, "wwid %s already in wwids file", wwid);
4728c8
-	return 0;
4728c8
+	return ret;
4728c8
 }
4728c8
 
4728c8
 int remember_cmdline_wwid(void)
4728c8
@@ -344,7 +344,7 @@ int remember_cmdline_wwid(void)
4728c8
 			next++;
4728c8
 		}
4728c8
 		if (strlen(ptr)) {
4728c8
-			if (remember_wwid(ptr) != 0)
4728c8
+			if (remember_wwid(ptr) < 0)
4728c8
 				ret = -1;
4728c8
 		}
4728c8
 		else {
4728c8
Index: multipath-tools-130222/multipath/main.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/multipath/main.c
4728c8
+++ multipath-tools-130222/multipath/main.c
4728c8
@@ -303,7 +303,7 @@ configure (void)
4728c8
 		}
4728c8
 		if (conf->cmd == CMD_ADD_WWID) {
4728c8
 			r = remember_wwid(refwwid);
4728c8
-			if (r == 0)
4728c8
+			if (r >= 0)
4728c8
 				printf("wwid '%s' added\n", refwwid);
4728c8
 			else
4728c8
 				printf("failed adding '%s' to wwids file\n",
4728c8
Index: multipath-tools-130222/libmultipath/configure.h
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/configure.h
4728c8
+++ multipath-tools-130222/libmultipath/configure.h
4728c8
@@ -31,3 +31,4 @@ int coalesce_paths (struct vectors *vecs
4728c8
 int get_refwwid (char * dev, enum devtypes dev_type, vector pathvec, char **wwid);
4728c8
 int reload_map(struct vectors *vecs, struct multipath *mpp, int refresh);
4728c8
 int sysfs_get_host_adapter_name(struct path *pp, char *adapter_name);
4728c8
+void trigger_uevents (struct multipath *mpp);
4728c8
Index: multipath-tools-130222/multipathd/main.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/multipathd/main.c
4728c8
+++ multipath-tools-130222/multipathd/main.c
4728c8
@@ -1435,7 +1435,8 @@ configure (struct vectors * vecs, int st
4728c8
 
4728c8
 	sync_maps_state(mpvec);
4728c8
 	vector_foreach_slot(mpvec, mpp, i){
4728c8
-		remember_wwid(mpp->wwid);
4728c8
+		if (remember_wwid(mpp->wwid) > 0)
4728c8
+			trigger_uevents(mpp);
4728c8
 		update_map_pr(mpp);
4728c8
 	}
4728c8