xref: /openbmc/linux/include/trace/events/dlm.h (revision bb26cfd9)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM dlm
4 
5 #if !defined(_TRACE_DLM_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_DLM_H
7 
8 #include <linux/dlm.h>
9 #include <linux/dlmconstants.h>
10 #include <linux/tracepoint.h>
11 
12 #include "../../../fs/dlm/dlm_internal.h"
13 
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" })
34 
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"},				\
42 	{ DLM_LOCK_EX,		"EX"})
43 
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" })
48 
49 /* note: we begin tracing dlm_lock_start() only if ls and lkb are found */
50 TRACE_EVENT(dlm_lock_start,
51 
52 	TP_PROTO(struct dlm_ls *ls, struct dlm_lkb *lkb, void *name,
53 		 unsigned int namelen, int mode, __u32 flags),
54 
55 	TP_ARGS(ls, lkb, name, namelen, mode, flags),
56 
57 	TP_STRUCT__entry(
58 		__field(__u32, ls_id)
59 		__field(__u32, lkb_id)
60 		__field(int, mode)
61 		__field(__u32, flags)
62 		__dynamic_array(unsigned char, res_name,
63 				lkb->lkb_resource ? lkb->lkb_resource->res_length : namelen)
64 	),
65 
66 	TP_fast_assign(
67 		struct dlm_rsb *r;
68 
69 		__entry->ls_id = ls->ls_global_id;
70 		__entry->lkb_id = lkb->lkb_id;
71 		__entry->mode = mode;
72 		__entry->flags = flags;
73 
74 		r = lkb->lkb_resource;
75 		if (r)
76 			memcpy(__get_dynamic_array(res_name), r->res_name,
77 			       __get_dynamic_array_len(res_name));
78 		else if (name)
79 			memcpy(__get_dynamic_array(res_name), name,
80 			       __get_dynamic_array_len(res_name));
81 	),
82 
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)))
89 
90 );
91 
92 TRACE_EVENT(dlm_lock_end,
93 
94 	TP_PROTO(struct dlm_ls *ls, struct dlm_lkb *lkb, void *name,
95 		 unsigned int namelen, int mode, __u32 flags, int error),
96 
97 	TP_ARGS(ls, lkb, name, namelen, mode, flags, error),
98 
99 	TP_STRUCT__entry(
100 		__field(__u32, ls_id)
101 		__field(__u32, lkb_id)
102 		__field(int, mode)
103 		__field(__u32, flags)
104 		__field(int, error)
105 		__dynamic_array(unsigned char, res_name,
106 				lkb->lkb_resource ? lkb->lkb_resource->res_length : namelen)
107 	),
108 
109 	TP_fast_assign(
110 		struct dlm_rsb *r;
111 
112 		__entry->ls_id = ls->ls_global_id;
113 		__entry->lkb_id = lkb->lkb_id;
114 		__entry->mode = mode;
115 		__entry->flags = flags;
116 
117 		r = lkb->lkb_resource;
118 		if (r)
119 			memcpy(__get_dynamic_array(res_name), r->res_name,
120 			       __get_dynamic_array_len(res_name));
121 		else if (name)
122 			memcpy(__get_dynamic_array(res_name), name,
123 			       __get_dynamic_array_len(res_name));
124 
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.
128 		 */
129 		if (error == -EAGAIN || error == -EDEADLK)
130 			__entry->error = 0;
131 		else
132 			__entry->error = error;
133 
134 	),
135 
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)))
142 
143 );
144 
145 TRACE_EVENT(dlm_bast,
146 
147 	TP_PROTO(struct dlm_ls *ls, struct dlm_lkb *lkb, int mode),
148 
149 	TP_ARGS(ls, lkb, mode),
150 
151 	TP_STRUCT__entry(
152 		__field(__u32, ls_id)
153 		__field(__u32, lkb_id)
154 		__field(int, mode)
155 		__dynamic_array(unsigned char, res_name,
156 				lkb->lkb_resource ? lkb->lkb_resource->res_length : 0)
157 	),
158 
159 	TP_fast_assign(
160 		struct dlm_rsb *r;
161 
162 		__entry->ls_id = ls->ls_global_id;
163 		__entry->lkb_id = lkb->lkb_id;
164 		__entry->mode = mode;
165 
166 		r = lkb->lkb_resource;
167 		if (r)
168 			memcpy(__get_dynamic_array(res_name), r->res_name,
169 			       __get_dynamic_array_len(res_name));
170 	),
171 
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)))
177 
178 );
179 
180 TRACE_EVENT(dlm_ast,
181 
182 	TP_PROTO(struct dlm_ls *ls, struct dlm_lkb *lkb),
183 
184 	TP_ARGS(ls, lkb),
185 
186 	TP_STRUCT__entry(
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)
193 	),
194 
195 	TP_fast_assign(
196 		struct dlm_rsb *r;
197 
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;
202 
203 		r = lkb->lkb_resource;
204 		if (r)
205 			memcpy(__get_dynamic_array(res_name), r->res_name,
206 			       __get_dynamic_array_len(res_name));
207 	),
208 
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)))
214 
215 );
216 
217 /* note: we begin tracing dlm_unlock_start() only if ls and lkb are found */
218 TRACE_EVENT(dlm_unlock_start,
219 
220 	TP_PROTO(struct dlm_ls *ls, struct dlm_lkb *lkb, __u32 flags),
221 
222 	TP_ARGS(ls, lkb, flags),
223 
224 	TP_STRUCT__entry(
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)
230 	),
231 
232 	TP_fast_assign(
233 		struct dlm_rsb *r;
234 
235 		__entry->ls_id = ls->ls_global_id;
236 		__entry->lkb_id = lkb->lkb_id;
237 		__entry->flags = flags;
238 
239 		r = lkb->lkb_resource;
240 		if (r)
241 			memcpy(__get_dynamic_array(res_name), r->res_name,
242 			       __get_dynamic_array_len(res_name));
243 	),
244 
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)))
250 
251 );
252 
253 TRACE_EVENT(dlm_unlock_end,
254 
255 	TP_PROTO(struct dlm_ls *ls, struct dlm_lkb *lkb, __u32 flags,
256 		 int error),
257 
258 	TP_ARGS(ls, lkb, flags, error),
259 
260 	TP_STRUCT__entry(
261 		__field(__u32, ls_id)
262 		__field(__u32, lkb_id)
263 		__field(__u32, flags)
264 		__field(int, error)
265 		__dynamic_array(unsigned char, res_name,
266 				lkb->lkb_resource ? lkb->lkb_resource->res_length : 0)
267 	),
268 
269 	TP_fast_assign(
270 		struct dlm_rsb *r;
271 
272 		__entry->ls_id = ls->ls_global_id;
273 		__entry->lkb_id = lkb->lkb_id;
274 		__entry->flags = flags;
275 		__entry->error = error;
276 
277 		r = lkb->lkb_resource;
278 		if (r)
279 			memcpy(__get_dynamic_array(res_name), r->res_name,
280 			       __get_dynamic_array_len(res_name));
281 	),
282 
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)))
288 
289 );
290 
291 TRACE_EVENT(dlm_send,
292 
293 	TP_PROTO(int nodeid, int ret),
294 
295 	TP_ARGS(nodeid, ret),
296 
297 	TP_STRUCT__entry(
298 		__field(int, nodeid)
299 		__field(int, ret)
300 	),
301 
302 	TP_fast_assign(
303 		__entry->nodeid = nodeid;
304 		__entry->ret = ret;
305 	),
306 
307 	TP_printk("nodeid=%d ret=%d", __entry->nodeid, __entry->ret)
308 
309 );
310 
311 TRACE_EVENT(dlm_recv,
312 
313 	TP_PROTO(int nodeid, int ret),
314 
315 	TP_ARGS(nodeid, ret),
316 
317 	TP_STRUCT__entry(
318 		__field(int, nodeid)
319 		__field(int, ret)
320 	),
321 
322 	TP_fast_assign(
323 		__entry->nodeid = nodeid;
324 		__entry->ret = ret;
325 	),
326 
327 	TP_printk("nodeid=%d ret=%d", __entry->nodeid, __entry->ret)
328 
329 );
330 
331 #endif /* if !defined(_TRACE_DLM_H) || defined(TRACE_HEADER_MULTI_READ) */
332 
333 /* This part must be outside protection */
334 #include <trace/define_trace.h>
335