2020-05-30 01:47:35 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2017-05-25 22:12:56 +00:00
|
|
|
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
|
Date: Wed, 15 Oct 2014 10:39:30 -0500
|
|
|
|
Subject: [PATCH] RH: don't start without a config file
|
|
|
|
|
|
|
|
If /etc/multipath.conf doesn't exist, don't start multipathd and blacklist
|
|
|
|
all devices when running multipath. A completely blank configuration file
|
|
|
|
is almost never what users want. Also, people may have the multipath
|
|
|
|
packages installed but don't want to use them. This patch provides a
|
|
|
|
simple way to disable multipath. Simply removing or renaming
|
|
|
|
/etc/multipath.conf will keep multipath from doing anything.
|
|
|
|
|
|
|
|
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
|
---
|
2021-01-20 00:06:09 +00:00
|
|
|
libmultipath/config.c | 13 +++++++++++++
|
2017-05-25 22:12:56 +00:00
|
|
|
libmultipath/config.h | 1 +
|
2023-09-22 20:29:43 +00:00
|
|
|
multipath/main.c | 6 ++++++
|
2022-11-16 20:11:59 +00:00
|
|
|
multipath/multipath.rules.in | 1 +
|
2023-09-22 20:29:43 +00:00
|
|
|
multipathd/multipathd.8.in | 2 ++
|
2017-05-25 22:12:56 +00:00
|
|
|
multipathd/multipathd.service | 1 +
|
2021-10-07 03:13:34 +00:00
|
|
|
multipathd/multipathd.socket | 1 +
|
2023-09-22 20:29:43 +00:00
|
|
|
7 files changed, 25 insertions(+)
|
2017-05-25 22:12:56 +00:00
|
|
|
|
|
|
|
diff --git a/libmultipath/config.c b/libmultipath/config.c
|
2023-09-22 20:29:43 +00:00
|
|
|
index b7dbc6f5..3a374b3d 100644
|
2017-05-25 22:12:56 +00:00
|
|
|
--- a/libmultipath/config.c
|
|
|
|
+++ b/libmultipath/config.c
|
2023-09-22 20:29:43 +00:00
|
|
|
@@ -958,6 +958,19 @@ int _init_config (const char *file, struct config *conf)
|
2017-05-25 22:12:56 +00:00
|
|
|
}
|
2018-07-17 19:55:00 +00:00
|
|
|
factorize_hwtable(conf->hwtable, builtin_hwtable_size, file);
|
2022-07-13 21:51:42 +00:00
|
|
|
validate_pctable(conf->overrides, 0, file);
|
2017-05-25 22:12:56 +00:00
|
|
|
+ } else {
|
|
|
|
+ condlog(0, "/etc/multipath.conf does not exist, blacklisting all devices.");
|
|
|
|
+ if (conf->blist_devnode == NULL) {
|
|
|
|
+ conf->blist_devnode = vector_alloc();
|
|
|
|
+ if (!conf->blist_devnode) {
|
|
|
|
+ condlog(0, "cannot allocate blacklist\n");
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
|
|
+ }
|
2021-01-20 00:06:09 +00:00
|
|
|
+ if (store_ble(conf->blist_devnode, ".*", ORIGIN_NO_CONFIG)) {
|
2017-05-25 22:12:56 +00:00
|
|
|
+ condlog(0, "cannot store default no-config blacklist\n");
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
conf->processed_main_config = 1;
|
|
|
|
diff --git a/libmultipath/config.h b/libmultipath/config.h
|
2023-09-22 20:29:43 +00:00
|
|
|
index 8c22ce75..92f3a0df 100644
|
2017-05-25 22:12:56 +00:00
|
|
|
--- a/libmultipath/config.h
|
|
|
|
+++ b/libmultipath/config.h
|
2022-11-16 20:11:59 +00:00
|
|
|
@@ -10,6 +10,7 @@
|
2017-05-25 22:12:56 +00:00
|
|
|
|
|
|
|
#define ORIGIN_DEFAULT 0
|
|
|
|
#define ORIGIN_CONFIG 1
|
|
|
|
+#define ORIGIN_NO_CONFIG 2
|
|
|
|
|
2021-01-20 00:06:09 +00:00
|
|
|
enum devtypes {
|
|
|
|
DEV_NONE,
|
2023-09-22 20:29:43 +00:00
|
|
|
diff --git a/multipath/main.c b/multipath/main.c
|
|
|
|
index 9e1c5052..46944589 100644
|
|
|
|
--- a/multipath/main.c
|
|
|
|
+++ b/multipath/main.c
|
|
|
|
@@ -829,11 +829,14 @@ main (int argc, char *argv[])
|
|
|
|
struct config *conf;
|
|
|
|
int retries = -1;
|
|
|
|
bool enable_foreign = false;
|
|
|
|
+ bool have_config;
|
|
|
|
+ struct stat buf;
|
|
|
|
|
|
|
|
libmultipath_init();
|
|
|
|
if (atexit(dm_lib_exit) || atexit(libmultipath_exit))
|
|
|
|
condlog(1, "failed to register cleanup handler for libmultipath: %m");
|
|
|
|
logsink = LOGSINK_STDERR_WITH_TIME;
|
|
|
|
+ have_config = (stat(DEFAULT_CONFIGFILE, &buf) == 0);
|
|
|
|
if (init_config(DEFAULT_CONFIGFILE))
|
|
|
|
exit(RTVL_FAIL);
|
|
|
|
if (atexit(uninit_config))
|
|
|
|
@@ -1081,6 +1084,9 @@ main (int argc, char *argv[])
|
|
|
|
while ((r = configure(conf, cmd, dev_type, dev)) == RTVL_RETRY)
|
|
|
|
condlog(3, "restart multipath configuration process");
|
|
|
|
|
|
|
|
+ if (!have_config && r == RTVL_OK &&
|
|
|
|
+ (cmd == CMD_LIST_SHORT || cmd == CMD_LIST_LONG))
|
|
|
|
+ r = RTVL_FAIL;
|
|
|
|
out:
|
|
|
|
put_multipath_config(conf);
|
|
|
|
if (dev)
|
2022-11-16 20:11:59 +00:00
|
|
|
diff --git a/multipath/multipath.rules.in b/multipath/multipath.rules.in
|
2023-05-16 22:02:58 +00:00
|
|
|
index 6f123760..70b69a06 100644
|
2022-11-16 20:11:59 +00:00
|
|
|
--- a/multipath/multipath.rules.in
|
|
|
|
+++ b/multipath/multipath.rules.in
|
2018-06-12 19:11:55 +00:00
|
|
|
@@ -9,6 +9,7 @@ IMPORT{cmdline}="nompath"
|
2017-05-25 22:12:56 +00:00
|
|
|
ENV{nompath}=="?*", GOTO="end_mpath"
|
|
|
|
IMPORT{cmdline}="multipath"
|
|
|
|
ENV{multipath}=="off", GOTO="end_mpath"
|
|
|
|
+TEST!="/etc/multipath.conf", GOTO="end_mpath"
|
|
|
|
|
|
|
|
ENV{DEVTYPE}!="partition", GOTO="test_dev"
|
2017-11-07 23:51:09 +00:00
|
|
|
IMPORT{parent}="DM_MULTIPATH_DEVICE_PATH"
|
2023-09-22 20:29:43 +00:00
|
|
|
diff --git a/multipathd/multipathd.8.in b/multipathd/multipathd.8.in
|
|
|
|
index e98c27fd..fd2061e5 100644
|
|
|
|
--- a/multipathd/multipathd.8.in
|
|
|
|
+++ b/multipathd/multipathd.8.in
|
|
|
|
@@ -49,6 +49,8 @@ map regains its maximum performance and redundancy.
|
2022-11-16 20:11:59 +00:00
|
|
|
With the \fB-k\fR option, \fBmultipathd\fR acts as a client utility that
|
|
|
|
sends commands to a running instance of the multipathd daemon (see
|
|
|
|
\fBCOMMANDS\fR below).
|
2017-06-02 05:34:02 +00:00
|
|
|
+
|
2017-09-21 18:00:03 +00:00
|
|
|
+In this Linux distribution, multipathd does not run unless a /etc/multipath.conf file exists.
|
2017-06-02 05:34:02 +00:00
|
|
|
.
|
|
|
|
.
|
|
|
|
.\" ----------------------------------------------------------------------------
|
2017-05-25 22:12:56 +00:00
|
|
|
diff --git a/multipathd/multipathd.service b/multipathd/multipathd.service
|
2023-05-16 22:02:58 +00:00
|
|
|
index 5a9cde12..311f49c7 100644
|
2017-05-25 22:12:56 +00:00
|
|
|
--- a/multipathd/multipathd.service
|
|
|
|
+++ b/multipathd/multipathd.service
|
2022-03-28 20:47:01 +00:00
|
|
|
@@ -6,6 +6,7 @@ Wants=systemd-udevd-kernel.socket
|
|
|
|
After=systemd-udevd-kernel.socket
|
|
|
|
After=multipathd.socket systemd-remount-fs.service
|
|
|
|
Before=initrd-cleanup.service
|
2017-05-25 22:12:56 +00:00
|
|
|
+ConditionPathExists=/etc/multipath.conf
|
|
|
|
DefaultDependencies=no
|
|
|
|
Conflicts=shutdown.target
|
2022-03-28 20:47:01 +00:00
|
|
|
Conflicts=initrd-cleanup.service
|
2021-10-07 03:13:34 +00:00
|
|
|
diff --git a/multipathd/multipathd.socket b/multipathd/multipathd.socket
|
|
|
|
index c777e5e3..3c20a2ff 100644
|
|
|
|
--- a/multipathd/multipathd.socket
|
|
|
|
+++ b/multipathd/multipathd.socket
|
|
|
|
@@ -1,6 +1,7 @@
|
|
|
|
[Unit]
|
|
|
|
Description=multipathd control socket
|
|
|
|
DefaultDependencies=no
|
|
|
|
+ConditionPathExists=/etc/multipath.conf
|
|
|
|
ConditionKernelCommandLine=!nompath
|
|
|
|
ConditionKernelCommandLine=!multipath=off
|
|
|
|
ConditionVirtualization=!container
|