Blame SOURCES/0080-RHBZ-1075796-cmdline-wwid.patch

f20720
---
f20720
 libmultipath/wwids.c          |   44 ++++++++++++++++++++++++++++++++++++++++++
f20720
 libmultipath/wwids.h          |    1 
f20720
 multipath/main.c              |   12 ++++++++---
f20720
 multipath/multipath.8         |    5 +++-
f20720
 multipathd/multipathd.service |    1 
f20720
 5 files changed, 59 insertions(+), 4 deletions(-)
f20720
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
@@ -305,3 +305,47 @@ remember_wwid(char *wwid)
f20720
 		condlog(4, "wwid %s already in wwids file", wwid);
f20720
 	return 0;
f20720
 }
f20720
+
f20720
+int remember_cmdline_wwid(void)
f20720
+{
f20720
+	FILE *f = NULL;
f20720
+	char buf[LINE_MAX], *next, *ptr;
f20720
+	int ret = 0;
f20720
+
f20720
+	f = fopen("/proc/cmdline", "re");
f20720
+	if (!f) {
f20720
+		condlog(0, "can't open /proc/cmdline : %s", strerror(errno));
f20720
+		return -1;
f20720
+	}
f20720
+
f20720
+	if (!fgets(buf, sizeof(buf), f)) {
f20720
+		if (ferror(f))
f20720
+			condlog(0, "read of /proc/cmdline failed : %s",
f20720
+				strerror(errno));
f20720
+		else
f20720
+			condlog(0, "couldn't read /proc/cmdline");
f20720
+		fclose(f);
f20720
+		return -1;
f20720
+	}
f20720
+	fclose(f);
f20720
+	next = buf;
f20720
+	while((ptr = strstr(next, "mpath.wwid="))) {
f20720
+		ptr += 11;
f20720
+		next = strpbrk(ptr, " \t\n");
f20720
+		if (next) {
f20720
+			*next = '\0';
f20720
+			next++;
f20720
+		}
f20720
+		if (strlen(ptr)) {
f20720
+			if (remember_wwid(ptr) != 0)
f20720
+				ret = -1;
f20720
+		}
f20720
+		else {
f20720
+			condlog(0, "empty mpath.wwid kernel command line option");
f20720
+			ret = -1;
f20720
+		}
f20720
+		if (!next)
f20720
+			break;
f20720
+	}
f20720
+	return ret;
f20720
+}
f20720
Index: multipath-tools-130222/libmultipath/wwids.h
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/libmultipath/wwids.h
f20720
+++ multipath-tools-130222/libmultipath/wwids.h
f20720
@@ -17,5 +17,6 @@ int remember_wwid(char *wwid);
f20720
 int check_wwids_file(char *wwid, int write_wwid);
f20720
 int remove_wwid(char *wwid);
f20720
 int replace_wwids(vector mp);
f20720
+int remember_cmdline_wwid(void);
f20720
 
f20720
 #endif /* _WWIDS_H */
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
@@ -85,7 +85,7 @@ usage (char * progname)
f20720
 {
f20720
 	fprintf (stderr, VERSION_STRING);
f20720
 	fprintf (stderr, "Usage:\n");
f20720
-	fprintf (stderr, "  %s [-a|-c|-w|-W] [-d] [-T tm:val] [-r] [-v lvl] [-p pol] [-b fil] [-q] [dev]\n", progname);
f20720
+	fprintf (stderr, "  %s [-a|-A|-c|-w|-W] [-d] [-T tm:val] [-r] [-v lvl] [-p pol] [-b fil] [-q] [dev]\n", progname);
f20720
 	fprintf (stderr, "  %s -l|-ll|-f [-v lvl] [-b fil] [dev]\n", progname);
f20720
 	fprintf (stderr, "  %s -F [-v lvl]\n", progname);
f20720
 	fprintf (stderr, "  %s -t\n", progname);
f20720
@@ -99,6 +99,8 @@ usage (char * progname)
f20720
 		"  -f      flush a multipath device map\n" \
f20720
 		"  -F      flush all multipath device maps\n" \
f20720
 		"  -a      add a device wwid to the wwids file\n" \
f20720
+		"  -A      add devices from kernel command line mpath.wwids\n"
f20720
+		"          parameters to wwids file\n" \
f20720
 		"  -c      check if a device should be a path in a multipath device\n" \
f20720
 		"  -T tm:val\n" \
f20720
 		"          check if tm matches the multipathd timestamp. If so val is\n" \
f20720
@@ -438,7 +440,7 @@ main (int argc, char *argv[])
f20720
 	int r = 1;
f20720
 	long int timestamp = -1;
f20720
 	int valid = -1;
f20720
-	while ((arg = getopt(argc, argv, ":adchl::FfM:v:p:b:BrtT:qwW")) != EOF ) {
f20720
+	while ((arg = getopt(argc, argv, ":aAdchl::FfM:v:p:b:BrtT:qwW")) != EOF ) {
f20720
 		switch(arg) {
f20720
 		case 'T':
f20720
 			if (optarg[0] == ':')
f20720
@@ -474,7 +476,7 @@ main (int argc, char *argv[])
f20720
 	if (dm_prereq())
f20720
 		exit(1);
f20720
 
f20720
-	while ((arg = getopt(argc, argv, ":adchl::FfM:v:p:b:BrtT:qwW")) != EOF ) {
f20720
+	while ((arg = getopt(argc, argv, ":aAdchl::FfM:v:p:b:BrtT:qwW")) != EOF ) {
f20720
 		switch(arg) {
f20720
 		case 1: printf("optarg : %s\n",optarg);
f20720
 			break;
f20720
@@ -538,6 +540,10 @@ main (int argc, char *argv[])
f20720
 			goto out;
f20720
 		case 'T':
f20720
 			break;
f20720
+		case 'A':
f20720
+			if (remember_cmdline_wwid() != 0)
f20720
+				exit(1);
f20720
+			exit(0);
f20720
 		case 'h':
f20720
 			usage(argv[0]);
f20720
 			exit(0);
f20720
Index: multipath-tools-130222/multipathd/multipathd.service
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/multipathd/multipathd.service
f20720
+++ multipath-tools-130222/multipathd/multipathd.service
f20720
@@ -11,6 +11,7 @@ Conflicts=shutdown.target
f20720
 Type=forking
f20720
 PIDFile=/var/run/multipathd/multipathd.pid
f20720
 ExecStartPre=/sbin/modprobe dm-multipath
f20720
+ExecStartPre=-/sbin/multipath -A
f20720
 ExecStart=/sbin/multipathd
f20720
 ExecReload=/sbin/multipathd reconfigure
f20720
 #ExecStop=/path/to/scrip delete-me if not necessary
f20720
Index: multipath-tools-130222/multipath/multipath.8
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/multipath/multipath.8
f20720
+++ multipath-tools-130222/multipath/multipath.8
f20720
@@ -8,7 +8,7 @@ multipath \- Device mapper target autoco
f20720
 .RB [\| \-b\ \c
f20720
 .IR bindings_file \|]
f20720
 .RB [\| \-d \|]
f20720
-.RB [\| \-h | \-l | \-ll | \-f | \-t | \-F | \-B | \-c | \-q | \|-r | \-a | \-w | \-W \|]
f20720
+.RB [\| \-h | \-l | \-ll | \-f | \-t | \-F | \-B | \-c | \-q | \|-r | \-a | \-A | \-w | \-W \|]
f20720
 .RB [\| \-p\ \c
f20720
 .BR failover | multibus | group_by_serial | group_by_prio | group_by_node_name \|]
f20720
 .RB [\| device \|]
f20720
@@ -71,6 +71,9 @@ allow device tables with queue_if_no_pat
f20720
 .B \-a
f20720
 add the wwid for the specified device to the wwids file
f20720
 .TP
f20720
+.B \-A
f20720
+add wwids from any kernel command line mpath.wwid parameters to the wwids file
f20720
+.TP
f20720
 .B \-w
f20720
 remove the wwid for the specified device from the wwids file
f20720
 .TP