b74a8acd38fa50c0e982c1a1d4871ac20c5017f9
[linux-2.6-block.git] / include / trace / events / sunrpc.h
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM sunrpc
3
4 #if !defined(_TRACE_SUNRPC_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_SUNRPC_H
6
7 #include <linux/sunrpc/sched.h>
8 #include <linux/sunrpc/clnt.h>
9 #include <net/tcp_states.h>
10 #include <linux/net.h>
11 #include <linux/tracepoint.h>
12
13 DECLARE_EVENT_CLASS(rpc_task_status,
14
15         TP_PROTO(struct rpc_task *task),
16
17         TP_ARGS(task),
18
19         TP_STRUCT__entry(
20                 __field(const struct rpc_task *, task)
21                 __field(const struct rpc_clnt *, clnt)
22                 __field(int, status)
23         ),
24
25         TP_fast_assign(
26                 __entry->task = task;
27                 __entry->clnt = task->tk_client;
28                 __entry->status = task->tk_status;
29         ),
30
31         TP_printk("task:%p@%p, status %d",__entry->task, __entry->clnt, __entry->status)
32 );
33
34 DEFINE_EVENT(rpc_task_status, rpc_call_status,
35         TP_PROTO(struct rpc_task *task),
36
37         TP_ARGS(task)
38 );
39
40 DEFINE_EVENT(rpc_task_status, rpc_bind_status,
41         TP_PROTO(struct rpc_task *task),
42
43         TP_ARGS(task)
44 );
45
46 TRACE_EVENT(rpc_connect_status,
47         TP_PROTO(struct rpc_task *task, int status),
48
49         TP_ARGS(task, status),
50
51         TP_STRUCT__entry(
52                 __field(const struct rpc_task *, task)
53                 __field(const struct rpc_clnt *, clnt)
54                 __field(int, status)
55         ),
56
57         TP_fast_assign(
58                 __entry->task = task;
59                 __entry->clnt = task->tk_client;
60                 __entry->status = status;
61         ),
62
63         TP_printk("task:%p@%p, status %d",__entry->task, __entry->clnt, __entry->status)
64 );
65
66 DECLARE_EVENT_CLASS(rpc_task_running,
67
68         TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
69
70         TP_ARGS(clnt, task, action),
71
72         TP_STRUCT__entry(
73                 __field(const struct rpc_clnt *, clnt)
74                 __field(const struct rpc_task *, task)
75                 __field(const void *, action)
76                 __field(unsigned long, runstate)
77                 __field(int, status)
78                 __field(unsigned short, flags)
79                 ),
80
81         TP_fast_assign(
82                 __entry->clnt = clnt;
83                 __entry->task = task;
84                 __entry->action = action;
85                 __entry->runstate = task->tk_runstate;
86                 __entry->status = task->tk_status;
87                 __entry->flags = task->tk_flags;
88                 ),
89
90         TP_printk("task:%p@%p flags=%4.4x state=%4.4lx status=%d action=%pf",
91                 __entry->task,
92                 __entry->clnt,
93                 __entry->flags,
94                 __entry->runstate,
95                 __entry->status,
96                 __entry->action
97                 )
98 );
99
100 DEFINE_EVENT(rpc_task_running, rpc_task_begin,
101
102         TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
103
104         TP_ARGS(clnt, task, action)
105
106 );
107
108 DEFINE_EVENT(rpc_task_running, rpc_task_run_action,
109
110         TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
111
112         TP_ARGS(clnt, task, action)
113
114 );
115
116 DEFINE_EVENT(rpc_task_running, rpc_task_complete,
117
118         TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
119
120         TP_ARGS(clnt, task, action)
121
122 );
123
124 DECLARE_EVENT_CLASS(rpc_task_queued,
125
126         TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q),
127
128         TP_ARGS(clnt, task, q),
129
130         TP_STRUCT__entry(
131                 __field(const struct rpc_clnt *, clnt)
132                 __field(const struct rpc_task *, task)
133                 __field(unsigned long, timeout)
134                 __field(unsigned long, runstate)
135                 __field(int, status)
136                 __field(unsigned short, flags)
137                 __string(q_name, rpc_qname(q))
138                 ),
139
140         TP_fast_assign(
141                 __entry->clnt = clnt;
142                 __entry->task = task;
143                 __entry->timeout = task->tk_timeout;
144                 __entry->runstate = task->tk_runstate;
145                 __entry->status = task->tk_status;
146                 __entry->flags = task->tk_flags;
147                 __assign_str(q_name, rpc_qname(q));
148                 ),
149
150         TP_printk("task:%p@%p flags=%4.4x state=%4.4lx status=%d timeout=%lu queue=%s",
151                 __entry->task,
152                 __entry->clnt,
153                 __entry->flags,
154                 __entry->runstate,
155                 __entry->status,
156                 __entry->timeout,
157                 __get_str(q_name)
158                 )
159 );
160
161 DEFINE_EVENT(rpc_task_queued, rpc_task_sleep,
162
163         TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q),
164
165         TP_ARGS(clnt, task, q)
166
167 );
168
169 DEFINE_EVENT(rpc_task_queued, rpc_task_wakeup,
170
171         TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q),
172
173         TP_ARGS(clnt, task, q)
174
175 );
176
177 #define rpc_show_socket_state(state) \
178         __print_symbolic(state, \
179                 { SS_FREE, "FREE" }, \
180                 { SS_UNCONNECTED, "UNCONNECTED" }, \
181                 { SS_CONNECTING, "CONNECTING," }, \
182                 { SS_CONNECTED, "CONNECTED," }, \
183                 { SS_DISCONNECTING, "DISCONNECTING" })
184
185 #define rpc_show_sock_state(state) \
186         __print_symbolic(state, \
187                 { TCP_ESTABLISHED, "ESTABLISHED" }, \
188                 { TCP_SYN_SENT, "SYN_SENT" }, \
189                 { TCP_SYN_RECV, "SYN_RECV" }, \
190                 { TCP_FIN_WAIT1, "FIN_WAIT1" }, \
191                 { TCP_FIN_WAIT2, "FIN_WAIT2" }, \
192                 { TCP_TIME_WAIT, "TIME_WAIT" }, \
193                 { TCP_CLOSE, "CLOSE" }, \
194                 { TCP_CLOSE_WAIT, "CLOSE_WAIT" }, \
195                 { TCP_LAST_ACK, "LAST_ACK" }, \
196                 { TCP_LISTEN, "LISTEN" }, \
197                 { TCP_CLOSING, "CLOSING" })
198
199 DECLARE_EVENT_CLASS(xs_socket_event,
200
201                 TP_PROTO(
202                         struct rpc_xprt *xprt,
203                         struct socket *socket
204                 ),
205
206                 TP_ARGS(xprt, socket),
207
208                 TP_STRUCT__entry(
209                         __field(unsigned int, socket_state)
210                         __field(unsigned int, sock_state)
211                         __field(unsigned long long, ino)
212                         __string(dstaddr,
213                                 xprt->address_strings[RPC_DISPLAY_ADDR])
214                         __string(dstport,
215                                 xprt->address_strings[RPC_DISPLAY_PORT])
216                 ),
217
218                 TP_fast_assign(
219                         struct inode *inode = SOCK_INODE(socket);
220                         __entry->socket_state = socket->state;
221                         __entry->sock_state = socket->sk->sk_state;
222                         __entry->ino = (unsigned long long)inode->i_ino;
223                         __assign_str(dstaddr,
224                                 xprt->address_strings[RPC_DISPLAY_ADDR]);
225                         __assign_str(dstport,
226                                 xprt->address_strings[RPC_DISPLAY_PORT]);
227                 ),
228
229                 TP_printk(
230                         "socket:[%llu] dstaddr=%s/%s "
231                         "state=%u (%s) sk_state=%u (%s)",
232                         __entry->ino, __get_str(dstaddr), __get_str(dstport),
233                         __entry->socket_state,
234                         rpc_show_socket_state(__entry->socket_state),
235                         __entry->sock_state,
236                         rpc_show_sock_state(__entry->sock_state)
237                 )
238 );
239 #define DEFINE_RPC_SOCKET_EVENT(name) \
240         DEFINE_EVENT(xs_socket_event, name, \
241                         TP_PROTO( \
242                                 struct rpc_xprt *xprt, \
243                                 struct socket *socket \
244                         ), \
245                         TP_ARGS(xprt, socket))
246
247 DECLARE_EVENT_CLASS(xs_socket_event_done,
248
249                 TP_PROTO(
250                         struct rpc_xprt *xprt,
251                         struct socket *socket,
252                         int error
253                 ),
254
255                 TP_ARGS(xprt, socket, error),
256
257                 TP_STRUCT__entry(
258                         __field(int, error)
259                         __field(unsigned int, socket_state)
260                         __field(unsigned int, sock_state)
261                         __field(unsigned long long, ino)
262                         __string(dstaddr,
263                                 xprt->address_strings[RPC_DISPLAY_ADDR])
264                         __string(dstport,
265                                 xprt->address_strings[RPC_DISPLAY_PORT])
266                 ),
267
268                 TP_fast_assign(
269                         struct inode *inode = SOCK_INODE(socket);
270                         __entry->socket_state = socket->state;
271                         __entry->sock_state = socket->sk->sk_state;
272                         __entry->ino = (unsigned long long)inode->i_ino;
273                         __entry->error = error;
274                         __assign_str(dstaddr,
275                                 xprt->address_strings[RPC_DISPLAY_ADDR]);
276                         __assign_str(dstport,
277                                 xprt->address_strings[RPC_DISPLAY_PORT]);
278                 ),
279
280                 TP_printk(
281                         "error=%d socket:[%llu] dstaddr=%s/%s "
282                         "state=%u (%s) sk_state=%u (%s)",
283                         __entry->error,
284                         __entry->ino, __get_str(dstaddr), __get_str(dstport),
285                         __entry->socket_state,
286                         rpc_show_socket_state(__entry->socket_state),
287                         __entry->sock_state,
288                         rpc_show_sock_state(__entry->sock_state)
289                 )
290 );
291 #define DEFINE_RPC_SOCKET_EVENT_DONE(name) \
292         DEFINE_EVENT(xs_socket_event_done, name, \
293                         TP_PROTO( \
294                                 struct rpc_xprt *xprt, \
295                                 struct socket *socket, \
296                                 int error \
297                         ), \
298                         TP_ARGS(xprt, socket, error))
299
300 DEFINE_RPC_SOCKET_EVENT(rpc_socket_state_change);
301 DEFINE_RPC_SOCKET_EVENT_DONE(rpc_socket_connect);
302 DEFINE_RPC_SOCKET_EVENT_DONE(rpc_socket_reset_connection);
303 DEFINE_RPC_SOCKET_EVENT(rpc_socket_close);
304 DEFINE_RPC_SOCKET_EVENT(rpc_socket_shutdown);
305
306 #endif /* _TRACE_SUNRPC_H */
307
308 #include <trace/define_trace.h>