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