Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1 | From 0bf8ff8dab26201b268b419809844c07e168f17d Mon Sep 17 00:00:00 2001 |
| 2 | From: Changqing Li <changqing.li@windriver.com> |
| 3 | Date: Fri, 23 Nov 2018 17:25:15 +0800 |
| 4 | Subject: [PATCH] From 0000000000000000000000000000000000000000 Mon Sep 17 |
| 5 | 00:00:00 2001 From: Benjamin Marzinski <bmarzins@redhat.com> Date: Wed, 15 |
| 6 | Oct 2014 10:39:30 -0500 Subject: [PATCH] RH: don't start without a config |
| 7 | file |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 8 | |
| 9 | If /etc/multipath.conf doesn't exist, don't start multipathd and blacklist |
| 10 | all devices when running multipath. A completely blank configuration file |
| 11 | is almost never what users want. Also, people may have the multipath |
| 12 | packages installed but don't want to use them. This patch provides a |
| 13 | simple way to disable multipath. Simply removing or renaming |
| 14 | /etc/multipath.conf will keep multipath from doing anything. |
| 15 | |
| 16 | Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 17 | |
| 18 | Upstream-Status: Pending |
| 19 | |
| 20 | update this patch to new version |
| 21 | Signed-off-by: Changqing Li <changqing.li@windriver.com> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 22 | --- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 23 | libmultipath/config.c | 18 ++++++++++++++++++ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 24 | libmultipath/config.h | 1 + |
| 25 | multipath/multipath.rules | 1 + |
| 26 | multipathd/multipathd.8 | 2 ++ |
| 27 | multipathd/multipathd.service | 1 + |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 28 | 5 files changed, 23 insertions(+) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 29 | |
| 30 | diff --git a/libmultipath/config.c b/libmultipath/config.c |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 31 | index 5af7af5..e4233f1 100644 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 32 | --- a/libmultipath/config.c |
| 33 | +++ b/libmultipath/config.c |
| 34 | @@ -26,6 +26,7 @@ |
| 35 | #include "devmapper.h" |
| 36 | #include "mpath_cmd.h" |
| 37 | #include "propsel.h" |
| 38 | +#include "version.h" |
| 39 | |
| 40 | static int |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 41 | hwe_strmatch (const struct hwentry *hwe1, const struct hwentry *hwe2) |
| 42 | @@ -743,6 +745,23 @@ load_config (char * file) |
| 43 | goto out; |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 44 | } |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 45 | factorize_hwtable(conf->hwtable, builtin_hwtable_size, file); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 46 | + } else { |
| 47 | + condlog(0, "/etc/multipath.conf does not exist, blacklisting all devices."); |
| 48 | + if (conf->blist_devnode == NULL) { |
| 49 | + conf->blist_devnode = vector_alloc(); |
| 50 | + if (!conf->blist_devnode) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 51 | + conf->blist_devnode = vector_alloc(); |
| 52 | + if (!conf->blist_devnode) { |
| 53 | + condlog(0, "cannot allocate blacklist\n"); |
| 54 | + goto out; |
| 55 | + } |
| 56 | + } |
| 57 | + if (store_ble(conf->blist_devnode, strdup(".*"), |
| 58 | + ORIGIN_NO_CONFIG)) { |
| 59 | + condlog(0, "cannot store default no-config blacklist\n"); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 60 | + goto out; |
| 61 | + } |
| 62 | + } |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | conf->processed_main_config = 1; |
| 66 | diff --git a/libmultipath/config.h b/libmultipath/config.h |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 67 | index 7d0cd9a..d7fb8e2 100644 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 68 | --- a/libmultipath/config.h |
| 69 | +++ b/libmultipath/config.h |
| 70 | @@ -9,6 +9,7 @@ |
| 71 | |
| 72 | #define ORIGIN_DEFAULT 0 |
| 73 | #define ORIGIN_CONFIG 1 |
| 74 | +#define ORIGIN_NO_CONFIG 2 |
| 75 | |
| 76 | /* |
| 77 | * In kernel, fast_io_fail == 0 means immediate failure on rport delete. |
| 78 | diff --git a/multipath/multipath.rules b/multipath/multipath.rules |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 79 | index 9df11a9..0486bf7 100644 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 80 | --- a/multipath/multipath.rules |
| 81 | +++ b/multipath/multipath.rules |
| 82 | @@ -9,6 +9,7 @@ IMPORT{cmdline}="nompath" |
| 83 | ENV{nompath}=="?*", GOTO="end_mpath" |
| 84 | IMPORT{cmdline}="multipath" |
| 85 | ENV{multipath}=="off", GOTO="end_mpath" |
| 86 | +TEST!="/etc/multipath.conf", GOTO="end_mpath" |
| 87 | |
| 88 | ENV{DEVTYPE}!="partition", GOTO="test_dev" |
| 89 | IMPORT{parent}="DM_MULTIPATH_DEVICE_PATH" |
| 90 | diff --git a/multipathd/multipathd.8 b/multipathd/multipathd.8 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 91 | index 94c3f97..ed13efd 100644 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 92 | --- a/multipathd/multipathd.8 |
| 93 | +++ b/multipathd/multipathd.8 |
| 94 | @@ -38,6 +38,8 @@ map regains its maximum performance and redundancy. |
| 95 | This daemon executes the external \fBmultipath\fR tool when events occur. |
| 96 | In turn, the multipath tool signals the multipathd daemon when it is done with |
| 97 | devmap reconfiguration, so that it can refresh its failed path list. |
| 98 | + |
| 99 | +In this Linux distribution, multipathd does not run unless a /etc/multipath.conf file exists. |
| 100 | . |
| 101 | . |
| 102 | .\" ---------------------------------------------------------------------------- |
| 103 | diff --git a/multipathd/multipathd.service b/multipathd/multipathd.service |
| 104 | index ba24983..17434ce 100644 |
| 105 | --- a/multipathd/multipathd.service |
| 106 | +++ b/multipathd/multipathd.service |
| 107 | @@ -4,6 +4,7 @@ Wants=systemd-udev-trigger.service systemd-udev-settle.service |
| 108 | Before=iscsi.service iscsid.service lvm2-activation-early.service |
| 109 | Before=local-fs-pre.target blk-availability.service |
| 110 | After=multipathd.socket systemd-udev-trigger.service systemd-udev-settle.service |
| 111 | +ConditionPathExists=/etc/multipath.conf |
| 112 | DefaultDependencies=no |
| 113 | Conflicts=shutdown.target |
| 114 | ConditionKernelCommandLine=!nompath |
| 115 | -- |
| 116 | 2.7.4 |
| 117 | |