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