Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1 | From 056fdaece0f1a3a5ca92e8c08912730faa89875d Mon Sep 17 00:00:00 2001 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 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> |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 22 | [OP: Rebase to 0.9.3] |
| 23 | Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 24 | --- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 25 | libmultipath/config.c | 18 ++++++++++++++++++ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 26 | libmultipath/config.h | 1 + |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 27 | multipath/multipath.rules.in | 1 + |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 28 | multipathd/multipathd.8 | 2 ++ |
| 29 | multipathd/multipathd.service | 1 + |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 30 | 5 files changed, 23 insertions(+) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 31 | |
| 32 | diff --git a/libmultipath/config.c b/libmultipath/config.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 33 | index 5c5c0726..31894810 100644 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 34 | --- a/libmultipath/config.c |
| 35 | +++ b/libmultipath/config.c |
| 36 | @@ -26,6 +26,7 @@ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 37 | #include "mpath_cmd.h" |
| 38 | #include "propsel.h" |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 39 | #include "foreign.h" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 40 | +#include "version.h" |
| 41 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 42 | /* |
| 43 | * We don't support re-initialization after |
| 44 | @@ -966,6 +967,23 @@ int _init_config (const char *file, struct config *conf) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 45 | } |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 46 | factorize_hwtable(conf->hwtable, builtin_hwtable_size, file); |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 47 | validate_pctable(conf->overrides, 0, file); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 48 | + } else { |
| 49 | + condlog(0, "/etc/multipath.conf does not exist, blacklisting all devices."); |
| 50 | + if (conf->blist_devnode == NULL) { |
| 51 | + conf->blist_devnode = vector_alloc(); |
| 52 | + if (!conf->blist_devnode) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 53 | + conf->blist_devnode = vector_alloc(); |
| 54 | + if (!conf->blist_devnode) { |
| 55 | + condlog(0, "cannot allocate blacklist\n"); |
| 56 | + goto out; |
| 57 | + } |
| 58 | + } |
| 59 | + if (store_ble(conf->blist_devnode, strdup(".*"), |
| 60 | + ORIGIN_NO_CONFIG)) { |
| 61 | + condlog(0, "cannot store default no-config blacklist\n"); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 62 | + goto out; |
| 63 | + } |
| 64 | + } |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | conf->processed_main_config = 1; |
| 68 | diff --git a/libmultipath/config.h b/libmultipath/config.h |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 69 | index 87947469..0dc89c16 100644 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 70 | --- a/libmultipath/config.h |
| 71 | +++ b/libmultipath/config.h |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 72 | @@ -10,6 +10,7 @@ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 73 | |
| 74 | #define ORIGIN_DEFAULT 0 |
| 75 | #define ORIGIN_CONFIG 1 |
| 76 | +#define ORIGIN_NO_CONFIG 2 |
| 77 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 78 | enum devtypes { |
| 79 | DEV_NONE, |
| 80 | diff --git a/multipath/multipath.rules.in b/multipath/multipath.rules.in |
| 81 | index 8d3cf33a..5c4447a2 100644 |
| 82 | --- a/multipath/multipath.rules.in |
| 83 | +++ b/multipath/multipath.rules.in |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 84 | @@ -9,6 +9,7 @@ IMPORT{cmdline}="nompath" |
| 85 | ENV{nompath}=="?*", GOTO="end_mpath" |
| 86 | IMPORT{cmdline}="multipath" |
| 87 | ENV{multipath}=="off", GOTO="end_mpath" |
| 88 | +TEST!="/etc/multipath.conf", GOTO="end_mpath" |
| 89 | |
| 90 | ENV{DEVTYPE}!="partition", GOTO="test_dev" |
| 91 | IMPORT{parent}="DM_MULTIPATH_DEVICE_PATH" |
| 92 | diff --git a/multipathd/multipathd.8 b/multipathd/multipathd.8 |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 93 | index bdf102eb..a16a0bd5 100644 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 94 | --- a/multipathd/multipathd.8 |
| 95 | +++ b/multipathd/multipathd.8 |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 96 | @@ -48,6 +48,8 @@ map regains its maximum performance and redundancy. |
| 97 | With the \fB-k\fR option, \fBmultipathd\fR acts as a client utility that |
| 98 | sends commands to a running instance of the multipathd daemon (see |
| 99 | \fBCOMMANDS\fR below). |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 100 | + |
| 101 | +In this Linux distribution, multipathd does not run unless a /etc/multipath.conf file exists. |
| 102 | . |
| 103 | . |
| 104 | .\" ---------------------------------------------------------------------------- |
| 105 | diff --git a/multipathd/multipathd.service b/multipathd/multipathd.service |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 106 | index aec62dbb..ab7585de 100644 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 107 | --- a/multipathd/multipathd.service |
| 108 | +++ b/multipathd/multipathd.service |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 109 | @@ -5,6 +5,7 @@ Before=local-fs-pre.target blk-availability.service shutdown.target |
| 110 | Wants=systemd-udevd-kernel.socket |
| 111 | After=systemd-udevd-kernel.socket |
| 112 | After=multipathd.socket systemd-remount-fs.service |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 113 | +ConditionPathExists=/etc/multipath.conf |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 114 | Before=initrd-cleanup.service |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 115 | DefaultDependencies=no |
| 116 | Conflicts=shutdown.target |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 117 | -- |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 118 | 2.38.1 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 119 | |