dlm_tool: add fail functionality if dump failed
PATCH 1/8 dlm_tool: add fail functionality if dump failed
Currently dlm_controld sets a embedded data int value of dlm_controld dump functionality failed for e.g. if lockspace cannot be found. The dlm_tool does not parse this possible error functionality and will exit successfully. This patch will add dlm_tool fail functionality if dlm_controld sets an embedded data error value.
--- dlm_controld/lib.c | 25 +++++++++------- dlm_controld/libdlmcontrol.h | 10 +++---- dlm_tool/main.c | 57 +++++++++++++++++++++++++++--------- 3 files changed, 62 insertions(+), 30 deletions(-)
dlm_controld/lib.c +14 -11
@@ -109,7 +109,7 @@ static void init_header(struct dlmc_header *h, int cmd, char *name,static char copy_buf[DLMC_DUMP_SIZE ]; -static int do_dump (int cmd,char *name,char *buf) +static int do_dump (int cmd,char *name,char *buf,int *data) {struct dlmc_header h;int fd, rv, len;
@@ -118,6 +118,8 @@ static int do_dump(int cmd, char *name, char *buf)init_header (&h, cmd, name,0 ); + *data =0 ; + fd =do_connect (DLMC_QUERY_SOCK_PATH );if (fd <0 ) { rv = fd;
@@ -134,6 +136,7 @@ static int do_dump(int cmd, char *name, char *buf)if (rv <0 ) goto out_close; + *data = h.data; len = h.len -sizeof (h);if (len <=0 || len >DLMC_DUMP_SIZE )
@@ -150,29 +153,29 @@ static int do_dump(int cmd, char *name, char *buf)return rv; } -int dlmc_dump_debug (char *buf) +int dlmc_dump_debug (char *buf,int *data) { -return do_dump (DLMC_CMD_DUMP_DEBUG ,NULL , buf); +return do_dump (DLMC_CMD_DUMP_DEBUG ,NULL , buf, data); } -int dlmc_dump_config (char *buf) +int dlmc_dump_config (char *buf,int *data) { -return do_dump (DLMC_CMD_DUMP_CONFIG ,NULL , buf); +return do_dump (DLMC_CMD_DUMP_CONFIG ,NULL , buf, data); } -int dlmc_dump_log_plock (char *buf) +int dlmc_dump_log_plock (char *buf,int *data) { -return do_dump (DLMC_CMD_DUMP_LOG_PLOCK ,NULL , buf); +return do_dump (DLMC_CMD_DUMP_LOG_PLOCK ,NULL , buf, data); } -int dlmc_dump_plocks (char *name,char *buf) +int dlmc_dump_plocks (char *name,char *buf,int *data) { -return do_dump (DLMC_CMD_DUMP_PLOCKS , name, buf); +return do_dump (DLMC_CMD_DUMP_PLOCKS , name, buf, data); } -int dlmc_dump_run (char *buf) +int dlmc_dump_run (char *buf,int *data) { -return do_dump (DLMC_CMD_DUMP_RUN ,NULL , buf); +return do_dump (DLMC_CMD_DUMP_RUN ,NULL , buf, data); }int dlmc_reload_config (void )
dlm_controld/libdlmcontrol.h +5 -5
@@ -80,11 +80,11 @@ struct dlmc_lockspace {#define DLMC_STATUS_VERBOSE 0x00000001 -int dlmc_dump_debug (char *buf); -int dlmc_dump_config (char *buf); -int dlmc_dump_run (char *buf); -int dlmc_dump_log_plock (char *buf); -int dlmc_dump_plocks (char *name,char *buf); +int dlmc_dump_debug (char *buf,int *data); +int dlmc_dump_config (char *buf,int *data); +int dlmc_dump_run (char *buf,int *data); +int dlmc_dump_log_plock (char *buf,int *data); +int dlmc_dump_plocks (char *name,char *buf,int *data);int dlmc_lockspace_info (char *lsname,struct dlmc_lockspace *ls);int dlmc_node_info (char *lsname,int nodeid,struct dlmc_node *node);/* caller need to free *lss */
dlm_tool/main.c +43 -14
134 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH 2/8 dlm_controld: always create logdir
Currently the logdir will be created only if logfile does contain a string. To add another logfiles we simple create the logdir always on startup.
--- dlm_controld/logging.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
dlm_controld/logging.c +17 -17
@@ -38,27 +38,27 @@ void init_logging(void)set_logfile_priority (); -if (logfile[0 ]) { - old_umask =umask (0077 ); - rv =mkdir (SYS_VARDIR ,0700 ); -if (rv <0 && errno !=EEXIST ) { -umask (old_umask); - goto skip_logfile; - } + old_umask =umask (0077 ); + rv =mkdir (SYS_VARDIR ,0700 ); +if (rv <0 && errno !=EEXIST ) { +umask (old_umask); + goto skip_logfile; + } - rv =mkdir (SYS_LOGDIR ,0700 ); -if (rv <0 && errno !=EEXIST ) { -umask (old_umask); - goto skip_logfile; - } + rv =mkdir (SYS_LOGDIR ,0700 ); +if (rv <0 && errno !=EEXIST ) { +umask (old_umask); + goto skip_logfile; + } - rv =mkdir (LOGDIR ,0700 ); -if (rv <0 && errno !=EEXIST ) { -umask (old_umask); - goto skip_logfile; - } + rv =mkdir (LOGDIR ,0700 ); +if (rv <0 && errno !=EEXIST ) {umask (old_umask); + goto skip_logfile; + } +umask (old_umask); +if (logfile[0 ]) { logfile_fp =fopen (logfile,"a+" );if (logfile_fp !=NULL ) {int fd =fileno (logfile_fp);
Signature · 1 line
2.31.1
PATCH 3/8 dlm_controld: add plock logfile
In reply to Alexander AringThe current plock logging is limited due a in-memory log buffer which can be dumped via dlm_contol log_plock functionality. To trace plock performance issues it's necessary to log plock activity in a bigger log buffer such as a file. This patch will add functionality that plock logging information will be appended into a log file.
WARNING: depending on plock activity the resulting log file can be resulting in enormous file size. This option should be used for debugging purpose only.
--- dlm_controld/dlm_daemon.h | 4 ++++ dlm_controld/logging.c | 39 +++++++++++++++++++++++++++++++-------- dlm_controld/main.c | 5 +++++ 3 files changed, 40 insertions(+), 8 deletions(-)
dlm_controld/dlm_daemon.h +4 -0
@@ -76,10 +76,12 @@#define RUN_FILE_NAME "dlm_controld.pid"#define LOG_FILE_NAME "dlm_controld.log" +#define PLOCK_LOG_FILE_NAME "plock.log"#define CONF_FILE_NAME "dlm.conf"#define RUN_FILE_PATH RUNDIR "/" RUN_FILE_NAME#define LOG_FILE_PATH LOGDIR "/" LOG_FILE_NAME +#define PLOCK_LOG_FILE_PATH LOGDIR "/" PLOCK_LOG_FILE_NAME#define CONF_FILE_PATH CONFDIR "/" CONF_FILE_NAME#define DEFAULT_LOG_MODE LOG_MODE_OUTPUT_FILE | LOG_MODE_OUTPUT_SYSLOG
@@ -87,6 +89,7 @@#define DEFAULT_SYSLOG_PRIORITY LOG_INFO#define DEFAULT_LOGFILE_PRIORITY LOG_INFO#define DEFAULT_LOGFILE LOG_FILE_PATH +#define DEFAULT_PLOCK_LOGFILE PLOCK_LOG_FILE_PATH#define DEFAULT_NETLINK_RCVBUF (2 * 1024 * 1024)
@@ -110,6 +113,7 @@ enum { enable_fscontrol_ind, enable_plock_ind, plock_debug_ind, + plock_debug_logfile_ind, plock_rate_limit_ind, plock_ownership_ind, drop_resources_time_ind,
dlm_controld/logging.c +31 -8
@@ -12,7 +12,9 @@ static int syslog_facility;static int syslog_priority;static int logfile_priority;static char logfile[PATH_MAX ]; +static char plock_logfile[PATH_MAX ];static FILE *logfile_fp; +static FILE *plock_logfile_fp;/* logfile_priority is the only one of these options that can be controlled from command line, environment variable
@@ -35,6 +37,7 @@ void init_logging(void) syslog_priority =DEFAULT_SYSLOG_PRIORITY ; logfile_priority =DEFAULT_LOGFILE_PRIORITY ;strcpy (logfile,DEFAULT_LOGFILE ); +strcpy (plock_logfile,DEFAULT_PLOCK_LOGFILE );set_logfile_priority ();
@@ -66,6 +69,15 @@ void init_logging(void) } } +if (dlm_options[plock_debug_logfile_ind].use_int && + plock_logfile[0 ]) { + plock_logfile_fp =fopen (plock_logfile,"a+" ); +if (plock_logfile_fp !=NULL ) { +int fd =fileno (plock_logfile_fp); +fcntl (fd,F_SETFD ,fcntl (fd,F_GETFD ,0 ) |FD_CLOEXEC ); + } + } + skip_logfile:openlog (DAEMON_NAME ,LOG_CONS |LOG_PID , syslog_facility); }
@@ -75,6 +87,8 @@ void close_logging(void)closelog ();if (logfile_fp)fclose (logfile_fp); +if (plock_logfile_fp) +fclose (plock_logfile_fp); }#define NAME_ID_SIZE 32
@@ -151,6 +165,16 @@ static void log_save_str(int len, char *log_buf, unsigned int *point, *wrap = w; } +static void log_str_to_file (FILE *fp) +{ +time_t logtime =time (NULL ); +char tbuf[64 ]; + +strftime (tbuf,sizeof (tbuf),"%b %d %T" ,localtime (&logtime)); +fprintf (fp,"%s %s" , tbuf, log_str); +fflush (fp); +} +void log_level (char *name_in,uint32_t level_in,const char *fmt, ...) {va_list ap;
@@ -191,19 +215,18 @@ void log_level(char *name_in, uint32_t level_in, const char *fmt, ...)if (level <LOG_NONE )log_save_str (pos -1 , log_dump, &log_point, &log_wrap); -if (plock) +if (plock) {log_save_str (pos -1 , log_dump_plock, &log_point_plock, &log_wrap_plock); +if (plock_logfile_fp) +log_str_to_file (plock_logfile_fp); + } +if (level <= syslog_priority)syslog (level,"%s" , log_str); -if (level <= logfile_priority && logfile_fp) { -time_t logtime =time (NULL ); -char tbuf[64 ]; -strftime (tbuf,sizeof (tbuf),"%b %d %T" ,localtime (&logtime)); -fprintf (logfile_fp,"%s %s" , tbuf, log_str); -fflush (logfile_fp); - } +if (level <= logfile_priority && logfile_fp) +log_str_to_file (logfile_fp);if (!dlm_options[daemon_debug_ind].use_int)return ;
dlm_controld/main.c +5 -0
@@ -1854,6 +1854,11 @@ static void set_opt_defaults(void)0 ,NULL ,0 ,1 , "enable plock debugging"); +set_opt_default (plock_debug_logfile_ind, +"plock_debug_logfile" ,'O' , req_arg_bool, +0 ,NULL ,0 ,1 , +"write plock debugging to log file. Note: resulting log file can take enormous space." ); + set_opt_default(plock_rate_limit_ind, "plock_rate_limit", 'l', req_arg_int, 0, NULL, 0, 1,
Signature · 1 line
2.31.1
PATCH 4/8 dlm_controld: move processing of saved messages to plock level
In reply to Alexander AringAd the loglevel is for save plock messages during corosync resource membership upate. This patch will put the processing of saved messages on the same loglevel.
--- dlm_controld/plock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
dlm_controld/plock.c +2 -2
@@ -1612,7 +1612,7 @@ void process_saved_plocks(struct lockspace *ls)struct dlm_header *hd;int count =0 ; -log_dlock (ls,"process_saved_plocks begin" ); +log_plock (ls,"process_saved_plocks begin" );if (list_empty (&ls->saved_messages)) goto out;
@@ -1643,7 +1643,7 @@ void process_saved_plocks(struct lockspace *ls) count++; } out: -log_dlock (ls,"process_saved_plocks %d done" , count); +log_plock (ls,"process_saved_plocks %d done" , count); }/* locks still marked SYNCING should not go into the ckpt; the new node
Signature · 1 line
2.31.1
PATCH 5/8 dlm_controld: remove ls parameter
In reply to Alexander AringThe ls parameter in write_result() is not used, so we can remove it.
--- dlm_controld/plock.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
dlm_controld/plock.c +6 -7
@@ -684,8 +684,7 @@ static int add_waiter(struct lockspace *ls, struct resource *r,return 0 ; } -static void write_result (struct lockspace *ls,struct dlm_plock_info *in, -int rv) +static void write_result (struct dlm_plock_info *in,int rv) {int write_rv;
@@ -719,7 +718,7 @@ static void do_waiters(struct lockspace *ls, struct resource *r) rv =lock_internal (ls, r, in);if (in->nodeid == our_nodeid) -write_result (ls, in, rv); +write_result (in, rv);free (w); }
@@ -744,7 +743,7 @@ static void do_lock(struct lockspace *ls, struct dlm_plock_info *in, out:if (in->nodeid == our_nodeid && rv != -EINPROGRESS ) -write_result (ls, in, rv); +write_result (in, rv);do_waiters (ls, r);put_resource (ls, r);
@@ -768,7 +767,7 @@ static void do_unlock(struct lockspace *ls, struct dlm_plock_info *in, }if (in->nodeid == our_nodeid) -write_result (ls, in, rv); +write_result (in, rv); skip_result:do_waiters (ls, r);
@@ -787,7 +786,7 @@ static void do_get(struct lockspace *ls, struct dlm_plock_info *in,else rv =0 ; -write_result (ls, in, rv); +write_result (in, rv);put_resource (ls, r); }
@@ -830,7 +829,7 @@ static void __receive_plock(struct lockspace *ls, struct dlm_plock_info *in,log_elock (ls,"receive_plock error from %d optype %d" , from, in->optype);if (from == our_nodeid) -write_result (ls, in, -EINVAL ); +write_result (in, -EINVAL ); } }
Signature · 1 line
2.31.1
PATCH 6/8 dlm_controld: log lock/pending/waiter state changes
In reply to Alexander AringThis patch will trace lock state changes of the used dlm posix locks. In combination with the plock logfile we can see state changes over time and follow posix locks and their state.
--- dlm_controld/dlm_daemon.h | 2 +- dlm_controld/logging.c | 2 +- dlm_controld/plock.c | 124 +++++++++++++++++++++++++++++--------- 3 files changed, 97 insertions(+), 31 deletions(-)
dlm_controld/dlm_daemon.h +1 -1
@@ -220,7 +220,7 @@ EXTERN struct list_head run_ops;#define LOG_PLOCK 0x00010000#define LOG_NONE 0x00001111 -void log_level (char *name_in,uint32_t level_in,const char *fmt, ...); +void log_level (const char *name_in,uint32_t level_in,const char *fmt, ...); #define log_error(fmt, args...) log_level(NULL, LOG_ERR, fmt, ##args) #define log_debug(fmt, args...) log_level(NULL, LOG_DEBUG, fmt, ##args)
dlm_controld/logging.c +1 -1
@@ -175,7 +175,7 @@ static void log_str_to_file(FILE *fp)fflush (fp); } -void log_level (char *name_in,uint32_t level_in,const char *fmt, ...) +void log_level (const char *name_in,uint32_t level_in,const char *fmt, ...) {va_list ap;char name[NAME_ID_SIZE +2 ];
dlm_controld/plock.c +95 -29
331 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH 6/8 dlm_controld: log lock/pending/waiter state changes
Hi,
Quoted 72 lines · Alexander Aring
This patch will trace lock state changes of the used dlm posix locks. In combination with the plock logfile we can see state changes over time and follow posix locks and their state.
--- dlm_controld/dlm_daemon.h | 2 +- dlm_controld/logging.c | 2 +- dlm_controld/plock.c | 124 +++++++++++++++++++++++++++++--------- 3 files changed, 97 insertions(+), 31 deletions(-)dlm_controld/dlm_daemon.h +1
-1@@ -220,7 +220,7 @@ EXTERN struct list_head run_ops;#define LOG_PLOCK 0x00010000#define LOG_NONE 0x00001111 -void log_level (char *name_in,uint32_t level_in,const char *fmt, ...); +void log_level (const char *name_in,uint32_t level_in,const char *fmt, ...); #define log_error(fmt, args...) log_level(NULL, LOG_ERR, fmt, ##args) #define log_debug(fmt, args...) log_level(NULL, LOG_DEBUG, fmt, ##args)dlm_controld/logging.c +1
-1@@ -175,7 +175,7 @@ static void log_str_to_file(FILE *fp)fflush (fp); } -void log_level (char *name_in,uint32_t level_in,const char *fmt, ...) +void log_level (const char *name_in,uint32_t level_in,const char *fmt, ...) {va_list ap;char name[NAME_ID_SIZE +2 ];dlm_controld/plock.c +28
-0@@ -208,6 +208,62 @@ static uint64_t dt_usec(struct timeval *start, struct timeval *stop)return dt; } +static void plock_print_lock_add_state (const struct lockspace *ls, +const struct lock_waiter *w, +const char *state) +{ +log_dlock (ls,"state: add %s %llx %llx-%llx %d/%u/%llx" , + state, + (unsigned long long )w->info.number, + (unsigned long long )w->info.start, + (unsigned long long )w->info.end, + w->info.nodeid, w->info.pid, + (unsigned long long )w->info.owner); +} + +static void plock_print_lock_clear_state (const struct lockspace *ls, +const struct lock_waiter *w, +const char *state) +{ +log_dlock (ls,"state: clear %s %llx %llx-%llx %d/%u/%llx" , + state, + (unsigned long long )w->info.number, + (unsigned long long )w->info.start, + (unsigned long long )w->info.end, + w->info.nodeid, w->info.pid, + (unsigned long long )w->info.owner); +} + +#define plock_print_add_waiter (ls, w) \ + plock_print_lock_add_state(ls, w, "waiter")
dlm_controld/plock.c static uint64_t dt_usec(struct timeval *start, struct timeval *stop) · line 248
Quoted 10 lines
dlm_controld/plock.c +10
-0+#define plock_print_clear_waiter (ls, w) \ + plock_print_lock_clear_state(ls, w, "waiter") + +#define plock_print_add_pending (ls, w) \ + plock_print_lock_add_state(ls, w, "pending") +#define plock_print_clear_pending (ls, w) \ + plock_print_lock_clear_state(ls, w, "pending") + +static void plock_print_add_plock (const struct lockspace *ls, +const struct posix_lock *plock)
changes *plock to *po, because it's commonly used as *po in other parts of the code for a struct posix_lock...
dlm_controld/plock.c static uint64_t dt_usec(struct timeval *start, struct timeval *stop) · line 250
Quoted 2 lines
dlm_controld/plock.c +2
-0+{ + log_dlock(ls, "state: add plock NA %llx-%llx %d/%u/%llx",
removed this NA stuff, there is one attribute which plock doesn't have but waiter has and I did this as placeholder... it's removed in 8/8 so I drop to add it.
Quoted 5 lines
dlm_controld/plock.c +5
-0+ (unsigned long long )plock->start, + (unsigned long long )plock->end, + plock->nodeid, plock->pid, + (unsigned long long)plock->owner); +}
dlm_controld/plock.c static uint64_t dt_usec(struct timeval *start, struct timeval *stop) · line 265
Quoted 10 lines
dlm_controld/plock.c +10
-0+ +static void plock_print_del_plock (const struct lockspace *ls, +const struct posix_lock *plock) +{ +log_dlock (ls,"state: del plock NA %llx-%llx %d/%u/%llx" , + (unsigned long long )plock->start, + (unsigned long long )plock->end, + plock->nodeid, plock->pid, + (unsigned long long )plock->owner); +}
same here.
- Alex
PATCH 7/8 dlm_controld: constify timeval of dt_usec()
In reply to Alexander AringThose parameters are only used read only. We don't change any data where those pointers point to.
--- dlm_controld/plock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
dlm_controld/plock.c +1 -1
@@ -198,7 +198,7 @@ static unsigned long time_diff_ms(struct timeval *begin, struct timeval *end)return (result.tv_sec *1000 ) + (result.tv_usec /1000 ); } -static uint64_t dt_usec (struct timeval *start,struct timeval *stop) +static uint64_t dt_usec (const struct timeval *start,const struct timeval *stop) {uint64_t dt;
Signature · 1 line
2.31.1
PATCH 8/8 dlm_controld: add time diff for state time intervals
In reply to Alexander AringThis patch adds functionality to see how long a posix lock is alive or is in waiting or pending state. It can be used to filter out interesting locks which are stuck in e.g. waiting state to know that a user space process probably has contention on it. The logging information will printout additional lock information to do more search and find to get more information about it's corosync or kernel communication.
--- dlm_controld/plock.c | 48 ++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 15 deletions(-)
dlm_controld/plock.c +33 -15
@@ -72,6 +72,7 @@ struct resource {struct posix_lock {struct list_head list;/* resource locks or waiters list */ +struct timeval list_time;uint32_t pid;uint64_t owner;uint64_t start;
@@ -83,6 +84,7 @@ struct posix_lock {struct lock_waiter {struct list_head list; +struct timeval list_time;uint32_t flags;struct dlm_plock_info info; };
@@ -209,9 +211,11 @@ static uint64_t dt_usec(const struct timeval *start, const struct timeval *stop) }static void plock_print_lock_add_state (const struct lockspace *ls, -const struct lock_waiter *w, +struct lock_waiter *w,const char *state) { +gettimeofday (&w->list_time,NULL ); + log_dlock(ls, "state: add %s %llx %llx-%llx %d/%u/%llx", state, (unsigned long long)w->info.number,
@@ -225,13 +229,20 @@ static void plock_print_lock_clear_state(const struct lockspace *ls,const struct lock_waiter *w, const char *state) { - log_dlock(ls, "state: clear %s %llx %llx-%llx %d/%u/%llx", + struct timeval now; +uint64_t usec; + +gettimeofday (&now,NULL ); + usec =dt_usec (&w->list_time, &now); + +log_dlock (ls,"state: clear %s %llx %llx-%llx %d/%u/%llx %.3f" , state, (unsigned long long )w->info.number, (unsigned long long )w->info.start, (unsigned long long )w->info.end, w->info.nodeid, w->info.pid, - (unsigned long long)w->info.owner); + (unsigned long long )w->info.owner, + usec *1.e-6 ); }#define plock_print_add_waiter (ls, w) \
@@ -245,23 +256,30 @@ static void plock_print_lock_clear_state(const struct lockspace *ls, plock_print_lock_clear_state(ls, w, "pending")static void plock_print_add_plock (const struct lockspace *ls, -const struct posix_lock *plock) +struct posix_lock *po) { -log_dlock (ls,"state: add plock NA %llx-%llx %d/%u/%llx" , - (unsigned long long )plock->start, - (unsigned long long )plock->end, - plock->nodeid, plock->pid, - (unsigned long long )plock->owner); +gettimeofday (&po->list_time,NULL ); +log_dlock (ls,"state: add plock %llx-%llx %d/%u/%llx %.3f" , + (unsigned long long )po->start, + (unsigned long long )po->end, + po->nodeid, po->pid, + (unsigned long long )po->owner); }static void plock_print_del_plock (const struct lockspace *ls, -const struct posix_lock *plock) +const struct posix_lock *po) { -log_dlock (ls,"state: del plock NA %llx-%llx %d/%u/%llx" , - (unsigned long long )plock->start, - (unsigned long long )plock->end, - plock->nodeid, plock->pid, - (unsigned long long )plock->owner); +struct timeval now; +uint64_t usec; + +gettimeofday (&now,NULL ); + usec =dt_usec (&po->list_time, &now); +log_dlock (ls,"state: clear plock %llx-%llx %d/%u/%llx %.3f" , + (unsigned long long )po->start, + (unsigned long long )po->end, + po->nodeid, po->pid, + (unsigned long long )po->owner, + usec *1.e-6 ); }static struct resource *rb_search_plock_resource (struct lockspace *ls,uint64_t number)
Signature · 1 line
2.31.1
PATCH 8/8 dlm_controld: add time diff for state time intervals
Hi,
Quoted 71 lines · Alexander Aring
This patch adds functionality to see how long a posix lock is alive or is in waiting or pending state. It can be used to filter out interesting locks which are stuck in e.g. waiting state to know that a user space process probably has contention on it. The logging information will printout additional lock information to do more search and find to get more information about it's corosync or kernel communication.
--- dlm_controld/plock.c | 48 ++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 15 deletions(-)dlm_controld/plock.c +14
-3@@ -72,6 +72,7 @@ struct resource {struct posix_lock {struct list_head list;/* resource locks or waiters list */ +struct timeval list_time;uint32_t pid;uint64_t owner;uint64_t start;@@ -83,6 +84,7 @@ struct posix_lock {struct lock_waiter {struct list_head list; +struct timeval list_time;uint32_t flags;struct dlm_plock_info info; };@@ -209,9 +211,11 @@ static uint64_t dt_usec(const struct timeval *start, const struct timeval *stop) }static void plock_print_lock_add_state (const struct lockspace *ls, -const struct lock_waiter *w, +struct lock_waiter *w,const char *state) { +gettimeofday (&w->list_time,NULL ); + log_dlock(ls, "state: add %s %llx %llx-%llx %d/%u/%llx", state, (unsigned long long)w->info.number,@@ -225,13 +229,20 @@ static void plock_print_lock_clear_state(const struct lockspace *ls,const struct lock_waiter *w, const char *state) { - log_dlock(ls, "state: clear %s %llx %llx-%llx %d/%u/%llx", + struct timeval now; +uint64_t usec; + +gettimeofday (&now,NULL ); + usec =dt_usec (&w->list_time, &now); + +log_dlock (ls,"state: clear %s %llx %llx-%llx %d/%u/%llx %.3f" , state, (unsigned long long )w->info.number, (unsigned long long )w->info.start, (unsigned long long )w->info.end, w->info.nodeid, w->info.pid, - (unsigned long long)w->info.owner); + (unsigned long long )w->info.owner, + usec *1.e-6 ); }#define plock_print_add_waiter (ls, w) \@@ -245,23 +256,30 @@ static void plock_print_lock_clear_state(const struct lockspace *ls, plock_print_lock_clear_state(ls, w, "pending") static void plock_print_add_plock(const struct lockspace *ls,
dlm_controld/plock.c static void plock_print_lock_clear_state(const struct lockspace *ls, · line 262
Quoted 10 lines
dlm_controld/plock.c +3
-6- const struct posix_lock *plock) + struct posix_lock *po) { -log_dlock (ls,"state: add plock NA %llx-%llx %d/%u/%llx" , - (unsigned long long )plock->start, - (unsigned long long )plock->end, - plock->nodeid, plock->pid, - (unsigned long long )plock->owner); +gettimeofday (&po->list_time,NULL ); + log_dlock(ls, "state: add plock %llx-%llx %d/%u/%llx %.3f",
removed "%.3f" for plock_print_add_plock(), it's only necessary for clear. We probably need to add some format(printf, 2, 3) gcc attribute to see such mistakes...
- Alex