1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Events for filesystem locks
5 * Copyright 2013 Jeff Layton <jlayton@poochiereds.net>
8 #define TRACE_SYSTEM filelock
10 #if !defined(_TRACE_FILELOCK_H) || defined(TRACE_HEADER_MULTI_READ)
11 #define _TRACE_FILELOCK_H
13 #include <linux/tracepoint.h>
15 #include <linux/device.h>
16 #include <linux/kdev_t.h>
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" })
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" })
38 TRACE_EVENT(locks_get_lock_context
,
39 TP_PROTO(struct inode
*inode
, int type
, struct file_lock_context
*ctx
),
41 TP_ARGS(inode
, type
, ctx
),
44 __field(unsigned long, i_ino
)
46 __field(unsigned char, type
)
47 __field(struct file_lock_context
*, ctx
)
51 __entry
->s_dev
= inode
->i_sb
->s_dev
;
52 __entry
->i_ino
= inode
->i_ino
;
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
)
62 DECLARE_EVENT_CLASS(filelock_lock
,
63 TP_PROTO(struct inode
*inode
, struct file_lock
*fl
, int ret
),
65 TP_ARGS(inode
, fl
, ret
),
68 __field(struct file_lock
*, fl
)
69 __field(unsigned long, i_ino
)
71 __field(struct file_lock
*, fl_next
)
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
)
82 __entry
->fl
= fl
? fl
: NULL
;
83 __entry
->s_dev
= inode
->i_sb
->s_dev
;
84 __entry
->i_ino
= inode
->i_ino
;
85 __entry
->fl_next
= fl
? fl
->fl_next
: NULL
;
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;
95 TP_printk("fl=0x%p dev=0x%x:0x%x ino=0x%lx fl_next=0x%p fl_owner=0x%p fl_pid=%u fl_flags=%s fl_type=%s fl_start=%lld fl_end=%lld ret=%d",
96 __entry
->fl
, MAJOR(__entry
->s_dev
), MINOR(__entry
->s_dev
),
97 __entry
->i_ino
, __entry
->fl_next
, __entry
->fl_owner
,
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
)
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
));
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
));
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
));
115 DECLARE_EVENT_CLASS(filelock_lease
,
117 TP_PROTO(struct inode
*inode
, struct file_lock
*fl
),
122 __field(struct file_lock
*, fl
)
123 __field(unsigned long, i_ino
)
124 __field(dev_t
, s_dev
)
125 __field(struct file_lock
*, fl_next
)
126 __field(fl_owner_t
, fl_owner
)
127 __field(unsigned int, fl_flags
)
128 __field(unsigned char, fl_type
)
129 __field(unsigned long, fl_break_time
)
130 __field(unsigned long, fl_downgrade_time
)
134 __entry
->fl
= fl
? fl
: NULL
;
135 __entry
->s_dev
= inode
->i_sb
->s_dev
;
136 __entry
->i_ino
= inode
->i_ino
;
137 __entry
->fl_next
= fl
? fl
->fl_next
: NULL
;
138 __entry
->fl_owner
= fl
? fl
->fl_owner
: NULL
;
139 __entry
->fl_flags
= fl
? fl
->fl_flags
: 0;
140 __entry
->fl_type
= fl
? fl
->fl_type
: 0;
141 __entry
->fl_break_time
= fl
? fl
->fl_break_time
: 0;
142 __entry
->fl_downgrade_time
= fl
? fl
->fl_downgrade_time
: 0;
145 TP_printk("fl=0x%p dev=0x%x:0x%x ino=0x%lx fl_next=0x%p fl_owner=0x%p fl_flags=%s fl_type=%s fl_break_time=%lu fl_downgrade_time=%lu",
146 __entry
->fl
, MAJOR(__entry
->s_dev
), MINOR(__entry
->s_dev
),
147 __entry
->i_ino
, __entry
->fl_next
, __entry
->fl_owner
,
148 show_fl_flags(__entry
->fl_flags
),
149 show_fl_type(__entry
->fl_type
),
150 __entry
->fl_break_time
, __entry
->fl_downgrade_time
)
153 DEFINE_EVENT(filelock_lease
, break_lease_noblock
, TP_PROTO(struct inode
*inode
, struct file_lock
*fl
),
156 DEFINE_EVENT(filelock_lease
, break_lease_block
, TP_PROTO(struct inode
*inode
, struct file_lock
*fl
),
159 DEFINE_EVENT(filelock_lease
, break_lease_unblock
, TP_PROTO(struct inode
*inode
, struct file_lock
*fl
),
162 DEFINE_EVENT(filelock_lease
, generic_delete_lease
, TP_PROTO(struct inode
*inode
, struct file_lock
*fl
),
165 DEFINE_EVENT(filelock_lease
, time_out_leases
, TP_PROTO(struct inode
*inode
, struct file_lock
*fl
),
168 TRACE_EVENT(generic_add_lease
,
169 TP_PROTO(struct inode
*inode
, struct file_lock
*fl
),
174 __field(unsigned long, i_ino
)
178 __field(dev_t
, s_dev
)
179 __field(fl_owner_t
, fl_owner
)
180 __field(unsigned int, fl_flags
)
181 __field(unsigned char, fl_type
)
185 __entry
->s_dev
= inode
->i_sb
->s_dev
;
186 __entry
->i_ino
= inode
->i_ino
;
187 __entry
->wcount
= atomic_read(&inode
->i_writecount
);
188 __entry
->dcount
= d_count(fl
->fl_file
->f_path
.dentry
);
189 __entry
->icount
= atomic_read(&inode
->i_count
);
190 __entry
->fl_owner
= fl
? fl
->fl_owner
: NULL
;
191 __entry
->fl_flags
= fl
? fl
->fl_flags
: 0;
192 __entry
->fl_type
= fl
? fl
->fl_type
: 0;
195 TP_printk("dev=0x%x:0x%x ino=0x%lx wcount=%d dcount=%d icount=%d fl_owner=0x%p fl_flags=%s fl_type=%s",
196 MAJOR(__entry
->s_dev
), MINOR(__entry
->s_dev
),
197 __entry
->i_ino
, __entry
->wcount
, __entry
->dcount
,
198 __entry
->icount
, __entry
->fl_owner
,
199 show_fl_flags(__entry
->fl_flags
),
200 show_fl_type(__entry
->fl_type
))
203 #endif /* _TRACE_FILELOCK_H */
205 /* This part must be outside protection */
206 #include <trace/define_trace.h>