Commit 5d92a30e authored by Alexander Aring's avatar Alexander Aring Committed by David Teigland

fs: dlm: add resource name to tracepoints

This patch adds the resource name to dlm tracepoints.  The name
usually comes through the lkb_resource, but in some cases a resource
may not yet be associated with an lkb, in which case the name and
namelen parameters are used.

It should be okay to access the lkb_resource and the res_name field at
the time when the tracepoint is invoked. The resource is assigned to a
lkb and it's reference is being held during the tracepoint call. During
this time the resource cannot be freed. Also a lkb will never switch
its assigned resource. The name of a dlm_rsb is assigned at creation
time and should never be changed during runtime as well.

The TP_printk() call uses always a hexadecimal string array
representation for the resource name (which is not necessarily ascii.)
Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
parent 0c4c516f
...@@ -3472,7 +3472,7 @@ int dlm_lock(dlm_lockspace_t *lockspace, ...@@ -3472,7 +3472,7 @@ int dlm_lock(dlm_lockspace_t *lockspace,
if (error) if (error)
goto out; goto out;
trace_dlm_lock_start(ls, lkb, mode, flags); trace_dlm_lock_start(ls, lkb, name, namelen, mode, flags);
error = set_lock_args(mode, lksb, flags, namelen, 0, ast, error = set_lock_args(mode, lksb, flags, namelen, 0, ast,
astarg, bast, &args); astarg, bast, &args);
...@@ -3487,7 +3487,7 @@ int dlm_lock(dlm_lockspace_t *lockspace, ...@@ -3487,7 +3487,7 @@ int dlm_lock(dlm_lockspace_t *lockspace,
if (error == -EINPROGRESS) if (error == -EINPROGRESS)
error = 0; error = 0;
out_put: out_put:
trace_dlm_lock_end(ls, lkb, mode, flags, error); trace_dlm_lock_end(ls, lkb, name, namelen, mode, flags, error);
if (convert || error) if (convert || error)
__put_lkb(ls, lkb); __put_lkb(ls, lkb);
......
...@@ -49,38 +49,52 @@ ...@@ -49,38 +49,52 @@
/* note: we begin tracing dlm_lock_start() only if ls and lkb are found */ /* note: we begin tracing dlm_lock_start() only if ls and lkb are found */
TRACE_EVENT(dlm_lock_start, TRACE_EVENT(dlm_lock_start,
TP_PROTO(struct dlm_ls *ls, struct dlm_lkb *lkb, int mode, TP_PROTO(struct dlm_ls *ls, struct dlm_lkb *lkb, void *name,
__u32 flags), unsigned int namelen, int mode, __u32 flags),
TP_ARGS(ls, lkb, mode, flags), TP_ARGS(ls, lkb, name, namelen, mode, flags),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(__u32, ls_id) __field(__u32, ls_id)
__field(__u32, lkb_id) __field(__u32, lkb_id)
__field(int, mode) __field(int, mode)
__field(__u32, flags) __field(__u32, flags)
__dynamic_array(unsigned char, res_name,
lkb->lkb_resource ? lkb->lkb_resource->res_length : namelen)
), ),
TP_fast_assign( TP_fast_assign(
struct dlm_rsb *r;
__entry->ls_id = ls->ls_global_id; __entry->ls_id = ls->ls_global_id;
__entry->lkb_id = lkb->lkb_id; __entry->lkb_id = lkb->lkb_id;
__entry->mode = mode; __entry->mode = mode;
__entry->flags = flags; __entry->flags = flags;
r = lkb->lkb_resource;
if (r)
memcpy(__get_dynamic_array(res_name), r->res_name,
__get_dynamic_array_len(res_name));
else if (name)
memcpy(__get_dynamic_array(res_name), name,
__get_dynamic_array_len(res_name));
), ),
TP_printk("ls_id=%u lkb_id=%x mode=%s flags=%s", TP_printk("ls_id=%u lkb_id=%x mode=%s flags=%s res_name=%s",
__entry->ls_id, __entry->lkb_id, __entry->ls_id, __entry->lkb_id,
show_lock_mode(__entry->mode), show_lock_mode(__entry->mode),
show_lock_flags(__entry->flags)) show_lock_flags(__entry->flags),
__print_hex_str(__get_dynamic_array(res_name),
__get_dynamic_array_len(res_name)))
); );
TRACE_EVENT(dlm_lock_end, TRACE_EVENT(dlm_lock_end,
TP_PROTO(struct dlm_ls *ls, struct dlm_lkb *lkb, int mode, __u32 flags, TP_PROTO(struct dlm_ls *ls, struct dlm_lkb *lkb, void *name,
int error), unsigned int namelen, int mode, __u32 flags, int error),
TP_ARGS(ls, lkb, mode, flags, error), TP_ARGS(ls, lkb, name, namelen, mode, flags, error),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(__u32, ls_id) __field(__u32, ls_id)
...@@ -88,14 +102,26 @@ TRACE_EVENT(dlm_lock_end, ...@@ -88,14 +102,26 @@ TRACE_EVENT(dlm_lock_end,
__field(int, mode) __field(int, mode)
__field(__u32, flags) __field(__u32, flags)
__field(int, error) __field(int, error)
__dynamic_array(unsigned char, res_name,
lkb->lkb_resource ? lkb->lkb_resource->res_length : namelen)
), ),
TP_fast_assign( TP_fast_assign(
struct dlm_rsb *r;
__entry->ls_id = ls->ls_global_id; __entry->ls_id = ls->ls_global_id;
__entry->lkb_id = lkb->lkb_id; __entry->lkb_id = lkb->lkb_id;
__entry->mode = mode; __entry->mode = mode;
__entry->flags = flags; __entry->flags = flags;
r = lkb->lkb_resource;
if (r)
memcpy(__get_dynamic_array(res_name), r->res_name,
__get_dynamic_array_len(res_name));
else if (name)
memcpy(__get_dynamic_array(res_name), name,
__get_dynamic_array_len(res_name));
/* return value will be zeroed in those cases by dlm_lock() /* return value will be zeroed in those cases by dlm_lock()
* we do it here again to not introduce more overhead if * we do it here again to not introduce more overhead if
* trace isn't running and error reflects the return value. * trace isn't running and error reflects the return value.
...@@ -104,12 +130,15 @@ TRACE_EVENT(dlm_lock_end, ...@@ -104,12 +130,15 @@ TRACE_EVENT(dlm_lock_end,
__entry->error = 0; __entry->error = 0;
else else
__entry->error = error; __entry->error = error;
), ),
TP_printk("ls_id=%u lkb_id=%x mode=%s flags=%s error=%d", TP_printk("ls_id=%u lkb_id=%x mode=%s flags=%s error=%d res_name=%s",
__entry->ls_id, __entry->lkb_id, __entry->ls_id, __entry->lkb_id,
show_lock_mode(__entry->mode), show_lock_mode(__entry->mode),
show_lock_flags(__entry->flags), __entry->error) show_lock_flags(__entry->flags), __entry->error,
__print_hex_str(__get_dynamic_array(res_name),
__get_dynamic_array_len(res_name)))
); );
...@@ -123,16 +152,28 @@ TRACE_EVENT(dlm_bast, ...@@ -123,16 +152,28 @@ TRACE_EVENT(dlm_bast,
__field(__u32, ls_id) __field(__u32, ls_id)
__field(__u32, lkb_id) __field(__u32, lkb_id)
__field(int, mode) __field(int, mode)
__dynamic_array(unsigned char, res_name,
lkb->lkb_resource ? lkb->lkb_resource->res_length : 0)
), ),
TP_fast_assign( TP_fast_assign(
struct dlm_rsb *r;
__entry->ls_id = ls->ls_global_id; __entry->ls_id = ls->ls_global_id;
__entry->lkb_id = lkb->lkb_id; __entry->lkb_id = lkb->lkb_id;
__entry->mode = mode; __entry->mode = mode;
r = lkb->lkb_resource;
if (r)
memcpy(__get_dynamic_array(res_name), r->res_name,
__get_dynamic_array_len(res_name));
), ),
TP_printk("ls_id=%u lkb_id=%x mode=%s", __entry->ls_id, TP_printk("ls_id=%u lkb_id=%x mode=%s res_name=%s",
__entry->lkb_id, show_lock_mode(__entry->mode)) __entry->ls_id, __entry->lkb_id,
show_lock_mode(__entry->mode),
__print_hex_str(__get_dynamic_array(res_name),
__get_dynamic_array_len(res_name)))
); );
...@@ -147,18 +188,29 @@ TRACE_EVENT(dlm_ast, ...@@ -147,18 +188,29 @@ TRACE_EVENT(dlm_ast,
__field(__u32, lkb_id) __field(__u32, lkb_id)
__field(u8, sb_flags) __field(u8, sb_flags)
__field(int, sb_status) __field(int, sb_status)
__dynamic_array(unsigned char, res_name,
lkb->lkb_resource ? lkb->lkb_resource->res_length : 0)
), ),
TP_fast_assign( TP_fast_assign(
struct dlm_rsb *r;
__entry->ls_id = ls->ls_global_id; __entry->ls_id = ls->ls_global_id;
__entry->lkb_id = lkb->lkb_id; __entry->lkb_id = lkb->lkb_id;
__entry->sb_flags = lkb->lkb_lksb->sb_flags; __entry->sb_flags = lkb->lkb_lksb->sb_flags;
__entry->sb_status = lkb->lkb_lksb->sb_status; __entry->sb_status = lkb->lkb_lksb->sb_status;
r = lkb->lkb_resource;
if (r)
memcpy(__get_dynamic_array(res_name), r->res_name,
__get_dynamic_array_len(res_name));
), ),
TP_printk("ls_id=%u lkb_id=%x sb_flags=%s sb_status=%d", TP_printk("ls_id=%u lkb_id=%x sb_flags=%s sb_status=%d res_name=%s",
__entry->ls_id, __entry->lkb_id, __entry->ls_id, __entry->lkb_id,
show_dlm_sb_flags(__entry->sb_flags), __entry->sb_status) show_dlm_sb_flags(__entry->sb_flags), __entry->sb_status,
__print_hex_str(__get_dynamic_array(res_name),
__get_dynamic_array_len(res_name)))
); );
...@@ -173,17 +225,28 @@ TRACE_EVENT(dlm_unlock_start, ...@@ -173,17 +225,28 @@ TRACE_EVENT(dlm_unlock_start,
__field(__u32, ls_id) __field(__u32, ls_id)
__field(__u32, lkb_id) __field(__u32, lkb_id)
__field(__u32, flags) __field(__u32, flags)
__dynamic_array(unsigned char, res_name,
lkb->lkb_resource ? lkb->lkb_resource->res_length : 0)
), ),
TP_fast_assign( TP_fast_assign(
struct dlm_rsb *r;
__entry->ls_id = ls->ls_global_id; __entry->ls_id = ls->ls_global_id;
__entry->lkb_id = lkb->lkb_id; __entry->lkb_id = lkb->lkb_id;
__entry->flags = flags; __entry->flags = flags;
r = lkb->lkb_resource;
if (r)
memcpy(__get_dynamic_array(res_name), r->res_name,
__get_dynamic_array_len(res_name));
), ),
TP_printk("ls_id=%u lkb_id=%x flags=%s", TP_printk("ls_id=%u lkb_id=%x flags=%s res_name=%s",
__entry->ls_id, __entry->lkb_id, __entry->ls_id, __entry->lkb_id,
show_lock_flags(__entry->flags)) show_lock_flags(__entry->flags),
__print_hex_str(__get_dynamic_array(res_name),
__get_dynamic_array_len(res_name)))
); );
...@@ -199,18 +262,29 @@ TRACE_EVENT(dlm_unlock_end, ...@@ -199,18 +262,29 @@ TRACE_EVENT(dlm_unlock_end,
__field(__u32, lkb_id) __field(__u32, lkb_id)
__field(__u32, flags) __field(__u32, flags)
__field(int, error) __field(int, error)
__dynamic_array(unsigned char, res_name,
lkb->lkb_resource ? lkb->lkb_resource->res_length : 0)
), ),
TP_fast_assign( TP_fast_assign(
struct dlm_rsb *r;
__entry->ls_id = ls->ls_global_id; __entry->ls_id = ls->ls_global_id;
__entry->lkb_id = lkb->lkb_id; __entry->lkb_id = lkb->lkb_id;
__entry->flags = flags; __entry->flags = flags;
__entry->error = error; __entry->error = error;
r = lkb->lkb_resource;
if (r)
memcpy(__get_dynamic_array(res_name), r->res_name,
__get_dynamic_array_len(res_name));
), ),
TP_printk("ls_id=%u lkb_id=%x flags=%s error=%d", TP_printk("ls_id=%u lkb_id=%x flags=%s error=%d res_name=%s",
__entry->ls_id, __entry->lkb_id, __entry->ls_id, __entry->lkb_id,
show_lock_flags(__entry->flags), __entry->error) show_lock_flags(__entry->flags), __entry->error,
__print_hex_str(__get_dynamic_array(res_name),
__get_dynamic_array_len(res_name)))
); );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment