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