add new command reload_config set_config
cover add new command reload_config set_config
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(-)
Signature · 1 line
2.32.0
PATCH 1/5 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
@@ -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
PATCH 2/5 man: add reload_config in dlm_tool & dlm.conf
In reply to Heming Zhao--- dlm_controld/dlm.conf.5 | 42 ++++++++++++++++++++++++++++++----------- dlm_tool/dlm_tool.8 | 11 +++++++++++ 2 files changed, 42 insertions(+), 11 deletions(-)
dlm_controld/dlm.conf.5 +31 -11
@@ -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
dlm_tool/dlm_tool.8 +11 -0
@@ -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 -
Signature · 1 line
2.32.0
PATCH 3/5 dlm_controld: add reload_config feature
In reply to Heming Zhao--- 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(-)
dlm_controld/action.c +5 -0
@@ -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/config.c +105 -14
180 lines not on this page · raw message
dlm_controld/dlm_controld.h +1 -0
@@ -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 18struct dlmc_header {unsigned int magic;
dlm_controld/dlm_daemon.h +4 -0
@@ -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);
dlm_controld/lib.c +19 -0
@@ -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;
dlm_controld/libdlmcontrol.h +1 -0
@@ -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
dlm_controld/logging.c +13 -5
@@ -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 +79 -49
308 lines not on this page · raw message
dlm_tool/main.c +20 -1
@@ -47,6 +47,7 @@#define OP_RUN_CANCEL 17#define OP_RUN_LIST 18#define OP_DUMP_RUN 19 +#define OP_RELOAD_CONFIG 20static 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 ;
Signature · 1 line
2.32.0
PATCH 4/5 dlm_tool man: add new command set_config
In reply to Heming Zhao--- dlm_tool/dlm_tool.8 | 89 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+)
dlm_tool/dlm_tool.8 +89 -0
@@ -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)
Signature · 1 line
2.32.0
PATCH 5/5 dlm_controld: add new feature set_config
In reply to Heming Zhao--- 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(-)
dlm_controld/config.c +169 -0
@@ -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 ; +}
dlm_controld/dlm_controld.h +1 -0
@@ -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 19struct dlmc_header {unsigned int magic;
dlm_controld/dlm_daemon.h +11 -0
@@ -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 );
dlm_controld/helper.c +0 -4
@@ -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;
dlm_controld/lib.c +37 -1
@@ -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; }
dlm_controld/libdlmcontrol.h +1 -0
@@ -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
dlm_controld/main.c +15 -3
@@ -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);
dlm_tool/main.c +26 -3
@@ -48,6 +48,7 @@#define OP_RUN_LIST 18#define OP_DUMP_RUN 19#define OP_RELOAD_CONFIG 20 +#define OP_SET_CONFIG 21static 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 ;
Signature · 1 line
2.32.0