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

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