]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
62af4f1f JL |
2 | /* |
3 | * Events for filesystem locks | |
4 | * | |
5 | * Copyright 2013 Jeff Layton <jlayton@poochiereds.net> | |
6 | */ | |
7 | #undef TRACE_SYSTEM | |
8 | #define TRACE_SYSTEM filelock | |
9 | ||
10 | #if !defined(_TRACE_FILELOCK_H) || defined(TRACE_HEADER_MULTI_READ) | |
11 | #define _TRACE_FILELOCK_H | |
12 | ||
13 | #include <linux/tracepoint.h> | |
14 | #include <linux/fs.h> | |
15 | #include <linux/device.h> | |
16 | #include <linux/kdev_t.h> | |
17 | ||
18 | #define show_fl_flags(val) \ | |
19 | __print_flags(val, "|", \ | |
20 | { FL_POSIX, "FL_POSIX" }, \ | |
21 | { FL_FLOCK, "FL_FLOCK" }, \ | |
22 | { FL_DELEG, "FL_DELEG" }, \ | |
23 | { FL_ACCESS, "FL_ACCESS" }, \ | |
24 | { FL_EXISTS, "FL_EXISTS" }, \ | |
25 | { FL_LEASE, "FL_LEASE" }, \ | |
26 | { FL_CLOSE, "FL_CLOSE" }, \ | |
27 | { FL_SLEEP, "FL_SLEEP" }, \ | |
28 | { FL_DOWNGRADE_PENDING, "FL_DOWNGRADE_PENDING" }, \ | |
29 | { FL_UNLOCK_PENDING, "FL_UNLOCK_PENDING" }, \ | |
30 | { FL_OFDLCK, "FL_OFDLCK" }) | |
31 | ||
32 | #define show_fl_type(val) \ | |
33 | __print_symbolic(val, \ | |
34 | { F_RDLCK, "F_RDLCK" }, \ | |
35 | { F_WRLCK, "F_WRLCK" }, \ | |
36 | { F_UNLCK, "F_UNLCK" }) | |
37 | ||
1890910f JL |
38 | TRACE_EVENT(locks_get_lock_context, |
39 | TP_PROTO(struct inode *inode, int type, struct file_lock_context *ctx), | |
40 | ||
41 | TP_ARGS(inode, type, ctx), | |
42 | ||
43 | TP_STRUCT__entry( | |
44 | __field(unsigned long, i_ino) | |
45 | __field(dev_t, s_dev) | |
46 | __field(unsigned char, type) | |
47 | __field(struct file_lock_context *, ctx) | |
48 | ), | |
49 | ||
50 | TP_fast_assign( | |
51 | __entry->s_dev = inode->i_sb->s_dev; | |
52 | __entry->i_ino = inode->i_ino; | |
53 | __entry->type = type; | |
54 | __entry->ctx = ctx; | |
55 | ), | |
56 | ||
57 | TP_printk("dev=0x%x:0x%x ino=0x%lx type=%s ctx=%p", | |
58 | MAJOR(__entry->s_dev), MINOR(__entry->s_dev), | |
59 | __entry->i_ino, show_fl_type(__entry->type), __entry->ctx) | |
60 | ); | |
61 | ||
62 | DECLARE_EVENT_CLASS(filelock_lock, | |
63 | TP_PROTO(struct inode *inode, struct file_lock *fl, int ret), | |
64 | ||
65 | TP_ARGS(inode, fl, ret), | |
66 | ||
67 | TP_STRUCT__entry( | |
68 | __field(struct file_lock *, fl) | |
69 | __field(unsigned long, i_ino) | |
70 | __field(dev_t, s_dev) | |
ada5c1da | 71 | __field(struct file_lock *, fl_blocker) |
1890910f JL |
72 | __field(fl_owner_t, fl_owner) |
73 | __field(unsigned int, fl_pid) | |
74 | __field(unsigned int, fl_flags) | |
75 | __field(unsigned char, fl_type) | |
76 | __field(loff_t, fl_start) | |
77 | __field(loff_t, fl_end) | |
78 | __field(int, ret) | |
79 | ), | |
80 | ||
81 | TP_fast_assign( | |
82 | __entry->fl = fl ? fl : NULL; | |
83 | __entry->s_dev = inode->i_sb->s_dev; | |
84 | __entry->i_ino = inode->i_ino; | |
ada5c1da | 85 | __entry->fl_blocker = fl ? fl->fl_blocker : NULL; |
1890910f JL |
86 | __entry->fl_owner = fl ? fl->fl_owner : NULL; |
87 | __entry->fl_pid = fl ? fl->fl_pid : 0; | |
88 | __entry->fl_flags = fl ? fl->fl_flags : 0; | |
89 | __entry->fl_type = fl ? fl->fl_type : 0; | |
90 | __entry->fl_start = fl ? fl->fl_start : 0; | |
91 | __entry->fl_end = fl ? fl->fl_end : 0; | |
92 | __entry->ret = ret; | |
93 | ), | |
94 | ||
1ad5f100 | 95 | TP_printk("fl=%p dev=0x%x:0x%x ino=0x%lx fl_blocker=%p fl_owner=%p fl_pid=%u fl_flags=%s fl_type=%s fl_start=%lld fl_end=%lld ret=%d", |
1890910f | 96 | __entry->fl, MAJOR(__entry->s_dev), MINOR(__entry->s_dev), |
ada5c1da | 97 | __entry->i_ino, __entry->fl_blocker, __entry->fl_owner, |
1890910f JL |
98 | __entry->fl_pid, show_fl_flags(__entry->fl_flags), |
99 | show_fl_type(__entry->fl_type), | |
100 | __entry->fl_start, __entry->fl_end, __entry->ret) | |
101 | ); | |
102 | ||
103 | DEFINE_EVENT(filelock_lock, posix_lock_inode, | |
104 | TP_PROTO(struct inode *inode, struct file_lock *fl, int ret), | |
105 | TP_ARGS(inode, fl, ret)); | |
106 | ||
107 | DEFINE_EVENT(filelock_lock, fcntl_setlk, | |
108 | TP_PROTO(struct inode *inode, struct file_lock *fl, int ret), | |
109 | TP_ARGS(inode, fl, ret)); | |
110 | ||
111 | DEFINE_EVENT(filelock_lock, locks_remove_posix, | |
112 | TP_PROTO(struct inode *inode, struct file_lock *fl, int ret), | |
113 | TP_ARGS(inode, fl, ret)); | |
114 | ||
c883da31 JL |
115 | DEFINE_EVENT(filelock_lock, flock_lock_inode, |
116 | TP_PROTO(struct inode *inode, struct file_lock *fl, int ret), | |
117 | TP_ARGS(inode, fl, ret)); | |
62af4f1f | 118 | |
c883da31 | 119 | DECLARE_EVENT_CLASS(filelock_lease, |
62af4f1f JL |
120 | TP_PROTO(struct inode *inode, struct file_lock *fl), |
121 | ||
122 | TP_ARGS(inode, fl), | |
123 | ||
124 | TP_STRUCT__entry( | |
125 | __field(struct file_lock *, fl) | |
126 | __field(unsigned long, i_ino) | |
127 | __field(dev_t, s_dev) | |
ada5c1da | 128 | __field(struct file_lock *, fl_blocker) |
62af4f1f JL |
129 | __field(fl_owner_t, fl_owner) |
130 | __field(unsigned int, fl_flags) | |
131 | __field(unsigned char, fl_type) | |
132 | __field(unsigned long, fl_break_time) | |
133 | __field(unsigned long, fl_downgrade_time) | |
134 | ), | |
135 | ||
136 | TP_fast_assign( | |
0efaa7e8 | 137 | __entry->fl = fl ? fl : NULL; |
62af4f1f JL |
138 | __entry->s_dev = inode->i_sb->s_dev; |
139 | __entry->i_ino = inode->i_ino; | |
ada5c1da | 140 | __entry->fl_blocker = fl ? fl->fl_blocker : NULL; |
0efaa7e8 JL |
141 | __entry->fl_owner = fl ? fl->fl_owner : NULL; |
142 | __entry->fl_flags = fl ? fl->fl_flags : 0; | |
143 | __entry->fl_type = fl ? fl->fl_type : 0; | |
144 | __entry->fl_break_time = fl ? fl->fl_break_time : 0; | |
145 | __entry->fl_downgrade_time = fl ? fl->fl_downgrade_time : 0; | |
62af4f1f JL |
146 | ), |
147 | ||
1ad5f100 | 148 | TP_printk("fl=%p dev=0x%x:0x%x ino=0x%lx fl_blocker=%p fl_owner=%p fl_flags=%s fl_type=%s fl_break_time=%lu fl_downgrade_time=%lu", |
62af4f1f | 149 | __entry->fl, MAJOR(__entry->s_dev), MINOR(__entry->s_dev), |
ada5c1da | 150 | __entry->i_ino, __entry->fl_blocker, __entry->fl_owner, |
62af4f1f JL |
151 | show_fl_flags(__entry->fl_flags), |
152 | show_fl_type(__entry->fl_type), | |
153 | __entry->fl_break_time, __entry->fl_downgrade_time) | |
154 | ); | |
155 | ||
156 | DEFINE_EVENT(filelock_lease, break_lease_noblock, TP_PROTO(struct inode *inode, struct file_lock *fl), | |
157 | TP_ARGS(inode, fl)); | |
158 | ||
159 | DEFINE_EVENT(filelock_lease, break_lease_block, TP_PROTO(struct inode *inode, struct file_lock *fl), | |
160 | TP_ARGS(inode, fl)); | |
161 | ||
162 | DEFINE_EVENT(filelock_lease, break_lease_unblock, TP_PROTO(struct inode *inode, struct file_lock *fl), | |
163 | TP_ARGS(inode, fl)); | |
164 | ||
62af4f1f JL |
165 | DEFINE_EVENT(filelock_lease, generic_delete_lease, TP_PROTO(struct inode *inode, struct file_lock *fl), |
166 | TP_ARGS(inode, fl)); | |
167 | ||
168 | DEFINE_EVENT(filelock_lease, time_out_leases, TP_PROTO(struct inode *inode, struct file_lock *fl), | |
169 | TP_ARGS(inode, fl)); | |
170 | ||
d11797a0 JL |
171 | TRACE_EVENT(generic_add_lease, |
172 | TP_PROTO(struct inode *inode, struct file_lock *fl), | |
173 | ||
174 | TP_ARGS(inode, fl), | |
175 | ||
176 | TP_STRUCT__entry( | |
177 | __field(unsigned long, i_ino) | |
178 | __field(int, wcount) | |
6b0e4277 | 179 | __field(int, rcount) |
d11797a0 JL |
180 | __field(int, icount) |
181 | __field(dev_t, s_dev) | |
182 | __field(fl_owner_t, fl_owner) | |
183 | __field(unsigned int, fl_flags) | |
184 | __field(unsigned char, fl_type) | |
185 | ), | |
186 | ||
187 | TP_fast_assign( | |
188 | __entry->s_dev = inode->i_sb->s_dev; | |
189 | __entry->i_ino = inode->i_ino; | |
190 | __entry->wcount = atomic_read(&inode->i_writecount); | |
6b0e4277 | 191 | __entry->rcount = atomic_read(&inode->i_readcount); |
d11797a0 | 192 | __entry->icount = atomic_read(&inode->i_count); |
6b0e4277 JL |
193 | __entry->fl_owner = fl->fl_owner; |
194 | __entry->fl_flags = fl->fl_flags; | |
195 | __entry->fl_type = fl->fl_type; | |
d11797a0 JL |
196 | ), |
197 | ||
1ad5f100 | 198 | TP_printk("dev=0x%x:0x%x ino=0x%lx wcount=%d rcount=%d icount=%d fl_owner=%p fl_flags=%s fl_type=%s", |
d11797a0 | 199 | MAJOR(__entry->s_dev), MINOR(__entry->s_dev), |
6b0e4277 | 200 | __entry->i_ino, __entry->wcount, __entry->rcount, |
d11797a0 JL |
201 | __entry->icount, __entry->fl_owner, |
202 | show_fl_flags(__entry->fl_flags), | |
203 | show_fl_type(__entry->fl_type)) | |
204 | ); | |
205 | ||
d51f527f IW |
206 | TRACE_EVENT(leases_conflict, |
207 | TP_PROTO(bool conflict, struct file_lock *lease, struct file_lock *breaker), | |
208 | ||
209 | TP_ARGS(conflict, lease, breaker), | |
210 | ||
211 | TP_STRUCT__entry( | |
212 | __field(void *, lease) | |
213 | __field(void *, breaker) | |
214 | __field(unsigned int, l_fl_flags) | |
215 | __field(unsigned int, b_fl_flags) | |
216 | __field(unsigned char, l_fl_type) | |
217 | __field(unsigned char, b_fl_type) | |
218 | __field(bool, conflict) | |
219 | ), | |
220 | ||
221 | TP_fast_assign( | |
222 | __entry->lease = lease; | |
223 | __entry->l_fl_flags = lease->fl_flags; | |
224 | __entry->l_fl_type = lease->fl_type; | |
225 | __entry->breaker = breaker; | |
226 | __entry->b_fl_flags = breaker->fl_flags; | |
227 | __entry->b_fl_type = breaker->fl_type; | |
228 | __entry->conflict = conflict; | |
229 | ), | |
230 | ||
1ad5f100 | 231 | TP_printk("conflict %d: lease=%p fl_flags=%s fl_type=%s; breaker=%p fl_flags=%s fl_type=%s", |
d51f527f IW |
232 | __entry->conflict, |
233 | __entry->lease, | |
234 | show_fl_flags(__entry->l_fl_flags), | |
235 | show_fl_type(__entry->l_fl_type), | |
236 | __entry->breaker, | |
237 | show_fl_flags(__entry->b_fl_flags), | |
238 | show_fl_type(__entry->b_fl_type)) | |
239 | ); | |
240 | ||
62af4f1f JL |
241 | #endif /* _TRACE_FILELOCK_H */ |
242 | ||
243 | /* This part must be outside protection */ | |
244 | #include <trace/define_trace.h> |