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