|
|
b7ef27 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
b7ef27 |
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
b7ef27 |
Date: Fri, 17 Oct 2014 11:20:34 -0500
|
|
|
b7ef27 |
Subject: [PATCH] RH: add wwids from kernel cmdline mpath.wwids with -A
|
|
|
b7ef27 |
|
|
|
b7ef27 |
This patch adds another option to multipath, "-A", which reads
|
|
|
b7ef27 |
/proc/cmdline for mpath.wwid=<WWID> options, and adds any wwids it finds
|
|
|
b7ef27 |
to /etc/multipath/wwids. While this isn't usually important during
|
|
|
b7ef27 |
normal operation, since these wwids should already be added, it can be
|
|
|
b7ef27 |
helpful during installation, to make sure that multipath can claim
|
|
|
b7ef27 |
devices as its own, before LVM or something else makes use of them. The
|
|
|
b7ef27 |
patch also execs "/sbin/multipath -A" before running multipathd in
|
|
|
b7ef27 |
multipathd.service
|
|
|
b7ef27 |
|
|
|
b7ef27 |
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
b7ef27 |
---
|
|
|
b7ef27 |
libmultipath/wwids.c | 44 +++++++++++++++++++++++++++++++++++
|
|
|
b7ef27 |
libmultipath/wwids.h | 1 +
|
|
|
b7ef27 |
multipath/main.c | 10 ++++++--
|
|
|
b7ef27 |
multipath/multipath.8 | 7 +++++-
|
|
|
b7ef27 |
multipathd/multipathd.service | 1 +
|
|
|
b7ef27 |
5 files changed, 60 insertions(+), 3 deletions(-)
|
|
|
b7ef27 |
|
|
|
b7ef27 |
diff --git a/libmultipath/wwids.c b/libmultipath/wwids.c
|
|
|
6bed34 |
index 28a2150d..fab6fc8f 100644
|
|
|
b7ef27 |
--- a/libmultipath/wwids.c
|
|
|
b7ef27 |
+++ b/libmultipath/wwids.c
|
|
|
6bed34 |
@@ -454,3 +454,47 @@ int op ## _wwid(const char *wwid) \
|
|
|
b7ef27 |
declare_failed_wwid_op(is_failed, false)
|
|
|
b7ef27 |
declare_failed_wwid_op(mark_failed, true)
|
|
|
b7ef27 |
declare_failed_wwid_op(unmark_failed, true)
|
|
|
b7ef27 |
+
|
|
|
b7ef27 |
+int remember_cmdline_wwid(void)
|
|
|
b7ef27 |
+{
|
|
|
b7ef27 |
+ FILE *f = NULL;
|
|
|
b7ef27 |
+ char buf[LINE_MAX], *next, *ptr;
|
|
|
b7ef27 |
+ int ret = 0;
|
|
|
b7ef27 |
+
|
|
|
b7ef27 |
+ f = fopen("/proc/cmdline", "re");
|
|
|
b7ef27 |
+ if (!f) {
|
|
|
b7ef27 |
+ condlog(0, "can't open /proc/cmdline : %s", strerror(errno));
|
|
|
b7ef27 |
+ return -1;
|
|
|
b7ef27 |
+ }
|
|
|
b7ef27 |
+
|
|
|
b7ef27 |
+ if (!fgets(buf, sizeof(buf), f)) {
|
|
|
b7ef27 |
+ if (ferror(f))
|
|
|
b7ef27 |
+ condlog(0, "read of /proc/cmdline failed : %s",
|
|
|
b7ef27 |
+ strerror(errno));
|
|
|
b7ef27 |
+ else
|
|
|
b7ef27 |
+ condlog(0, "couldn't read /proc/cmdline");
|
|
|
b7ef27 |
+ fclose(f);
|
|
|
b7ef27 |
+ return -1;
|
|
|
b7ef27 |
+ }
|
|
|
b7ef27 |
+ fclose(f);
|
|
|
b7ef27 |
+ next = buf;
|
|
|
b7ef27 |
+ while((ptr = strstr(next, "mpath.wwid="))) {
|
|
|
b7ef27 |
+ ptr += 11;
|
|
|
b7ef27 |
+ next = strpbrk(ptr, " \t\n");
|
|
|
b7ef27 |
+ if (next) {
|
|
|
b7ef27 |
+ *next = '\0';
|
|
|
b7ef27 |
+ next++;
|
|
|
b7ef27 |
+ }
|
|
|
b7ef27 |
+ if (strlen(ptr)) {
|
|
|
b7ef27 |
+ if (remember_wwid(ptr) != 0)
|
|
|
b7ef27 |
+ ret = -1;
|
|
|
b7ef27 |
+ }
|
|
|
b7ef27 |
+ else {
|
|
|
b7ef27 |
+ condlog(0, "empty mpath.wwid kernel command line option");
|
|
|
b7ef27 |
+ ret = -1;
|
|
|
b7ef27 |
+ }
|
|
|
b7ef27 |
+ if (!next)
|
|
|
b7ef27 |
+ break;
|
|
|
b7ef27 |
+ }
|
|
|
b7ef27 |
+ return ret;
|
|
|
b7ef27 |
+}
|
|
|
b7ef27 |
diff --git a/libmultipath/wwids.h b/libmultipath/wwids.h
|
|
|
b6d9ac |
index 0c6ee54d..e32a0b0e 100644
|
|
|
b7ef27 |
--- a/libmultipath/wwids.h
|
|
|
b7ef27 |
+++ b/libmultipath/wwids.h
|
|
|
b7ef27 |
@@ -17,6 +17,7 @@ int remember_wwid(char *wwid);
|
|
|
b7ef27 |
int check_wwids_file(char *wwid, int write_wwid);
|
|
|
b7ef27 |
int remove_wwid(char *wwid);
|
|
|
b7ef27 |
int replace_wwids(vector mp);
|
|
|
b7ef27 |
+int remember_cmdline_wwid(void);
|
|
|
b7ef27 |
|
|
|
b7ef27 |
enum {
|
|
|
b7ef27 |
WWID_IS_NOT_FAILED = 0,
|
|
|
b7ef27 |
diff --git a/multipath/main.c b/multipath/main.c
|
|
|
6bed34 |
index cf9d2a28..78822ee1 100644
|
|
|
b7ef27 |
--- a/multipath/main.c
|
|
|
b7ef27 |
+++ b/multipath/main.c
|
|
|
b6d9ac |
@@ -138,7 +138,7 @@ usage (char * progname)
|
|
|
b6d9ac |
fprintf (stderr, " %s [-v level] [-R retries] -F\n", progname);
|
|
|
b6d9ac |
fprintf (stderr, " %s [-v level] [-l|-ll] [device]\n", progname);
|
|
|
b6d9ac |
fprintf (stderr, " %s [-v level] [-a|-w] device\n", progname);
|
|
|
b6d9ac |
- fprintf (stderr, " %s [-v level] -W\n", progname);
|
|
|
b6d9ac |
+ fprintf (stderr, " %s [-v level] [-A|-W]\n", progname);
|
|
|
b6d9ac |
fprintf (stderr, " %s [-v level] [-i] [-c|-C] device\n", progname);
|
|
|
b6d9ac |
fprintf (stderr, " %s [-v level] [-i] [-u|-U]\n", progname);
|
|
|
b6d9ac |
fprintf (stderr, " %s [-h|-t|-T]\n", progname);
|
|
|
b6d9ac |
@@ -151,6 +151,8 @@ usage (char * progname)
|
|
|
b7ef27 |
" -f flush a multipath device map\n"
|
|
|
b7ef27 |
" -F flush all multipath device maps\n"
|
|
|
b7ef27 |
" -a add a device wwid to the wwids file\n"
|
|
|
b7ef27 |
+ " -A add devices from kernel command line mpath.wwids\n"
|
|
|
b7ef27 |
+ " parameters to wwids file\n"
|
|
|
b7ef27 |
" -c check if a device should be a path in a multipath device\n"
|
|
|
b7ef27 |
" -C check if a multipath device has usable paths\n"
|
|
|
b7ef27 |
" -q allow queue_if_no_path when multipathd is not running\n"
|
|
|
6bed34 |
@@ -907,7 +909,7 @@ main (int argc, char *argv[])
|
|
|
b7ef27 |
multipath_conf = conf;
|
|
|
b7ef27 |
conf->retrigger_tries = 0;
|
|
|
6bed34 |
conf->force_sync = 1;
|
|
|
b7ef27 |
- while ((arg = getopt(argc, argv, ":adcChl::FfM:v:p:b:BrR:itTquUwW")) != EOF ) {
|
|
|
b7ef27 |
+ while ((arg = getopt(argc, argv, ":aAdcChl::FfM:v:p:b:BrR:itTquUwW")) != EOF ) {
|
|
|
b7ef27 |
switch(arg) {
|
|
|
b7ef27 |
case 1: printf("optarg : %s\n",optarg);
|
|
|
b7ef27 |
break;
|
|
|
6bed34 |
@@ -977,6 +979,10 @@ main (int argc, char *argv[])
|
|
|
b7ef27 |
case 'T':
|
|
|
b7ef27 |
cmd = CMD_DUMP_CONFIG;
|
|
|
b7ef27 |
break;
|
|
|
b7ef27 |
+ case 'A':
|
|
|
b7ef27 |
+ if (remember_cmdline_wwid() != 0)
|
|
|
b7ef27 |
+ exit(RTVL_FAIL);
|
|
|
b7ef27 |
+ exit(RTVL_OK);
|
|
|
b7ef27 |
case 'h':
|
|
|
b7ef27 |
usage(argv[0]);
|
|
|
b7ef27 |
exit(RTVL_OK);
|
|
|
b7ef27 |
diff --git a/multipath/multipath.8 b/multipath/multipath.8
|
|
|
b6d9ac |
index 9cdd05a3..8befc45a 100644
|
|
|
b7ef27 |
--- a/multipath/multipath.8
|
|
|
b7ef27 |
+++ b/multipath/multipath.8
|
|
|
b7ef27 |
@@ -63,7 +63,7 @@ multipath \- Device mapper target autoconfig.
|
|
|
b7ef27 |
.B multipath
|
|
|
b7ef27 |
.RB [\| \-v\ \c
|
|
|
b7ef27 |
.IR level \|]
|
|
|
b7ef27 |
-.B -W
|
|
|
b7ef27 |
+.RB [\| \-A | \-W \|]
|
|
|
b7ef27 |
.
|
|
|
b7ef27 |
.LP
|
|
|
b7ef27 |
.B multipath
|
|
|
b7ef27 |
@@ -145,6 +145,11 @@ device mapper, path checkers ...).
|
|
|
b7ef27 |
Add the WWID for the specified device to the WWIDs file.
|
|
|
b7ef27 |
.
|
|
|
b7ef27 |
.TP
|
|
|
b7ef27 |
+.B \-A
|
|
|
b7ef27 |
+Add the WWIDs from any kernel command line \fImpath.wwid\fR parameters to the
|
|
|
b7ef27 |
+WWIDs file.
|
|
|
b7ef27 |
+.
|
|
|
b7ef27 |
+.TP
|
|
|
b7ef27 |
.B \-w
|
|
|
b7ef27 |
Remove the WWID for the specified device from the WWIDs file.
|
|
|
b7ef27 |
.
|
|
|
b7ef27 |
diff --git a/multipathd/multipathd.service b/multipathd/multipathd.service
|
|
|
b6d9ac |
index 17434cef..0fbcc46b 100644
|
|
|
b7ef27 |
--- a/multipathd/multipathd.service
|
|
|
b7ef27 |
+++ b/multipathd/multipathd.service
|
|
|
b7ef27 |
@@ -15,6 +15,7 @@ Type=notify
|
|
|
b7ef27 |
NotifyAccess=main
|
|
|
b7ef27 |
LimitCORE=infinity
|
|
|
b7ef27 |
ExecStartPre=-/sbin/modprobe -a scsi_dh_alua scsi_dh_emc scsi_dh_rdac dm-multipath
|
|
|
b7ef27 |
+ExecStartPre=-/sbin/multipath -A
|
|
|
b7ef27 |
ExecStart=/sbin/multipathd -d -s
|
|
|
b7ef27 |
ExecReload=/sbin/multipathd reconfigure
|
|
|
b7ef27 |
TasksMax=infinity
|
|
|
b7ef27 |
--
|
|
|
b7ef27 |
2.17.2
|
|
|
b7ef27 |
|