1 /* SPDX-License-Identifier: GPL-2.0 */
3 #define TRACE_SYSTEM dlm
5 #if !defined(_TRACE_DLM_H) || defined(TRACE_HEADER_MULTI_READ)
9 #include <linux/dlmconstants.h>
10 #include <linux/tracepoint.h>
12 #include "../../../fs/dlm/dlm_internal.h"
14 #define show_lock_flags(flags) __print_flags(flags, "|", \
15 { DLM_LKF_NOQUEUE, "NOQUEUE" }, \
16 { DLM_LKF_CANCEL, "CANCEL" }, \
17 { DLM_LKF_CONVERT, "CONVERT" }, \
18 { DLM_LKF_VALBLK, "VALBLK" }, \
19 { DLM_LKF_QUECVT, "QUECVT" }, \
20 { DLM_LKF_IVVALBLK, "IVVALBLK" }, \
21 { DLM_LKF_CONVDEADLK, "CONVDEADLK" }, \
22 { DLM_LKF_PERSISTENT, "PERSISTENT" }, \
23 { DLM_LKF_NODLCKWT, "NODLCKWT" }, \
24 { DLM_LKF_NODLCKBLK, "NODLCKBLK" }, \
25 { DLM_LKF_EXPEDITE, "EXPEDITE" }, \
26 { DLM_LKF_NOQUEUEBAST, "NOQUEUEBAST" }, \
27 { DLM_LKF_HEADQUE, "HEADQUE" }, \
28 { DLM_LKF_NOORDER, "NOORDER" }, \
29 { DLM_LKF_ORPHAN, "ORPHAN" }, \
30 { DLM_LKF_ALTPR, "ALTPR" }, \
31 { DLM_LKF_ALTCW, "ALTCW" }, \
32 { DLM_LKF_FORCEUNLOCK, "FORCEUNLOCK" }, \
33 { DLM_LKF_TIMEOUT, "TIMEOUT" })
35 #define show_lock_mode(mode) __print_symbolic(mode, \
36 { DLM_LOCK_IV, "IV"}, \
37 { DLM_LOCK_NL, "NL"}, \
38 { DLM_LOCK_CR, "CR"}, \
39 { DLM_LOCK_CW, "CW"}, \
40 { DLM_LOCK_PR, "PR"}, \
41 { DLM_LOCK_PW, "PW"}, \
44 #define show_dlm_sb_flags(flags) __print_flags(flags, "|", \
45 { DLM_SBF_DEMOTED, "DEMOTED" }, \
46 { DLM_SBF_VALNOTVALID, "VALNOTVALID" }, \
47 { DLM_SBF_ALTMODE, "ALTMODE" })
49 /* note: we begin tracing dlm_lock_start() only if ls and lkb are found */
50 TRACE_EVENT(dlm_lock_start,
52 TP_PROTO(struct dlm_ls *ls, struct dlm_lkb *lkb, void *name,
53 unsigned int namelen, int mode, __u32 flags),
55 TP_ARGS(ls, lkb, name, namelen, mode, flags),
59 __field(__u32, lkb_id)
62 __dynamic_array(unsigned char, res_name,
63 lkb->lkb_resource ? lkb->lkb_resource->res_length : namelen)
69 __entry->ls_id = ls->ls_global_id;
70 __entry->lkb_id = lkb->lkb_id;
72 __entry->flags = flags;
74 r = lkb->lkb_resource;
76 memcpy(__get_dynamic_array(res_name), r->res_name,
77 __get_dynamic_array_len(res_name));
79 memcpy(__get_dynamic_array(res_name), name,
80 __get_dynamic_array_len(res_name));
83 TP_printk("ls_id=%u lkb_id=%x mode=%s flags=%s res_name=%s",
84 __entry->ls_id, __entry->lkb_id,
85 show_lock_mode(__entry->mode),
86 show_lock_flags(__entry->flags),
87 __print_hex_str(__get_dynamic_array(res_name),
88 __get_dynamic_array_len(res_name)))
92 TRACE_EVENT(dlm_lock_end,
94 TP_PROTO(struct dlm_ls *ls, struct dlm_lkb *lkb, void *name,
95 unsigned int namelen, int mode, __u32 flags, int error),
97 TP_ARGS(ls, lkb, name, namelen, mode, flags, error),
100 __field(__u32, ls_id)
101 __field(__u32, lkb_id)
103 __field(__u32, flags)
105 __dynamic_array(unsigned char, res_name,
106 lkb->lkb_resource ? lkb->lkb_resource->res_length : namelen)
112 __entry->ls_id = ls->ls_global_id;
113 __entry->lkb_id = lkb->lkb_id;
114 __entry->mode = mode;
115 __entry->flags = flags;
117 r = lkb->lkb_resource;
119 memcpy(__get_dynamic_array(res_name), r->res_name,
120 __get_dynamic_array_len(res_name));
122 memcpy(__get_dynamic_array(res_name), name,
123 __get_dynamic_array_len(res_name));
125 /* return value will be zeroed in those cases by dlm_lock()
126 * we do it here again to not introduce more overhead if
127 * trace isn't running and error reflects the return value.
129 if (error == -EAGAIN || error == -EDEADLK)
132 __entry->error = error;
136 TP_printk("ls_id=%u lkb_id=%x mode=%s flags=%s error=%d res_name=%s",
137 __entry->ls_id, __entry->lkb_id,
138 show_lock_mode(__entry->mode),
139 show_lock_flags(__entry->flags), __entry->error,
140 __print_hex_str(__get_dynamic_array(res_name),
141 __get_dynamic_array_len(res_name)))
145 TRACE_EVENT(dlm_bast,
147 TP_PROTO(struct dlm_ls *ls, struct dlm_lkb *lkb, int mode),
149 TP_ARGS(ls, lkb, mode),
152 __field(__u32, ls_id)
153 __field(__u32, lkb_id)
155 __dynamic_array(unsigned char, res_name,
156 lkb->lkb_resource ? lkb->lkb_resource->res_length : 0)
162 __entry->ls_id = ls->ls_global_id;
163 __entry->lkb_id = lkb->lkb_id;
164 __entry->mode = mode;
166 r = lkb->lkb_resource;
168 memcpy(__get_dynamic_array(res_name), r->res_name,
169 __get_dynamic_array_len(res_name));
172 TP_printk("ls_id=%u lkb_id=%x mode=%s res_name=%s",
173 __entry->ls_id, __entry->lkb_id,
174 show_lock_mode(__entry->mode),
175 __print_hex_str(__get_dynamic_array(res_name),
176 __get_dynamic_array_len(res_name)))
182 TP_PROTO(struct dlm_ls *ls, struct dlm_lkb *lkb),
187 __field(__u32, ls_id)
188 __field(__u32, lkb_id)
189 __field(u8, sb_flags)
190 __field(int, sb_status)
191 __dynamic_array(unsigned char, res_name,
192 lkb->lkb_resource ? lkb->lkb_resource->res_length : 0)
198 __entry->ls_id = ls->ls_global_id;
199 __entry->lkb_id = lkb->lkb_id;
200 __entry->sb_flags = lkb->lkb_lksb->sb_flags;
201 __entry->sb_status = lkb->lkb_lksb->sb_status;
203 r = lkb->lkb_resource;
205 memcpy(__get_dynamic_array(res_name), r->res_name,
206 __get_dynamic_array_len(res_name));
209 TP_printk("ls_id=%u lkb_id=%x sb_flags=%s sb_status=%d res_name=%s",
210 __entry->ls_id, __entry->lkb_id,
211 show_dlm_sb_flags(__entry->sb_flags), __entry->sb_status,
212 __print_hex_str(__get_dynamic_array(res_name),
213 __get_dynamic_array_len(res_name)))
217 /* note: we begin tracing dlm_unlock_start() only if ls and lkb are found */
218 TRACE_EVENT(dlm_unlock_start,
220 TP_PROTO(struct dlm_ls *ls, struct dlm_lkb *lkb, __u32 flags),
222 TP_ARGS(ls, lkb, flags),
225 __field(__u32, ls_id)
226 __field(__u32, lkb_id)
227 __field(__u32, flags)
228 __dynamic_array(unsigned char, res_name,
229 lkb->lkb_resource ? lkb->lkb_resource->res_length : 0)
235 __entry->ls_id = ls->ls_global_id;
236 __entry->lkb_id = lkb->lkb_id;
237 __entry->flags = flags;
239 r = lkb->lkb_resource;
241 memcpy(__get_dynamic_array(res_name), r->res_name,
242 __get_dynamic_array_len(res_name));
245 TP_printk("ls_id=%u lkb_id=%x flags=%s res_name=%s",
246 __entry->ls_id, __entry->lkb_id,
247 show_lock_flags(__entry->flags),
248 __print_hex_str(__get_dynamic_array(res_name),
249 __get_dynamic_array_len(res_name)))
253 TRACE_EVENT(dlm_unlock_end,
255 TP_PROTO(struct dlm_ls *ls, struct dlm_lkb *lkb, __u32 flags,
258 TP_ARGS(ls, lkb, flags, error),
261 __field(__u32, ls_id)
262 __field(__u32, lkb_id)
263 __field(__u32, flags)
265 __dynamic_array(unsigned char, res_name,
266 lkb->lkb_resource ? lkb->lkb_resource->res_length : 0)
272 __entry->ls_id = ls->ls_global_id;
273 __entry->lkb_id = lkb->lkb_id;
274 __entry->flags = flags;
275 __entry->error = error;
277 r = lkb->lkb_resource;
279 memcpy(__get_dynamic_array(res_name), r->res_name,
280 __get_dynamic_array_len(res_name));
283 TP_printk("ls_id=%u lkb_id=%x flags=%s error=%d res_name=%s",
284 __entry->ls_id, __entry->lkb_id,
285 show_lock_flags(__entry->flags), __entry->error,
286 __print_hex_str(__get_dynamic_array(res_name),
287 __get_dynamic_array_len(res_name)))
291 TRACE_EVENT(dlm_send,
293 TP_PROTO(int nodeid, int ret),
295 TP_ARGS(nodeid, ret),
303 __entry->nodeid = nodeid;
307 TP_printk("nodeid=%d ret=%d", __entry->nodeid, __entry->ret)
311 TRACE_EVENT(dlm_recv,
313 TP_PROTO(int nodeid, int ret),
315 TP_ARGS(nodeid, ret),
323 __entry->nodeid = nodeid;
327 TP_printk("nodeid=%d ret=%d", __entry->nodeid, __entry->ret)
331 #endif /* if !defined(_TRACE_DLM_H) || defined(TRACE_HEADER_MULTI_READ) */
333 /* This part must be outside protection */
334 #include <trace/define_trace.h>