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