summaryrefslogtreecommitdiffstats
path: root/0135-RHBZ-1299600-path-dev-uevents.patch
blob: 2de58a4eef6ebd0164969f7c43d50d7ada091bdd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
---
 libmultipath/configure.c |   30 ++++++++++++++++++++++++++++--
 libmultipath/configure.h |    1 +
 libmultipath/wwids.c     |    4 ++--
 multipath/main.c         |    2 +-
 multipathd/main.c        |    3 ++-
 5 files changed, 34 insertions(+), 6 deletions(-)

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