Skip to contentSkip to conversation

fs: dlm: add lkb attach resource trace

PATCH New Alexander Aring 1 participant 1 message Jan 17, 2022

Subsystems (2)
lore
Share & tools
lore

Alexander Aring

author maintainer
#0 lore raw

PATCH 1/1 fs: dlm: add lkb attach resource trace

This patch adds a tracpoint for dlm_attach() which indicates the local lkb is attached to a global resource. This becomes useful to make a connection between a local ls_id and lkb_id (from e.g. dlm_lock_start tracepoint) to a global lock reference which is the same cluster-wide.

The trace printk will look like the following output:

ls_id=3841231384, lkb_id=23, res_name=202020202020203520202020202020202020343531356462, res_length=24

Most time the resource name using ASCII codec which allows us to print it out. However this is not required. The printout used here will represent the resource name as a bytewise hexademical string.

---
 fs/dlm/lock.c              |  1 +
 include/trace/events/dlm.h | 28 ++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)
fs/dlm/lock.c +1 -0
index bdb51d209ba2..f6ad96de4f3b 100644
@@ -1169,6 +1169,7 @@ static void kill_rsb(struct kref *kref)
 static void attach_lkb(struct dlm_rsb *r, struct dlm_lkb *lkb)
 {
 	hold_rsb(r);
+	trace_dlm_attach_lkb(lkb, r);
 	lkb->lkb_resource = r;
 }
 
include/trace/events/dlm.h +28 -0
index 32088c603244..53b81faa5877 100644
@@ -214,6 +214,34 @@ TRACE_EVENT(dlm_unlock_end,
 
 );
 
+TRACE_EVENT(dlm_attach_lkb,
+
+	TP_PROTO(const struct dlm_lkb *lkb, const struct dlm_rsb *r),
+
+	TP_ARGS(lkb, r),
+
+	TP_STRUCT__entry(
+		__field(__u32, ls_id)
+		__field(__u32, lkb_id)
+		__field(int, res_length)
+		__dynamic_array(unsigned char, res_name, r->res_length)
+	),
+
+	TP_fast_assign(
+		__entry->ls_id = r->res_ls->ls_global_id;
+		__entry->lkb_id = lkb->lkb_id;
+		__entry->res_length = r->res_length;
+		memcpy(__get_dynamic_array(res_name), r->res_name,
+		       __get_dynamic_array_len(res_name));
+	),
+
+	TP_printk("ls_id=%u, lkb_id=%x, res_name=%s, res_length=%d",
+		  __entry->ls_id, __entry->lkb_id,
+		  __print_hex_str(__get_dynamic_array(res_name),
+				  __get_dynamic_array_len(res_name)),
+		  __entry->res_length)
+);
+
 TRACE_EVENT(dlm_send,
 
 	TP_PROTO(int nodeid, int ret),
Signature · 1 line
2.31.1