2020-05-30 01:47:35 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2017-05-25 22:12:56 +00:00
|
|
|
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
|
Date: Fri, 17 Oct 2014 11:20:34 -0500
|
|
|
|
Subject: [PATCH] RH: add wwids from kernel cmdline mpath.wwids with -A
|
|
|
|
|
|
|
|
This patch adds another option to multipath, "-A", which reads
|
|
|
|
/proc/cmdline for mpath.wwid=<WWID> options, and adds any wwids it finds
|
|
|
|
to /etc/multipath/wwids. While this isn't usually important during
|
|
|
|
normal operation, since these wwids should already be added, it can be
|
|
|
|
helpful during installation, to make sure that multipath can claim
|
|
|
|
devices as its own, before LVM or something else makes use of them. The
|
|
|
|
patch also execs "/sbin/multipath -A" before running multipathd in
|
|
|
|
multipathd.service
|
|
|
|
|
|
|
|
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
|
---
|
2021-01-20 00:06:09 +00:00
|
|
|
multipath/main.c | 54 +++++++++++++++++++++++++++++++++--
|
2023-09-22 20:29:43 +00:00
|
|
|
multipath/multipath.8.in | 7 ++++-
|
2017-05-25 22:12:56 +00:00
|
|
|
multipathd/multipathd.service | 1 +
|
2021-01-20 00:06:09 +00:00
|
|
|
3 files changed, 59 insertions(+), 3 deletions(-)
|
2017-05-25 22:12:56 +00:00
|
|
|
|
2021-01-20 00:06:09 +00:00
|
|
|
diff --git a/multipath/main.c b/multipath/main.c
|
2023-09-22 20:29:43 +00:00
|
|
|
index 46944589..47f89a0a 100644
|
2021-01-20 00:06:09 +00:00
|
|
|
--- a/multipath/main.c
|
|
|
|
+++ b/multipath/main.c
|
2022-03-28 20:47:01 +00:00
|
|
|
@@ -120,7 +120,7 @@ usage (char * progname)
|
2021-01-20 00:06:09 +00:00
|
|
|
fprintf (stderr, " %s [-v level] [-R retries] -F\n", progname);
|
|
|
|
fprintf (stderr, " %s [-v level] [-l|-ll] [device]\n", progname);
|
|
|
|
fprintf (stderr, " %s [-v level] [-a|-w] device\n", progname);
|
|
|
|
- fprintf (stderr, " %s [-v level] -W\n", progname);
|
|
|
|
+ fprintf (stderr, " %s [-v level] [-A|-W]\n", progname);
|
|
|
|
fprintf (stderr, " %s [-v level] [-i] [-c|-C] device\n", progname);
|
|
|
|
fprintf (stderr, " %s [-v level] [-i] [-u|-U]\n", progname);
|
|
|
|
fprintf (stderr, " %s [-h|-t|-T]\n", progname);
|
2022-03-28 20:47:01 +00:00
|
|
|
@@ -134,6 +134,8 @@ usage (char * progname)
|
2021-01-20 00:06:09 +00:00
|
|
|
" -f flush a multipath device map\n"
|
|
|
|
" -F flush all multipath device maps\n"
|
|
|
|
" -a add a device wwid to the wwids file\n"
|
|
|
|
+ " -A add devices from kernel command line mpath.wwids\n"
|
|
|
|
+ " parameters to wwids file\n"
|
|
|
|
" -c check if a device should be a path in a multipath device\n"
|
|
|
|
" -C check if a multipath device has usable paths\n"
|
|
|
|
" -q allow queue_if_no_path when multipathd is not running\n"
|
2023-09-22 20:29:43 +00:00
|
|
|
@@ -448,6 +450,50 @@ static void cleanup_vecs(void)
|
2021-01-20 00:06:09 +00:00
|
|
|
free_pathvec(vecs.pathvec, FREE_PATHS);
|
2020-07-09 04:16:57 +00:00
|
|
|
}
|
2021-01-20 00:06:09 +00:00
|
|
|
|
|
|
|
+static int remember_cmdline_wwid(void)
|
2017-05-25 22:12:56 +00:00
|
|
|
+{
|
|
|
|
+ FILE *f = NULL;
|
|
|
|
+ char buf[LINE_MAX], *next, *ptr;
|
|
|
|
+ int ret = 0;
|
|
|
|
+
|
|
|
|
+ f = fopen("/proc/cmdline", "re");
|
|
|
|
+ if (!f) {
|
|
|
|
+ condlog(0, "can't open /proc/cmdline : %s", strerror(errno));
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!fgets(buf, sizeof(buf), f)) {
|
|
|
|
+ if (ferror(f))
|
|
|
|
+ condlog(0, "read of /proc/cmdline failed : %s",
|
|
|
|
+ strerror(errno));
|
|
|
|
+ else
|
|
|
|
+ condlog(0, "couldn't read /proc/cmdline");
|
|
|
|
+ fclose(f);
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ fclose(f);
|
|
|
|
+ next = buf;
|
|
|
|
+ while((ptr = strstr(next, "mpath.wwid="))) {
|
|
|
|
+ ptr += 11;
|
|
|
|
+ next = strpbrk(ptr, " \t\n");
|
|
|
|
+ if (next) {
|
|
|
|
+ *next = '\0';
|
|
|
|
+ next++;
|
|
|
|
+ }
|
|
|
|
+ if (strlen(ptr)) {
|
|
|
|
+ if (remember_wwid(ptr) != 0)
|
|
|
|
+ ret = -1;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ condlog(0, "empty mpath.wwid kernel command line option");
|
|
|
|
+ ret = -1;
|
|
|
|
+ }
|
|
|
|
+ if (!next)
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ return ret;
|
|
|
|
+}
|
2021-01-20 00:06:09 +00:00
|
|
|
+
|
|
|
|
static int
|
|
|
|
configure (struct config *conf, enum mpath_cmds cmd,
|
|
|
|
enum devtypes dev_type, char *devpath)
|
2023-09-22 20:29:43 +00:00
|
|
|
@@ -848,7 +894,7 @@ main (int argc, char *argv[])
|
2022-03-28 20:47:01 +00:00
|
|
|
condlog(1, "failed to register cleanup handler for vecs: %m");
|
2023-09-22 20:29:43 +00:00
|
|
|
if (atexit(cleanup_bindings))
|
|
|
|
condlog(1, "failed to register cleanup handler for bindings: %m");
|
2020-07-09 04:16:57 +00:00
|
|
|
- while ((arg = getopt(argc, argv, ":adDcChl::eFfM:v:p:b:BrR:itTquUwW")) != EOF ) {
|
|
|
|
+ while ((arg = getopt(argc, argv, ":aAdDcChl::eFfM:v:p:b:BrR:itTquUwW")) != EOF ) {
|
2017-05-25 22:12:56 +00:00
|
|
|
switch(arg) {
|
2022-03-28 20:47:01 +00:00
|
|
|
case 'v':
|
|
|
|
if (!isdigit(optarg[0])) {
|
2023-09-22 20:29:43 +00:00
|
|
|
@@ -919,6 +965,10 @@ main (int argc, char *argv[])
|
2018-07-17 19:55:00 +00:00
|
|
|
case 'T':
|
|
|
|
cmd = CMD_DUMP_CONFIG;
|
|
|
|
break;
|
2017-05-25 22:12:56 +00:00
|
|
|
+ case 'A':
|
|
|
|
+ if (remember_cmdline_wwid() != 0)
|
2019-01-16 00:08:53 +00:00
|
|
|
+ exit(RTVL_FAIL);
|
|
|
|
+ exit(RTVL_OK);
|
2017-05-25 22:12:56 +00:00
|
|
|
case 'h':
|
|
|
|
usage(argv[0]);
|
2019-01-16 00:08:53 +00:00
|
|
|
exit(RTVL_OK);
|
2023-09-22 20:29:43 +00:00
|
|
|
diff --git a/multipath/multipath.8.in b/multipath/multipath.8.in
|
|
|
|
index 348eb220..82a7e68e 100644
|
|
|
|
--- a/multipath/multipath.8.in
|
|
|
|
+++ b/multipath/multipath.8.in
|
|
|
|
@@ -64,7 +64,7 @@ multipath \- Device mapper target autoconfig.
|
2018-12-03 21:24:23 +00:00
|
|
|
.B multipath
|
|
|
|
.RB [\| \-v\ \c
|
|
|
|
.IR level \|]
|
|
|
|
-.B -W
|
|
|
|
+.RB [\| \-A | \-W \|]
|
2017-05-25 22:12:56 +00:00
|
|
|
.
|
2018-12-03 21:24:23 +00:00
|
|
|
.LP
|
|
|
|
.B multipath
|
2023-09-22 20:29:43 +00:00
|
|
|
@@ -146,6 +146,11 @@ device mapper, path checkers ...).
|
2018-12-03 21:24:23 +00:00
|
|
|
Add the WWID for the specified device to the WWIDs file.
|
|
|
|
.
|
|
|
|
.TP
|
2017-05-25 22:12:56 +00:00
|
|
|
+.B \-A
|
2018-12-03 21:24:23 +00:00
|
|
|
+Add the WWIDs from any kernel command line \fImpath.wwid\fR parameters to the
|
|
|
|
+WWIDs file.
|
2017-05-25 22:12:56 +00:00
|
|
|
+.
|
2018-12-03 21:24:23 +00:00
|
|
|
+.TP
|
|
|
|
.B \-w
|
|
|
|
Remove the WWID for the specified device from the WWIDs file.
|
|
|
|
.
|
2017-05-25 22:12:56 +00:00
|
|
|
diff --git a/multipathd/multipathd.service b/multipathd/multipathd.service
|
2023-05-16 22:02:58 +00:00
|
|
|
index 311f49c7..5324f4bc 100644
|
2017-05-25 22:12:56 +00:00
|
|
|
--- a/multipathd/multipathd.service
|
|
|
|
+++ b/multipathd/multipathd.service
|
2022-03-28 20:47:01 +00:00
|
|
|
@@ -17,6 +17,7 @@ ConditionVirtualization=!container
|
|
|
|
[Service]
|
|
|
|
Type=notify
|
2017-05-25 22:12:56 +00:00
|
|
|
NotifyAccess=main
|
|
|
|
+ExecStartPre=-/sbin/multipath -A
|
|
|
|
ExecStart=/sbin/multipathd -d -s
|
|
|
|
ExecReload=/sbin/multipathd reconfigure
|
2018-04-02 22:29:20 +00:00
|
|
|
TasksMax=infinity
|