[Cluster-devel] [PATCH dlm-tool 6/8] dlm_controld: log lock/pending/waiter state changes

Alexander Aring aahringo at redhat.com
Mon Jan 30 21:26:33 UTC 2023


Hi,

On Mon, Jan 30, 2023 at 2:24 PM Alexander Aring <aahringo at redhat.com> wrote:
>
> 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(-)
>
> diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h
> index c74f684a..9bf3f621 100644
> --- a/dlm_controld/dlm_daemon.h
> +++ b/dlm_controld/dlm_daemon.h
> @@ -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)
> diff --git a/dlm_controld/logging.c b/dlm_controld/logging.c
> index 83de2da4..e71fe52c 100644
> --- a/dlm_controld/logging.c
> +++ b/dlm_controld/logging.c
> @@ -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];
> diff --git a/dlm_controld/plock.c b/dlm_controld/plock.c
> index 462c9212..77c043fd 100644
> --- a/dlm_controld/plock.c
> +++ b/dlm_controld/plock.c
> @@ -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")
> +#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...

> +{
> +       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.

> +                 (unsigned long long)plock->start,
> +                 (unsigned long long)plock->end,
> +                 plock->nodeid, plock->pid,
> +                 (unsigned long long)plock->owner);
> +}
> +
> +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



More information about the Cluster-devel mailing list