From: Martin Wilck <mwilck@suse.com>
To: dm-devel@redhat.com
Cc: Martin Wilck <mwilck@suse.de>
Subject: [PATCH 18/33] multipathd: use weaker "force_reload" at startup
Date: Tue, 28 Feb 2017 17:23:14 +0100 [thread overview]
Message-ID: <20170228162329.14517-19-mwilck@suse.com> (raw)
In-Reply-To: <20170228162329.14517-1-mwilck@suse.com>
From: Martin Wilck <mwilck@suse.de>
"force_reload" has originally been created to support multipath -r
(admin triggered reload). multipathd also uses this parameter
in DAEMON_CONFIGURE state, too. But this is causes unnecessary
device-mapper ioctls when multipathd is first started, if existing
maps have been discovered (perhaps set up by previous instance of
multipathd, e.g. in the initrd).
This patch introduces a weaker form of the force_reload parameter
to coalesce_paths(). The parameter can now take three values:
* FORCE_RELOAD_NONE: existing maps aren't touched at all
* FORCE_RELOAD_YES: all maps are rebuilt from scratch and (re)loaded in DM
* FORCE_RELOAD_WEAK: existing maps are compared to the current conf and only
reloaded in DM if there's a difference. This is useful during startup.
Signed-off-by: Martin Wilck <mwilck@suse.com>
---
libmultipath/config.h | 6 ++++++
libmultipath/configure.c | 16 ++++++++++++----
multipath/main.c | 2 +-
multipathd/cli_handlers.c | 3 ++-
multipathd/main.c | 12 ++++++++++--
5 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/libmultipath/config.h b/libmultipath/config.h
index 9a90745b..16f8b1cc 100644
--- a/libmultipath/config.h
+++ b/libmultipath/config.h
@@ -36,6 +36,12 @@ enum mpath_cmds {
CMD_ADD_WWID,
};
+enum force_reload_types {
+ FORCE_RELOAD_NONE,
+ FORCE_RELOAD_YES,
+ FORCE_RELOAD_WEAK,
+};
+
struct hwentry {
char * vendor;
char * product;
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 5ad30074..f164801b 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -750,8 +750,15 @@ out:
return ret;
}
-int coalesce_paths(struct vectors *vecs, vector newmp, char *refwwid,
- int force_reload, enum mpath_cmds cmd)
+/*
+ * The force_reload parameter determines how coalesce_paths treats existing maps.
+ * FORCE_RELOAD_NONE: existing maps aren't touched at all
+ * FORCE_RELOAD_YES: all maps are rebuilt from scratch and (re)loaded in DM
+ * FORCE_RELOAD_WEAK: existing maps are compared to the current conf and only
+ * reloaded in DM if there's a difference. This is useful during startup.
+ */
+int coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid,
+ int force_reload, enum mpath_cmds cmd)
{
int r = 1;
int k, i;
@@ -769,7 +776,7 @@ int coalesce_paths(struct vectors *vecs, vector newmp, char *refwwid,
if (refwwid && !strlen(refwwid))
refwwid = NULL;
- if (force_reload) {
+ if (force_reload != FORCE_RELOAD_NONE) {
vector_foreach_slot (pathvec, pp1, k) {
pp1->mpp = NULL;
}
@@ -858,7 +865,8 @@ int coalesce_paths(struct vectors *vecs, vector newmp, char *refwwid,
if (cmd == CMD_DRY_RUN)
mpp->action = ACT_DRY_RUN;
if (mpp->action == ACT_UNDEF)
- select_action(mpp, curmp, force_reload);
+ select_action(mpp, curmp,
+ force_reload == FORCE_RELOAD_YES ? 1 : 0);
r = domap(mpp, params, is_daemon);
diff --git a/multipath/main.c b/multipath/main.c
index ed57135a..4174d43d 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -578,7 +578,7 @@ main (int argc, char *argv[])
}
break;
case 'r':
- conf->force_reload = 1;
+ conf->force_reload = FORCE_RELOAD_YES;
break;
case 'i':
conf->ignore_wwids = 1;
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index b20b0546..c59e7fdc 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -778,7 +778,8 @@ cli_add_map (void * v, char ** reply, int * len, void * data)
rc = get_refwwid(CMD_NONE, param, DEV_DEVMAP,
vecs->pathvec, &refwwid);
if (refwwid) {
- if (coalesce_paths(vecs, NULL, refwwid, 0, 1))
+ if (coalesce_paths(vecs, NULL, refwwid,
+ FORCE_RELOAD_NONE, 1))
condlog(2, "%s: coalesce_paths failed",
param);
dm_lib_release();
diff --git a/multipathd/main.c b/multipathd/main.c
index 8f464bfb..e2e73749 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -535,7 +535,8 @@ ev_add_map (char * dev, char * alias, struct vectors * vecs)
r = get_refwwid(CMD_NONE, dev, DEV_DEVMAP, vecs->pathvec, &refwwid);
if (refwwid) {
- r = coalesce_paths(vecs, NULL, refwwid, 0, CMD_NONE);
+ r = coalesce_paths(vecs, NULL, refwwid, FORCE_RELOAD_NONE,
+ CMD_NONE);
dm_lib_release();
}
@@ -2039,6 +2040,7 @@ configure (struct vectors * vecs, int start_waiters)
vector mpvec;
int i, ret;
struct config *conf;
+ static int force_reload = FORCE_RELOAD_WEAK;
if (!vecs->pathvec && !(vecs->pathvec = vector_alloc())) {
condlog(0, "couldn't allocate path vec in configure");
@@ -2082,8 +2084,14 @@ configure (struct vectors * vecs, int start_waiters)
/*
* create new set of maps & push changed ones into dm
+ * In the first call, use FORCE_RELOAD_WEAK to avoid making
+ * superfluous ACT_RELOAD ioctls. Later calls are done
+ * with FORCE_RELOAD_YES.
*/
- if (coalesce_paths(vecs, mpvec, NULL, 1, CMD_NONE)) {
+ ret = coalesce_paths(vecs, mpvec, NULL, force_reload, CMD_NONE);
+ if (force_reload == FORCE_RELOAD_WEAK)
+ force_reload = FORCE_RELOAD_YES;
+ if (ret) {
condlog(0, "configure failed while coalescing paths");
return 1;
}
--
2.11.0
next prev parent reply other threads:[~2017-02-28 16:23 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-28 16:22 [PATCH 00/33] multipath-tools fixes from SUSE Martin Wilck
2017-02-28 16:22 ` [PATCH 01/33] multipathd.service: fixup Wants= and Before= statements Martin Wilck
2017-03-13 23:06 ` Benjamin Marzinski
2017-03-14 7:36 ` Martin Wilck
2017-02-28 16:22 ` [PATCH 02/33] multipathd: start daemon after udev trigger Martin Wilck
2017-02-28 16:22 ` [PATCH 03/33] Add support for "multipath=off" and "nompath" on kernel cmdline Martin Wilck
2017-02-28 16:23 ` [PATCH 04/33] multipath: do not check daemon from udev rules Martin Wilck
2017-04-05 21:54 ` Benjamin Marzinski
2017-04-06 12:10 ` Martin Wilck
2017-02-28 16:23 ` [PATCH 05/33] Invalid error code when using multipathd CLI Martin Wilck
2017-02-28 16:23 ` [PATCH 06/33] multipathd: set timeout for CLI commands correctly Martin Wilck
2017-04-05 22:07 ` Benjamin Marzinski
2017-04-12 20:26 ` Martin Wilck
2017-04-13 13:11 ` [PATCH] Revert "multipathd: set timeout for CLI commands correctly" Martin Wilck
2017-02-28 16:23 ` [PATCH 07/33] libmultipath: fall back to search paths by devt Martin Wilck
2017-02-28 16:23 ` [PATCH 08/33] libmultipath: Do not crash on empty features Martin Wilck
2017-02-28 16:23 ` [PATCH 09/33] multipathd: Set CLI timeout correctly Martin Wilck
2017-02-28 16:23 ` [PATCH 10/33] multipath: avoid crash when using modified configuration Martin Wilck
2017-02-28 16:23 ` [PATCH 11/33] multipathd: issue systemd READY after initial configuration Martin Wilck
2017-02-28 16:23 ` [PATCH 12/33] libmultipath/discovery: do not cache 'access_state' sysfs attribute Martin Wilck
2017-02-28 16:23 ` [PATCH 13/33] libmultipath: use existing alias from bindings file Martin Wilck
2017-02-28 16:23 ` [PATCH 14/33] multipath -ll: set DI_SERIAL Martin Wilck
2017-02-28 16:23 ` [PATCH 15/33] libmultipath: move suspend logic to _dm_flush_map Martin Wilck
2017-04-05 22:44 ` Benjamin Marzinski
2017-04-12 20:54 ` Martin Wilck
2017-04-13 13:05 ` [PATCH] libmultipath: fix skip_kpartx support for removing maps Martin Wilck
2017-04-14 8:42 ` Christophe Varoqui
2017-02-28 16:23 ` [PATCH 16/33] multipath: ignore -i if find_multipaths is set Martin Wilck
2017-02-28 16:23 ` [PATCH 17/33] multipathd: imply -n " Martin Wilck
2017-04-05 23:03 ` Benjamin Marzinski
2017-04-12 21:36 ` Martin Wilck
2017-04-13 21:54 ` Benjamin Marzinski
2017-02-28 16:23 ` Martin Wilck [this message]
2017-02-28 16:23 ` [PATCH 19/33] libmultipath: setup_features: log msg if queue_if_no_path is ignored Martin Wilck
2017-02-28 16:23 ` [PATCH 20/33] libmultipath: setup_feature: print log msg if no_path_retry cant be set Martin Wilck
2017-02-28 16:23 ` [PATCH 21/33] libmultipath: setup_feature: handle "retain_attached_hw_handler" Martin Wilck
2017-02-28 16:23 ` [PATCH 22/33] libmultipath: disassemble_map: skip no_path_retry check Martin Wilck
2017-02-28 16:23 ` [PATCH 23/33] libmultipath: disassemble_map: treat minio like assemble_map does Martin Wilck
2017-02-28 16:23 ` [PATCH 24/33] libmultipath: select_action: check special features separately Martin Wilck
2017-02-28 16:23 ` [PATCH 25/33] libmultipath: sysfs_attr_set_value: use const char* Martin Wilck
2017-02-28 16:23 ` [PATCH 26/33] libmultipath: reload map if not known to udev Martin Wilck
2017-02-28 16:23 ` [PATCH 27/33] libmultipath: differentiate ACT_NOTHING and ACT_IMPOSSIBLE Martin Wilck
2017-02-28 16:23 ` [PATCH 28/33] libmultipath: coalesce_paths: trigger uevent if nothing done Martin Wilck
2017-02-28 16:23 ` [PATCH 29/33] kpartx: sanitize delete partitions Martin Wilck
2017-02-28 16:23 ` [PATCH 30/33] tur: Add pthread_testcancel() Martin Wilck
2017-02-28 16:23 ` [PATCH 31/33] multipathd: fixup check for new path states Martin Wilck
2017-02-28 16:23 ` [PATCH 32/33] libmultipath/checkers: make RADOS checker optional Martin Wilck
2017-02-28 16:23 ` [PATCH 33/33] Make libdmmp build optional Martin Wilck
2017-02-28 22:44 ` [PATCH 00/33] multipath-tools fixes from SUSE Xose Vazquez Perez
2017-03-01 8:12 ` Martin Wilck
2017-03-23 18:43 ` multipath-tools (patch): Do not select sysfs prioritizer for RDAC arrays (was Re: [PATCH 00/33] multipath-tools fixes from SUSE) Xose Vazquez Perez
2017-03-23 20:40 ` Stewart, Sean
2017-03-22 19:02 ` [PATCH 00/33] multipath-tools fixes from SUSE Xose Vazquez Perez
2017-03-22 21:29 ` Christophe Varoqui
2017-03-23 8:30 ` Christophe Varoqui
2017-03-24 7:44 ` Martin Wilck
2017-04-12 7:38 ` Christophe Varoqui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170228162329.14517-19-mwilck@suse.com \
--to=mwilck@suse.com \
--cc=dm-devel@redhat.com \
--cc=mwilck@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox