* [Cluster-devel] [RFC PATCH 0/5] add new command reload_config set_config
@ 2021-09-25 14:21 Heming Zhao
2021-09-25 14:21 ` [Cluster-devel] [PATCH 1/5] dlm_tool man: add command "joinleave", add "USAGE" section Heming Zhao
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Heming Zhao @ 2021-09-25 14:21 UTC (permalink / raw)
To: cluster-devel.redhat.com
This serial patches gives dlm ability to change config settings
on the fly.
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.
There are two ways to do the dynamic changing job:
- by modification dlm.conf
- by dlm_tool command
The man page of dlm_tool.8 and dlm.conf.5 show examples of this feature.
Original code has bug for those no_arg type options. Whatever use 0 or 1
to set no_arg type option, the option value always 1. To fix this bug,
the 03/05 patch changes some options type from no_arg to req_arg_bool:
daemon_debug, foreground, log_debug, debug_logfile, plock_debug.
Only keeps help & version with no_arg type.
For daemon_debug option, the 03/05 patch changes dlm_controld behavior.
Before this patch, when the value is 1, dlm_controld won't become a
daemon.
With 03/05 patch, daemon_debug only means dlm_controld enter debug mode.
the foreground option totally controls whether the program becomes a
daemon.
Heming Zhao (5):
dlm_tool man: add command "joinleave", add "USAGE" section
man: add reload_config in dlm_tool & dlm.conf
dlm_controld: add reload_config feature
dlm_tool man: add new command set_config
dlm_controld: add new feature set_config
dlm_controld/action.c | 5 +
dlm_controld/config.c | 288 +++++++++++++++++++++++++++++++++--
dlm_controld/dlm.conf.5 | 42 +++--
dlm_controld/dlm_controld.h | 2 +
dlm_controld/dlm_daemon.h | 15 ++
dlm_controld/helper.c | 4 -
dlm_controld/lib.c | 55 +++++++
dlm_controld/libdlmcontrol.h | 2 +
dlm_controld/logging.c | 18 ++-
dlm_controld/main.c | 146 +++++++++++-------
dlm_tool/dlm_tool.8 | 179 ++++++++++++++++++++++
dlm_tool/main.c | 48 +++++-
12 files changed, 715 insertions(+), 89 deletions(-)
--
2.32.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cluster-devel] [PATCH 1/5] dlm_tool man: add command "joinleave", add "USAGE" section
2021-09-25 14:21 [Cluster-devel] [RFC PATCH 0/5] add new command reload_config set_config Heming Zhao
@ 2021-09-25 14:21 ` Heming Zhao
2021-09-25 14:21 ` [Cluster-devel] [PATCH 2/5] man: add reload_config in dlm_tool & dlm.conf Heming Zhao
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Heming Zhao @ 2021-09-25 14:21 UTC (permalink / raw)
To: cluster-devel.redhat.com
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
dlm_tool/dlm_tool.8 | 79 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)
diff --git a/dlm_tool/dlm_tool.8 b/dlm_tool/dlm_tool.8
index bbc11c261b7e..056c4af0213c 100644
--- a/dlm_tool/dlm_tool.8
+++ b/dlm_tool/dlm_tool.8
@@ -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)
--
2.32.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Cluster-devel] [PATCH 2/5] man: add reload_config in dlm_tool & dlm.conf
2021-09-25 14:21 [Cluster-devel] [RFC PATCH 0/5] add new command reload_config set_config Heming Zhao
2021-09-25 14:21 ` [Cluster-devel] [PATCH 1/5] dlm_tool man: add command "joinleave", add "USAGE" section Heming Zhao
@ 2021-09-25 14:21 ` Heming Zhao
2021-09-25 14:21 ` [Cluster-devel] [PATCH 3/5] dlm_controld: add reload_config feature Heming Zhao
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Heming Zhao @ 2021-09-25 14:21 UTC (permalink / raw)
To: cluster-devel.redhat.com
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
dlm_controld/dlm.conf.5 | 42 ++++++++++++++++++++++++++++++-----------
dlm_tool/dlm_tool.8 | 11 +++++++++++
2 files changed, 42 insertions(+), 11 deletions(-)
diff --git a/dlm_controld/dlm.conf.5 b/dlm_controld/dlm.conf.5
index 1ce0c6445ee1..99e302a92bd2 100644
--- a/dlm_controld/dlm.conf.5
+++ b/dlm_controld/dlm.conf.5
@@ -34,7 +34,9 @@ protocol=tcp
Options:
-log_debug
+daemon_debug(*)
+.br
+log_debug(*)
.br
protocol
.br
@@ -42,23 +44,23 @@ bind_all
.br
mark
.br
-debug_logfile
+debug_logfile(*)
.br
enable_plock
.br
-plock_debug
+plock_debug(*)
.br
-plock_rate_limit
+plock_rate_limit(*)
.br
plock_ownership
.br
-drop_resources_time
+drop_resources_time(*)
.br
-drop_resources_count
+drop_resources_count(*)
.br
-drop_resources_age
+drop_resources_age(*)
.br
-post_join_delay
+post_join_delay(*)
.br
enable_fencing
.br
@@ -66,15 +68,33 @@ enable_concurrent_fencing
.br
enable_startup_fencing
.br
-enable_quorum_fencing
+enable_quorum_fencing(*)
.br
-enable_quorum_lockspace
+enable_quorum_lockspace(*)
.br
-repeat_failed_fencing
+repeat_failed_fencing(*)
.br
enable_helper
.br
+Option with tail (*) means this item can be reload on the fly by "dlm_tool reload_config". See \fB"Reload config"\fP for more examples.
+
+.SH Reload config
+
+dlm.conf can be changed then reloaded some settings on the fly, it gives users more flexible and powerful ability to manage dlm.
+
+The supported reload operations:
+.br
+- add a new item
+.br
+- remove an exist item
+.br
+- commented out an item
+.br
+- change an item value
+
+After modifying settings in dlm.conf, run "dlm_tool reload_config" to take effect. User can use "dlm_tool dump_config" to check the result. Again, only reloadable item can be changed.
+
.SH Fencing
A fence device definition begins with a
diff --git a/dlm_tool/dlm_tool.8 b/dlm_tool/dlm_tool.8
index 056c4af0213c..e1242308302f 100644
--- a/dlm_tool/dlm_tool.8
+++ b/dlm_tool/dlm_tool.8
@@ -28,6 +28,10 @@ dlm_tool \- a utility for the dlm and dlm_controld daemon
.br
Dump dlm_controld config settings.
+.B reload_config
+.br
+ Reload dlm_controld config settings from dlm.conf.
+
.BI fence_ack " nodeid"
.br
Quit trying to fence a node.
@@ -134,6 +138,13 @@ dlm_tool dump_config
-
+dlm_tool reload_config
+.RS 4
+see examples in \fBdlm.conf(5)\fP
+.RE
+
+-
+
dlm_tool fence_ack \fIls-name\fP
-
--
2.32.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Cluster-devel] [PATCH 3/5] dlm_controld: add reload_config feature
2021-09-25 14:21 [Cluster-devel] [RFC PATCH 0/5] add new command reload_config set_config Heming Zhao
2021-09-25 14:21 ` [Cluster-devel] [PATCH 1/5] dlm_tool man: add command "joinleave", add "USAGE" section Heming Zhao
2021-09-25 14:21 ` [Cluster-devel] [PATCH 2/5] man: add reload_config in dlm_tool & dlm.conf Heming Zhao
@ 2021-09-25 14:21 ` Heming Zhao
2021-09-25 14:21 ` [Cluster-devel] [PATCH 4/5] dlm_tool man: add new command set_config Heming Zhao
2021-09-25 14:21 ` [Cluster-devel] [PATCH 5/5] dlm_controld: add new feature set_config Heming Zhao
4 siblings, 0 replies; 6+ messages in thread
From: Heming Zhao @ 2021-09-25 14:21 UTC (permalink / raw)
To: cluster-devel.redhat.com
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
dlm_controld/action.c | 5 ++
dlm_controld/config.c | 119 ++++++++++++++++++++++++++++----
dlm_controld/dlm_controld.h | 1 +
dlm_controld/dlm_daemon.h | 4 ++
dlm_controld/lib.c | 19 ++++++
dlm_controld/libdlmcontrol.h | 1 +
dlm_controld/logging.c | 18 +++--
dlm_controld/main.c | 128 +++++++++++++++++++++--------------
dlm_tool/main.c | 21 +++++-
9 files changed, 247 insertions(+), 69 deletions(-)
diff --git a/dlm_controld/action.c b/dlm_controld/action.c
index 0eff27997e1c..baddaf81cb4f 100644
--- a/dlm_controld/action.c
+++ b/dlm_controld/action.c
@@ -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
diff --git a/dlm_controld/config.c b/dlm_controld/config.c
index 947480dabe85..91ca10a62b15 100644
--- a/dlm_controld/config.c
+++ b/dlm_controld/config.c
@@ -188,6 +188,55 @@ static void get_val_str(char *line, char *val_out)
strcpy(val_out, val);
}
+inline static void reload_setting(int index)
+{
+ switch(index) {
+ case log_debug_ind:
+ set_configfs_opt("log_debug", NULL, opt(log_debug_ind));
+ break;
+ case debug_logfile_ind:
+ set_logfile_priority();
+ break;
+ default:
+ break;
+ }
+}
+
+static void reset_opt_value(int index)
+{
+ struct dlm_option *o = &dlm_options[index];
+
+ /* 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;
+
+ } else if (o->file_set) {
+ o->use_int = o->file_int;
+ o->use_uint = o->file_uint;
+ o->use_str = o->file_str;
+
+ } else {
+ o->use_int = o->default_int;
+ o->use_uint = o->default_uint;
+ o->use_str = (char *)o->default_str;
+ }
+
+ /*
+ * We don't handle reset value same as legacy value.
+ *
+ * i.e.
+ * 1. option abc default value is 0, while in dlm.conf abc=0.
+ * 2. Then remove abc from dlm.conf.
+ * 3. This function still call reload_setting(), and won't bypass this calling
+ * for no change.
+ */
+ reload_setting(index);
+ return;
+}
+
void set_opt_file(int update)
{
unsigned int uval = 0;
@@ -195,7 +244,8 @@ void set_opt_file(int update)
FILE *file;
char line[MAX_LINE];
char str[MAX_LINE];
- int i, val = 0;
+ int i, val = 0, ind;
+ char scanned_dlm_opt[dlm_options_max];
if (!path_exists(CONF_FILE_PATH))
return;
@@ -204,6 +254,12 @@ void set_opt_file(int update)
if (!file)
return;
+ /* In update mode, there is a little bit bother if one option ever set
+ * but later be removed or commented out */
+ memset(scanned_dlm_opt, 0, sizeof(scanned_dlm_opt));
+ scanned_dlm_opt[help_ind] = 1;
+ scanned_dlm_opt[version_ind] = 1;
+
while (fgets(line, MAX_LINE, file)) {
if (line[0] == '#')
continue;
@@ -226,30 +282,31 @@ void set_opt_file(int update)
str[i] = line[i];
}
- o = get_dlm_option(str);
+ ind = get_ind_name(str);
+ if (ind < 0)
+ continue;
+ o = &dlm_options[ind];
if (!o)
continue;
- /* Doesn't make sense to set this in conf file. */
- if (!strcmp(str, "daemon_debug"))
+ scanned_dlm_opt[ind] = 1;
+
+ /* In update flow, option item doesn't support reload. */
+ if (update && !o->reload)
continue;
o->file_set++;
if (!o->req_arg) {
- /* ignore any = x */
-
- o->file_int = 1;
-
- if (!o->cli_set)
- o->use_int = o->file_int;
-
- log_debug("config file %s = %d cli_set %d use %d",
- o->name, o->file_int, o->cli_set, o->use_int);
+ /* current only help & version are no_arg type, ignore */
+ continue;
} else if (o->req_arg == req_arg_int) {
get_val_int(line, &val);
+ if (update && (o->file_int == val))
+ continue;
+
o->file_int = val;
if (!o->cli_set)
@@ -261,6 +318,9 @@ void set_opt_file(int update)
} else if (o->req_arg == req_arg_uint) {
get_val_uint(line, &uval);
+ if (update && (o->file_uint == uval))
+ continue;
+
o->file_uint = uval;
if (!o->cli_set)
@@ -271,8 +331,12 @@ void set_opt_file(int update)
} else if (o->req_arg == req_arg_bool) {
get_val_int(line, &val);
+ val = val ? 1 : 0;
+
+ if (update && (o->file_int == val))
+ continue;
- o->file_int = val ? 1 : 0;
+ o->file_int = val;
if (!o->cli_set)
o->use_int = o->file_int;
@@ -283,6 +347,11 @@ void set_opt_file(int update)
memset(str, 0, sizeof(str));
get_val_str(line, str);
+ if (update && !strcmp(o->file_str, str))
+ continue;
+
+ if (o->file_str)
+ free(o->file_str);
o->file_str = strdup(str);
if (!o->cli_set)
@@ -291,6 +360,28 @@ void set_opt_file(int update)
log_debug("config file %s = %s cli_set %d use %s",
o->name, o->file_str, o->cli_set, o->use_str);
}
+
+ if (update)
+ reload_setting(ind);
+ }
+
+ if (update) {
+ /* handle commented out options */
+ for (i=0; i<dlm_options_max; i++) {
+ if (scanned_dlm_opt[i])
+ continue;
+ if (!dlm_options[i].reload || !dlm_options[i].file_set)
+ continue;
+
+ dlm_options[i].file_set = 0;
+ dlm_options[i].file_int = 0;
+ dlm_options[i].file_uint = 0;
+ if(dlm_options[i].file_str) {
+ free(dlm_options[i].file_str);
+ dlm_options[i].file_str = NULL;
+ }
+ reset_opt_value(i);
+ }
}
fclose(file);
diff --git a/dlm_controld/dlm_controld.h b/dlm_controld/dlm_controld.h
index 649b2a5826f9..0ea3548fce7d 100644
--- a/dlm_controld/dlm_controld.h
+++ b/dlm_controld/dlm_controld.h
@@ -35,6 +35,7 @@
#define DLMC_CMD_RUN_START 15
#define DLMC_CMD_RUN_CHECK 16
#define DLMC_CMD_DUMP_RUN 17
+#define DLMC_CMD_RELOAD_CONFIG 18
struct dlmc_header {
unsigned int magic;
diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h
index 436fc9109aa6..9e68f8257cb5 100644
--- a/dlm_controld/dlm_daemon.h
+++ b/dlm_controld/dlm_daemon.h
@@ -132,6 +132,7 @@ struct dlm_option {
const char *name;
char letter;
int req_arg;
+ char reload;
const char *desc;
int use_int;
@@ -383,6 +384,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);
@@ -471,6 +473,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);
@@ -522,6 +525,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);
diff --git a/dlm_controld/lib.c b/dlm_controld/lib.c
index 53c11cf9f269..951eb6561ba9 100644
--- a/dlm_controld/lib.c
+++ b/dlm_controld/lib.c
@@ -174,6 +174,25 @@ int dlmc_dump_run(char *buf)
return do_dump(DLMC_CMD_DUMP_RUN, NULL, buf);
}
+int dlmc_reload_config(void)
+{
+ struct dlmc_header h;
+ int fd, rv;
+
+ init_header(&h, DLMC_CMD_RELOAD_CONFIG, NULL, 0);
+
+ fd = do_connect(DLMC_SOCK_PATH);
+ if (fd < 0) {
+ rv = fd;
+ goto out;
+ }
+
+ rv = do_write(fd, &h, sizeof(h));
+ close(fd);
+ out:
+ return rv;
+}
+
static int nodeid_compare(const void *va, const void *vb)
{
const int *a = va;
diff --git a/dlm_controld/libdlmcontrol.h b/dlm_controld/libdlmcontrol.h
index ba603feeccf0..ac84e702fb58 100644
--- a/dlm_controld/libdlmcontrol.h
+++ b/dlm_controld/libdlmcontrol.h
@@ -91,6 +91,7 @@ int dlmc_lockspaces(int max, int *count, struct dlmc_lockspace *lss);
int dlmc_lockspace_nodes(char *lsname, int type, int max, int *count,
struct dlmc_node *nodes);
int dlmc_print_status(uint32_t flags);
+int dlmc_reload_config(void);
#define DLMC_RESULT_REGISTER 1
#define DLMC_RESULT_NOTIFIED 2
diff --git a/dlm_controld/logging.c b/dlm_controld/logging.c
index d48b8aebc237..2c57138ce766 100644
--- a/dlm_controld/logging.c
+++ b/dlm_controld/logging.c
@@ -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);
diff --git a/dlm_controld/main.c b/dlm_controld/main.c
index 504cafa12ec6..a49bb0c9b9ad 100644
--- a/dlm_controld/main.c
+++ b/dlm_controld/main.c
@@ -1230,6 +1230,10 @@ static void process_connection(int ci)
client_dead(ci);
break;
#endif
+ case DLMC_CMD_RELOAD_CONFIG:
+ set_opt_file(1);
+ break;
+
default:
log_error("process_connection %d unknown command %d",
ci, h.command);
@@ -1749,12 +1753,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, char reload, 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].reload = reload;
dlm_options[ind].default_int = default_int;
dlm_options[ind].default_str = default_str;
dlm_options[ind].default_uint = default_uint;
@@ -1766,142 +1771,142 @@ static void set_opt_default(int ind, const char *name, char letter, int arg_type
static void set_opt_defaults(void)
{
set_opt_default(daemon_debug_ind,
- "daemon_debug", 'D', no_arg,
- 0, NULL, 0,
+ "daemon_debug", 'D', req_arg_bool,
+ 0, NULL, 0, 1,
"enable debugging to stderr and don't fork");
set_opt_default(foreground_ind,
- "foreground", '\0', no_arg,
- 0, NULL, 0,
+ "foreground", '\0', req_arg_bool,
+ 0, NULL, 0, 0,
"don't fork");
set_opt_default(log_debug_ind,
- "log_debug", 'K', no_arg,
- 0, NULL, 0,
+ "log_debug", 'K', req_arg_bool,
+ 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,
+ "debug_logfile", 'L', req_arg_bool,
+ 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,
+ "plock_debug", 'P', req_arg_bool,
+ 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");
}
-static int get_ind_name(char *s)
+int get_ind_name(char *s)
{
char name[PATH_MAX];
char *p = s;
@@ -1948,11 +1953,12 @@ struct dlm_option *get_dlm_option(char *name)
static void set_opt_cli(int argc, char **argv)
{
struct dlm_option *o;
- char *arg1, *p, *arg_str;
+ char *arg1, *p, *arg_str, *endptr;
+ char bool_str[]="1";
char bundled_letters[8];
int b, blc = 0, blc_max = 8;
int debug_options = 0;
- int i, ind;
+ int i, ind, bundled;
if (argc < 2)
return;
@@ -1996,20 +2002,26 @@ static void set_opt_cli(int argc, char **argv)
o = &dlm_options[ind];
o->cli_set++;
- if (!o->req_arg) {
- /* "-x" has same effect as "-x 1" */
- o->cli_int = 1;
- o->use_int = 1;
+ if (!o->req_arg || (o->req_arg == req_arg_bool)) {
+ bundled = 0;
- /* save bundled, arg-less, single letters, e.g. -DKP */
+ /* current for no_arg type, there is not possible to have bundled options.
+ * for req_arg_bool, bundled options, e.g. -DKP. all treat as "true".
+ * below code save bundled, arg-less, single letters */
if ((p[0] == '-') && isalpha(p[1]) && (strlen(p) > 2)) {
for (b = 2; b < strlen(p) && blc < blc_max; b++) {
if (!isalpha(p[b]))
break;
bundled_letters[blc++] = p[b];
+ bundled = 1;
}
}
- continue;
+ if (bundled) {
+ /* "-x" has same effect as "-x 1" */
+ o->cli_int = 1;
+ o->use_int = 1;
+ continue;
+ }
}
arg_str = NULL;
@@ -2024,17 +2036,31 @@ static void set_opt_cli(int argc, char **argv)
} else {
/* space separates arg from name or letter */
- if (i >= argc) {
- fprintf(stderr, "option %s no arg", p);
- exit(EXIT_FAILURE);
+ if (o->req_arg == req_arg_bool) {
+ /* bool type treat empty arg as true */
+ if (i >= argc || argv[i][0] == '-')
+ arg_str = bool_str;
+ else
+ arg_str = argv[i++];
+ } else {
+ if (i >= argc) {
+ fprintf(stderr, "option %s no arg\n", p);
+ exit(EXIT_FAILURE);
+ }
+ arg_str = argv[i++];
}
- arg_str = argv[i++];
}
if (!arg_str || arg_str[0] == '-' || arg_str[0] == '\0') {
- fprintf(stderr, "option %s requires arg", p);
+ fprintf(stderr, "option %s requires arg\n", p);
exit(EXIT_FAILURE);
}
+ if ((o->req_arg != req_arg_str) && !strtol(arg_str, &endptr, 10)) {
+ if (endptr == arg_str) {
+ fprintf(stderr, "option %s requires digit number\n", p);
+ exit(EXIT_FAILURE);
+ }
+ }
if (o->req_arg == req_arg_str) {
o->cli_str = strdup(arg_str);
@@ -2059,6 +2085,7 @@ static void set_opt_cli(int argc, char **argv)
fprintf(stderr, "unknown option char %c\n", bundled_letters[i]);
exit(EXIT_FAILURE);
}
+ /* bundled letter must be bool type, treat it with "true" value */
o = &dlm_options[ind];
o->cli_set++;
o->cli_int = 1;
@@ -2109,8 +2136,11 @@ int main(int argc, char **argv)
* - explicit cli setting will override default,
* - explicit file setting will override default
* - explicit file setting will not override explicit cli setting
+ *
+ * "dlm reload_config" will trigger to reload config file, and
+ * reload action also follows the rule: not override explicit
+ * cli setting
*/
-
set_opt_defaults();
set_opt_cli(argc, argv);
set_opt_file(0);
@@ -2128,7 +2158,7 @@ int main(int argc, char **argv)
INIT_LIST_HEAD(&run_ops);
init_daemon();
- if (!opt(daemon_debug_ind) && !opt(foreground_ind)) {
+ if (!opt(foreground_ind)) {
if (daemon(0, 0) < 0) {
perror("daemon error");
exit(EXIT_FAILURE);
diff --git a/dlm_tool/main.c b/dlm_tool/main.c
index 53d9336d59c6..07f020d71a66 100644
--- a/dlm_tool/main.c
+++ b/dlm_tool/main.c
@@ -47,6 +47,7 @@
#define OP_RUN_CANCEL 17
#define OP_RUN_LIST 18
#define OP_DUMP_RUN 19
+#define OP_RELOAD_CONFIG 20
static char *prog_name;
static char *lsname;
@@ -196,7 +197,7 @@ static void print_usage(void)
printf("dlm_tool [command] [options] [name]\n");
printf("\n");
printf("Commands:\n");
- printf("ls, status, dump, dump_config, fence_ack\n");
+ printf("ls, status, dump, dump_config, reload_config, fence_ack\n");
printf("log_plock, plocks\n");
printf("join, leave, lockdebug\n");
printf("run, run_start, run_check, run_cancel, run_list\n");
@@ -363,6 +364,12 @@ static void decode_arguments(int argc, char **argv)
opt_ind = optind + 1;
need_lsname = 0;
break;
+ } else if (!strncmp(argv[optind], "reload_config", 13) &&
+ (strlen(argv[optind]) == 13)) {
+ operation = OP_RELOAD_CONFIG;
+ opt_ind = optind + 1;
+ need_lsname = 0;
+ break;
} else if (!strncmp(argv[optind], "plocks", 6) &&
(strlen(argv[optind]) == 6)) {
operation = OP_PLOCKS;
@@ -1472,6 +1479,14 @@ static void do_dump(int op)
printf("\n");
}
+static void do_reload_config(void)
+{
+ if (dlmc_reload_config() < 0)
+ printf("Issue reload_config failed.\n");
+ else
+ printf("Issue reload_config done.\n");
+}
+
static void do_log_plock(void)
{
char buf[DLMC_DUMP_SIZE];
@@ -1570,6 +1585,10 @@ int main(int argc, char **argv)
do_dump(operation);
break;
+ case OP_RELOAD_CONFIG:
+ do_reload_config();
+ break;
+
case OP_LOG_PLOCK:
do_log_plock();
break;
--
2.32.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Cluster-devel] [PATCH 4/5] dlm_tool man: add new command set_config
2021-09-25 14:21 [Cluster-devel] [RFC PATCH 0/5] add new command reload_config set_config Heming Zhao
` (2 preceding siblings ...)
2021-09-25 14:21 ` [Cluster-devel] [PATCH 3/5] dlm_controld: add reload_config feature Heming Zhao
@ 2021-09-25 14:21 ` Heming Zhao
2021-09-25 14:21 ` [Cluster-devel] [PATCH 5/5] dlm_controld: add new feature set_config Heming Zhao
4 siblings, 0 replies; 6+ messages in thread
From: Heming Zhao @ 2021-09-25 14:21 UTC (permalink / raw)
To: cluster-devel.redhat.com
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
dlm_tool/dlm_tool.8 | 89 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 89 insertions(+)
diff --git a/dlm_tool/dlm_tool.8 b/dlm_tool/dlm_tool.8
index e1242308302f..e6012315f082 100644
--- a/dlm_tool/dlm_tool.8
+++ b/dlm_tool/dlm_tool.8
@@ -32,6 +32,10 @@ dlm_tool \- a utility for the dlm and dlm_controld daemon
.br
Reload dlm_controld config settings from dlm.conf.
+.B set_config
+.br
+ Set dlm_controld config settings on the fly.
+
.BI fence_ack " nodeid"
.br
Quit trying to fence a node.
@@ -145,6 +149,13 @@ see examples in \fBdlm.conf(5)\fP
-
+dlm_tool set_config "dlm_controld-config-item=x"
+.RS 4
+see below \fBEXAMPLES\fP section
+.RE
+
+-
+
dlm_tool fence_ack \fIls-name\fP
-
@@ -202,6 +213,84 @@ dlm_tool -h
dlm_tool -V
+.SH EXAMPLES
+
+command \fIdlm_tool set_config "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 indicates this item supports dynamic config.
+.br
+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 more usage
+
+.RS 4
+.EX
+Default log_debug is 0, we use "set_config" to change to 1.
+.br
+
+# dlm_tool dump_config | grep log_debug
+(*-) log_debug=0
+# dlm_tool set_config "log_debug=1"
+Issue set_config done.
+# dlm_tool dump_config | grep log_debug
+(*+) log_debug=1
+
+Default log_debug is 0, we do "set_config", it will overwrite with 0.
+"dump_config" show "(*+)" to indicate this option had been changed by set_config.
+.br
+
+# dlm_tool dump_config | grep log_debug
+(*-) log_debug=0
+# dlm_tool set_config "log_debug=0"
+Issue set_config done.
+# dlm_tool dump_config | grep log_debug
+(*+) log_debug=0
+
+We use "restore" to reset dlm_controld setting. change status "(*)" to "(*-)"
+.br
+
+# dlm_tool dump_config | grep log_debug
+(*+) log_debug=0
+# dlm_tool set_config "log_debug=restore"
+# dlm_tool dump_config | grep log_debug
+(*-) log_debug=0
+
+Below we use "restore_all" to reset all dynamic settings in one command
+.br
+
+# dlm_tool dump_config | grep _debug
+(*-) daemon_debug=0
+(*-) log_debug=0
+(*-) plock_debug=0
+# dlm_tool set_config "daemon_debug=1 log_debug=1"
+Issue set_config done.
+# dlm_tool dump_config | grep _debug
+(*+) daemon_debug=1
+(*+) log_debug=1
+(*-) plock_debug=0
+# dlm_tool set_config "restore_all"
+Issue set_config done.
+# dlm_tool dump_config | grep _debug
+(*-) daemon_debug=0
+(*-) log_debug=0
+(*-) plock_debug=0
+.EE
+.RE
+
.SH SEE ALSO
.BR dlm_controld (8),
.BR dlm.conf (5)
--
2.32.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Cluster-devel] [PATCH 5/5] dlm_controld: add new feature set_config
2021-09-25 14:21 [Cluster-devel] [RFC PATCH 0/5] add new command reload_config set_config Heming Zhao
` (3 preceding siblings ...)
2021-09-25 14:21 ` [Cluster-devel] [PATCH 4/5] dlm_tool man: add new command set_config Heming Zhao
@ 2021-09-25 14:21 ` Heming Zhao
4 siblings, 0 replies; 6+ messages in thread
From: Heming Zhao @ 2021-09-25 14:21 UTC (permalink / raw)
To: cluster-devel.redhat.com
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
dlm_controld/config.c | 169 +++++++++++++++++++++++++++++++++++
dlm_controld/dlm_controld.h | 1 +
dlm_controld/dlm_daemon.h | 11 +++
dlm_controld/helper.c | 4 -
dlm_controld/lib.c | 38 +++++++-
dlm_controld/libdlmcontrol.h | 1 +
dlm_controld/main.c | 18 +++-
dlm_tool/main.c | 29 +++++-
8 files changed, 260 insertions(+), 11 deletions(-)
diff --git a/dlm_controld/config.c b/dlm_controld/config.c
index 91ca10a62b15..e825e2f8a1a6 100644
--- a/dlm_controld/config.c
+++ b/dlm_controld/config.c
@@ -387,3 +387,172 @@ void set_opt_file(int update)
fclose(file);
}
+/*
+ * do the clean/restore job:
+ * - clean up dlm_options[].dynamic_xx
+ * - using top priority item to set use option.
+ */
+static void reset_dynamic(int index)
+{
+ struct dlm_option *o = &dlm_options[index];
+
+ if (!o->reload)
+ return;
+
+ 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(index);
+
+ return;
+}
+
+/* copy code from exec_command() */
+void set_opt_online(char *cmd_str, int cmd_len)
+{
+ int i, ind, val = 0;
+ int av_count = 0;
+ int arg_len;
+ unsigned int uval = 0;
+ struct dlm_option *o;
+ char str[MAX_LINE];
+ char arg[ONE_ARG_LEN];
+ char *av[MAX_AV_COUNT + 1]; /* +1 for NULL */
+
+ if (cmd_len > RUN_COMMAND_LEN)
+ return;
+
+ for (i = 0; i < MAX_AV_COUNT + 1; i++)
+ av[i] = NULL;
+
+ if (!cmd_str[0])
+ return;
+
+ /* this should already be done, but make sure */
+ cmd_str[cmd_len - 1] = '\0';
+
+ memset(&arg, 0, sizeof(arg));
+ arg_len = 0;
+ cmd_len = strlen(cmd_str);
+
+ for (i = 0; i < cmd_len; i++) {
+ if (!cmd_str[i])
+ break;
+
+ if (av_count == MAX_AV_COUNT)
+ break;
+
+ if (cmd_str[i] == '\\') {
+ if (i == (cmd_len - 1))
+ break;
+ i++;
+
+ if (cmd_str[i] == '\\') {
+ arg[arg_len++] = cmd_str[i];
+ continue;
+ }
+ if (isspace(cmd_str[i])) {
+ arg[arg_len++] = cmd_str[i];
+ continue;
+ } else {
+ break;
+ }
+ }
+
+ if (isalnum(cmd_str[i]) || ispunct(cmd_str[i])) {
+ arg[arg_len++] = cmd_str[i];
+ } else if (isspace(cmd_str[i])) {
+ if (arg_len)
+ av[av_count++] = strdup(arg);
+
+ memset(arg, 0, sizeof(arg));
+ arg_len = 0;
+ } else {
+ break;
+ }
+ }
+
+ if ((av_count < MAX_AV_COUNT) && arg_len) {
+ av[av_count++] = strdup(arg);
+ }
+
+ /*
+ for (i = 0; i < MAX_AV_COUNT + 1; i++) {
+ if (!av[i])
+ break;
+
+ syslog(LOG_ERR, "command av[%d] \"%s\"", i, av[i]);
+ }
+ */
+
+ if (!strcmp(av[0], "restore_all")) {
+ for (i = 0; i < dlm_options_max; i++)
+ reset_dynamic(i);
+ return;
+ }
+
+ i = -1;
+ while (++i < av_count) {
+
+ ind = get_ind_name(av[i]);
+ if (ind < 0)
+ continue;
+ o = &dlm_options[ind];
+ if (!o || !o->reload)
+ continue;
+
+ get_val_str(av[i], str);
+ if (!strcmp(str, "restore")) {
+ reset_dynamic(ind);
+ continue;
+ }
+
+ o->dynamic_set++;
+
+ if (!o->req_arg || o->req_arg == req_arg_int) {
+ get_val_int(av[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(av[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(av[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(av[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;
+ }
+
+ reload_setting(ind);
+ }
+
+ return;
+}
diff --git a/dlm_controld/dlm_controld.h b/dlm_controld/dlm_controld.h
index 0ea3548fce7d..94e5c49e88bd 100644
--- a/dlm_controld/dlm_controld.h
+++ b/dlm_controld/dlm_controld.h
@@ -36,6 +36,7 @@
#define DLMC_CMD_RUN_CHECK 16
#define DLMC_CMD_DUMP_RUN 17
#define DLMC_CMD_RELOAD_CONFIG 18
+#define DLMC_CMD_SET_CONFIG 19
struct dlmc_header {
unsigned int magic;
diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h
index 9e68f8257cb5..da261774bee0 100644
--- a/dlm_controld/dlm_daemon.h
+++ b/dlm_controld/dlm_daemon.h
@@ -25,6 +25,7 @@
#include <arpa/inet.h>
#include <net/if.h>
#include <stdio.h>
+#include <ctype.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
@@ -133,6 +134,7 @@ struct dlm_option {
char letter;
int req_arg;
char reload;
+ char dynamic;
const char *desc;
int use_int;
@@ -152,6 +154,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];
@@ -328,6 +335,9 @@ struct lockspace {
#define RUN_COMMAND_LEN DLMC_RUN_COMMAND_LEN /* 1024 */
+#define MAX_AV_COUNT 32
+#define ONE_ARG_LEN 256
+
struct run_info {
int dest_nodeid;
int start_nodeid;
@@ -390,6 +400,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(char *cmd_str, int cmd_len);
/* cpg.c */
void process_lockspace_changes(void);
diff --git a/dlm_controld/helper.c b/dlm_controld/helper.c
index a20965b76195..469dd22095f0 100644
--- a/dlm_controld/helper.c
+++ b/dlm_controld/helper.c
@@ -20,7 +20,6 @@
#include <time.h>
#include <stdarg.h>
#include <signal.h>
-#include <ctype.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
@@ -29,9 +28,6 @@
#include "dlm_daemon.h"
-#define MAX_AV_COUNT 32
-#define ONE_ARG_LEN 256
-
static int _log_stderr;
diff --git a/dlm_controld/lib.c b/dlm_controld/lib.c
index 951eb6561ba9..8cbdd27f15e2 100644
--- a/dlm_controld/lib.c
+++ b/dlm_controld/lib.c
@@ -189,7 +189,43 @@ int dlmc_reload_config(void)
rv = do_write(fd, &h, sizeof(h));
close(fd);
- out:
+out:
+ return rv;
+}
+
+int dlmc_set_config(char *command)
+{
+ struct dlmc_header h;
+ char *cmdbuf;
+ int fd, rv;
+
+ cmdbuf = malloc(DLMC_RUN_COMMAND_LEN);
+ if (!cmdbuf)
+ return -1;
+
+ memset(cmdbuf, 0, DLMC_RUN_COMMAND_LEN);
+ strncpy(cmdbuf, command, DLMC_RUN_COMMAND_LEN-1);
+
+ init_header(&h, DLMC_CMD_SET_CONFIG, NULL, DLMC_RUN_COMMAND_LEN);
+
+ fd = do_connect(DLMC_SOCK_PATH);
+ if (fd < 0) {
+ rv = fd;
+ goto out;
+ }
+
+ rv = do_write(fd, &h, sizeof(h));
+ if (rv < 0)
+ goto out_close;
+
+ rv = do_write(fd, cmdbuf, DLMC_RUN_COMMAND_LEN);
+ if (rv < 0)
+ goto out_close;
+
+out_close:
+ close(fd);
+out:
+ free(cmdbuf);
return rv;
}
diff --git a/dlm_controld/libdlmcontrol.h b/dlm_controld/libdlmcontrol.h
index ac84e702fb58..a106171b1073 100644
--- a/dlm_controld/libdlmcontrol.h
+++ b/dlm_controld/libdlmcontrol.h
@@ -92,6 +92,7 @@ int dlmc_lockspace_nodes(char *lsname, int type, int max, int *count,
struct dlmc_node *nodes);
int dlmc_print_status(uint32_t flags);
int dlmc_reload_config(void);
+int dlmc_set_config(char *command);
#define DLMC_RESULT_REGISTER 1
#define DLMC_RESULT_NOTIFIED 2
diff --git a/dlm_controld/main.c b/dlm_controld/main.c
index a49bb0c9b9ad..02fe89bbc60b 100644
--- a/dlm_controld/main.c
+++ b/dlm_controld/main.c
@@ -919,17 +919,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->reload)
+ 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;
@@ -1234,6 +1241,11 @@ static void process_connection(int ci)
set_opt_file(1);
break;
+ case DLMC_CMD_SET_CONFIG:
+ if (extra_len)
+ set_opt_online(extra, extra_len);
+ break;
+
default:
log_error("process_connection %d unknown command %d",
ci, h.command);
diff --git a/dlm_tool/main.c b/dlm_tool/main.c
index 07f020d71a66..5364f7ea22d8 100644
--- a/dlm_tool/main.c
+++ b/dlm_tool/main.c
@@ -48,6 +48,7 @@
#define OP_RUN_LIST 18
#define OP_DUMP_RUN 19
#define OP_RELOAD_CONFIG 20
+#define OP_SET_CONFIG 21
static char *prog_name;
static char *lsname;
@@ -197,7 +198,8 @@ static void print_usage(void)
printf("dlm_tool [command] [options] [name]\n");
printf("\n");
printf("Commands:\n");
- printf("ls, status, dump, dump_config, reload_config, fence_ack\n");
+ printf("ls, status, dump, fence_ack\n");
+ printf("dump_config, reload_config, set_config\n");
printf("log_plock, plocks\n");
printf("join, leave, lockdebug\n");
printf("run, run_start, run_check, run_cancel, run_list\n");
@@ -370,6 +372,13 @@ static void decode_arguments(int argc, char **argv)
opt_ind = optind + 1;
need_lsname = 0;
break;
+ } else if (!strncmp(argv[optind], "set_config", 10) &&
+ (strlen(argv[optind]) == 10)) {
+ operation = OP_SET_CONFIG;
+ opt_ind = optind + 1;
+ need_lsname = 0;
+ need_command = 1;
+ break;
} else if (!strncmp(argv[optind], "plocks", 6) &&
(strlen(argv[optind]) == 6)) {
operation = OP_PLOCKS;
@@ -477,8 +486,10 @@ static void decode_arguments(int argc, char **argv)
exit(EXIT_FAILURE);
}
- strcat(run_command, argv[i]);
- strcat(run_command, " ");
+ if (strlen(argv[i])) {
+ strcat(run_command, argv[i]);
+ strcat(run_command, " ");
+ }
}
}
@@ -1487,6 +1498,14 @@ static void do_reload_config(void)
printf("Issue reload_config done.\n");
}
+static void do_set_config(void)
+{
+ if (dlmc_set_config(run_command) < 0)
+ printf("Issue set_config failed.\n");
+ else
+ printf("Issue set_config done.\n");
+}
+
static void do_log_plock(void)
{
char buf[DLMC_DUMP_SIZE];
@@ -1589,6 +1608,10 @@ int main(int argc, char **argv)
do_reload_config();
break;
+ case OP_SET_CONFIG:
+ do_set_config();
+ break;
+
case OP_LOG_PLOCK:
do_log_plock();
break;
--
2.32.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-09-25 14:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-25 14:21 [Cluster-devel] [RFC PATCH 0/5] add new command reload_config set_config Heming Zhao
2021-09-25 14:21 ` [Cluster-devel] [PATCH 1/5] dlm_tool man: add command "joinleave", add "USAGE" section Heming Zhao
2021-09-25 14:21 ` [Cluster-devel] [PATCH 2/5] man: add reload_config in dlm_tool & dlm.conf Heming Zhao
2021-09-25 14:21 ` [Cluster-devel] [PATCH 3/5] dlm_controld: add reload_config feature Heming Zhao
2021-09-25 14:21 ` [Cluster-devel] [PATCH 4/5] dlm_tool man: add new command set_config Heming Zhao
2021-09-25 14:21 ` [Cluster-devel] [PATCH 5/5] dlm_controld: add new feature set_config Heming Zhao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).