Skip to contentSkip to conversation

Add "reconfigure all" multipath command

PATCH Superseded Benjamin Marzinski 2 participants 9 messages Nov 17, 2021 – Nov 18, 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 from v1 as suggested by Martin Wilck:

0001: update libmultipath.version to handle ABI change in struct config 0003: Clarify commit message

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.

 libmpathpersist/libmpathpersist.version | 12 ++--
 libmultipath/config.h                   |  1 -
 libmultipath/configure.c                |  2 +-
 libmultipath/libmultipath.version       | 22 +++---
 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 ++-
 11 files changed, 91 insertions(+), 67 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.

---
 libmpathpersist/libmpathpersist.version | 12 +++----
 libmultipath/config.h                   |  1 -
 libmultipath/libmultipath.version       | 22 +++++-------
 multipathd/main.c                       | 45 ++++++++++++++++---------
 4 files changed, 42 insertions(+), 38 deletions(-)
libmpathpersist/libmpathpersist.version +5 -7
index e0748138..b52b7500 100644
@@ -10,7 +10,7 @@
  *
  * See libmultipath.version for general policy about version numbers.
  */
-LIBMPATHPERSIST_1.0.0 {
+LIBMPATHPERSIST_2.0.0 {
 global:
 
 	__mpath_persistent_reserve_in;
@@ -28,11 +28,9 @@ global:
 	prout_do_scsi_ioctl;
 	update_map_pr;
 
-local: *;
-};
-
-LIBMPATHPERSIST_1.1.0 {
-global:
+	/* added int 1.1.0 */
 	libmpathpersist_init;
 	libmpathpersist_exit;
-} LIBMPATHPERSIST_1.0.0;
+
+local: *;
+};
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;
libmultipath/libmultipath.version +8 -14
index b2feee2a..6473091d 100644
@@ -31,7 +31,7 @@
  *   The new version inherits the previous ones.
  */
 
-LIBMULTIPATH_9.0.0 {
+LIBMULTIPATH_10.0.0 {
 global:
 	/* symbols referenced by multipath and multipathd */
 	add_foreign;
@@ -284,21 +284,15 @@ global:
 	/* added in 8.2.0 */
 	check_daemon;
 
-local:
-	*;
-};
-
-LIBMULTIPATH_9.1.0 {
-global:
+	/* added in 9.1.0 */
 	timespeccmp;
-} LIBMULTIPATH_9.0.0;
 
-LIBMULTIPATH_9.2.0 {
-global:
+	/* added in 9.2.0 */
 	set_wakeup_fn;
-} LIBMULTIPATH_9.1.0;
 
-LIBMULTIPATH_9.3.0 {
-global:
+	/* added in 9.3.0 */
 	__snprint_config;
-} LIBMULTIPATH_9.2.0;
+
+local:
+	*;
+};
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

schedule_reconfigure() now 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. Currently cli_reconfigure() and the HUP signal request full reconfigures, while the initial reconfigure, ev_add_map(), and missing_uev_wait_tick() request weak reconfigures. 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
author maintainer
#6 lore raw
Quoted 10 lines · Martin Wilck
Quoted 6 lines · Benjamin Marzinski

Changes from v1 as suggested by Martin Wilck:

0001: update libmultipath.version to handle ABI change in struct config
0003: Clarify commit message

Did you overlook the two other comments I had on 0003, or did you deliberately ignore them? Just asking.

Ooops. Missed them. I'll resend.

-Ben

Quoted 2 lines

Martin

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

author maintainer
#7 lore raw
In reply to Martin Wilck
Quoted 10 lines · Martin Wilck
Quoted 6 lines · Benjamin Marzinski

Changes from v1 as suggested by Martin Wilck:

0001: update libmultipath.version to handle ABI change in struct config
0003: Clarify commit message

Did you overlook the two other comments I had on 0003, or did you deliberately ignore them? Just asking.

Now that I look at this, I'd rather not change the reconfigure() and configure() argument names to reload_type. That's the name of the global variable which has serialization concerns, and reusing it as an argument seems like it would lead to more confusion.

Actually, since reload_type can only be changed when switching to the DAEMON_CONFIGURE state, and you can't switch to that state again until after do the reconfigure, it's safe to simply have configure() access the global variable, reload_type.

-Ben

Quoted 2 lines

Martin

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

#8 lore raw
Quoted 12 lines · Benjamin Marzinski
Quoted 10 lines · Martin Wilck
Quoted 6 lines · Benjamin Marzinski

Changes from v1 as suggested by Martin Wilck:

0001: update libmultipath.version to handle ABI change in struct config
0003: Clarify commit message

Did you overlook the two other comments I had on 0003, or did you deliberately ignore them? Just asking.

Quoted 6 lines

Now that I look at this, I'd rather not change the reconfigure() and configure() argument names to reload_type. That's the name of the global
variable which has serialization concerns, and reusing it as an argument
seems like it would lead to more confusion.

Right. My point was that "type" is too generic. I didn't think about the name clash.

Quoted 5 lines

Actually, since reload_type can only be changed when switching to the DAEMON_CONFIGURE state, and you can't switch to that state again until
after do the reconfigure, it's safe to simply have configure() access the global variable, reload_type.

I'm not a big fan of new global variables, but this should be fine.

Regards
Martin

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