Skip to contentSkip to conversation

Add "reconfigure all" multipath command

PATCH Superseded Benjamin Marzinski 1 participant 5 messages Oct 6, 2021 Device mapper

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Benjamin Marzinski

author maintainer
#0 lore raw

v2 cover Add "reconfigure all" multipath command

This patchset is supposed to replace Martin's

multipathd: add "force_reconfigure" option

patch from his uxlsnr overhaul patchset. It also makes the default reconfigure be a weak reconfigure, but instead of adding a configuration option to control this, it adds a new multipathd command, "reconfigure all", to do a full reconfigure. The HUP signal is left doing only weak reconfigures.

In order to keep from having two states that are handled nearly identically, the code adds an extra variable to track the type of configuration that was selected, but this could easily be switch to use a new DAEMON_CONFIGURE_ALL state instead.

The final patch, that added the new command, is meant to apply on top of Martin's changed client handler code. I can send one that works with the current client handler code, if people would rather review that.

Changes in v2:

4/4: Added text to the multipathd man page to explain the two types of
reconfigure.

Benjamin Marzinski (4):
multipathd: move delayed_reconfig out of struct config
multipathd: remove reconfigure from header file.
multipathd: pass in the type of reconfigure
multipathd: add "reconfigure all" command.

 libmultipath/config.h     |  1 -
 libmultipath/configure.c  |  2 +-
 multipath/main.c          |  2 +-
 multipathd/cli.c          |  1 +
 multipathd/cli.h          |  2 +
 multipathd/cli_handlers.c | 12 +++++-
 multipathd/main.c         | 91 +++++++++++++++++++++++----------------
 multipathd/main.h         |  3 +-
 multipathd/multipathd.8   | 10 ++++-
 9 files changed, 78 insertions(+), 46 deletions(-)
Signature · 6 lines
2.17.2

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
author maintainer
#1 lore raw

PATCH v2 1/4 multipathd: move delayed_reconfig out of struct config

delayed_reconfig was inside the config struct, but it wasn't updated during an RCU write section, so there's no synchronization on it. Instead, pull it out of the config structure, and use the config_lock to synchronize it.

---
 libmultipath/config.h |  1 -
 multipathd/main.c     | 45 ++++++++++++++++++++++++++++---------------
 2 files changed, 29 insertions(+), 17 deletions(-)
libmultipath/config.h +0 -1
index 933fe0d1..c73389b5 100644
@@ -178,7 +178,6 @@ struct config {
 	int strict_timing;
 	int retrigger_tries;
 	int retrigger_delay;
-	int delayed_reconfig;
 	int uev_wait_timeout;
 	int skip_kpartx;
 	int remove_retries;
multipathd/main.c +29 -16

99 lines not on this page · raw message

Signature · 6 lines
2.17.2

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
author maintainer
#2 lore raw

PATCH v2 2/4 multipathd: remove reconfigure from header file.

In reply to Benjamin Marzinski

Only multipathd/main.c uses it.

---
 multipathd/main.h | 1 -
 1 file changed, 1 deletion(-)
multipathd/main.h +0 -1
index 23ce919e..a1697a74 100644
@@ -39,7 +39,6 @@ enum daemon_status wait_for_state_change_if(enum daemon_status oldstate,
 					    unsigned long ms);
 void schedule_reconfigure(void);
 int need_to_delay_reconfig (struct vectors *);
-int reconfigure (struct vectors *);
 int ev_add_path (struct path *, struct vectors *, int);
 int ev_remove_path (struct path *, struct vectors *, int);
 int ev_add_map (char *, const char *, struct vectors *);
Signature · 6 lines
2.17.2

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
author maintainer
#3 lore raw

PATCH v2 3/4 multipathd: pass in the type of reconfigure

In reply to Benjamin Marzinski

This code doesn't actually change how multipathd reconfigures. It still does a weak reconfigure at the start, and full reconfigures later. But now schedule_reconfigure() takes the type of reconfigure to do, and that gets passed down to reconfigure(). If a full reconfigure has already been requested but not started, weak reconfigure requests will be upgraded. A future patch will enable users to control what kind of reconfigures happen.

---
 libmultipath/configure.c  |  2 +-
 multipathd/cli_handlers.c |  2 +-
 multipathd/main.c         | 62 ++++++++++++++++++++-------------------
 multipathd/main.h         |  2 +-
 4 files changed, 35 insertions(+), 33 deletions(-)
libmultipath/configure.c +1 -1
index 7edb355b..eb8ec1bd 100644
@@ -1098,7 +1098,7 @@ out:
  * 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.
+ * reloaded in DM if there's a difference. This is normally sufficient.
  */
 int coalesce_paths (struct vectors *vecs, vector mpvec, char *refwwid,
 		    int force_reload, enum mpath_cmds cmd)
multipathd/cli_handlers.c +1 -1
index f59db3ab..b12a4e7e 100644
@@ -1012,7 +1012,7 @@ cli_reconfigure(void * v, struct strbuf *reply, void * data)
 {
 	condlog(2, "reconfigure (operator)");
 
-	schedule_reconfigure();
+	schedule_reconfigure(true);
 	return 0;
 }
 
multipathd/main.c +32 -30

159 lines not on this page · raw message

multipathd/main.h +1 -1
index a1697a74..c8a1ce92 100644
@@ -37,7 +37,7 @@ void exit_daemon(void);
 const char * daemon_status(void);
 enum daemon_status wait_for_state_change_if(enum daemon_status oldstate,
 					    unsigned long ms);
-void schedule_reconfigure(void);
+void schedule_reconfigure(bool reconfig_all);
 int need_to_delay_reconfig (struct vectors *);
 int ev_add_path (struct path *, struct vectors *, int);
 int ev_remove_path (struct path *, struct vectors *, int);
Signature · 6 lines
2.17.2

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
author maintainer
#4 lore raw

PATCH v2 4/4 multipathd: add "reconfigure all" command.

In reply to Benjamin Marzinski

With this commit, multipathd no longer defaults to full reconfigures for the "reconfigure" command and the HUP signal. The default is a weak reconfigure. A new command, "reconfigure all", has been added to do a full reconfigure.

---
 multipath/main.c          |  2 +-
 multipathd/cli.c          |  1 +
 multipathd/cli.h          |  2 ++
 multipathd/cli_handlers.c | 10 ++++++++++
 multipathd/main.c         |  2 +-
 multipathd/multipathd.8   | 10 ++++++++--
 6 files changed, 23 insertions(+), 4 deletions(-)
multipath/main.c +1 -1
index 65ece830..7b9797ec 100644
@@ -759,7 +759,7 @@ int delegate_to_multipathd(enum mpath_cmds cmd,
 		return NOT_DELEGATED;
 
 	if (cmd == CMD_CREATE && conf->force_reload == FORCE_RELOAD_YES) {
-		p += snprintf(p, n, "reconfigure");
+		p += snprintf(p, n, "reconfigure all");
 	}
 	else if (cmd == CMD_FLUSH_ONE && dev && dev_type == DEV_DEVMAP) {
 		p += snprintf(p, n, "del map %s", dev);
multipathd/cli.c +1 -0
index 414f6608..d9308bdf 100644
@@ -212,6 +212,7 @@ load_keys (void)
 	r += add_key(keys, "local", LOCAL, 0);
 	r += add_key(keys, "setmarginal", SETMARGINAL, 0);
 	r += add_key(keys, "unsetmarginal", UNSETMARGINAL, 0);
+	r += add_key(keys, "all", ALL, 0);
 
 
 	if (r) {
multipathd/cli.h +2 -0
index fcb6af00..bba705e8 100644
@@ -47,6 +47,7 @@ enum {
 	__LOCAL,			/* 40 */
 	__SETMARGINAL,
 	__UNSETMARGINAL,
+	__ALL,
 };
 
 #define LIST		(1ULL << __LIST)
@@ -93,6 +94,7 @@ enum {
 #define LOCAL		(1ULL << __LOCAL)
 #define SETMARGINAL	(1ULL << __SETMARGINAL)
 #define UNSETMARGINAL	(1ULL << __UNSETMARGINAL)
+#define ALL		(1ULL << __ALL)
 
 #define INITIAL_REPLY_LEN	1200
 
multipathd/cli_handlers.c +10 -0
index b12a4e7e..58b9916c 100644
@@ -1012,6 +1012,15 @@ cli_reconfigure(void * v, struct strbuf *reply, void * data)
 {
 	condlog(2, "reconfigure (operator)");
 
+	schedule_reconfigure(false);
+	return 0;
+}
+
+int
+cli_reconfigure_all(void * v, struct strbuf *reply, void * data)
+{
+	condlog(2, "reconfigure all (operator)");
+
 	schedule_reconfigure(true);
 	return 0;
 }
@@ -1497,6 +1506,7 @@ void init_handler_callbacks(void)
 	set_handler_callback(DEL+MAPS, cli_del_maps);
 	set_handler_callback(SWITCH+MAP+GROUP, cli_switch_group);
 	set_unlocked_handler_callback(RECONFIGURE, cli_reconfigure);
+	set_unlocked_handler_callback(RECONFIGURE+ALL, cli_reconfigure_all);
 	set_handler_callback(SUSPEND+MAP, cli_suspend);
 	set_handler_callback(RESUME+MAP, cli_resume);
 	set_handler_callback(RESIZE+MAP, cli_resize);
multipathd/main.c +1 -1
index 5c831e8d..cc4a4a5d 100644
@@ -2817,7 +2817,7 @@ handle_signals(bool nonfatal)
 		return;
 	if (reconfig_sig) {
 		condlog(2, "reconfigure (signal)");
-		schedule_reconfigure(true);
+		schedule_reconfigure(false);
 	}
 	if (log_reset_sig) {
 		condlog(2, "reset log (signal)");
multipathd/multipathd.8 +8 -2
index 048a838d..e60d7f7f 100644
@@ -195,10 +195,16 @@ group index, starting with 1.
 .
 .TP
 .B reconfigure
-Reconfigures the multipaths. This should be triggered automatically after anyi
-hotplug event.
+Rereads the configuration, and reloads all changed multipath devices. This
+also happens at startup, when the service is reload, or when a SIGHUP is
+received.
 .
 .TP
+.B reconfigure all
+Rereads the configuration, and reloads all multipath devices regardless of
+whether or not they have changed. This also happens when \fImultipath -r\fR is
+run.
+.TP
 .B suspend map|multipath $map
 Sets map $map into suspend state.
 .
Signature · 6 lines
2.17.2

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel