Skip to contentSkip to conversation

dlm_controld config settings can be

RFC PATCH New Heming Zhao 2 participants 17 messages Sep 19, 2021 – Sep 22, 2021

lore
Share & tools
lore
#0 lore raw

cover dlm_controld config settings can be

This new feature gives dlm ability to change config settings dynamically. It's very useful for debugging, and also useful for adjusting HA behaviours while running. This feature gives more power function to advanced users. And HA Resource-Agent (RA) could also benefit from this feature.

The new man page dlm_tool.8 show some example of this feature.

For easy managing command running list, there is a patch to add "-A" on "dlm run_(check|cancel)". We can get rid of the boring uuid input when checking lots of running commands result/status.

Heming Zhao (10):
dlm_tool man: add command "joinleave", add "USAGE" section
dlm_tool: add run_(check|cancel) all feature
dlm_tool man: add dynamic setting and examples
dlm_controld: put MAX_LINE in header file
dlm_controld: add dynamic setting items in "struct dlm_option"
dlm_controld: change dlm_options[] to shared memory type
dlm_controld: make few APIs public
dlm_controld: support "dlm_tool dump_config" to show dynamic setting
dlm_controld: add new API set_opt_online()
dlm_controld: enable "dlm_tool run|run_start" dynamic setting feature

 dlm_controld/action.c      |   5 ++
 dlm_controld/config.c      | 132 +++++++++++++++++++++++++++++++++--
 dlm_controld/dlm_daemon.h  |  15 +++-
 dlm_controld/helper.c      |  41 ++++++++---
 dlm_controld/logging.c     |  18 +++--
 dlm_controld/main.c        |  86 ++++++++++++++---------
 dlm_controld/node_config.c |   2 -
 dlm_tool/dlm_tool.8        | 139 +++++++++++++++++++++++++++++++++++++
 dlm_tool/main.c            |  80 +++++++++++++++------
 9 files changed, 442 insertions(+), 76 deletions(-)
Signature · 1 line
2.32.0
#1 lore raw

PATCH 1/10 dlm_tool man: add command "joinleave", add "USAGE" section

---
 dlm_tool/dlm_tool.8 | 79 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)
dlm_tool/dlm_tool.8 +79 -0
index bbc11c261b7e..056c4af0213c 100644
@@ -48,6 +48,10 @@ dlm_tool \- a utility for the dlm and dlm_controld daemon
 .br
 	Leave a lockspace.
 
+.BI joinleave " name"
+.br
+	Do two actions: first Join then Leave a lockspace.
+
 .BI lockdebug " name"
 .br
 	Complete display of locks from the lockspace.
@@ -112,6 +116,81 @@ Print help, then exit
 .B \-V
 Print program version information, then exit
 
+.SH USAGE
+
+dlm_tool ls [-n] [ls_name]
+
+-
+
+dlm_tool status [-v]
+
+-
+
+dlm_tool dump
+
+-
+
+dlm_tool dump_config
+
+-
+
+dlm_tool fence_ack \fIls-name\fP
+
+-
+
+dlm_tool log_plock
+
+-
+
+dlm_tool plocks \fIls-name\fP
+
+-
+
+dlm_tool join [-e 0|1] [-f 0|1] \fIls-name\fP
+
+-
+
+dlm_tool leave \fIls-name\fP
+
+-
+
+dlm_tool joinleave [-e 0|1] [-f 0|1] \fIls-name\fP
+
+-
+
+dlm_tool lockdebug [-s] [-v] [-w] \fIls-name\fP
+
+-
+
+dlm_tool lockdump [-M] \fIls-name\fP
+
+-
+
+dlm_tool run|run_start [-n] \fIcommand\fP
+
+* current run & run_start support \fIcommand\fP:
+.RS 4
+"lvm lvchange --refresh"
+.br
+"lvm lvs"
+.RE
+
+-
+
+dlm_tool run_check|run_cancel [-i "sec"] \fIuuid\fP
+
+-
+
+dlm_tool run_list
+
+-
+
+dlm_tool -h
+
+-
+
+dlm_tool -V
+
 .SH SEE ALSO
 .BR dlm_controld (8),
 .BR dlm.conf (5)
Signature · 1 line
2.32.0
#2 lore raw

PATCH 2/10 dlm_tool: add run_(check|cancel) all feature

In reply to Heming Zhao

Current run_check and run_cancel require uuid for executing. If users want to check/cancel all commands, they must input every command uuid, which is a boring action.
This commit add a new option "-A", which makes one time travel all the command without uuid.

---
 dlm_tool/dlm_tool.8 |  5 ++-
 dlm_tool/main.c     | 80 ++++++++++++++++++++++++++++++++-------------
 2 files changed, 62 insertions(+), 23 deletions(-)
dlm_tool/dlm_tool.8 +4 -1
index 056c4af0213c..086596c67dbf 100644
@@ -110,6 +110,9 @@ Wide lockdebug output
 .B \-M
 Include MSTCPY locks in lockdump output
 
+.B \-A
+Include all uuid in run_check and run_cancel
+
 .B \-h
 Print help, then exit
 
@@ -177,7 +180,7 @@ dlm_tool run|run_start [-n] \fIcommand\fP
 
 -
 
-dlm_tool run_check|run_cancel [-i "sec"] \fIuuid\fP
+dlm_tool run_check|run_cancel [-A] [-i "sec"] \fIuuid\fP
 
 -
 
dlm_tool/main.c +58 -22

122 lines not on this page · raw message

Signature · 1 line
2.32.0
#3 lore raw

PATCH 3/10 dlm_tool man: add dynamic setting and examples

In reply to Heming Zhao
---
 dlm_tool/dlm_tool.8 | 57 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)
dlm_tool/dlm_tool.8 +57 -0
index 086596c67dbf..cdfe948815bf 100644
@@ -176,6 +176,8 @@ dlm_tool run|run_start [-n] \fIcommand\fP
 "lvm lvchange --refresh"
 .br
 "lvm lvs"
+.br
+"opt dlm_controld-config-item=x"  (see below \fBEXAMPLES\fP section)
 .RE
 
 -
@@ -194,6 +196,61 @@ dlm_tool -h
 
 dlm_tool -V
 
+.SH EXAMPLES
+
+command \fIdlm_tool run "opt xxx"\fP can do the dynamic config job. It makes possible to debug, or to do flexible operations on the fly.
+
+If the line of "dlm_tool dump_config" output leading with "(*)", the START symbol, it means this item supports dynamic config. i.e.
+
+.RS 4
+.EX
+# dlm_tool dump_config | grep log_debug
+(*-) log_debug=1
+.EE
+
+The "log_debug" supports dynamic setting.
+.br
+The '-' (minus) means dynamic config doesn't take effect on this item.
+.br
+If "(*-)" becomes "(*+)", it means this item is dynamically changed on the fly.
+.RE
+
+
+Below show options: restore, restore_all
+
+.RS 4
+.EX
+# dlm_tool dump_config | grep log_debug
+(*-) log_debug=1
+# dlm_tool run "opt log_debug=0"
+# dlm_tool dump_config | grep log_debug
+(*+) log_debug=0
+
+# dlm_tool run "opt log_debug=1"
+# dlm_tool dump_config | grep log_debug
+(*+) log_debug=1
+
+# dlm_tool run "opt log_debug=restore"
+# dlm_tool dump_config | grep log_debug
+(*-) log_debug=1
+
+# dlm_tool dump_config | grep _debug
+(*-) daemon_debug=0
+(*-) log_debug=1
+(*-) plock_debug=0
+# dlm_tool run "opt daemon_debug=1 log_debug=0"
+# dlm_tool dump_config | grep _debug
+(*+) daemon_debug=1
+(*+) log_debug=0
+(*-) plock_debug=0
+# dlm_tool run "opt restore_all"
+# dlm_tool dump_config | grep _debug
+(*-) daemon_debug=0
+(*-) log_debug=1
+(*-) plock_debug=0
+.EE
+.RE
+
 .SH SEE ALSO
 .BR dlm_controld (8),
 .BR dlm.conf (5)
Signature · 1 line
2.32.0
#4 lore raw

PATCH 4/10 dlm_controld: put MAX_LINE in header file

In reply to Heming Zhao
---
 dlm_controld/config.c      | 4 ----
 dlm_controld/dlm_daemon.h  | 3 +++
 dlm_controld/node_config.c | 2 --
 3 files changed, 3 insertions(+), 6 deletions(-)
dlm_controld/config.c +0 -4
index 947480dabe85..d77f3826bfe6 100644
@@ -21,10 +21,6 @@ master node=2 weight=1
 
 #endif
 
-/* The max line length in dlm.conf */
-
-#define MAX_LINE 256
-
 int get_weight(struct lockspace *ls, int nodeid)
 {
 	int i;
dlm_controld/dlm_daemon.h +3 -0
index 436fc9109aa6..eae17a28c749 100644
@@ -220,6 +220,9 @@ void log_level(char *name_in, uint32_t level_in, const char *fmt, ...);
 #define log_dlock(ls, fmt, args...) log_level((ls)->name, LOG_PLOCK|LOG_DEBUG, fmt, ##args)
 #define log_elock(ls, fmt, args...) log_level((ls)->name, LOG_PLOCK|LOG_ERR, fmt, ##args)
 
+/* The max line length in dlm.conf */
+#define MAX_LINE 256
+
 /* dlm_header types */
 enum {
 	DLM_MSG_PROTOCOL = 1,
dlm_controld/node_config.c +0 -2
index fe794be72f22..0889451848b9 100644
@@ -8,8 +8,6 @@
 
 #include "dlm_daemon.h"
 
-#define MAX_LINE 4096
-
 static struct node_config nc[MAX_NODES];
 
 static const struct node_config nc_default = {
Signature · 1 line
2.32.0
#5 lore raw

PATCH 5/10 dlm_controld: add dynamic setting items in "struct dlm_option"

In reply to Heming Zhao
---
 dlm_controld/dlm_daemon.h | 6 ++++++
 1 file changed, 6 insertions(+)
dlm_controld/dlm_daemon.h +6 -0
index eae17a28c749..76f5f4d082a5 100644
@@ -132,6 +132,7 @@ struct dlm_option {
 	const char *name;
 	char letter;
 	int req_arg;
+	int dynamic;
 	const char *desc;
 
 	int use_int;
@@ -151,6 +152,11 @@ struct dlm_option {
 	int file_int;
 	char *file_str;
 	unsigned int file_uint;
+
+	int dynamic_set;
+	int dynamic_int;
+	char *dynamic_str;
+	unsigned int dynamic_uint;
 };
 
 EXTERN struct dlm_option dlm_options[dlm_options_max];
Signature · 1 line
2.32.0
#6 lore raw

PATCH 6/10 dlm_controld: change dlm_options[] to shared memory type

In reply to Heming Zhao

This commit makes dlm_options[] could be modified after fork(). The patch is foundation to dynamic setting feature.

---
 dlm_controld/dlm_daemon.h |  2 +-
 dlm_controld/main.c       | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)
dlm_controld/dlm_daemon.h +1 -1
index 76f5f4d082a5..e20e98e78707 100644
@@ -159,7 +159,7 @@ struct dlm_option {
 	unsigned int dynamic_uint;
 };
 
-EXTERN struct dlm_option dlm_options[dlm_options_max];
+EXTERN struct dlm_option *dlm_options;
 #define opt(x) dlm_options[x].use_int
 #define opts(x) dlm_options[x].use_str
 #define optu(x) dlm_options[x].use_uint
dlm_controld/main.c +12 -1
index 504cafa12ec6..2a4f33b1b455 100644
@@ -14,6 +14,7 @@
 #include <linux/genetlink.h>
 #include <linux/dlm_netlink.h>
 #include <uuid/uuid.h>
+#include <sys/mman.h>
 
 #ifdef USE_SD_NOTIFY
 #include <systemd/sd-daemon.h>
@@ -2104,11 +2105,21 @@ int main(int argc, char **argv)
 	struct sigaction act;
 	int fd, rv;
 
+	/* share the cfg memory for helper process */
+	dlm_options = mmap(NULL, sizeof(struct dlm_option)*dlm_options_max,
+						PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANON, -1, 0);
+	if (dlm_options == MAP_FAILED) {
+		perror("mmap failed");
+		return 1;
+	}
+
 	/*
-	 * config priority: cli, config file, default
+	 * config priority: dynamic, cli, config file, default
 	 * - explicit cli setting will override default,
 	 * - explicit file setting will override default
 	 * - explicit file setting will not override explicit cli setting
+	 * - explicit dynamic setting will override using value,
+	 *   "dlm_tool dump_config" will show which option is using dynamic setting.
 	 */
 
 	set_opt_defaults();
Signature · 1 line
2.32.0
#7 lore raw

PATCH 7/10 dlm_controld: make few APIs public

In reply to Heming Zhao

This commit makes possible for helper process accessing config info

---
 dlm_controld/action.c     |  5 +++++
 dlm_controld/dlm_daemon.h |  3 +++
 dlm_controld/logging.c    | 18 +++++++++++++-----
 dlm_controld/main.c       |  2 +-
 4 files changed, 22 insertions(+), 6 deletions(-)
dlm_controld/action.c +5 -0
index 0eff27997e1c..baddaf81cb4f 100644
@@ -766,6 +766,11 @@ static int set_configfs_cluster(const char *name, char *str, int num)
 	return 0;
 }
 
+int set_configfs_opt(const char *name, char *str, int num)
+{
+	return set_configfs_cluster(name, str, num);
+}
+
 #define NET_RMEM_DEFAULT 4194304
 #define NET_RMEM_MAX 4194304
 
dlm_controld/dlm_daemon.h +3 -0
index e20e98e78707..904bb0b50df9 100644
@@ -392,6 +392,7 @@ int setup_configfs_members(void);
 int check_uncontrolled_lockspaces(void);
 int setup_misc_devices(void);
 int path_exists(const char *path);
+int set_configfs_opt(const char *name, char *str, int num);
 
 /* config.c */
 void set_opt_file(int update);
@@ -480,6 +481,7 @@ struct lockspace *find_ls_id(uint32_t id);
 const char *dlm_mode_str(int mode);
 void cluster_dead(int ci);
 struct dlm_option *get_dlm_option(char *name);
+int get_ind_name(char *s);
 struct run *find_run(char *uuid_str);
 void clear_run(struct run *run);
 void send_helper_run_request(struct run_request *req);
@@ -531,6 +533,7 @@ void init_logging(void);
 void close_logging(void);
 void copy_log_dump(char *buf, int *len);
 void copy_log_dump_plock(char *buf, int *len);
+void set_logfile_priority(void);
 
 /* crc.c */
 uint32_t cpgname_to_crc(const char *data, int len);
dlm_controld/logging.c +13 -5
index d48b8aebc237..2c57138ce766 100644
@@ -14,6 +14,18 @@ static int logfile_priority;
 static char logfile[PATH_MAX];
 static FILE *logfile_fp;
 
+/* logfile_priority is the only one of these options that
+   can be controlled from command line, environment variable
+   and dynamic setting.
+ */
+void set_logfile_priority(void)
+{
+	if (opt(debug_logfile_ind))
+		logfile_priority = LOG_DEBUG;
+	else
+		logfile_priority = DEFAULT_LOGFILE_PRIORITY;
+}
+
 void init_logging(void)
 {
 	mode_t old_umask;
@@ -24,11 +36,7 @@ void init_logging(void)
 	logfile_priority = DEFAULT_LOGFILE_PRIORITY;
 	strcpy(logfile, DEFAULT_LOGFILE);
 
-	/* logfile_priority is the only one of these options that
-	   can be controlled from command line or environment variable */
-
-	if (opt(debug_logfile_ind))
-		logfile_priority = LOG_DEBUG;
+	set_logfile_priority();
 
 	if (logfile[0]) {
 		old_umask = umask(0077);
dlm_controld/main.c +1 -1
index 2a4f33b1b455..91187f2d2402 100644
@@ -1902,7 +1902,7 @@ static void set_opt_defaults(void)
 			"Print program version information, then exit");
 }
 
-static int get_ind_name(char *s)
+int get_ind_name(char *s)
 {
 	char name[PATH_MAX];
 	char *p = s;
Signature · 1 line
2.32.0
#8 lore raw

PATCH 8/10 dlm_controld: support "dlm_tool dump_config" to show dynamic setting

In reply to Heming Zhao
---
 dlm_controld/main.c | 70 +++++++++++++++++++++++++--------------------
 1 file changed, 39 insertions(+), 31 deletions(-)
dlm_controld/main.c +39 -31
index 91187f2d2402..c4ee3540f508 100644
@@ -920,17 +920,24 @@ static void copy_options(char *buf, int *len)
 {
 	struct dlm_option *o;
 	char tmp[256];
-	int i, ret, pos = 0;
+	int i, ret, pos = 0, p=5;
 
 	for (i = 0; i < dlm_options_max; i++) {
 		o = &dlm_options[i];
 
 		memset(tmp, 0, sizeof(tmp));
 
+		if (o->dynamic)
+			snprintf(tmp, p+1, "(%c%c) ", '*', o->dynamic_set ? '+' : '-');
+		else
+			memset(tmp, ' ', p);
+
 		if (o->req_arg == req_arg_str)
-			snprintf(tmp, 255, "%s=%s\n", o->name, o->use_str);
+			snprintf(tmp+p, 250, "%s=%s\n", o->name, o->use_str);
+		else if (o->req_arg == req_arg_uint)
+			snprintf(tmp+p, 250, "%s=%u\n", o->name, o->use_uint);
 		else
-			snprintf(tmp, 255, "%s=%d\n", o->name, o->use_int);
+			snprintf(tmp+p, 250, "%s=%d\n", o->name, o->use_int);
 
 		if (pos + strlen(tmp) >= LOG_DUMP_SIZE)
 			break;
@@ -1750,12 +1757,13 @@ static void print_usage(void)
 
 static void set_opt_default(int ind, const char *name, char letter, int arg_type,
 			    int default_int, const char *default_str,
-			    unsigned int default_uint, const char *desc)
+			    unsigned int default_uint, int dynamic, const char *desc)
 {
 	dlm_options[ind].name = name;
 	dlm_options[ind].letter = letter;
 	dlm_options[ind].req_arg = arg_type;
 	dlm_options[ind].desc = desc;
+	dlm_options[ind].dynamic = dynamic;
 	dlm_options[ind].default_int = default_int;
 	dlm_options[ind].default_str = default_str;
 	dlm_options[ind].default_uint = default_uint;
@@ -1768,137 +1776,137 @@ static void set_opt_defaults(void)
 {
 	set_opt_default(daemon_debug_ind,
 			"daemon_debug", 'D', no_arg,
-			0, NULL, 0,
+			0, NULL, 0, 1,
 			"enable debugging to stderr and don't fork");
 
 	set_opt_default(foreground_ind,
 			"foreground", '\0', no_arg,
-			0, NULL, 0,
+			0, NULL, 0, 0,
 			"don't fork");
 
 	set_opt_default(log_debug_ind,
 			"log_debug", 'K', no_arg,
-			0, NULL, 0,
+			0, NULL, 0, 1,
 			"enable kernel dlm debugging messages");
 
 	set_opt_default(timewarn_ind,
 			"timewarn", '\0', req_arg_int,
-			0, NULL, 0,
+			0, NULL, 0, 0,
 			""); /* do not advertise */
 
 	set_opt_default(protocol_ind,
 			"protocol", 'r', req_arg_str,
-			-1, "detect", 0,
+			-1, "detect", 0, 0,
 			"dlm kernel lowcomms protocol: tcp, sctp, detect");
 
 	set_opt_default(port_ind,
 			"port", 'R', req_arg_uint,
-			-1, NULL, 21064,
+			-1, NULL, 21064, 0,
 			"dlm kernel lowcomms protocol port");
 
 	set_opt_default(bind_all_ind,
 			"bind_all", '\0', req_arg_int,
-			0, NULL, 0,
+			0, NULL, 0, 0,
 			""); /* do not advertise */
 
 	set_opt_default(mark_ind,
 			"mark", '\0', req_arg_uint,
-			0, NULL, 0,
+			0, NULL, 0, 0,
 			"set mark value for DLM if not explicit by nodeid specified");
 
 	set_opt_default(debug_logfile_ind,
 			"debug_logfile", 'L', no_arg,
-			0, NULL, 0,
+			0, NULL, 0, 1,
 			"write debugging to log file");
 
 	set_opt_default(enable_fscontrol_ind,
 			"enable_fscontrol", '\0', req_arg_bool,
-			0, NULL, 0,
+			0, NULL, 0, 0,
 			""); /* do not advertise */
 
 	set_opt_default(enable_plock_ind,
 			"enable_plock", 'p', req_arg_bool,
-			1, NULL, 0,
+			1, NULL, 0, 0,
 			"enable/disable posix lock support for cluster fs");
 
 	set_opt_default(plock_debug_ind,
 			"plock_debug", 'P', no_arg,
-			0, NULL, 0,
+			0, NULL, 0, 1,
 			"enable plock debugging");
 
 	set_opt_default(plock_rate_limit_ind,
 			"plock_rate_limit", 'l', req_arg_int,
-			0, NULL, 0,
+			0, NULL, 0, 1,
 			"limit rate of plock operations (0 for none)");
 
 	set_opt_default(plock_ownership_ind,
 			"plock_ownership", 'o', req_arg_bool,
-			0, NULL, 0,
+			0, NULL, 0, 0,
 			"enable/disable plock ownership");
 
 	set_opt_default(drop_resources_time_ind,
 			"drop_resources_time", 't', req_arg_int,
-			10000, NULL, 0,
+			10000, NULL, 0, 1,
 			"plock ownership drop resources time (milliseconds)");
 
 	set_opt_default(drop_resources_count_ind,
 			"drop_resources_count", 'c', req_arg_int,
-			10, NULL, 0,
+			10, NULL, 0, 1,
 			"plock ownership drop resources count");
 
 	set_opt_default(drop_resources_age_ind,
 			"drop_resources_age", 'a', req_arg_int,
-			10000, NULL, 0,
+			10000, NULL, 0, 1,
 			"plock ownership drop resources age (milliseconds)");
 
 	set_opt_default(post_join_delay_ind,
 			"post_join_delay", 'j', req_arg_int,
-			30, NULL, 0,
+			30, NULL, 0, 1,
 			"seconds to delay fencing after cluster join");
 
 	set_opt_default(enable_fencing_ind,
 			"enable_fencing", 'f', req_arg_bool,
-			1, NULL, 0,
+			1, NULL, 0, 0,
 			"enable/disable fencing");
 
 	set_opt_default(enable_concurrent_fencing_ind,
 			"enable_concurrent_fencing", '\0', req_arg_bool,
-			0, NULL, 0,
+			0, NULL, 0, 0,
 			"enable/disable concurrent fencing");
 
 	set_opt_default(enable_startup_fencing_ind,
 			"enable_startup_fencing", 's', req_arg_bool,
-			1, NULL, 0,
+			1, NULL, 0, 0,
 			"enable/disable startup fencing");
 
 	set_opt_default(repeat_failed_fencing_ind,
 			"repeat_failed_fencing", '\0', req_arg_bool,
-			1, NULL, 0,
+			1, NULL, 0, 1,
 			"enable/disable retrying after fencing fails");
 
 	set_opt_default(enable_quorum_fencing_ind,
 			"enable_quorum_fencing", 'q', req_arg_bool,
-			1, NULL, 0,
+			1, NULL, 0, 1,
 			"enable/disable quorum requirement for fencing");
 
 	set_opt_default(enable_quorum_lockspace_ind,
 			"enable_quorum_lockspace", '\0', req_arg_bool,
-			1, NULL, 0,
+			1, NULL, 0, 1,
 			"enable/disable quorum requirement for lockspace operations");
 
 	set_opt_default(enable_helper_ind,
 			"enable_helper", '\0', req_arg_bool,
-			1, NULL, 0,
+			1, NULL, 0, 0,
 			"enable/disable helper process for running commands");
 
 	set_opt_default(help_ind,
 			"help", 'h', no_arg,
-			-1, NULL, 0,
+			-1, NULL, 0, 0,
 			"print this help, then exit");
 
 	set_opt_default(version_ind,
 			"version", 'V', no_arg,
-			-1, NULL, 0,
+			-1, NULL, 0, 0,
 			"Print program version information, then exit");
 }
 
Signature · 1 line
2.32.0
#9 lore raw

PATCH 9/10 dlm_controld: add new API set_opt_online()

In reply to Heming Zhao

This API has ability to change dlm_controld settings on the fly.

---
 dlm_controld/config.c     | 128 ++++++++++++++++++++++++++++++++++++++
 dlm_controld/dlm_daemon.h |   1 +
 2 files changed, 129 insertions(+)
dlm_controld/config.c +126 -0
index d77f3826bfe6..9e799c8c04d2 100644
@@ -292,3 +292,129 @@ void set_opt_file(int update)
 	fclose(file);
 }
 
+static void reset_opt_value(struct dlm_option *o)
+{
+	/* config priority: cli, config file, default */
+
+	if (o->cli_set) {
+		o->use_int = o->cli_int;
+		o->use_uint = o->cli_uint;
+		o->use_str = o->cli_str;
+		return;
+	}
+
+	if (o->file_set) {
+		o->use_int = o->file_int;
+		o->use_uint = o->file_uint;
+		o->use_str = o->file_str;
+		return;
+	}
+
+	o->use_int = o->default_int;
+	o->use_uint = o->default_uint;
+	o->use_str = (char *)o->default_str;
+
+	return;
+}
+
+/*
+ * do the clean/restore job:
+ * - clean up dlm_options[].dynamic_xx
+ * - using high priority config to set use_xx items.
+ */
+static void reset_dynamic(struct dlm_option *o)
+{
+	o->dynamic_set = 0;
+	o->dynamic_int = 0;
+	if (o->dynamic_str){
+		free(o->dynamic_str);
+		o->dynamic_str = NULL;
+	}
+	o->dynamic_uint = 0;
+	reset_opt_value(o);
+
+	set_configfs_opt("log_debug", NULL, opt(log_debug_ind));
+	set_logfile_priority();
+
+	return;
+}
+
+void set_opt_online(int argc, char **argv)
+{
+	int i = -1, val = 0, ind;
+	unsigned int uval = 0;
+	struct dlm_option *o;
+	char str[MAX_LINE];
+
+	if (!strcmp(argv[0], "restore_all")) {
+		for (i = 0; i < dlm_options_max; i++)
+			reset_dynamic(&dlm_options[i]);
+
+		return;
+	}
+
+	while (++i < argc) {
+		ind = get_ind_name(argv[i]);
+		if (ind < 0)
+			continue;
+		o = &dlm_options[ind];
+		if (!o || !o->dynamic)
+			continue;
+
+		get_val_str(argv[i], str);
+		if (!strcmp(str, "restore")) {
+			reset_dynamic(o);
+			continue;
+		}
+
+		o->dynamic_set++;
+
+		if (!o->req_arg || o->req_arg == req_arg_int) {
+			get_val_int(argv[i], &val);
+			if (!o->req_arg)
+				val = val ? 1 : 0;
+
+			o->dynamic_int = val;
+
+			log_debug("config dynamic %s = %d previous use %d",
+				  o->name, o->dynamic_int, o->use_int);
+			o->use_int = o->dynamic_int;
+
+		} else if (o->req_arg == req_arg_uint) {
+			get_val_uint(argv[i], &uval);
+			o->dynamic_uint = uval;
+
+			log_debug("config dynamic %s = %u previous use %u",
+				  o->name, o->dynamic_uint, o->use_uint);
+			o->use_uint = o->dynamic_uint;
+
+		} else if (o->req_arg == req_arg_bool) {
+			get_val_int(argv[i], &val);
+			o->dynamic_int = val ? 1 : 0;
+
+			log_debug("config dynamic %s = %d previous use %d",
+				  o->name, o->dynamic_int, o->use_int);
+			o->use_int = o->dynamic_int;
+
+		} else if (o->req_arg == req_arg_str) {
+			memset(str, 0, sizeof(str));
+			get_val_str(argv[i], str);
+
+			o->dynamic_str = strdup(str);
+
+			log_debug("config dynamic %s = %s previous use %s",
+				  o->name, o->dynamic_str, o->use_str);
+			o->use_str = o->dynamic_str;
+		}
+
+		if (ind == log_debug_ind) {
+			set_configfs_opt("log_debug", NULL, opt(log_debug_ind));
+		} else if (ind == debug_logfile_ind) {
+			set_logfile_priority();
+		}
+
+	}
+
+	return;
+}
+
dlm_controld/dlm_daemon.h +1 -0
index 904bb0b50df9..8cc9f666872e 100644
@@ -398,6 +398,7 @@ int set_configfs_opt(const char *name, char *str, int num);
 void set_opt_file(int update);
 int get_weight(struct lockspace *ls, int nodeid);
 void setup_lockspace_config(struct lockspace *ls);
+void set_opt_online(int argc, char **argv);
 
 /* cpg.c */
 void process_lockspace_changes(void);
Signature · 1 line
2.32.0
#10 lore raw

PATCH 10/10 dlm_controld: enable "dlm_tool run|run_start" dynamic setting feature

In reply to Heming Zhao

This commit gives dlm_tool the ability to change dlm_controld settings on the fly.

---
 dlm_controld/helper.c | 41 ++++++++++++++++++++++++++++++++---------
 1 file changed, 32 insertions(+), 9 deletions(-)
dlm_controld/helper.c +32 -9
index a20965b76195..dd03cb1c973f 100644
@@ -48,6 +48,7 @@ do { \
 
 #define CMD_ID_LVCHANGE_REFRESH 1
 #define CMD_ID_LVS 2
+#define CMD_ID_OPT 3
 
 static int _get_cmd_id(char **av, int av_count)
 {
@@ -64,6 +65,11 @@ static int _get_cmd_id(char **av, int av_count)
 		return CMD_ID_LVS;
 	}
 
+	if ((av_count >= 2) &&
+	    (!strcmp(av[0], "option") || !strcmp(av[0], "opt"))) {
+		return CMD_ID_OPT;
+	}
+
 	return 0;
 }
 
@@ -133,19 +139,19 @@ static void _clear_running_cmd(struct running *running)
 
 /* runs in child process that was forked by helper */
 
-static void exec_command(char *cmd_str, int out_fd)
+static int exec_command(char *cmd_str, int out_fd)
 {
 	char cmd_buf[16];
 	char arg[ONE_ARG_LEN];
 	char *av[MAX_AV_COUNT + 1]; /* +1 for NULL */
 	int av_count = 0;
-	int i, rv, arg_len, cmd_len, cmd_id;
+	int i, rv = -1, arg_len, cmd_len, cmd_id;
 
 	for (i = 0; i < MAX_AV_COUNT + 1; i++)
 		av[i] = NULL;
 
 	if (!cmd_str[0])
-		return;
+		return rv;
 
 	/* this should already be done, but make sure */
 	cmd_str[RUN_COMMAND_LEN - 1] = '\0';
@@ -214,11 +220,26 @@ static void exec_command(char *cmd_str, int out_fd)
 		log_helper("write cmd_buf from child error %d", rv);
 	close(out_fd);
 
-	/* if we return before exec, the child does exit(1) (failure) */
-	if (!cmd_id)
-		return;
+	switch (cmd_id) {
+	case 0:
+		/* if we return from here, the child does exit(1) (failure) */
+		rv = -1;
+		break;
+	case 1:
+	case 2:
+		rv = 0;
+		execvp(av[0], av);
+		break; /* useless */
+	case 3:
+		set_opt_online(av_count-1, av+1);
+		rv = 0;
+		break;
+	default:
+		rv = -1;
+		break;
+	}
 
-	execvp(av[0], av);
+	return rv;
 }
 
 static int read_request(int fd, struct run_request *req)
@@ -352,8 +373,10 @@ int run_helper(int in_fd, int out_fd, int log_stderr)
 				pid = fork();
 				if (!pid) {
 					close(cmd_pipe[0]);
-					exec_command(req.command, cmd_pipe[1]);
-					exit(1);
+					if (exec_command(req.command, cmd_pipe[1]) < 0)
+						exit(1);
+					else
+						exit(0);
 				}
 
 				close(cmd_pipe[1]);
Signature · 1 line
2.32.0
#11 lore raw

cover dlm_controld config settings can be

In reply to Heming Zhao
Quoted 1 line · Heming Zhao

This new feature gives dlm ability to change config settings dynamically.

Hi Heming,

Letting dlm_controld reload certain settings from dlm.conf makes sense, but I'd like something more basic. Let the user edit dlm.conf, then run dlm_tool reload_config to tell dlm_controld to reread dlm.conf, and apply new settings. This doesn't involve remote nodes, it's all local. If the user wants, they can make changes on other nodes the same way.

(We don't need to touch the "run" extension, which I'd like to remove some day since it doesn't really belong in the dlm.)

Dave

#12 lore raw

cover dlm_controld config settings can be

Quoted 5 lines · David Teigland
Quoted 1 line · Heming Zhao

This new feature gives dlm ability to change config settings dynamically.

Hi Heming,

Quoted 9 lines

Letting dlm_controld reload certain settings from dlm.conf makes sense, but I'd like something more basic. Let the user edit dlm.conf, then run dlm_tool reload_config to tell dlm_controld to reread dlm.conf, and apply new settings. This doesn't involve remote nodes, it's all local. If the user wants, they can make changes on other nodes the same way.

(We don't need to touch the "run" extension, which I'd like to remove some day since it doesn't really belong in the dlm.)

Hello Dave,

Thank you for your comment.

One of the reasons for my patch based on run command is user could send command to all nodes by only one-line command.
Dynamic settings (my patch) requires user the least time/work to change dlm_controld behaviors. If not, it needs to separately edit dlm.conf & run reload cmd on every local node.

But I am ok with the reload_config idea, it's more basic.
We could give dlm_controld a chance to change behavior on the fly. If needed, I could file a new patch for feature "reload_config", can I do it?

Heming

#13 lore raw

cover dlm_controld config settings can be

Quoted 3 lines · heming.zhao at suse.com

But I am ok with the reload_config idea, it's more basic.
We could give dlm_controld a chance to change behavior on the fly. If needed, I could file a new patch for feature "reload_config", can I do it?

Yes, I'd welcome a patch adding a dlm_tool reload_config option to reread dlm.conf and apply new settings from it.
Thanks,
Dave

#14 lore raw

cover dlm_controld config settings can be

Quoted 10 lines · David Teigland
Quoted 3 lines · heming.zhao at suse.com

But I am ok with the reload_config idea, it's more basic.
We could give dlm_controld a chance to change behavior on the fly. If needed, I could file a new patch for feature "reload_config", can I do it?

Yes, I'd welcome a patch adding a dlm_tool reload_config option to reread dlm.conf and apply new settings from it.
Thanks,
Dave

Before sending the new feature patch, I want to have more discussion.

In my opinion, changing and reloading dlm.conf is a ***heavy*** way to update dlm_controld settings. This manner is well suited for the change of a setting still valid to next turn startup dlm_controld.
There are some use cases which require a ***light*** way to update settings. It just needs updating settings in memory and validating in a short time (or until one dlm_controld running turn).

Examples:

1. debug

debugging the code temporarily with no intention to change dlm.conf.

2. to get some log

temporarily enable dlm log for checking status.

3. temporarily change dlm_controld behaviour

(there is a production use case.)
a. In 3+ nodes HA cluster env, dlm_controld startup with default settings.
b. after stopping 2 of 3 nodes in cluster. (by cmd "crm cluster stop")
c. the only left node is lacking quorum and quorate become "NO". (by cmd "corosync-quorumtool") d. on the last active node, run "crm cluster stop" to stop this node.
the result is the node will be hung and will be fenced for a short while by trigging timeout.

The hanging in <d> can be avoid by temporarily changing settings:
enable_quorum_fencing and enable_quorum_lockspace from default value 1 to 0. and the changing does not need lasting for node restart.

So,
If there is no chance to add dynamic updating setting by run command. Is it a good idea to add a parameter "-I", like "dlm_tool -I reload_config". "-I" means directly change without reading from dlm.conf.
When users want to restore the original setting, run "dlm_tool reload_config" (without "-I") to override with predefined/default values.

Thanks
Heming

#15 lore raw

cover dlm_controld config settings can be

Quoted 5 lines · heming.zhao at suse.com

If there is no chance to add dynamic updating setting by run command. Is it a good idea to add a parameter "-I", like "dlm_tool -I reload_config". "-I" means directly change without reading from dlm.conf.
When users want to restore the original setting, run "dlm_tool reload_config" (without "-I") to override with predefined/default values.

How about "dlm_tool set_config x=y" to make a temporary change in dlm_controld, and "dlm_tool reload_config" to reread dlm.conf. Dave

#16 lore raw

cover dlm_controld config settings can be

Quoted 11 lines · David Teigland
Quoted 5 lines · heming.zhao at suse.com

If there is no chance to add dynamic updating setting by run command. Is it a good idea to add a parameter "-I", like "dlm_tool -I reload_config". "-I" means directly change without reading from dlm.conf.
When users want to restore the original setting, run "dlm_tool reload_config" (without "-I") to override with predefined/default values.

How about "dlm_tool set_config x=y" to make a temporary change in dlm_controld, and "dlm_tool reload_config" to reread dlm.conf. Dave

Yes, "set_config x=y" is more better.
I just found I missed part of parameter of "-I reload_config". The whole cmd should be "-I reload_config x=y". But add a new command is more clear and better.

Heming