Brad Bishop | 00ab237 | 2019-10-14 11:06:18 -0400 | [diff] [blame] | 1 | From 0f54b3120ca06ff3168cdbf901a27b68c4638398 Mon Sep 17 00:00:00 2001 |
| 2 | From: Changqing Li <changqing.li@windriver.com> |
| 3 | Date: Thu, 26 Sep 2019 16:29:48 +0800 |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 4 | Subject: [PATCH] From 0000000000000000000000000000000000000000 Mon Sep |
| 5 | 17 |
| 6 | 00:00:00 2001 From: Benjamin Marzinski <bmarzins@redhat.com> Date: Fri, |
| 7 | 17 |
| 8 | Oct 2014 11:20:34 -0500 Subject: [PATCH] RH: add wwids from kernel |
| 9 | cmdline |
Brad Bishop | 00ab237 | 2019-10-14 11:06:18 -0400 | [diff] [blame] | 10 | mpath.wwids with -A |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 11 | |
| 12 | This patch adds another option to multipath, "-A", which reads |
| 13 | /proc/cmdline for mpath.wwid=<WWID> options, and adds any wwids it finds |
| 14 | to /etc/multipath/wwids. While this isn't usually important during |
| 15 | normal operation, since these wwids should already be added, it can be |
| 16 | helpful during installation, to make sure that multipath can claim |
| 17 | devices as its own, before LVM or something else makes use of them. The |
| 18 | patch also execs "/sbin/multipath -A" before running multipathd in |
| 19 | multipathd.service |
| 20 | |
| 21 | Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 22 | |
| 23 | Upstream-Status: Pending |
| 24 | |
Brad Bishop | 00ab237 | 2019-10-14 11:06:18 -0400 | [diff] [blame] | 25 | Update this patch to new version 0.8.2 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 26 | |
| 27 | Signed-off-by: Changqing Li <changqing.li@windriver.com> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 28 | --- |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 29 | libmultipath/wwids.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ |
| 30 | libmultipath/wwids.h | 1 + |
| 31 | 2 files changed, 45 insertions(+) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 32 | |
| 33 | diff --git a/libmultipath/wwids.c b/libmultipath/wwids.c |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 34 | index 28a2150d..a0bfa851 100644 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 35 | --- a/libmultipath/wwids.c |
| 36 | +++ b/libmultipath/wwids.c |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 37 | @@ -454,3 +454,47 @@ int op ## _wwid(const char *wwid) \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 38 | declare_failed_wwid_op(is_failed, false) |
| 39 | declare_failed_wwid_op(mark_failed, true) |
| 40 | declare_failed_wwid_op(unmark_failed, true) |
| 41 | + |
| 42 | +int remember_cmdline_wwid(void) |
| 43 | +{ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 44 | + FILE *f = NULL; |
| 45 | + char buf[LINE_MAX], *next, *ptr; |
| 46 | + int ret = 0; |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 47 | + |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 48 | + f = fopen("/proc/cmdline", "re"); |
| 49 | + if (!f) { |
| 50 | + condlog(0, "can't open /proc/cmdline : %s", strerror(errno)); |
| 51 | + return -1; |
| 52 | + } |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 53 | + |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 54 | + if (!fgets(buf, sizeof(buf), f)) { |
| 55 | + if (ferror(f)) |
| 56 | + condlog(0, "read of /proc/cmdline failed : %s", |
| 57 | + strerror(errno)); |
| 58 | + else |
| 59 | + condlog(0, "couldn't read /proc/cmdline"); |
| 60 | + fclose(f); |
| 61 | + return -1; |
| 62 | + } |
| 63 | + fclose(f); |
| 64 | + next = buf; |
| 65 | + while((ptr = strstr(next, "mpath.wwid="))) { |
| 66 | + ptr += 11; |
| 67 | + next = strpbrk(ptr, " \t\n"); |
| 68 | + if (next) { |
| 69 | + *next = '\0'; |
| 70 | + next++; |
| 71 | + } |
| 72 | + if (strlen(ptr)) { |
| 73 | + if (remember_wwid(ptr) != 0) |
| 74 | + ret = -1; |
| 75 | + } |
| 76 | + else { |
| 77 | + condlog(0, "empty mpath.wwid kernel command line option"); |
| 78 | + ret = -1; |
| 79 | + } |
| 80 | + if (!next) |
| 81 | + break; |
| 82 | + } |
| 83 | + return ret; |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 84 | +} |
| 85 | diff --git a/libmultipath/wwids.h b/libmultipath/wwids.h |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 86 | index 0c6ee54d..e32a0b0e 100644 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 87 | --- a/libmultipath/wwids.h |
| 88 | +++ b/libmultipath/wwids.h |
| 89 | @@ -17,6 +17,7 @@ int remember_wwid(char *wwid); |
| 90 | int check_wwids_file(char *wwid, int write_wwid); |
| 91 | int remove_wwid(char *wwid); |
| 92 | int replace_wwids(vector mp); |
| 93 | +int remember_cmdline_wwid(void); |
| 94 | |
| 95 | enum { |
| 96 | WWID_IS_NOT_FAILED = 0, |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 97 | -- |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 98 | 2.17.1 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 99 | |