xref: /linux/fs/lockd/trace.h (revision 8bc7c5e525584903ea83332e18a2118ed3b1985e)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM lockd
4 
5 #if !defined(_TRACE_LOCKD_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_LOCKD_H
7 
8 #include <linux/tracepoint.h>
9 #include <linux/crc32.h>
10 #include <linux/nfs.h>
11 #include <linux/lockd/lockd.h>
12 
13 #ifdef CONFIG_LOCKD_V4
14 #define NLM_STATUS_LIST					\
15 	nlm_status_code(LCK_GRANTED)			\
16 	nlm_status_code(LCK_DENIED)			\
17 	nlm_status_code(LCK_DENIED_NOLOCKS)		\
18 	nlm_status_code(LCK_BLOCKED)			\
19 	nlm_status_code(LCK_DENIED_GRACE_PERIOD)	\
20 	nlm_status_code(DEADLCK)			\
21 	nlm_status_code(ROFS)				\
22 	nlm_status_code(STALE_FH)			\
23 	nlm_status_code(FBIG)				\
24 	nlm_status_code_end(FAILED)
25 #else
26 #define NLM_STATUS_LIST					\
27 	nlm_status_code(LCK_GRANTED)			\
28 	nlm_status_code(LCK_DENIED)			\
29 	nlm_status_code(LCK_DENIED_NOLOCKS)		\
30 	nlm_status_code(LCK_BLOCKED)			\
31 	nlm_status_code_end(LCK_DENIED_GRACE_PERIOD)
32 #endif
33 
34 #undef nlm_status_code
35 #undef nlm_status_code_end
36 #define nlm_status_code(x)	TRACE_DEFINE_ENUM(NLM_##x);
37 #define nlm_status_code_end(x)	TRACE_DEFINE_ENUM(NLM_##x);
38 
39 NLM_STATUS_LIST
40 
41 #undef nlm_status_code
42 #undef nlm_status_code_end
43 #define nlm_status_code(x)	{ NLM_##x, #x },
44 #define nlm_status_code_end(x)	{ NLM_##x, #x }
45 
46 #define show_nlm_status(x)	__print_symbolic(x, NLM_STATUS_LIST)
47 
48 DECLARE_EVENT_CLASS(nlmclnt_lock_event,
49 		TP_PROTO(
50 			const struct nlm_lock *lock,
51 			const struct sockaddr *addr,
52 			unsigned int addrlen,
53 			__be32 status
54 		),
55 
56 		TP_ARGS(lock, addr, addrlen, status),
57 
58 		TP_STRUCT__entry(
59 			__field(u32, oh)
60 			__field(u32, svid)
61 			__field(u32, fh)
62 			__field(unsigned long, status)
63 			__field(u64, start)
64 			__field(u64, len)
65 			__sockaddr(addr, addrlen)
66 		),
67 
68 		TP_fast_assign(
69 			__entry->oh = ~crc32_le(0xffffffff, lock->oh.data, lock->oh.len);
70 			__entry->svid = lock->svid;
71 			__entry->fh = nfs_fhandle_hash(&lock->fh);
72 			__entry->start = lock->lock_start;
73 			__entry->len = lock->lock_len;
74 			__entry->status = be32_to_cpu(status);
75 			__assign_sockaddr(addr, addr, addrlen);
76 		),
77 
78 		TP_printk(
79 			"addr=%pISpc oh=0x%08x svid=0x%08x fh=0x%08x start=%llu len=%llu status=%s",
80 			__get_sockaddr(addr), __entry->oh, __entry->svid,
81 			__entry->fh, __entry->start, __entry->len,
82 			show_nlm_status(__entry->status)
83 		)
84 );
85 
86 #define DEFINE_NLMCLNT_EVENT(name)				\
87 	DEFINE_EVENT(nlmclnt_lock_event, name,			\
88 			TP_PROTO(				\
89 				const struct nlm_lock *lock,	\
90 				const struct sockaddr *addr,	\
91 				unsigned int addrlen,		\
92 				__be32	status			\
93 			),					\
94 			TP_ARGS(lock, addr, addrlen, status))
95 
96 DEFINE_NLMCLNT_EVENT(nlmclnt_test);
97 DEFINE_NLMCLNT_EVENT(nlmclnt_lock);
98 DEFINE_NLMCLNT_EVENT(nlmclnt_unlock);
99 DEFINE_NLMCLNT_EVENT(nlmclnt_grant);
100 
101 #endif /* _TRACE_LOCKD_H */
102 
103 #undef TRACE_INCLUDE_PATH
104 #define TRACE_INCLUDE_PATH .
105 #define TRACE_INCLUDE_FILE trace
106 #include <trace/define_trace.h>
107