• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Events for filesystem locks
3  *
4  * Copyright 2013 Jeff Layton <jlayton@poochiereds.net>
5  */
6 #undef TRACE_SYSTEM
7 #define TRACE_SYSTEM filelock
8 
9 #if !defined(_TRACE_FILELOCK_H) || defined(TRACE_HEADER_MULTI_READ)
10 #define _TRACE_FILELOCK_H
11 
12 #include <linux/tracepoint.h>
13 #include <linux/fs.h>
14 #include <linux/device.h>
15 #include <linux/kdev_t.h>
16 
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" })
30 
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" })
36 
37 TRACE_EVENT(locks_get_lock_context,
38 	TP_PROTO(struct inode *inode, int type, struct file_lock_context *ctx),
39 
40 	TP_ARGS(inode, type, ctx),
41 
42 	TP_STRUCT__entry(
43 		__field(unsigned long, i_ino)
44 		__field(dev_t, s_dev)
45 		__field(unsigned char, type)
46 		__field(struct file_lock_context *, ctx)
47 	),
48 
49 	TP_fast_assign(
50 		__entry->s_dev = inode->i_sb->s_dev;
51 		__entry->i_ino = inode->i_ino;
52 		__entry->type = type;
53 		__entry->ctx = ctx;
54 	),
55 
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)
59 );
60 
61 DECLARE_EVENT_CLASS(filelock_lock,
62 	TP_PROTO(struct inode *inode, struct file_lock *fl, int ret),
63 
64 	TP_ARGS(inode, fl, ret),
65 
66 	TP_STRUCT__entry(
67 		__field(struct file_lock *, fl)
68 		__field(unsigned long, i_ino)
69 		__field(dev_t, s_dev)
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)
77 		__field(int, ret)
78 	),
79 
80 	TP_fast_assign(
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;
91 		__entry->ret = ret;
92 	),
93 
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)
100 );
101 
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));
105 
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));
109 
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));
113 
114 DECLARE_EVENT_CLASS(filelock_lease,
115 
116 	TP_PROTO(struct inode *inode, struct file_lock *fl),
117 
118 	TP_ARGS(inode, fl),
119 
120 	TP_STRUCT__entry(
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)
130 	),
131 
132 	TP_fast_assign(
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;
142 	),
143 
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)
150 );
151 
152 DEFINE_EVENT(filelock_lease, break_lease_noblock, TP_PROTO(struct inode *inode, struct file_lock *fl),
153 		TP_ARGS(inode, fl));
154 
155 DEFINE_EVENT(filelock_lease, break_lease_block, TP_PROTO(struct inode *inode, struct file_lock *fl),
156 		TP_ARGS(inode, fl));
157 
158 DEFINE_EVENT(filelock_lease, break_lease_unblock, TP_PROTO(struct inode *inode, struct file_lock *fl),
159 		TP_ARGS(inode, fl));
160 
161 DEFINE_EVENT(filelock_lease, generic_delete_lease, TP_PROTO(struct inode *inode, struct file_lock *fl),
162 		TP_ARGS(inode, fl));
163 
164 DEFINE_EVENT(filelock_lease, time_out_leases, TP_PROTO(struct inode *inode, struct file_lock *fl),
165 		TP_ARGS(inode, fl));
166 
167 TRACE_EVENT(generic_add_lease,
168 	TP_PROTO(struct inode *inode, struct file_lock *fl),
169 
170 	TP_ARGS(inode, fl),
171 
172 	TP_STRUCT__entry(
173 		__field(unsigned long, i_ino)
174 		__field(int, wcount)
175 		__field(int, dcount)
176 		__field(int, icount)
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)
181 	),
182 
183 	TP_fast_assign(
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;
192 	),
193 
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))
200 );
201 
202 #endif /* _TRACE_FILELOCK_H */
203 
204 /* This part must be outside protection */
205 #include <trace/define_trace.h>
206