2 * Events for filesystem locks
4 * Copyright 2013 Jeff Layton <jlayton@poochiereds.net>
7 #define TRACE_SYSTEM filelock
9 #if !defined(_TRACE_FILELOCK_H) || defined(TRACE_HEADER_MULTI_READ)
10 #define _TRACE_FILELOCK_H
12 #include <linux/tracepoint.h>
14 #include <linux/device.h>
15 #include <linux/kdev_t.h>
17 #define show_fl_flags(val) \
18 __print_flags(val, "|", \
19 { FL_POSIX, "FL_POSIX" }, \
20 { FL_FLOCK, "FL_FLOCK" }, \
21 { FL_DELEG, "FL_DELEG" }, \
22 { FL_ACCESS, "FL_ACCESS" }, \
23 { FL_EXISTS, "FL_EXISTS" }, \
24 { FL_LEASE, "FL_LEASE" }, \
25 { FL_CLOSE, "FL_CLOSE" }, \
26 { FL_SLEEP, "FL_SLEEP" }, \
27 { FL_DOWNGRADE_PENDING, "FL_DOWNGRADE_PENDING" }, \
28 { FL_UNLOCK_PENDING, "FL_UNLOCK_PENDING" }, \
29 { FL_OFDLCK, "FL_OFDLCK" })
31 #define show_fl_type(val) \
32 __print_symbolic(val, \
33 { F_RDLCK, "F_RDLCK" }, \
34 { F_WRLCK, "F_WRLCK" }, \
35 { F_UNLCK, "F_UNLCK" })
37 TRACE_EVENT(locks_get_lock_context
,
38 TP_PROTO(struct inode
*inode
, int type
, struct file_lock_context
*ctx
),
40 TP_ARGS(inode
, type
, ctx
),
43 __field(unsigned long, i_ino
)
45 __field(unsigned char, type
)
46 __field(struct file_lock_context
*, ctx
)
50 __entry
->s_dev
= inode
->i_sb
->s_dev
;
51 __entry
->i_ino
= inode
->i_ino
;
56 TP_printk("dev=0x%x:0x%x ino=0x%lx type=%s ctx=%p",
57 MAJOR(__entry
->s_dev
), MINOR(__entry
->s_dev
),
58 __entry
->i_ino
, show_fl_type(__entry
->type
), __entry
->ctx
)
61 DECLARE_EVENT_CLASS(filelock_lock
,
62 TP_PROTO(struct inode
*inode
, struct file_lock
*fl
, int ret
),
64 TP_ARGS(inode
, fl
, ret
),
67 __field(struct file_lock
*, fl
)
68 __field(unsigned long, i_ino
)
70 __field(struct file_lock
*, fl_next
)
71 __field(fl_owner_t
, fl_owner
)
72 __field(unsigned int, fl_pid
)
73 __field(unsigned int, fl_flags
)
74 __field(unsigned char, fl_type
)
75 __field(loff_t
, fl_start
)
76 __field(loff_t
, fl_end
)
81 __entry
->fl
= fl
? fl
: NULL
;
82 __entry
->s_dev
= inode
->i_sb
->s_dev
;
83 __entry
->i_ino
= inode
->i_ino
;
84 __entry
->fl_next
= fl
? fl
->fl_next
: NULL
;
85 __entry
->fl_owner
= fl
? fl
->fl_owner
: NULL
;
86 __entry
->fl_pid
= fl
? fl
->fl_pid
: 0;
87 __entry
->fl_flags
= fl
? fl
->fl_flags
: 0;
88 __entry
->fl_type
= fl
? fl
->fl_type
: 0;
89 __entry
->fl_start
= fl
? fl
->fl_start
: 0;
90 __entry
->fl_end
= fl
? fl
->fl_end
: 0;
94 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",
95 __entry
->fl
, MAJOR(__entry
->s_dev
), MINOR(__entry
->s_dev
),
96 __entry
->i_ino
, __entry
->fl_next
, __entry
->fl_owner
,
97 __entry
->fl_pid
, show_fl_flags(__entry
->fl_flags
),
98 show_fl_type(__entry
->fl_type
),
99 __entry
->fl_start
, __entry
->fl_end
, __entry
->ret
)
102 DEFINE_EVENT(filelock_lock
, posix_lock_inode
,
103 TP_PROTO(struct inode
*inode
, struct file_lock
*fl
, int ret
),
104 TP_ARGS(inode
, fl
, ret
));
106 DEFINE_EVENT(filelock_lock
, fcntl_setlk
,
107 TP_PROTO(struct inode
*inode
, struct file_lock
*fl
, int ret
),
108 TP_ARGS(inode
, fl
, ret
));
110 DEFINE_EVENT(filelock_lock
, locks_remove_posix
,
111 TP_PROTO(struct inode
*inode
, struct file_lock
*fl
, int ret
),
112 TP_ARGS(inode
, fl
, ret
));
114 DECLARE_EVENT_CLASS(filelock_lease
,
116 TP_PROTO(struct inode
*inode
, struct file_lock
*fl
),
121 __field(struct file_lock
*, fl
)
122 __field(unsigned long, i_ino
)
123 __field(dev_t
, s_dev
)
124 __field(struct file_lock
*, fl_next
)
125 __field(fl_owner_t
, fl_owner
)
126 __field(unsigned int, fl_flags
)
127 __field(unsigned char, fl_type
)
128 __field(unsigned long, fl_break_time
)
129 __field(unsigned long, fl_downgrade_time
)
133 __entry
->fl
= fl
? fl
: NULL
;
134 __entry
->s_dev
= inode
->i_sb
->s_dev
;
135 __entry
->i_ino
= inode
->i_ino
;
136 __entry
->fl_next
= fl
? fl
->fl_next
: NULL
;
137 __entry
->fl_owner
= fl
? fl
->fl_owner
: NULL
;
138 __entry
->fl_flags
= fl
? fl
->fl_flags
: 0;
139 __entry
->fl_type
= fl
? fl
->fl_type
: 0;
140 __entry
->fl_break_time
= fl
? fl
->fl_break_time
: 0;
141 __entry
->fl_downgrade_time
= fl
? fl
->fl_downgrade_time
: 0;
144 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",
145 __entry
->fl
, MAJOR(__entry
->s_dev
), MINOR(__entry
->s_dev
),
146 __entry
->i_ino
, __entry
->fl_next
, __entry
->fl_owner
,
147 show_fl_flags(__entry
->fl_flags
),
148 show_fl_type(__entry
->fl_type
),
149 __entry
->fl_break_time
, __entry
->fl_downgrade_time
)
152 DEFINE_EVENT(filelock_lease
, break_lease_noblock
, TP_PROTO(struct inode
*inode
, struct file_lock
*fl
),
155 DEFINE_EVENT(filelock_lease
, break_lease_block
, TP_PROTO(struct inode
*inode
, struct file_lock
*fl
),
158 DEFINE_EVENT(filelock_lease
, break_lease_unblock
, TP_PROTO(struct inode
*inode
, struct file_lock
*fl
),
161 DEFINE_EVENT(filelock_lease
, generic_delete_lease
, TP_PROTO(struct inode
*inode
, struct file_lock
*fl
),
164 DEFINE_EVENT(filelock_lease
, time_out_leases
, TP_PROTO(struct inode
*inode
, struct file_lock
*fl
),
167 TRACE_EVENT(generic_add_lease
,
168 TP_PROTO(struct inode
*inode
, struct file_lock
*fl
),
173 __field(unsigned long, i_ino
)
177 __field(dev_t
, s_dev
)
178 __field(fl_owner_t
, fl_owner
)
179 __field(unsigned int, fl_flags
)
180 __field(unsigned char, fl_type
)
184 __entry
->s_dev
= inode
->i_sb
->s_dev
;
185 __entry
->i_ino
= inode
->i_ino
;
186 __entry
->wcount
= atomic_read(&inode
->i_writecount
);
187 __entry
->dcount
= d_count(fl
->fl_file
->f_path
.dentry
);
188 __entry
->icount
= atomic_read(&inode
->i_count
);
189 __entry
->fl_owner
= fl
? fl
->fl_owner
: NULL
;
190 __entry
->fl_flags
= fl
? fl
->fl_flags
: 0;
191 __entry
->fl_type
= fl
? fl
->fl_type
: 0;
194 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",
195 MAJOR(__entry
->s_dev
), MINOR(__entry
->s_dev
),
196 __entry
->i_ino
, __entry
->wcount
, __entry
->dcount
,
197 __entry
->icount
, __entry
->fl_owner
,
198 show_fl_flags(__entry
->fl_flags
),
199 show_fl_type(__entry
->fl_type
))
202 #endif /* _TRACE_FILELOCK_H */
204 /* This part must be outside protection */
205 #include <trace/define_trace.h>