blob: 823ac436a1da2359a53d0c63426727fff89f355c [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Trond Myklebustc6d01c62013-08-09 11:51:26 -04002/*
3 * Copyright (c) 2013 Trond Myklebust <Trond.Myklebust@netapp.com>
4 */
5#undef TRACE_SYSTEM
6#define TRACE_SYSTEM nfs4
7
8#if !defined(_TRACE_NFS4_H) || defined(TRACE_HEADER_MULTI_READ)
9#define _TRACE_NFS4_H
10
11#include <linux/tracepoint.h>
Chuck Leverb4776a32021-10-16 18:02:24 -040012#include <trace/events/sunrpc_base.h>
Trond Myklebustc6d01c62013-08-09 11:51:26 -040013
Chuck Lever9d2d48b2021-10-22 16:16:56 -040014#include <trace/events/fs.h>
Chuck Lever87915452021-10-22 16:17:03 -040015#include <trace/events/nfs.h>
Trond Myklebustc6d01c62013-08-09 11:51:26 -040016
Trond Myklebustb5f875a2013-08-13 13:01:39 -040017#define show_nfs_fattr_flags(valid) \
18 __print_flags((unsigned long)valid, "|", \
19 { NFS_ATTR_FATTR_TYPE, "TYPE" }, \
20 { NFS_ATTR_FATTR_MODE, "MODE" }, \
21 { NFS_ATTR_FATTR_NLINK, "NLINK" }, \
22 { NFS_ATTR_FATTR_OWNER, "OWNER" }, \
23 { NFS_ATTR_FATTR_GROUP, "GROUP" }, \
24 { NFS_ATTR_FATTR_RDEV, "RDEV" }, \
25 { NFS_ATTR_FATTR_SIZE, "SIZE" }, \
26 { NFS_ATTR_FATTR_FSID, "FSID" }, \
27 { NFS_ATTR_FATTR_FILEID, "FILEID" }, \
28 { NFS_ATTR_FATTR_ATIME, "ATIME" }, \
29 { NFS_ATTR_FATTR_MTIME, "MTIME" }, \
30 { NFS_ATTR_FATTR_CTIME, "CTIME" }, \
31 { NFS_ATTR_FATTR_CHANGE, "CHANGE" }, \
32 { NFS_ATTR_FATTR_OWNER_NAME, "OWNER_NAME" }, \
33 { NFS_ATTR_FATTR_GROUP_NAME, "GROUP_NAME" })
34
Trond Myklebustc6d01c62013-08-09 11:51:26 -040035DECLARE_EVENT_CLASS(nfs4_clientid_event,
36 TP_PROTO(
37 const struct nfs_client *clp,
38 int error
39 ),
40
41 TP_ARGS(clp, error),
42
43 TP_STRUCT__entry(
Anna Schumaker39443692017-11-01 15:48:43 -040044 __string(dstaddr, clp->cl_hostname)
Chuck Lever96650e22019-06-19 10:33:53 -040045 __field(unsigned long, error)
Trond Myklebustc6d01c62013-08-09 11:51:26 -040046 ),
47
48 TP_fast_assign(
Trond Myklebust118b6292020-01-06 15:25:06 -050049 __entry->error = error < 0 ? -error : 0;
Anna Schumaker39443692017-11-01 15:48:43 -040050 __assign_str(dstaddr, clp->cl_hostname);
Trond Myklebustc6d01c62013-08-09 11:51:26 -040051 ),
52
53 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -040054 "error=%ld (%s) dstaddr=%s",
55 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -040056 show_nfs4_status(__entry->error),
Trond Myklebustc6d01c62013-08-09 11:51:26 -040057 __get_str(dstaddr)
58 )
59);
60#define DEFINE_NFS4_CLIENTID_EVENT(name) \
61 DEFINE_EVENT(nfs4_clientid_event, name, \
62 TP_PROTO( \
63 const struct nfs_client *clp, \
64 int error \
65 ), \
66 TP_ARGS(clp, error))
67DEFINE_NFS4_CLIENTID_EVENT(nfs4_setclientid);
68DEFINE_NFS4_CLIENTID_EVENT(nfs4_setclientid_confirm);
69DEFINE_NFS4_CLIENTID_EVENT(nfs4_renew);
70DEFINE_NFS4_CLIENTID_EVENT(nfs4_renew_async);
71#ifdef CONFIG_NFS_V4_1
72DEFINE_NFS4_CLIENTID_EVENT(nfs4_exchange_id);
73DEFINE_NFS4_CLIENTID_EVENT(nfs4_create_session);
74DEFINE_NFS4_CLIENTID_EVENT(nfs4_destroy_session);
75DEFINE_NFS4_CLIENTID_EVENT(nfs4_destroy_clientid);
76DEFINE_NFS4_CLIENTID_EVENT(nfs4_bind_conn_to_session);
77DEFINE_NFS4_CLIENTID_EVENT(nfs4_sequence);
78DEFINE_NFS4_CLIENTID_EVENT(nfs4_reclaim_complete);
Trond Myklebust2f92ae32013-08-14 17:58:28 -040079
Trond Myklebust2f92ae32013-08-14 17:58:28 -040080TRACE_EVENT(nfs4_sequence_done,
81 TP_PROTO(
82 const struct nfs4_session *session,
83 const struct nfs4_sequence_res *res
84 ),
85 TP_ARGS(session, res),
86
87 TP_STRUCT__entry(
88 __field(unsigned int, session)
89 __field(unsigned int, slot_nr)
90 __field(unsigned int, seq_nr)
91 __field(unsigned int, highest_slotid)
92 __field(unsigned int, target_highest_slotid)
Chuck Lever87915452021-10-22 16:17:03 -040093 __field(unsigned long, status_flags)
Chuck Lever96650e22019-06-19 10:33:53 -040094 __field(unsigned long, error)
Trond Myklebust2f92ae32013-08-14 17:58:28 -040095 ),
96
97 TP_fast_assign(
98 const struct nfs4_slot *sr_slot = res->sr_slot;
99 __entry->session = nfs_session_id_hash(&session->sess_id);
100 __entry->slot_nr = sr_slot->slot_nr;
101 __entry->seq_nr = sr_slot->seq_nr;
102 __entry->highest_slotid = res->sr_highest_slotid;
103 __entry->target_highest_slotid =
104 res->sr_target_highest_slotid;
Andrew Elble52618df2015-12-02 09:19:43 -0500105 __entry->status_flags = res->sr_status_flags;
Trond Myklebust118b6292020-01-06 15:25:06 -0500106 __entry->error = res->sr_status < 0 ?
107 -res->sr_status : 0;
Trond Myklebust2f92ae32013-08-14 17:58:28 -0400108 ),
109 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -0400110 "error=%ld (%s) session=0x%08x slot_nr=%u seq_nr=%u "
Trond Myklebust2f92ae32013-08-14 17:58:28 -0400111 "highest_slotid=%u target_highest_slotid=%u "
Chuck Lever87915452021-10-22 16:17:03 -0400112 "status_flags=0x%lx (%s)",
Chuck Lever96650e22019-06-19 10:33:53 -0400113 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -0400114 show_nfs4_status(__entry->error),
Trond Myklebust2f92ae32013-08-14 17:58:28 -0400115 __entry->session,
116 __entry->slot_nr,
117 __entry->seq_nr,
118 __entry->highest_slotid,
119 __entry->target_highest_slotid,
120 __entry->status_flags,
Chuck Lever87915452021-10-22 16:17:03 -0400121 show_nfs4_seq4_status(__entry->status_flags)
Trond Myklebust2f92ae32013-08-14 17:58:28 -0400122 )
123);
124
125struct cb_sequenceargs;
126struct cb_sequenceres;
127
128TRACE_EVENT(nfs4_cb_sequence,
129 TP_PROTO(
130 const struct cb_sequenceargs *args,
131 const struct cb_sequenceres *res,
132 __be32 status
133 ),
134 TP_ARGS(args, res, status),
135
136 TP_STRUCT__entry(
137 __field(unsigned int, session)
138 __field(unsigned int, slot_nr)
139 __field(unsigned int, seq_nr)
140 __field(unsigned int, highest_slotid)
141 __field(unsigned int, cachethis)
Chuck Lever96650e22019-06-19 10:33:53 -0400142 __field(unsigned long, error)
Trond Myklebust2f92ae32013-08-14 17:58:28 -0400143 ),
144
145 TP_fast_assign(
146 __entry->session = nfs_session_id_hash(&args->csa_sessionid);
147 __entry->slot_nr = args->csa_slotid;
148 __entry->seq_nr = args->csa_sequenceid;
149 __entry->highest_slotid = args->csa_highestslotid;
150 __entry->cachethis = args->csa_cachethis;
Chuck Lever96650e22019-06-19 10:33:53 -0400151 __entry->error = be32_to_cpu(status);
Trond Myklebust2f92ae32013-08-14 17:58:28 -0400152 ),
153
154 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -0400155 "error=%ld (%s) session=0x%08x slot_nr=%u seq_nr=%u "
Trond Myklebust2f92ae32013-08-14 17:58:28 -0400156 "highest_slotid=%u",
Chuck Lever96650e22019-06-19 10:33:53 -0400157 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -0400158 show_nfs4_status(__entry->error),
Trond Myklebust2f92ae32013-08-14 17:58:28 -0400159 __entry->session,
160 __entry->slot_nr,
161 __entry->seq_nr,
162 __entry->highest_slotid
163 )
164);
Chuck Leverc5833f02019-06-19 10:33:47 -0400165
166TRACE_EVENT(nfs4_cb_seqid_err,
167 TP_PROTO(
168 const struct cb_sequenceargs *args,
169 __be32 status
170 ),
171 TP_ARGS(args, status),
172
173 TP_STRUCT__entry(
174 __field(unsigned int, session)
175 __field(unsigned int, slot_nr)
176 __field(unsigned int, seq_nr)
177 __field(unsigned int, highest_slotid)
178 __field(unsigned int, cachethis)
Chuck Lever96650e22019-06-19 10:33:53 -0400179 __field(unsigned long, error)
Chuck Leverc5833f02019-06-19 10:33:47 -0400180 ),
181
182 TP_fast_assign(
183 __entry->session = nfs_session_id_hash(&args->csa_sessionid);
184 __entry->slot_nr = args->csa_slotid;
185 __entry->seq_nr = args->csa_sequenceid;
186 __entry->highest_slotid = args->csa_highestslotid;
187 __entry->cachethis = args->csa_cachethis;
Chuck Lever96650e22019-06-19 10:33:53 -0400188 __entry->error = be32_to_cpu(status);
Chuck Leverc5833f02019-06-19 10:33:47 -0400189 ),
190
191 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -0400192 "error=%ld (%s) session=0x%08x slot_nr=%u seq_nr=%u "
Chuck Leverc5833f02019-06-19 10:33:47 -0400193 "highest_slotid=%u",
Chuck Lever96650e22019-06-19 10:33:53 -0400194 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -0400195 show_nfs4_status(__entry->error),
Chuck Leverc5833f02019-06-19 10:33:47 -0400196 __entry->session,
197 __entry->slot_nr,
198 __entry->seq_nr,
199 __entry->highest_slotid
200 )
201);
202
Trond Myklebustc6d01c62013-08-09 11:51:26 -0400203#endif /* CONFIG_NFS_V4_1 */
204
Anna Schumakerad05cc02017-01-11 13:37:06 -0500205TRACE_EVENT(nfs4_setup_sequence,
206 TP_PROTO(
207 const struct nfs4_session *session,
208 const struct nfs4_sequence_args *args
209 ),
210 TP_ARGS(session, args),
211
212 TP_STRUCT__entry(
213 __field(unsigned int, session)
214 __field(unsigned int, slot_nr)
215 __field(unsigned int, seq_nr)
216 __field(unsigned int, highest_used_slotid)
217 ),
218
219 TP_fast_assign(
220 const struct nfs4_slot *sa_slot = args->sa_slot;
221 __entry->session = session ? nfs_session_id_hash(&session->sess_id) : 0;
222 __entry->slot_nr = sa_slot->slot_nr;
223 __entry->seq_nr = sa_slot->seq_nr;
224 __entry->highest_used_slotid =
225 sa_slot->table->highest_used_slotid;
226 ),
227 TP_printk(
228 "session=0x%08x slot_nr=%u seq_nr=%u "
229 "highest_used_slotid=%u",
230 __entry->session,
231 __entry->slot_nr,
232 __entry->seq_nr,
233 __entry->highest_used_slotid
234 )
235);
236
Chuck Lever511ba522019-11-05 11:04:07 -0500237TRACE_DEFINE_ENUM(NFS4CLNT_MANAGER_RUNNING);
238TRACE_DEFINE_ENUM(NFS4CLNT_CHECK_LEASE);
239TRACE_DEFINE_ENUM(NFS4CLNT_LEASE_EXPIRED);
240TRACE_DEFINE_ENUM(NFS4CLNT_RECLAIM_REBOOT);
241TRACE_DEFINE_ENUM(NFS4CLNT_RECLAIM_NOGRACE);
242TRACE_DEFINE_ENUM(NFS4CLNT_DELEGRETURN);
243TRACE_DEFINE_ENUM(NFS4CLNT_SESSION_RESET);
244TRACE_DEFINE_ENUM(NFS4CLNT_LEASE_CONFIRM);
245TRACE_DEFINE_ENUM(NFS4CLNT_SERVER_SCOPE_MISMATCH);
246TRACE_DEFINE_ENUM(NFS4CLNT_PURGE_STATE);
247TRACE_DEFINE_ENUM(NFS4CLNT_BIND_CONN_TO_SESSION);
248TRACE_DEFINE_ENUM(NFS4CLNT_MOVED);
249TRACE_DEFINE_ENUM(NFS4CLNT_LEASE_MOVED);
250TRACE_DEFINE_ENUM(NFS4CLNT_DELEGATION_EXPIRED);
251TRACE_DEFINE_ENUM(NFS4CLNT_RUN_MANAGER);
Trond Myklebustb5fdf842020-02-18 15:58:31 -0500252TRACE_DEFINE_ENUM(NFS4CLNT_RECALL_RUNNING);
253TRACE_DEFINE_ENUM(NFS4CLNT_RECALL_ANY_LAYOUT_READ);
254TRACE_DEFINE_ENUM(NFS4CLNT_RECALL_ANY_LAYOUT_RW);
Chuck Lever511ba522019-11-05 11:04:07 -0500255
256#define show_nfs4_clp_state(state) \
257 __print_flags(state, "|", \
258 { NFS4CLNT_MANAGER_RUNNING, "MANAGER_RUNNING" }, \
259 { NFS4CLNT_CHECK_LEASE, "CHECK_LEASE" }, \
260 { NFS4CLNT_LEASE_EXPIRED, "LEASE_EXPIRED" }, \
261 { NFS4CLNT_RECLAIM_REBOOT, "RECLAIM_REBOOT" }, \
262 { NFS4CLNT_RECLAIM_NOGRACE, "RECLAIM_NOGRACE" }, \
263 { NFS4CLNT_DELEGRETURN, "DELEGRETURN" }, \
264 { NFS4CLNT_SESSION_RESET, "SESSION_RESET" }, \
265 { NFS4CLNT_LEASE_CONFIRM, "LEASE_CONFIRM" }, \
266 { NFS4CLNT_SERVER_SCOPE_MISMATCH, \
267 "SERVER_SCOPE_MISMATCH" }, \
268 { NFS4CLNT_PURGE_STATE, "PURGE_STATE" }, \
269 { NFS4CLNT_BIND_CONN_TO_SESSION, \
270 "BIND_CONN_TO_SESSION" }, \
271 { NFS4CLNT_MOVED, "MOVED" }, \
272 { NFS4CLNT_LEASE_MOVED, "LEASE_MOVED" }, \
273 { NFS4CLNT_DELEGATION_EXPIRED, "DELEGATION_EXPIRED" }, \
274 { NFS4CLNT_RUN_MANAGER, "RUN_MANAGER" }, \
Trond Myklebustb5fdf842020-02-18 15:58:31 -0500275 { NFS4CLNT_RECALL_RUNNING, "RECALL_RUNNING" }, \
276 { NFS4CLNT_RECALL_ANY_LAYOUT_READ, "RECALL_ANY_LAYOUT_READ" }, \
277 { NFS4CLNT_RECALL_ANY_LAYOUT_RW, "RECALL_ANY_LAYOUT_RW" })
Chuck Lever511ba522019-11-05 11:04:07 -0500278
279TRACE_EVENT(nfs4_state_mgr,
280 TP_PROTO(
281 const struct nfs_client *clp
282 ),
283
284 TP_ARGS(clp),
285
286 TP_STRUCT__entry(
287 __field(unsigned long, state)
288 __string(hostname, clp->cl_hostname)
289 ),
290
291 TP_fast_assign(
292 __entry->state = clp->cl_state;
Joe Perches78c14b32021-06-12 08:42:27 -0700293 __assign_str(hostname, clp->cl_hostname);
Chuck Lever511ba522019-11-05 11:04:07 -0500294 ),
295
296 TP_printk(
297 "hostname=%s clp state=%s", __get_str(hostname),
298 show_nfs4_clp_state(__entry->state)
299 )
300)
301
302TRACE_EVENT(nfs4_state_mgr_failed,
303 TP_PROTO(
304 const struct nfs_client *clp,
305 const char *section,
306 int status
307 ),
308
309 TP_ARGS(clp, section, status),
310
311 TP_STRUCT__entry(
312 __field(unsigned long, error)
313 __field(unsigned long, state)
314 __string(hostname, clp->cl_hostname)
315 __string(section, section)
316 ),
317
318 TP_fast_assign(
Trond Myklebust118b6292020-01-06 15:25:06 -0500319 __entry->error = status < 0 ? -status : 0;
Chuck Lever511ba522019-11-05 11:04:07 -0500320 __entry->state = clp->cl_state;
321 __assign_str(hostname, clp->cl_hostname);
322 __assign_str(section, section);
323 ),
324
325 TP_printk(
326 "hostname=%s clp state=%s error=%ld (%s) section=%s",
327 __get_str(hostname),
328 show_nfs4_clp_state(__entry->state), -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -0400329 show_nfs4_status(__entry->error), __get_str(section)
Chuck Lever511ba522019-11-05 11:04:07 -0500330
331 )
332)
333
Trond Myklebustda934ae2021-04-01 14:38:13 -0400334TRACE_EVENT(nfs4_xdr_bad_operation,
335 TP_PROTO(
336 const struct xdr_stream *xdr,
337 u32 op,
338 u32 expected
339 ),
340
341 TP_ARGS(xdr, op, expected),
342
343 TP_STRUCT__entry(
344 __field(unsigned int, task_id)
345 __field(unsigned int, client_id)
346 __field(u32, xid)
347 __field(u32, op)
348 __field(u32, expected)
349 ),
350
351 TP_fast_assign(
352 const struct rpc_rqst *rqstp = xdr->rqst;
353 const struct rpc_task *task = rqstp->rq_task;
354
355 __entry->task_id = task->tk_pid;
356 __entry->client_id = task->tk_client->cl_clid;
357 __entry->xid = be32_to_cpu(rqstp->rq_xid);
358 __entry->op = op;
359 __entry->expected = expected;
360 ),
361
Chuck Leverb4776a32021-10-16 18:02:24 -0400362 TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
363 " xid=0x%08x operation=%u, expected=%u",
Trond Myklebustda934ae2021-04-01 14:38:13 -0400364 __entry->task_id, __entry->client_id, __entry->xid,
365 __entry->op, __entry->expected
366 )
367);
368
Trond Myklebust3d66bae2021-04-01 13:54:19 -0400369DECLARE_EVENT_CLASS(nfs4_xdr_event,
Chuck Leverf23f6582019-02-11 11:24:26 -0500370 TP_PROTO(
Chuck Lever62a92ba2019-06-19 10:34:09 -0400371 const struct xdr_stream *xdr,
Chuck Leverf23f6582019-02-11 11:24:26 -0500372 u32 op,
Trond Myklebust118b6292020-01-06 15:25:06 -0500373 u32 error
Chuck Leverf23f6582019-02-11 11:24:26 -0500374 ),
375
Chuck Lever62a92ba2019-06-19 10:34:09 -0400376 TP_ARGS(xdr, op, error),
Chuck Leverf23f6582019-02-11 11:24:26 -0500377
378 TP_STRUCT__entry(
Chuck Lever62a92ba2019-06-19 10:34:09 -0400379 __field(unsigned int, task_id)
380 __field(unsigned int, client_id)
381 __field(u32, xid)
Chuck Leverf23f6582019-02-11 11:24:26 -0500382 __field(u32, op)
Chuck Lever96650e22019-06-19 10:33:53 -0400383 __field(unsigned long, error)
Chuck Leverf23f6582019-02-11 11:24:26 -0500384 ),
385
386 TP_fast_assign(
Chuck Lever62a92ba2019-06-19 10:34:09 -0400387 const struct rpc_rqst *rqstp = xdr->rqst;
388 const struct rpc_task *task = rqstp->rq_task;
389
390 __entry->task_id = task->tk_pid;
391 __entry->client_id = task->tk_client->cl_clid;
392 __entry->xid = be32_to_cpu(rqstp->rq_xid);
Chuck Leverf23f6582019-02-11 11:24:26 -0500393 __entry->op = op;
Chuck Lever96650e22019-06-19 10:33:53 -0400394 __entry->error = error;
Chuck Leverf23f6582019-02-11 11:24:26 -0500395 ),
396
Chuck Leverb4776a32021-10-16 18:02:24 -0400397 TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
398 " xid=0x%08x error=%ld (%s) operation=%u",
Chuck Lever62a92ba2019-06-19 10:34:09 -0400399 __entry->task_id, __entry->client_id, __entry->xid,
Chuck Lever87915452021-10-22 16:17:03 -0400400 -__entry->error, show_nfs4_status(__entry->error),
Chuck Lever96650e22019-06-19 10:33:53 -0400401 __entry->op
Chuck Leverf23f6582019-02-11 11:24:26 -0500402 )
403);
Trond Myklebust3d66bae2021-04-01 13:54:19 -0400404#define DEFINE_NFS4_XDR_EVENT(name) \
405 DEFINE_EVENT(nfs4_xdr_event, name, \
406 TP_PROTO( \
407 const struct xdr_stream *xdr, \
408 u32 op, \
409 u32 error \
410 ), \
411 TP_ARGS(xdr, op, error))
412DEFINE_NFS4_XDR_EVENT(nfs4_xdr_status);
Trond Myklebusteb3d58c2021-04-01 14:03:26 -0400413DEFINE_NFS4_XDR_EVENT(nfs4_xdr_bad_filehandle);
Chuck Leverf23f6582019-02-11 11:24:26 -0500414
Chuck Lever2bb50aa2019-12-23 10:28:38 -0500415DECLARE_EVENT_CLASS(nfs4_cb_error_class,
416 TP_PROTO(
417 __be32 xid,
418 u32 cb_ident
419 ),
420
421 TP_ARGS(xid, cb_ident),
422
423 TP_STRUCT__entry(
424 __field(u32, xid)
425 __field(u32, cbident)
426 ),
427
428 TP_fast_assign(
429 __entry->xid = be32_to_cpu(xid);
430 __entry->cbident = cb_ident;
431 ),
432
433 TP_printk(
434 "xid=0x%08x cb_ident=0x%08x",
435 __entry->xid, __entry->cbident
436 )
437);
438
439#define DEFINE_CB_ERROR_EVENT(name) \
440 DEFINE_EVENT(nfs4_cb_error_class, nfs_cb_##name, \
441 TP_PROTO( \
442 __be32 xid, \
443 u32 cb_ident \
444 ), \
445 TP_ARGS(xid, cb_ident))
446
447DEFINE_CB_ERROR_EVENT(no_clp);
448DEFINE_CB_ERROR_EVENT(badprinc);
449
Trond Myklebust42113a72013-08-12 16:19:27 -0400450DECLARE_EVENT_CLASS(nfs4_open_event,
451 TP_PROTO(
452 const struct nfs_open_context *ctx,
453 int flags,
454 int error
455 ),
456
457 TP_ARGS(ctx, flags, error),
458
459 TP_STRUCT__entry(
Chuck Lever96650e22019-06-19 10:33:53 -0400460 __field(unsigned long, error)
Chuck Lever9d2d48b2021-10-22 16:16:56 -0400461 __field(unsigned long, flags)
462 __field(unsigned long, fmode)
Trond Myklebust42113a72013-08-12 16:19:27 -0400463 __field(dev_t, dev)
464 __field(u32, fhandle)
465 __field(u64, fileid)
466 __field(u64, dir)
467 __string(name, ctx->dentry->d_name.name)
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500468 __field(int, stateid_seq)
469 __field(u32, stateid_hash)
470 __field(int, openstateid_seq)
471 __field(u32, openstateid_hash)
Trond Myklebust42113a72013-08-12 16:19:27 -0400472 ),
473
474 TP_fast_assign(
475 const struct nfs4_state *state = ctx->state;
476 const struct inode *inode = NULL;
477
Chuck Lever96650e22019-06-19 10:33:53 -0400478 __entry->error = -error;
Trond Myklebust42113a72013-08-12 16:19:27 -0400479 __entry->flags = flags;
Chuck Lever9d2d48b2021-10-22 16:16:56 -0400480 __entry->fmode = (__force unsigned long)ctx->mode;
Trond Myklebust42113a72013-08-12 16:19:27 -0400481 __entry->dev = ctx->dentry->d_sb->s_dev;
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500482 if (!IS_ERR_OR_NULL(state)) {
Trond Myklebust42113a72013-08-12 16:19:27 -0400483 inode = state->inode;
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500484 __entry->stateid_seq =
485 be32_to_cpu(state->stateid.seqid);
486 __entry->stateid_hash =
487 nfs_stateid_hash(&state->stateid);
488 __entry->openstateid_seq =
489 be32_to_cpu(state->open_stateid.seqid);
490 __entry->openstateid_hash =
491 nfs_stateid_hash(&state->open_stateid);
492 } else {
493 __entry->stateid_seq = 0;
494 __entry->stateid_hash = 0;
495 __entry->openstateid_seq = 0;
496 __entry->openstateid_hash = 0;
497 }
Trond Myklebust42113a72013-08-12 16:19:27 -0400498 if (inode != NULL) {
499 __entry->fileid = NFS_FILEID(inode);
500 __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
501 } else {
502 __entry->fileid = 0;
503 __entry->fhandle = 0;
504 }
David Howells2b0143b2015-03-17 22:25:59 +0000505 __entry->dir = NFS_FILEID(d_inode(ctx->dentry->d_parent));
Trond Myklebust42113a72013-08-12 16:19:27 -0400506 __assign_str(name, ctx->dentry->d_name.name);
507 ),
508
509 TP_printk(
Chuck Lever9d2d48b2021-10-22 16:16:56 -0400510 "error=%ld (%s) flags=%lu (%s) fmode=%s "
Trond Myklebust42113a72013-08-12 16:19:27 -0400511 "fileid=%02x:%02x:%llu fhandle=0x%08x "
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500512 "name=%02x:%02x:%llu/%s stateid=%d:0x%08x "
513 "openstateid=%d:0x%08x",
Chuck Lever96650e22019-06-19 10:33:53 -0400514 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -0400515 show_nfs4_status(__entry->error),
Trond Myklebust42113a72013-08-12 16:19:27 -0400516 __entry->flags,
Chuck Lever9d2d48b2021-10-22 16:16:56 -0400517 show_fs_fcntl_open_flags(__entry->flags),
518 show_fs_fmode_flags(__entry->fmode),
Trond Myklebust42113a72013-08-12 16:19:27 -0400519 MAJOR(__entry->dev), MINOR(__entry->dev),
520 (unsigned long long)__entry->fileid,
521 __entry->fhandle,
522 MAJOR(__entry->dev), MINOR(__entry->dev),
523 (unsigned long long)__entry->dir,
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500524 __get_str(name),
525 __entry->stateid_seq, __entry->stateid_hash,
526 __entry->openstateid_seq, __entry->openstateid_hash
Trond Myklebust42113a72013-08-12 16:19:27 -0400527 )
528);
529
530#define DEFINE_NFS4_OPEN_EVENT(name) \
531 DEFINE_EVENT(nfs4_open_event, name, \
532 TP_PROTO( \
533 const struct nfs_open_context *ctx, \
534 int flags, \
535 int error \
536 ), \
537 TP_ARGS(ctx, flags, error))
538DEFINE_NFS4_OPEN_EVENT(nfs4_open_reclaim);
539DEFINE_NFS4_OPEN_EVENT(nfs4_open_expired);
540DEFINE_NFS4_OPEN_EVENT(nfs4_open_file);
541
Olga Kornievskaia9759b0f2015-11-24 13:29:42 -0500542TRACE_EVENT(nfs4_cached_open,
543 TP_PROTO(
544 const struct nfs4_state *state
545 ),
546 TP_ARGS(state),
547 TP_STRUCT__entry(
548 __field(dev_t, dev)
549 __field(u32, fhandle)
550 __field(u64, fileid)
551 __field(unsigned int, fmode)
552 __field(int, stateid_seq)
553 __field(u32, stateid_hash)
554 ),
555
556 TP_fast_assign(
557 const struct inode *inode = state->inode;
558
559 __entry->dev = inode->i_sb->s_dev;
560 __entry->fileid = NFS_FILEID(inode);
561 __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
562 __entry->fmode = (__force unsigned int)state->state;
563 __entry->stateid_seq =
564 be32_to_cpu(state->stateid.seqid);
565 __entry->stateid_hash =
566 nfs_stateid_hash(&state->stateid);
567 ),
568
569 TP_printk(
570 "fmode=%s fileid=%02x:%02x:%llu "
571 "fhandle=0x%08x stateid=%d:0x%08x",
Chuck Lever9d2d48b2021-10-22 16:16:56 -0400572 __entry->fmode ? show_fs_fmode_flags(__entry->fmode) :
Olga Kornievskaia9759b0f2015-11-24 13:29:42 -0500573 "closed",
574 MAJOR(__entry->dev), MINOR(__entry->dev),
575 (unsigned long long)__entry->fileid,
576 __entry->fhandle,
577 __entry->stateid_seq, __entry->stateid_hash
578 )
579);
580
Trond Myklebust42113a72013-08-12 16:19:27 -0400581TRACE_EVENT(nfs4_close,
582 TP_PROTO(
583 const struct nfs4_state *state,
584 const struct nfs_closeargs *args,
585 const struct nfs_closeres *res,
586 int error
587 ),
588
589 TP_ARGS(state, args, res, error),
590
591 TP_STRUCT__entry(
592 __field(dev_t, dev)
593 __field(u32, fhandle)
594 __field(u64, fileid)
595 __field(unsigned int, fmode)
Chuck Lever96650e22019-06-19 10:33:53 -0400596 __field(unsigned long, error)
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500597 __field(int, stateid_seq)
598 __field(u32, stateid_hash)
Trond Myklebust42113a72013-08-12 16:19:27 -0400599 ),
600
601 TP_fast_assign(
602 const struct inode *inode = state->inode;
603
604 __entry->dev = inode->i_sb->s_dev;
605 __entry->fileid = NFS_FILEID(inode);
606 __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
607 __entry->fmode = (__force unsigned int)state->state;
Trond Myklebust118b6292020-01-06 15:25:06 -0500608 __entry->error = error < 0 ? -error : 0;
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500609 __entry->stateid_seq =
610 be32_to_cpu(args->stateid.seqid);
611 __entry->stateid_hash =
612 nfs_stateid_hash(&args->stateid);
Trond Myklebust42113a72013-08-12 16:19:27 -0400613 ),
614
615 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -0400616 "error=%ld (%s) fmode=%s fileid=%02x:%02x:%llu "
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500617 "fhandle=0x%08x openstateid=%d:0x%08x",
Chuck Lever96650e22019-06-19 10:33:53 -0400618 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -0400619 show_nfs4_status(__entry->error),
Chuck Lever9d2d48b2021-10-22 16:16:56 -0400620 __entry->fmode ? show_fs_fmode_flags(__entry->fmode) :
Trond Myklebust42113a72013-08-12 16:19:27 -0400621 "closed",
622 MAJOR(__entry->dev), MINOR(__entry->dev),
623 (unsigned long long)__entry->fileid,
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500624 __entry->fhandle,
625 __entry->stateid_seq, __entry->stateid_hash
Trond Myklebust42113a72013-08-12 16:19:27 -0400626 )
627);
628
Trond Myklebustd1b748a2013-08-12 16:35:20 -0400629DECLARE_EVENT_CLASS(nfs4_lock_event,
630 TP_PROTO(
631 const struct file_lock *request,
632 const struct nfs4_state *state,
633 int cmd,
634 int error
635 ),
636
637 TP_ARGS(request, state, cmd, error),
638
639 TP_STRUCT__entry(
Chuck Lever96650e22019-06-19 10:33:53 -0400640 __field(unsigned long, error)
Chuck Lever9d2d48b2021-10-22 16:16:56 -0400641 __field(unsigned long, cmd)
642 __field(unsigned long, type)
Trond Myklebustd1b748a2013-08-12 16:35:20 -0400643 __field(loff_t, start)
644 __field(loff_t, end)
645 __field(dev_t, dev)
646 __field(u32, fhandle)
647 __field(u64, fileid)
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500648 __field(int, stateid_seq)
649 __field(u32, stateid_hash)
Trond Myklebustd1b748a2013-08-12 16:35:20 -0400650 ),
651
652 TP_fast_assign(
653 const struct inode *inode = state->inode;
654
Trond Myklebust118b6292020-01-06 15:25:06 -0500655 __entry->error = error < 0 ? -error : 0;
Trond Myklebustd1b748a2013-08-12 16:35:20 -0400656 __entry->cmd = cmd;
657 __entry->type = request->fl_type;
658 __entry->start = request->fl_start;
659 __entry->end = request->fl_end;
660 __entry->dev = inode->i_sb->s_dev;
661 __entry->fileid = NFS_FILEID(inode);
662 __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500663 __entry->stateid_seq =
664 be32_to_cpu(state->stateid.seqid);
665 __entry->stateid_hash =
666 nfs_stateid_hash(&state->stateid);
Trond Myklebustd1b748a2013-08-12 16:35:20 -0400667 ),
668
669 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -0400670 "error=%ld (%s) cmd=%s:%s range=%lld:%lld "
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500671 "fileid=%02x:%02x:%llu fhandle=0x%08x "
672 "stateid=%d:0x%08x",
Chuck Lever96650e22019-06-19 10:33:53 -0400673 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -0400674 show_nfs4_status(__entry->error),
Chuck Lever9d2d48b2021-10-22 16:16:56 -0400675 show_fs_fcntl_cmd(__entry->cmd),
676 show_fs_fcntl_lock_type(__entry->type),
Trond Myklebustd1b748a2013-08-12 16:35:20 -0400677 (long long)__entry->start,
678 (long long)__entry->end,
679 MAJOR(__entry->dev), MINOR(__entry->dev),
680 (unsigned long long)__entry->fileid,
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500681 __entry->fhandle,
682 __entry->stateid_seq, __entry->stateid_hash
Trond Myklebustd1b748a2013-08-12 16:35:20 -0400683 )
684);
685
686#define DEFINE_NFS4_LOCK_EVENT(name) \
687 DEFINE_EVENT(nfs4_lock_event, name, \
688 TP_PROTO( \
689 const struct file_lock *request, \
690 const struct nfs4_state *state, \
691 int cmd, \
692 int error \
693 ), \
694 TP_ARGS(request, state, cmd, error))
695DEFINE_NFS4_LOCK_EVENT(nfs4_get_lock);
Trond Myklebustd1b748a2013-08-12 16:35:20 -0400696DEFINE_NFS4_LOCK_EVENT(nfs4_unlock);
697
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500698TRACE_EVENT(nfs4_set_lock,
699 TP_PROTO(
700 const struct file_lock *request,
701 const struct nfs4_state *state,
702 const nfs4_stateid *lockstateid,
703 int cmd,
704 int error
705 ),
706
707 TP_ARGS(request, state, lockstateid, cmd, error),
708
709 TP_STRUCT__entry(
Chuck Lever96650e22019-06-19 10:33:53 -0400710 __field(unsigned long, error)
Chuck Lever9d2d48b2021-10-22 16:16:56 -0400711 __field(unsigned long, cmd)
712 __field(unsigned long, type)
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500713 __field(loff_t, start)
714 __field(loff_t, end)
715 __field(dev_t, dev)
716 __field(u32, fhandle)
717 __field(u64, fileid)
718 __field(int, stateid_seq)
719 __field(u32, stateid_hash)
720 __field(int, lockstateid_seq)
721 __field(u32, lockstateid_hash)
722 ),
723
724 TP_fast_assign(
725 const struct inode *inode = state->inode;
726
Trond Myklebust118b6292020-01-06 15:25:06 -0500727 __entry->error = error < 0 ? -error : 0;
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500728 __entry->cmd = cmd;
729 __entry->type = request->fl_type;
730 __entry->start = request->fl_start;
731 __entry->end = request->fl_end;
732 __entry->dev = inode->i_sb->s_dev;
733 __entry->fileid = NFS_FILEID(inode);
734 __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
735 __entry->stateid_seq =
736 be32_to_cpu(state->stateid.seqid);
737 __entry->stateid_hash =
738 nfs_stateid_hash(&state->stateid);
739 __entry->lockstateid_seq =
740 be32_to_cpu(lockstateid->seqid);
741 __entry->lockstateid_hash =
742 nfs_stateid_hash(lockstateid);
743 ),
744
745 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -0400746 "error=%ld (%s) cmd=%s:%s range=%lld:%lld "
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500747 "fileid=%02x:%02x:%llu fhandle=0x%08x "
748 "stateid=%d:0x%08x lockstateid=%d:0x%08x",
Chuck Lever96650e22019-06-19 10:33:53 -0400749 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -0400750 show_nfs4_status(__entry->error),
Chuck Lever9d2d48b2021-10-22 16:16:56 -0400751 show_fs_fcntl_cmd(__entry->cmd),
752 show_fs_fcntl_lock_type(__entry->type),
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500753 (long long)__entry->start,
754 (long long)__entry->end,
755 MAJOR(__entry->dev), MINOR(__entry->dev),
756 (unsigned long long)__entry->fileid,
757 __entry->fhandle,
758 __entry->stateid_seq, __entry->stateid_hash,
759 __entry->lockstateid_seq, __entry->lockstateid_hash
760 )
761);
762
Chuck Lever21f86d22019-11-05 11:04:13 -0500763TRACE_DEFINE_ENUM(LK_STATE_IN_USE);
764TRACE_DEFINE_ENUM(NFS_DELEGATED_STATE);
765TRACE_DEFINE_ENUM(NFS_OPEN_STATE);
766TRACE_DEFINE_ENUM(NFS_O_RDONLY_STATE);
767TRACE_DEFINE_ENUM(NFS_O_WRONLY_STATE);
768TRACE_DEFINE_ENUM(NFS_O_RDWR_STATE);
769TRACE_DEFINE_ENUM(NFS_STATE_RECLAIM_REBOOT);
770TRACE_DEFINE_ENUM(NFS_STATE_RECLAIM_NOGRACE);
771TRACE_DEFINE_ENUM(NFS_STATE_POSIX_LOCKS);
772TRACE_DEFINE_ENUM(NFS_STATE_RECOVERY_FAILED);
773TRACE_DEFINE_ENUM(NFS_STATE_MAY_NOTIFY_LOCK);
774TRACE_DEFINE_ENUM(NFS_STATE_CHANGE_WAIT);
775TRACE_DEFINE_ENUM(NFS_CLNT_DST_SSC_COPY_STATE);
776TRACE_DEFINE_ENUM(NFS_CLNT_SRC_SSC_COPY_STATE);
777TRACE_DEFINE_ENUM(NFS_SRV_SSC_COPY_STATE);
778
779#define show_nfs4_state_flags(flags) \
780 __print_flags(flags, "|", \
781 { LK_STATE_IN_USE, "IN_USE" }, \
782 { NFS_DELEGATED_STATE, "DELEGATED" }, \
783 { NFS_OPEN_STATE, "OPEN" }, \
784 { NFS_O_RDONLY_STATE, "O_RDONLY" }, \
785 { NFS_O_WRONLY_STATE, "O_WRONLY" }, \
786 { NFS_O_RDWR_STATE, "O_RDWR" }, \
787 { NFS_STATE_RECLAIM_REBOOT, "RECLAIM_REBOOT" }, \
788 { NFS_STATE_RECLAIM_NOGRACE, "RECLAIM_NOGRACE" }, \
789 { NFS_STATE_POSIX_LOCKS, "POSIX_LOCKS" }, \
790 { NFS_STATE_RECOVERY_FAILED, "RECOVERY_FAILED" }, \
791 { NFS_STATE_MAY_NOTIFY_LOCK, "MAY_NOTIFY_LOCK" }, \
792 { NFS_STATE_CHANGE_WAIT, "CHANGE_WAIT" }, \
793 { NFS_CLNT_DST_SSC_COPY_STATE, "CLNT_DST_SSC_COPY" }, \
794 { NFS_CLNT_SRC_SSC_COPY_STATE, "CLNT_SRC_SSC_COPY" }, \
795 { NFS_SRV_SSC_COPY_STATE, "SRV_SSC_COPY" })
796
797#define show_nfs4_lock_flags(flags) \
798 __print_flags(flags, "|", \
799 { BIT(NFS_LOCK_INITIALIZED), "INITIALIZED" }, \
800 { BIT(NFS_LOCK_LOST), "LOST" })
801
802TRACE_EVENT(nfs4_state_lock_reclaim,
803 TP_PROTO(
804 const struct nfs4_state *state,
805 const struct nfs4_lock_state *lock
806 ),
807
808 TP_ARGS(state, lock),
809
810 TP_STRUCT__entry(
811 __field(dev_t, dev)
812 __field(u32, fhandle)
813 __field(u64, fileid)
814 __field(unsigned long, state_flags)
815 __field(unsigned long, lock_flags)
816 __field(int, stateid_seq)
817 __field(u32, stateid_hash)
818 ),
819
820 TP_fast_assign(
821 const struct inode *inode = state->inode;
822
823 __entry->dev = inode->i_sb->s_dev;
824 __entry->fileid = NFS_FILEID(inode);
825 __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
826 __entry->state_flags = state->flags;
827 __entry->lock_flags = lock->ls_flags;
828 __entry->stateid_seq =
829 be32_to_cpu(state->stateid.seqid);
830 __entry->stateid_hash =
831 nfs_stateid_hash(&state->stateid);
832 ),
833
834 TP_printk(
835 "fileid=%02x:%02x:%llu fhandle=0x%08x "
836 "stateid=%d:0x%08x state_flags=%s lock_flags=%s",
837 MAJOR(__entry->dev), MINOR(__entry->dev),
838 (unsigned long long)__entry->fileid, __entry->fhandle,
839 __entry->stateid_seq, __entry->stateid_hash,
840 show_nfs4_state_flags(__entry->state_flags),
841 show_nfs4_lock_flags(__entry->lock_flags)
842 )
843)
844
Trond Myklebustca8acf82013-08-13 10:36:56 -0400845DECLARE_EVENT_CLASS(nfs4_set_delegation_event,
846 TP_PROTO(
847 const struct inode *inode,
848 fmode_t fmode
849 ),
850
851 TP_ARGS(inode, fmode),
852
853 TP_STRUCT__entry(
854 __field(dev_t, dev)
855 __field(u32, fhandle)
856 __field(u64, fileid)
857 __field(unsigned int, fmode)
858 ),
859
860 TP_fast_assign(
861 __entry->dev = inode->i_sb->s_dev;
862 __entry->fileid = NFS_FILEID(inode);
863 __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
864 __entry->fmode = (__force unsigned int)fmode;
865 ),
866
867 TP_printk(
868 "fmode=%s fileid=%02x:%02x:%llu fhandle=0x%08x",
Chuck Lever9d2d48b2021-10-22 16:16:56 -0400869 show_fs_fmode_flags(__entry->fmode),
Trond Myklebustca8acf82013-08-13 10:36:56 -0400870 MAJOR(__entry->dev), MINOR(__entry->dev),
871 (unsigned long long)__entry->fileid,
872 __entry->fhandle
873 )
874);
875#define DEFINE_NFS4_SET_DELEGATION_EVENT(name) \
876 DEFINE_EVENT(nfs4_set_delegation_event, name, \
877 TP_PROTO( \
878 const struct inode *inode, \
879 fmode_t fmode \
880 ), \
881 TP_ARGS(inode, fmode))
882DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_set_delegation);
883DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_reclaim_delegation);
884
885TRACE_EVENT(nfs4_delegreturn_exit,
886 TP_PROTO(
887 const struct nfs4_delegreturnargs *args,
888 const struct nfs4_delegreturnres *res,
889 int error
890 ),
891
892 TP_ARGS(args, res, error),
893
894 TP_STRUCT__entry(
895 __field(dev_t, dev)
896 __field(u32, fhandle)
Chuck Lever96650e22019-06-19 10:33:53 -0400897 __field(unsigned long, error)
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500898 __field(int, stateid_seq)
899 __field(u32, stateid_hash)
Trond Myklebustca8acf82013-08-13 10:36:56 -0400900 ),
901
902 TP_fast_assign(
903 __entry->dev = res->server->s_dev;
904 __entry->fhandle = nfs_fhandle_hash(args->fhandle);
Trond Myklebust118b6292020-01-06 15:25:06 -0500905 __entry->error = error < 0 ? -error : 0;
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500906 __entry->stateid_seq =
907 be32_to_cpu(args->stateid->seqid);
908 __entry->stateid_hash =
909 nfs_stateid_hash(args->stateid);
Trond Myklebustca8acf82013-08-13 10:36:56 -0400910 ),
911
912 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -0400913 "error=%ld (%s) dev=%02x:%02x fhandle=0x%08x "
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500914 "stateid=%d:0x%08x",
Chuck Lever96650e22019-06-19 10:33:53 -0400915 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -0400916 show_nfs4_status(__entry->error),
Trond Myklebustca8acf82013-08-13 10:36:56 -0400917 MAJOR(__entry->dev), MINOR(__entry->dev),
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500918 __entry->fhandle,
919 __entry->stateid_seq, __entry->stateid_hash
Trond Myklebustca8acf82013-08-13 10:36:56 -0400920 )
921);
922
Trond Myklebust08cb47f2013-08-20 21:59:40 -0400923#ifdef CONFIG_NFS_V4_1
924DECLARE_EVENT_CLASS(nfs4_test_stateid_event,
925 TP_PROTO(
926 const struct nfs4_state *state,
927 const struct nfs4_lock_state *lsp,
928 int error
929 ),
930
931 TP_ARGS(state, lsp, error),
932
933 TP_STRUCT__entry(
Chuck Lever96650e22019-06-19 10:33:53 -0400934 __field(unsigned long, error)
Trond Myklebust08cb47f2013-08-20 21:59:40 -0400935 __field(dev_t, dev)
936 __field(u32, fhandle)
937 __field(u64, fileid)
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500938 __field(int, stateid_seq)
939 __field(u32, stateid_hash)
Trond Myklebust08cb47f2013-08-20 21:59:40 -0400940 ),
941
942 TP_fast_assign(
943 const struct inode *inode = state->inode;
944
Trond Myklebust118b6292020-01-06 15:25:06 -0500945 __entry->error = error < 0 ? -error : 0;
Trond Myklebust08cb47f2013-08-20 21:59:40 -0400946 __entry->dev = inode->i_sb->s_dev;
947 __entry->fileid = NFS_FILEID(inode);
948 __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500949 __entry->stateid_seq =
950 be32_to_cpu(state->stateid.seqid);
951 __entry->stateid_hash =
952 nfs_stateid_hash(&state->stateid);
Trond Myklebust08cb47f2013-08-20 21:59:40 -0400953 ),
954
955 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -0400956 "error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500957 "stateid=%d:0x%08x",
Chuck Lever96650e22019-06-19 10:33:53 -0400958 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -0400959 show_nfs4_status(__entry->error),
Trond Myklebust08cb47f2013-08-20 21:59:40 -0400960 MAJOR(__entry->dev), MINOR(__entry->dev),
961 (unsigned long long)__entry->fileid,
Olga Kornievskaia48c95792015-11-24 13:29:41 -0500962 __entry->fhandle,
963 __entry->stateid_seq, __entry->stateid_hash
Trond Myklebust08cb47f2013-08-20 21:59:40 -0400964 )
965);
966
967#define DEFINE_NFS4_TEST_STATEID_EVENT(name) \
968 DEFINE_EVENT(nfs4_test_stateid_event, name, \
969 TP_PROTO( \
970 const struct nfs4_state *state, \
971 const struct nfs4_lock_state *lsp, \
972 int error \
973 ), \
974 TP_ARGS(state, lsp, error))
975DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_delegation_stateid);
976DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_open_stateid);
977DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_lock_stateid);
978#endif /* CONFIG_NFS_V4_1 */
979
Trond Myklebust078ea3d2013-08-12 16:45:55 -0400980DECLARE_EVENT_CLASS(nfs4_lookup_event,
981 TP_PROTO(
982 const struct inode *dir,
983 const struct qstr *name,
984 int error
985 ),
986
987 TP_ARGS(dir, name, error),
988
989 TP_STRUCT__entry(
990 __field(dev_t, dev)
Chuck Lever96650e22019-06-19 10:33:53 -0400991 __field(unsigned long, error)
Trond Myklebust078ea3d2013-08-12 16:45:55 -0400992 __field(u64, dir)
993 __string(name, name->name)
994 ),
995
996 TP_fast_assign(
997 __entry->dev = dir->i_sb->s_dev;
998 __entry->dir = NFS_FILEID(dir);
Chuck Lever96650e22019-06-19 10:33:53 -0400999 __entry->error = -error;
Trond Myklebust078ea3d2013-08-12 16:45:55 -04001000 __assign_str(name, name->name);
1001 ),
1002
1003 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -04001004 "error=%ld (%s) name=%02x:%02x:%llu/%s",
1005 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -04001006 show_nfs4_status(__entry->error),
Trond Myklebust078ea3d2013-08-12 16:45:55 -04001007 MAJOR(__entry->dev), MINOR(__entry->dev),
1008 (unsigned long long)__entry->dir,
1009 __get_str(name)
1010 )
1011);
1012
1013#define DEFINE_NFS4_LOOKUP_EVENT(name) \
1014 DEFINE_EVENT(nfs4_lookup_event, name, \
1015 TP_PROTO( \
1016 const struct inode *dir, \
1017 const struct qstr *name, \
1018 int error \
1019 ), \
1020 TP_ARGS(dir, name, error))
1021
1022DEFINE_NFS4_LOOKUP_EVENT(nfs4_lookup);
1023DEFINE_NFS4_LOOKUP_EVENT(nfs4_symlink);
1024DEFINE_NFS4_LOOKUP_EVENT(nfs4_mkdir);
1025DEFINE_NFS4_LOOKUP_EVENT(nfs4_mknod);
1026DEFINE_NFS4_LOOKUP_EVENT(nfs4_remove);
1027DEFINE_NFS4_LOOKUP_EVENT(nfs4_get_fs_locations);
1028DEFINE_NFS4_LOOKUP_EVENT(nfs4_secinfo);
1029
Jeff Layton5b5faaf2017-06-29 06:34:52 -07001030TRACE_EVENT(nfs4_lookupp,
1031 TP_PROTO(
1032 const struct inode *inode,
1033 int error
1034 ),
1035
1036 TP_ARGS(inode, error),
1037
1038 TP_STRUCT__entry(
1039 __field(dev_t, dev)
1040 __field(u64, ino)
Chuck Lever96650e22019-06-19 10:33:53 -04001041 __field(unsigned long, error)
Jeff Layton5b5faaf2017-06-29 06:34:52 -07001042 ),
1043
1044 TP_fast_assign(
1045 __entry->dev = inode->i_sb->s_dev;
1046 __entry->ino = NFS_FILEID(inode);
Trond Myklebust118b6292020-01-06 15:25:06 -05001047 __entry->error = error < 0 ? -error : 0;
Jeff Layton5b5faaf2017-06-29 06:34:52 -07001048 ),
1049
1050 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -04001051 "error=%ld (%s) inode=%02x:%02x:%llu",
1052 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -04001053 show_nfs4_status(__entry->error),
Jeff Layton5b5faaf2017-06-29 06:34:52 -07001054 MAJOR(__entry->dev), MINOR(__entry->dev),
1055 (unsigned long long)__entry->ino
1056 )
1057);
1058
Trond Myklebustfbc6f7c2013-08-12 17:08:26 -04001059TRACE_EVENT(nfs4_rename,
1060 TP_PROTO(
1061 const struct inode *olddir,
1062 const struct qstr *oldname,
1063 const struct inode *newdir,
1064 const struct qstr *newname,
1065 int error
1066 ),
1067
1068 TP_ARGS(olddir, oldname, newdir, newname, error),
1069
1070 TP_STRUCT__entry(
1071 __field(dev_t, dev)
Chuck Lever96650e22019-06-19 10:33:53 -04001072 __field(unsigned long, error)
Trond Myklebustfbc6f7c2013-08-12 17:08:26 -04001073 __field(u64, olddir)
1074 __string(oldname, oldname->name)
1075 __field(u64, newdir)
1076 __string(newname, newname->name)
1077 ),
1078
1079 TP_fast_assign(
1080 __entry->dev = olddir->i_sb->s_dev;
1081 __entry->olddir = NFS_FILEID(olddir);
1082 __entry->newdir = NFS_FILEID(newdir);
Trond Myklebust118b6292020-01-06 15:25:06 -05001083 __entry->error = error < 0 ? -error : 0;
Trond Myklebustfbc6f7c2013-08-12 17:08:26 -04001084 __assign_str(oldname, oldname->name);
1085 __assign_str(newname, newname->name);
1086 ),
1087
1088 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -04001089 "error=%ld (%s) oldname=%02x:%02x:%llu/%s "
Trond Myklebustfbc6f7c2013-08-12 17:08:26 -04001090 "newname=%02x:%02x:%llu/%s",
Chuck Lever96650e22019-06-19 10:33:53 -04001091 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -04001092 show_nfs4_status(__entry->error),
Trond Myklebustfbc6f7c2013-08-12 17:08:26 -04001093 MAJOR(__entry->dev), MINOR(__entry->dev),
1094 (unsigned long long)__entry->olddir,
1095 __get_str(oldname),
1096 MAJOR(__entry->dev), MINOR(__entry->dev),
1097 (unsigned long long)__entry->newdir,
1098 __get_str(newname)
1099 )
1100);
1101
Trond Myklebustc1578b72013-08-12 16:58:42 -04001102DECLARE_EVENT_CLASS(nfs4_inode_event,
1103 TP_PROTO(
1104 const struct inode *inode,
1105 int error
1106 ),
1107
1108 TP_ARGS(inode, error),
1109
1110 TP_STRUCT__entry(
1111 __field(dev_t, dev)
1112 __field(u32, fhandle)
1113 __field(u64, fileid)
Chuck Lever96650e22019-06-19 10:33:53 -04001114 __field(unsigned long, error)
Trond Myklebustc1578b72013-08-12 16:58:42 -04001115 ),
1116
1117 TP_fast_assign(
1118 __entry->dev = inode->i_sb->s_dev;
1119 __entry->fileid = NFS_FILEID(inode);
1120 __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
Chuck Lever96650e22019-06-19 10:33:53 -04001121 __entry->error = error < 0 ? -error : 0;
Trond Myklebustc1578b72013-08-12 16:58:42 -04001122 ),
1123
1124 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -04001125 "error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x",
1126 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -04001127 show_nfs4_status(__entry->error),
Trond Myklebustc1578b72013-08-12 16:58:42 -04001128 MAJOR(__entry->dev), MINOR(__entry->dev),
1129 (unsigned long long)__entry->fileid,
1130 __entry->fhandle
1131 )
1132);
1133
1134#define DEFINE_NFS4_INODE_EVENT(name) \
1135 DEFINE_EVENT(nfs4_inode_event, name, \
1136 TP_PROTO( \
1137 const struct inode *inode, \
1138 int error \
1139 ), \
1140 TP_ARGS(inode, error))
1141
Trond Myklebustc1578b72013-08-12 16:58:42 -04001142DEFINE_NFS4_INODE_EVENT(nfs4_access);
1143DEFINE_NFS4_INODE_EVENT(nfs4_readlink);
1144DEFINE_NFS4_INODE_EVENT(nfs4_readdir);
1145DEFINE_NFS4_INODE_EVENT(nfs4_get_acl);
1146DEFINE_NFS4_INODE_EVENT(nfs4_set_acl);
1147#ifdef CONFIG_NFS_V4_SECURITY_LABEL
1148DEFINE_NFS4_INODE_EVENT(nfs4_get_security_label);
1149DEFINE_NFS4_INODE_EVENT(nfs4_set_security_label);
1150#endif /* CONFIG_NFS_V4_SECURITY_LABEL */
Olga Kornievskaia48c95792015-11-24 13:29:41 -05001151
1152DECLARE_EVENT_CLASS(nfs4_inode_stateid_event,
1153 TP_PROTO(
1154 const struct inode *inode,
1155 const nfs4_stateid *stateid,
1156 int error
1157 ),
1158
1159 TP_ARGS(inode, stateid, error),
1160
1161 TP_STRUCT__entry(
1162 __field(dev_t, dev)
1163 __field(u32, fhandle)
1164 __field(u64, fileid)
Chuck Lever96650e22019-06-19 10:33:53 -04001165 __field(unsigned long, error)
Olga Kornievskaia48c95792015-11-24 13:29:41 -05001166 __field(int, stateid_seq)
1167 __field(u32, stateid_hash)
1168 ),
1169
1170 TP_fast_assign(
1171 __entry->dev = inode->i_sb->s_dev;
1172 __entry->fileid = NFS_FILEID(inode);
1173 __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
Trond Myklebust118b6292020-01-06 15:25:06 -05001174 __entry->error = error < 0 ? -error : 0;
Olga Kornievskaia48c95792015-11-24 13:29:41 -05001175 __entry->stateid_seq =
1176 be32_to_cpu(stateid->seqid);
1177 __entry->stateid_hash =
1178 nfs_stateid_hash(stateid);
1179 ),
1180
1181 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -04001182 "error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
Olga Kornievskaia48c95792015-11-24 13:29:41 -05001183 "stateid=%d:0x%08x",
Chuck Lever96650e22019-06-19 10:33:53 -04001184 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -04001185 show_nfs4_status(__entry->error),
Olga Kornievskaia48c95792015-11-24 13:29:41 -05001186 MAJOR(__entry->dev), MINOR(__entry->dev),
1187 (unsigned long long)__entry->fileid,
1188 __entry->fhandle,
1189 __entry->stateid_seq, __entry->stateid_hash
1190 )
1191);
1192
1193#define DEFINE_NFS4_INODE_STATEID_EVENT(name) \
1194 DEFINE_EVENT(nfs4_inode_stateid_event, name, \
1195 TP_PROTO( \
1196 const struct inode *inode, \
1197 const nfs4_stateid *stateid, \
1198 int error \
1199 ), \
1200 TP_ARGS(inode, stateid, error))
1201
1202DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_setattr);
1203DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_delegreturn);
Trond Myklebustad9e02d2017-11-06 15:28:02 -05001204DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_open_stateid_update);
1205DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_open_stateid_update_wait);
Benjamin Coddingtonb4868b42020-09-25 15:48:39 -04001206DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_close_stateid_update_wait);
Trond Myklebustc1578b72013-08-12 16:58:42 -04001207
Trond Myklebustb5f875a2013-08-13 13:01:39 -04001208DECLARE_EVENT_CLASS(nfs4_getattr_event,
1209 TP_PROTO(
1210 const struct nfs_server *server,
1211 const struct nfs_fh *fhandle,
1212 const struct nfs_fattr *fattr,
1213 int error
1214 ),
1215
1216 TP_ARGS(server, fhandle, fattr, error),
1217
1218 TP_STRUCT__entry(
1219 __field(dev_t, dev)
1220 __field(u32, fhandle)
1221 __field(u64, fileid)
1222 __field(unsigned int, valid)
Chuck Lever96650e22019-06-19 10:33:53 -04001223 __field(unsigned long, error)
Trond Myklebustb5f875a2013-08-13 13:01:39 -04001224 ),
1225
1226 TP_fast_assign(
1227 __entry->dev = server->s_dev;
1228 __entry->valid = fattr->valid;
1229 __entry->fhandle = nfs_fhandle_hash(fhandle);
1230 __entry->fileid = (fattr->valid & NFS_ATTR_FATTR_FILEID) ? fattr->fileid : 0;
Trond Myklebust118b6292020-01-06 15:25:06 -05001231 __entry->error = error < 0 ? -error : 0;
Trond Myklebustb5f875a2013-08-13 13:01:39 -04001232 ),
1233
1234 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -04001235 "error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
Trond Myklebustb5f875a2013-08-13 13:01:39 -04001236 "valid=%s",
Chuck Lever96650e22019-06-19 10:33:53 -04001237 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -04001238 show_nfs4_status(__entry->error),
Trond Myklebustb5f875a2013-08-13 13:01:39 -04001239 MAJOR(__entry->dev), MINOR(__entry->dev),
1240 (unsigned long long)__entry->fileid,
1241 __entry->fhandle,
1242 show_nfs_fattr_flags(__entry->valid)
1243 )
1244);
1245
1246#define DEFINE_NFS4_GETATTR_EVENT(name) \
1247 DEFINE_EVENT(nfs4_getattr_event, name, \
1248 TP_PROTO( \
1249 const struct nfs_server *server, \
1250 const struct nfs_fh *fhandle, \
1251 const struct nfs_fattr *fattr, \
1252 int error \
1253 ), \
1254 TP_ARGS(server, fhandle, fattr, error))
1255DEFINE_NFS4_GETATTR_EVENT(nfs4_getattr);
1256DEFINE_NFS4_GETATTR_EVENT(nfs4_lookup_root);
1257DEFINE_NFS4_GETATTR_EVENT(nfs4_fsinfo);
1258
Trond Myklebust7cd14862015-08-20 20:07:54 -05001259DECLARE_EVENT_CLASS(nfs4_inode_callback_event,
1260 TP_PROTO(
1261 const struct nfs_client *clp,
1262 const struct nfs_fh *fhandle,
1263 const struct inode *inode,
1264 int error
1265 ),
1266
1267 TP_ARGS(clp, fhandle, inode, error),
1268
1269 TP_STRUCT__entry(
Chuck Lever96650e22019-06-19 10:33:53 -04001270 __field(unsigned long, error)
Trond Myklebust7cd14862015-08-20 20:07:54 -05001271 __field(dev_t, dev)
1272 __field(u32, fhandle)
1273 __field(u64, fileid)
Anna Schumaker39443692017-11-01 15:48:43 -04001274 __string(dstaddr, clp ? clp->cl_hostname : "unknown")
Trond Myklebust7cd14862015-08-20 20:07:54 -05001275 ),
1276
1277 TP_fast_assign(
Trond Myklebust118b6292020-01-06 15:25:06 -05001278 __entry->error = error < 0 ? -error : 0;
Trond Myklebust7cd14862015-08-20 20:07:54 -05001279 __entry->fhandle = nfs_fhandle_hash(fhandle);
Trond Myklebust2edaead2018-09-05 14:07:13 -04001280 if (!IS_ERR_OR_NULL(inode)) {
Trond Myklebust7cd14862015-08-20 20:07:54 -05001281 __entry->fileid = NFS_FILEID(inode);
1282 __entry->dev = inode->i_sb->s_dev;
1283 } else {
1284 __entry->fileid = 0;
1285 __entry->dev = 0;
1286 }
Joe Perches78c14b32021-06-12 08:42:27 -07001287 __assign_str(dstaddr, clp ? clp->cl_hostname : "unknown");
Trond Myklebust7cd14862015-08-20 20:07:54 -05001288 ),
1289
1290 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -04001291 "error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
Trond Myklebust7cd14862015-08-20 20:07:54 -05001292 "dstaddr=%s",
Chuck Lever96650e22019-06-19 10:33:53 -04001293 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -04001294 show_nfs4_status(__entry->error),
Trond Myklebust7cd14862015-08-20 20:07:54 -05001295 MAJOR(__entry->dev), MINOR(__entry->dev),
1296 (unsigned long long)__entry->fileid,
1297 __entry->fhandle,
1298 __get_str(dstaddr)
1299 )
1300);
1301
1302#define DEFINE_NFS4_INODE_CALLBACK_EVENT(name) \
1303 DEFINE_EVENT(nfs4_inode_callback_event, name, \
1304 TP_PROTO( \
1305 const struct nfs_client *clp, \
1306 const struct nfs_fh *fhandle, \
1307 const struct inode *inode, \
1308 int error \
1309 ), \
1310 TP_ARGS(clp, fhandle, inode, error))
1311DEFINE_NFS4_INODE_CALLBACK_EVENT(nfs4_cb_getattr);
1312
Trond Myklebuste07db902015-12-28 14:07:23 -05001313DECLARE_EVENT_CLASS(nfs4_inode_stateid_callback_event,
1314 TP_PROTO(
1315 const struct nfs_client *clp,
1316 const struct nfs_fh *fhandle,
1317 const struct inode *inode,
1318 const nfs4_stateid *stateid,
1319 int error
1320 ),
1321
1322 TP_ARGS(clp, fhandle, inode, stateid, error),
1323
1324 TP_STRUCT__entry(
Chuck Lever96650e22019-06-19 10:33:53 -04001325 __field(unsigned long, error)
Trond Myklebuste07db902015-12-28 14:07:23 -05001326 __field(dev_t, dev)
1327 __field(u32, fhandle)
1328 __field(u64, fileid)
Anna Schumaker39443692017-11-01 15:48:43 -04001329 __string(dstaddr, clp ? clp->cl_hostname : "unknown")
Trond Myklebuste07db902015-12-28 14:07:23 -05001330 __field(int, stateid_seq)
1331 __field(u32, stateid_hash)
1332 ),
1333
1334 TP_fast_assign(
Trond Myklebust118b6292020-01-06 15:25:06 -05001335 __entry->error = error < 0 ? -error : 0;
Trond Myklebuste07db902015-12-28 14:07:23 -05001336 __entry->fhandle = nfs_fhandle_hash(fhandle);
Trond Myklebust2a534a72018-08-23 11:02:49 -04001337 if (!IS_ERR_OR_NULL(inode)) {
Trond Myklebuste07db902015-12-28 14:07:23 -05001338 __entry->fileid = NFS_FILEID(inode);
1339 __entry->dev = inode->i_sb->s_dev;
1340 } else {
1341 __entry->fileid = 0;
1342 __entry->dev = 0;
1343 }
Joe Perches78c14b32021-06-12 08:42:27 -07001344 __assign_str(dstaddr, clp ? clp->cl_hostname : "unknown");
Trond Myklebuste07db902015-12-28 14:07:23 -05001345 __entry->stateid_seq =
1346 be32_to_cpu(stateid->seqid);
1347 __entry->stateid_hash =
1348 nfs_stateid_hash(stateid);
1349 ),
1350
1351 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -04001352 "error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
Trond Myklebuste07db902015-12-28 14:07:23 -05001353 "stateid=%d:0x%08x dstaddr=%s",
Chuck Lever96650e22019-06-19 10:33:53 -04001354 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -04001355 show_nfs4_status(__entry->error),
Trond Myklebuste07db902015-12-28 14:07:23 -05001356 MAJOR(__entry->dev), MINOR(__entry->dev),
1357 (unsigned long long)__entry->fileid,
1358 __entry->fhandle,
1359 __entry->stateid_seq, __entry->stateid_hash,
1360 __get_str(dstaddr)
1361 )
1362);
1363
1364#define DEFINE_NFS4_INODE_STATEID_CALLBACK_EVENT(name) \
1365 DEFINE_EVENT(nfs4_inode_stateid_callback_event, name, \
1366 TP_PROTO( \
1367 const struct nfs_client *clp, \
1368 const struct nfs_fh *fhandle, \
1369 const struct inode *inode, \
1370 const nfs4_stateid *stateid, \
1371 int error \
1372 ), \
1373 TP_ARGS(clp, fhandle, inode, stateid, error))
1374DEFINE_NFS4_INODE_STATEID_CALLBACK_EVENT(nfs4_cb_recall);
1375DEFINE_NFS4_INODE_STATEID_CALLBACK_EVENT(nfs4_cb_layoutrecall_file);
Trond Myklebust7cd14862015-08-20 20:07:54 -05001376
Trond Myklebust1f2d30b2013-08-13 11:34:01 -04001377DECLARE_EVENT_CLASS(nfs4_idmap_event,
1378 TP_PROTO(
1379 const char *name,
1380 int len,
1381 u32 id,
1382 int error
1383 ),
1384
1385 TP_ARGS(name, len, id, error),
1386
1387 TP_STRUCT__entry(
Chuck Lever96650e22019-06-19 10:33:53 -04001388 __field(unsigned long, error)
Trond Myklebust1f2d30b2013-08-13 11:34:01 -04001389 __field(u32, id)
1390 __dynamic_array(char, name, len > 0 ? len + 1 : 1)
1391 ),
1392
1393 TP_fast_assign(
1394 if (len < 0)
1395 len = 0;
1396 __entry->error = error < 0 ? error : 0;
1397 __entry->id = id;
Daniel Bristot de Oliveira752d5962016-07-01 20:44:36 -03001398 memcpy(__get_str(name), name, len);
1399 __get_str(name)[len] = 0;
Trond Myklebust1f2d30b2013-08-13 11:34:01 -04001400 ),
1401
1402 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -04001403 "error=%ld (%s) id=%u name=%s",
Chuck Lever87915452021-10-22 16:17:03 -04001404 -__entry->error, show_nfs4_status(__entry->error),
Trond Myklebust1f2d30b2013-08-13 11:34:01 -04001405 __entry->id,
1406 __get_str(name)
1407 )
1408);
1409#define DEFINE_NFS4_IDMAP_EVENT(name) \
1410 DEFINE_EVENT(nfs4_idmap_event, name, \
1411 TP_PROTO( \
1412 const char *name, \
1413 int len, \
1414 u32 id, \
1415 int error \
1416 ), \
1417 TP_ARGS(name, len, id, error))
1418DEFINE_NFS4_IDMAP_EVENT(nfs4_map_name_to_uid);
1419DEFINE_NFS4_IDMAP_EVENT(nfs4_map_group_to_gid);
1420DEFINE_NFS4_IDMAP_EVENT(nfs4_map_uid_to_name);
1421DEFINE_NFS4_IDMAP_EVENT(nfs4_map_gid_to_group);
1422
Trond Myklebust54898f72020-08-04 22:16:06 -04001423#ifdef CONFIG_NFS_V4_1
1424#define NFS4_LSEG_LAYOUT_STATEID_HASH(lseg) \
1425 (lseg ? nfs_stateid_hash(&lseg->pls_layout->plh_stateid) : 0)
1426#else
1427#define NFS4_LSEG_LAYOUT_STATEID_HASH(lseg) (0)
1428#endif
1429
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001430DECLARE_EVENT_CLASS(nfs4_read_event,
1431 TP_PROTO(
Weston Andros Adamsond45f60c2014-06-09 11:48:35 -04001432 const struct nfs_pgio_header *hdr,
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001433 int error
1434 ),
1435
Weston Andros Adamsond45f60c2014-06-09 11:48:35 -04001436 TP_ARGS(hdr, error),
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001437
1438 TP_STRUCT__entry(
1439 __field(dev_t, dev)
1440 __field(u32, fhandle)
1441 __field(u64, fileid)
1442 __field(loff_t, offset)
Trond Myklebust25925b02020-01-06 15:25:05 -05001443 __field(u32, arg_count)
1444 __field(u32, res_count)
Chuck Lever96650e22019-06-19 10:33:53 -04001445 __field(unsigned long, error)
Olga Kornievskaia48c95792015-11-24 13:29:41 -05001446 __field(int, stateid_seq)
1447 __field(u32, stateid_hash)
Trond Myklebust54898f72020-08-04 22:16:06 -04001448 __field(int, layoutstateid_seq)
1449 __field(u32, layoutstateid_hash)
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001450 ),
1451
1452 TP_fast_assign(
Weston Andros Adamsond45f60c2014-06-09 11:48:35 -04001453 const struct inode *inode = hdr->inode;
Trond Myklebust25925b02020-01-06 15:25:05 -05001454 const struct nfs_inode *nfsi = NFS_I(inode);
1455 const struct nfs_fh *fh = hdr->args.fh ?
1456 hdr->args.fh : &nfsi->fh;
Olga Kornievskaia48c95792015-11-24 13:29:41 -05001457 const struct nfs4_state *state =
1458 hdr->args.context->state;
Trond Myklebust54898f72020-08-04 22:16:06 -04001459 const struct pnfs_layout_segment *lseg = hdr->lseg;
Trond Myklebust25925b02020-01-06 15:25:05 -05001460
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001461 __entry->dev = inode->i_sb->s_dev;
Trond Myklebust25925b02020-01-06 15:25:05 -05001462 __entry->fileid = nfsi->fileid;
1463 __entry->fhandle = nfs_fhandle_hash(fh);
Weston Andros Adamsond45f60c2014-06-09 11:48:35 -04001464 __entry->offset = hdr->args.offset;
Trond Myklebust25925b02020-01-06 15:25:05 -05001465 __entry->arg_count = hdr->args.count;
1466 __entry->res_count = hdr->res.count;
Chuck Lever96650e22019-06-19 10:33:53 -04001467 __entry->error = error < 0 ? -error : 0;
Olga Kornievskaia48c95792015-11-24 13:29:41 -05001468 __entry->stateid_seq =
1469 be32_to_cpu(state->stateid.seqid);
1470 __entry->stateid_hash =
1471 nfs_stateid_hash(&state->stateid);
Trond Myklebust54898f72020-08-04 22:16:06 -04001472 __entry->layoutstateid_seq = lseg ? lseg->pls_seq : 0;
1473 __entry->layoutstateid_hash =
1474 NFS4_LSEG_LAYOUT_STATEID_HASH(lseg);
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001475 ),
1476
1477 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -04001478 "error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
Trond Myklebust54898f72020-08-04 22:16:06 -04001479 "offset=%lld count=%u res=%u stateid=%d:0x%08x "
1480 "layoutstateid=%d:0x%08x",
Chuck Lever96650e22019-06-19 10:33:53 -04001481 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -04001482 show_nfs4_status(__entry->error),
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001483 MAJOR(__entry->dev), MINOR(__entry->dev),
1484 (unsigned long long)__entry->fileid,
1485 __entry->fhandle,
1486 (long long)__entry->offset,
Trond Myklebust25925b02020-01-06 15:25:05 -05001487 __entry->arg_count, __entry->res_count,
Trond Myklebust54898f72020-08-04 22:16:06 -04001488 __entry->stateid_seq, __entry->stateid_hash,
1489 __entry->layoutstateid_seq, __entry->layoutstateid_hash
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001490 )
1491);
1492#define DEFINE_NFS4_READ_EVENT(name) \
1493 DEFINE_EVENT(nfs4_read_event, name, \
1494 TP_PROTO( \
Weston Andros Adamsond45f60c2014-06-09 11:48:35 -04001495 const struct nfs_pgio_header *hdr, \
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001496 int error \
1497 ), \
Weston Andros Adamsond45f60c2014-06-09 11:48:35 -04001498 TP_ARGS(hdr, error))
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001499DEFINE_NFS4_READ_EVENT(nfs4_read);
1500#ifdef CONFIG_NFS_V4_1
1501DEFINE_NFS4_READ_EVENT(nfs4_pnfs_read);
1502#endif /* CONFIG_NFS_V4_1 */
1503
1504DECLARE_EVENT_CLASS(nfs4_write_event,
1505 TP_PROTO(
Weston Andros Adamsond45f60c2014-06-09 11:48:35 -04001506 const struct nfs_pgio_header *hdr,
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001507 int error
1508 ),
1509
Weston Andros Adamsond45f60c2014-06-09 11:48:35 -04001510 TP_ARGS(hdr, error),
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001511
1512 TP_STRUCT__entry(
1513 __field(dev_t, dev)
1514 __field(u32, fhandle)
1515 __field(u64, fileid)
1516 __field(loff_t, offset)
Trond Myklebust25925b02020-01-06 15:25:05 -05001517 __field(u32, arg_count)
1518 __field(u32, res_count)
Chuck Lever96650e22019-06-19 10:33:53 -04001519 __field(unsigned long, error)
Olga Kornievskaia48c95792015-11-24 13:29:41 -05001520 __field(int, stateid_seq)
1521 __field(u32, stateid_hash)
Trond Myklebust54898f72020-08-04 22:16:06 -04001522 __field(int, layoutstateid_seq)
1523 __field(u32, layoutstateid_hash)
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001524 ),
1525
1526 TP_fast_assign(
Weston Andros Adamsond45f60c2014-06-09 11:48:35 -04001527 const struct inode *inode = hdr->inode;
Trond Myklebust25925b02020-01-06 15:25:05 -05001528 const struct nfs_inode *nfsi = NFS_I(inode);
1529 const struct nfs_fh *fh = hdr->args.fh ?
1530 hdr->args.fh : &nfsi->fh;
Olga Kornievskaia48c95792015-11-24 13:29:41 -05001531 const struct nfs4_state *state =
1532 hdr->args.context->state;
Trond Myklebust54898f72020-08-04 22:16:06 -04001533 const struct pnfs_layout_segment *lseg = hdr->lseg;
Trond Myklebust25925b02020-01-06 15:25:05 -05001534
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001535 __entry->dev = inode->i_sb->s_dev;
Trond Myklebust25925b02020-01-06 15:25:05 -05001536 __entry->fileid = nfsi->fileid;
1537 __entry->fhandle = nfs_fhandle_hash(fh);
Weston Andros Adamsond45f60c2014-06-09 11:48:35 -04001538 __entry->offset = hdr->args.offset;
Trond Myklebust25925b02020-01-06 15:25:05 -05001539 __entry->arg_count = hdr->args.count;
1540 __entry->res_count = hdr->res.count;
Chuck Lever96650e22019-06-19 10:33:53 -04001541 __entry->error = error < 0 ? -error : 0;
Olga Kornievskaia48c95792015-11-24 13:29:41 -05001542 __entry->stateid_seq =
1543 be32_to_cpu(state->stateid.seqid);
1544 __entry->stateid_hash =
1545 nfs_stateid_hash(&state->stateid);
Trond Myklebust54898f72020-08-04 22:16:06 -04001546 __entry->layoutstateid_seq = lseg ? lseg->pls_seq : 0;
1547 __entry->layoutstateid_hash =
1548 NFS4_LSEG_LAYOUT_STATEID_HASH(lseg);
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001549 ),
1550
1551 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -04001552 "error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
Trond Myklebust54898f72020-08-04 22:16:06 -04001553 "offset=%lld count=%u res=%u stateid=%d:0x%08x "
1554 "layoutstateid=%d:0x%08x",
Chuck Lever96650e22019-06-19 10:33:53 -04001555 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -04001556 show_nfs4_status(__entry->error),
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001557 MAJOR(__entry->dev), MINOR(__entry->dev),
1558 (unsigned long long)__entry->fileid,
1559 __entry->fhandle,
1560 (long long)__entry->offset,
Trond Myklebust25925b02020-01-06 15:25:05 -05001561 __entry->arg_count, __entry->res_count,
Trond Myklebust54898f72020-08-04 22:16:06 -04001562 __entry->stateid_seq, __entry->stateid_hash,
1563 __entry->layoutstateid_seq, __entry->layoutstateid_hash
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001564 )
1565);
1566
1567#define DEFINE_NFS4_WRITE_EVENT(name) \
1568 DEFINE_EVENT(nfs4_write_event, name, \
1569 TP_PROTO( \
Weston Andros Adamsond45f60c2014-06-09 11:48:35 -04001570 const struct nfs_pgio_header *hdr, \
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001571 int error \
1572 ), \
Weston Andros Adamsond45f60c2014-06-09 11:48:35 -04001573 TP_ARGS(hdr, error))
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001574DEFINE_NFS4_WRITE_EVENT(nfs4_write);
1575#ifdef CONFIG_NFS_V4_1
1576DEFINE_NFS4_WRITE_EVENT(nfs4_pnfs_write);
1577#endif /* CONFIG_NFS_V4_1 */
1578
1579DECLARE_EVENT_CLASS(nfs4_commit_event,
1580 TP_PROTO(
1581 const struct nfs_commit_data *data,
1582 int error
1583 ),
1584
1585 TP_ARGS(data, error),
1586
1587 TP_STRUCT__entry(
1588 __field(dev_t, dev)
1589 __field(u32, fhandle)
1590 __field(u64, fileid)
Chuck Lever96650e22019-06-19 10:33:53 -04001591 __field(unsigned long, error)
Trond Myklebust25925b02020-01-06 15:25:05 -05001592 __field(loff_t, offset)
1593 __field(u32, count)
Trond Myklebust54898f72020-08-04 22:16:06 -04001594 __field(int, layoutstateid_seq)
1595 __field(u32, layoutstateid_hash)
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001596 ),
1597
1598 TP_fast_assign(
1599 const struct inode *inode = data->inode;
Trond Myklebust25925b02020-01-06 15:25:05 -05001600 const struct nfs_inode *nfsi = NFS_I(inode);
1601 const struct nfs_fh *fh = data->args.fh ?
1602 data->args.fh : &nfsi->fh;
Trond Myklebust54898f72020-08-04 22:16:06 -04001603 const struct pnfs_layout_segment *lseg = data->lseg;
Trond Myklebust25925b02020-01-06 15:25:05 -05001604
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001605 __entry->dev = inode->i_sb->s_dev;
Trond Myklebust25925b02020-01-06 15:25:05 -05001606 __entry->fileid = nfsi->fileid;
1607 __entry->fhandle = nfs_fhandle_hash(fh);
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001608 __entry->offset = data->args.offset;
1609 __entry->count = data->args.count;
Trond Myklebust25925b02020-01-06 15:25:05 -05001610 __entry->error = error < 0 ? -error : 0;
Trond Myklebust54898f72020-08-04 22:16:06 -04001611 __entry->layoutstateid_seq = lseg ? lseg->pls_seq : 0;
1612 __entry->layoutstateid_hash =
1613 NFS4_LSEG_LAYOUT_STATEID_HASH(lseg);
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001614 ),
1615
1616 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -04001617 "error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
Trond Myklebust54898f72020-08-04 22:16:06 -04001618 "offset=%lld count=%u layoutstateid=%d:0x%08x",
Chuck Lever96650e22019-06-19 10:33:53 -04001619 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -04001620 show_nfs4_status(__entry->error),
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001621 MAJOR(__entry->dev), MINOR(__entry->dev),
1622 (unsigned long long)__entry->fileid,
1623 __entry->fhandle,
1624 (long long)__entry->offset,
Trond Myklebust54898f72020-08-04 22:16:06 -04001625 __entry->count,
1626 __entry->layoutstateid_seq, __entry->layoutstateid_hash
Trond Myklebustcc668ab2013-08-14 15:31:28 -04001627 )
1628);
1629#define DEFINE_NFS4_COMMIT_EVENT(name) \
1630 DEFINE_EVENT(nfs4_commit_event, name, \
1631 TP_PROTO( \
1632 const struct nfs_commit_data *data, \
1633 int error \
1634 ), \
1635 TP_ARGS(data, error))
1636DEFINE_NFS4_COMMIT_EVENT(nfs4_commit);
1637#ifdef CONFIG_NFS_V4_1
1638DEFINE_NFS4_COMMIT_EVENT(nfs4_pnfs_commit_ds);
Trond Myklebust1037e6e2013-08-14 16:36:51 -04001639
Trond Myklebust1037e6e2013-08-14 16:36:51 -04001640TRACE_EVENT(nfs4_layoutget,
1641 TP_PROTO(
1642 const struct nfs_open_context *ctx,
1643 const struct pnfs_layout_range *args,
1644 const struct pnfs_layout_range *res,
Olga Kornievskaia48c95792015-11-24 13:29:41 -05001645 const nfs4_stateid *layout_stateid,
Trond Myklebust1037e6e2013-08-14 16:36:51 -04001646 int error
1647 ),
1648
Olga Kornievskaia48c95792015-11-24 13:29:41 -05001649 TP_ARGS(ctx, args, res, layout_stateid, error),
Trond Myklebust1037e6e2013-08-14 16:36:51 -04001650
1651 TP_STRUCT__entry(
1652 __field(dev_t, dev)
1653 __field(u32, fhandle)
1654 __field(u64, fileid)
1655 __field(u32, iomode)
1656 __field(u64, offset)
1657 __field(u64, count)
Chuck Lever96650e22019-06-19 10:33:53 -04001658 __field(unsigned long, error)
Olga Kornievskaia48c95792015-11-24 13:29:41 -05001659 __field(int, stateid_seq)
1660 __field(u32, stateid_hash)
1661 __field(int, layoutstateid_seq)
1662 __field(u32, layoutstateid_hash)
Trond Myklebust1037e6e2013-08-14 16:36:51 -04001663 ),
1664
1665 TP_fast_assign(
David Howells2b0143b2015-03-17 22:25:59 +00001666 const struct inode *inode = d_inode(ctx->dentry);
Olga Kornievskaia48c95792015-11-24 13:29:41 -05001667 const struct nfs4_state *state = ctx->state;
Trond Myklebust1037e6e2013-08-14 16:36:51 -04001668 __entry->dev = inode->i_sb->s_dev;
1669 __entry->fileid = NFS_FILEID(inode);
1670 __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1671 __entry->iomode = args->iomode;
1672 __entry->offset = args->offset;
1673 __entry->count = args->length;
Trond Myklebust118b6292020-01-06 15:25:06 -05001674 __entry->error = error < 0 ? -error : 0;
Olga Kornievskaia48c95792015-11-24 13:29:41 -05001675 __entry->stateid_seq =
1676 be32_to_cpu(state->stateid.seqid);
1677 __entry->stateid_hash =
1678 nfs_stateid_hash(&state->stateid);
1679 if (!error) {
1680 __entry->layoutstateid_seq =
1681 be32_to_cpu(layout_stateid->seqid);
1682 __entry->layoutstateid_hash =
1683 nfs_stateid_hash(layout_stateid);
1684 } else {
1685 __entry->layoutstateid_seq = 0;
1686 __entry->layoutstateid_hash = 0;
1687 }
Trond Myklebust1037e6e2013-08-14 16:36:51 -04001688 ),
1689
1690 TP_printk(
Chuck Lever96650e22019-06-19 10:33:53 -04001691 "error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
Olga Kornievskaia48c95792015-11-24 13:29:41 -05001692 "iomode=%s offset=%llu count=%llu stateid=%d:0x%08x "
1693 "layoutstateid=%d:0x%08x",
Chuck Lever96650e22019-06-19 10:33:53 -04001694 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -04001695 show_nfs4_status(__entry->error),
Trond Myklebust1037e6e2013-08-14 16:36:51 -04001696 MAJOR(__entry->dev), MINOR(__entry->dev),
1697 (unsigned long long)__entry->fileid,
1698 __entry->fhandle,
Chuck Lever87915452021-10-22 16:17:03 -04001699 show_pnfs_layout_iomode(__entry->iomode),
Trond Myklebust1037e6e2013-08-14 16:36:51 -04001700 (unsigned long long)__entry->offset,
Olga Kornievskaia48c95792015-11-24 13:29:41 -05001701 (unsigned long long)__entry->count,
1702 __entry->stateid_seq, __entry->stateid_hash,
1703 __entry->layoutstateid_seq, __entry->layoutstateid_hash
Trond Myklebust1037e6e2013-08-14 16:36:51 -04001704 )
1705);
1706
Olga Kornievskaia48c95792015-11-24 13:29:41 -05001707DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layoutcommit);
1708DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layoutreturn);
Trond Myklebusta19b4782020-08-03 18:32:28 -04001709DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layoutreturn_on_close);
Trond Myklebust638037b2020-08-04 11:02:44 -04001710DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layouterror);
1711DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layoutstats);
Trond Myklebust1037e6e2013-08-14 16:36:51 -04001712
Chuck Lever5b2095d2018-12-19 11:00:11 -05001713TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_UNKNOWN);
1714TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_NO_PNFS);
1715TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_RD_ZEROLEN);
1716TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_MDSTHRESH);
1717TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_NOMEM);
1718TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_BULK_RECALL);
1719TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_IO_TEST_FAIL);
1720TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_FOUND_CACHED);
1721TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_RETURN);
1722TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_BLOCKED);
1723TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_INVALID_OPEN);
1724TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_RETRY);
1725TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_SEND_LAYOUTGET);
Trond Myklebustd5b92162019-07-18 09:32:17 -04001726TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_EXIT);
Chuck Lever5b2095d2018-12-19 11:00:11 -05001727
Jeff Layton9a4bf312015-12-10 10:41:58 -05001728#define show_pnfs_update_layout_reason(reason) \
1729 __print_symbolic(reason, \
1730 { PNFS_UPDATE_LAYOUT_UNKNOWN, "unknown" }, \
1731 { PNFS_UPDATE_LAYOUT_NO_PNFS, "no pnfs" }, \
1732 { PNFS_UPDATE_LAYOUT_RD_ZEROLEN, "read+zerolen" }, \
1733 { PNFS_UPDATE_LAYOUT_MDSTHRESH, "mdsthresh" }, \
1734 { PNFS_UPDATE_LAYOUT_NOMEM, "nomem" }, \
1735 { PNFS_UPDATE_LAYOUT_BULK_RECALL, "bulk recall" }, \
1736 { PNFS_UPDATE_LAYOUT_IO_TEST_FAIL, "io test fail" }, \
1737 { PNFS_UPDATE_LAYOUT_FOUND_CACHED, "found cached" }, \
1738 { PNFS_UPDATE_LAYOUT_RETURN, "layoutreturn" }, \
1739 { PNFS_UPDATE_LAYOUT_BLOCKED, "layouts blocked" }, \
Jeff Layton183d9e72016-05-17 12:28:47 -04001740 { PNFS_UPDATE_LAYOUT_INVALID_OPEN, "invalid open" }, \
1741 { PNFS_UPDATE_LAYOUT_RETRY, "retrying" }, \
Trond Myklebustd5b92162019-07-18 09:32:17 -04001742 { PNFS_UPDATE_LAYOUT_SEND_LAYOUTGET, "sent layoutget" }, \
1743 { PNFS_UPDATE_LAYOUT_EXIT, "exit" })
Jeff Layton9a4bf312015-12-10 10:41:58 -05001744
1745TRACE_EVENT(pnfs_update_layout,
1746 TP_PROTO(struct inode *inode,
1747 loff_t pos,
1748 u64 count,
1749 enum pnfs_iomode iomode,
Trond Myklebustf4848302015-12-26 18:03:07 -05001750 struct pnfs_layout_hdr *lo,
Jeff Layton183d9e72016-05-17 12:28:47 -04001751 struct pnfs_layout_segment *lseg,
Jeff Layton9a4bf312015-12-10 10:41:58 -05001752 enum pnfs_update_layout_reason reason
1753 ),
Jeff Layton183d9e72016-05-17 12:28:47 -04001754 TP_ARGS(inode, pos, count, iomode, lo, lseg, reason),
Jeff Layton9a4bf312015-12-10 10:41:58 -05001755 TP_STRUCT__entry(
1756 __field(dev_t, dev)
1757 __field(u64, fileid)
1758 __field(u32, fhandle)
1759 __field(loff_t, pos)
1760 __field(u64, count)
1761 __field(enum pnfs_iomode, iomode)
Trond Myklebustf4848302015-12-26 18:03:07 -05001762 __field(int, layoutstateid_seq)
1763 __field(u32, layoutstateid_hash)
Jeff Layton183d9e72016-05-17 12:28:47 -04001764 __field(long, lseg)
Jeff Layton9a4bf312015-12-10 10:41:58 -05001765 __field(enum pnfs_update_layout_reason, reason)
1766 ),
1767 TP_fast_assign(
1768 __entry->dev = inode->i_sb->s_dev;
1769 __entry->fileid = NFS_FILEID(inode);
1770 __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1771 __entry->pos = pos;
1772 __entry->count = count;
1773 __entry->iomode = iomode;
Jeff Layton9a4bf312015-12-10 10:41:58 -05001774 __entry->reason = reason;
Trond Myklebustf4848302015-12-26 18:03:07 -05001775 if (lo != NULL) {
1776 __entry->layoutstateid_seq =
1777 be32_to_cpu(lo->plh_stateid.seqid);
1778 __entry->layoutstateid_hash =
1779 nfs_stateid_hash(&lo->plh_stateid);
1780 } else {
1781 __entry->layoutstateid_seq = 0;
1782 __entry->layoutstateid_hash = 0;
1783 }
Jeff Layton183d9e72016-05-17 12:28:47 -04001784 __entry->lseg = (long)lseg;
Jeff Layton9a4bf312015-12-10 10:41:58 -05001785 ),
1786 TP_printk(
1787 "fileid=%02x:%02x:%llu fhandle=0x%08x "
Trond Myklebustf4848302015-12-26 18:03:07 -05001788 "iomode=%s pos=%llu count=%llu "
Jeff Layton183d9e72016-05-17 12:28:47 -04001789 "layoutstateid=%d:0x%08x lseg=0x%lx (%s)",
Jeff Layton9a4bf312015-12-10 10:41:58 -05001790 MAJOR(__entry->dev), MINOR(__entry->dev),
1791 (unsigned long long)__entry->fileid,
1792 __entry->fhandle,
Chuck Lever87915452021-10-22 16:17:03 -04001793 show_pnfs_layout_iomode(__entry->iomode),
Jeff Layton9a4bf312015-12-10 10:41:58 -05001794 (unsigned long long)__entry->pos,
Trond Myklebustf4848302015-12-26 18:03:07 -05001795 (unsigned long long)__entry->count,
1796 __entry->layoutstateid_seq, __entry->layoutstateid_hash,
Jeff Layton183d9e72016-05-17 12:28:47 -04001797 __entry->lseg,
Jeff Layton9a4bf312015-12-10 10:41:58 -05001798 show_pnfs_update_layout_reason(__entry->reason)
1799 )
1800);
1801
Trond Myklebustd5b92162019-07-18 09:32:17 -04001802DECLARE_EVENT_CLASS(pnfs_layout_event,
1803 TP_PROTO(struct inode *inode,
1804 loff_t pos,
1805 u64 count,
1806 enum pnfs_iomode iomode,
1807 struct pnfs_layout_hdr *lo,
1808 struct pnfs_layout_segment *lseg
1809 ),
1810 TP_ARGS(inode, pos, count, iomode, lo, lseg),
1811 TP_STRUCT__entry(
1812 __field(dev_t, dev)
1813 __field(u64, fileid)
1814 __field(u32, fhandle)
1815 __field(loff_t, pos)
1816 __field(u64, count)
1817 __field(enum pnfs_iomode, iomode)
1818 __field(int, layoutstateid_seq)
1819 __field(u32, layoutstateid_hash)
1820 __field(long, lseg)
1821 ),
1822 TP_fast_assign(
1823 __entry->dev = inode->i_sb->s_dev;
1824 __entry->fileid = NFS_FILEID(inode);
1825 __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1826 __entry->pos = pos;
1827 __entry->count = count;
1828 __entry->iomode = iomode;
1829 if (lo != NULL) {
1830 __entry->layoutstateid_seq =
1831 be32_to_cpu(lo->plh_stateid.seqid);
1832 __entry->layoutstateid_hash =
1833 nfs_stateid_hash(&lo->plh_stateid);
1834 } else {
1835 __entry->layoutstateid_seq = 0;
1836 __entry->layoutstateid_hash = 0;
1837 }
1838 __entry->lseg = (long)lseg;
1839 ),
1840 TP_printk(
1841 "fileid=%02x:%02x:%llu fhandle=0x%08x "
1842 "iomode=%s pos=%llu count=%llu "
1843 "layoutstateid=%d:0x%08x lseg=0x%lx",
1844 MAJOR(__entry->dev), MINOR(__entry->dev),
1845 (unsigned long long)__entry->fileid,
1846 __entry->fhandle,
Chuck Lever87915452021-10-22 16:17:03 -04001847 show_pnfs_layout_iomode(__entry->iomode),
Trond Myklebustd5b92162019-07-18 09:32:17 -04001848 (unsigned long long)__entry->pos,
1849 (unsigned long long)__entry->count,
1850 __entry->layoutstateid_seq, __entry->layoutstateid_hash,
1851 __entry->lseg
1852 )
1853);
1854
1855#define DEFINE_PNFS_LAYOUT_EVENT(name) \
1856 DEFINE_EVENT(pnfs_layout_event, name, \
1857 TP_PROTO(struct inode *inode, \
1858 loff_t pos, \
1859 u64 count, \
1860 enum pnfs_iomode iomode, \
1861 struct pnfs_layout_hdr *lo, \
1862 struct pnfs_layout_segment *lseg \
1863 ), \
1864 TP_ARGS(inode, pos, count, iomode, lo, lseg))
1865
1866DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_pg_init_read);
1867DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_pg_init_write);
1868DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_pg_get_mirror_count);
1869DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_read_done);
1870DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_write_done);
1871DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_read_pagelist);
1872DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_write_pagelist);
1873
Trond Myklebustcac1d3a2020-12-16 16:31:26 -05001874DECLARE_EVENT_CLASS(nfs4_deviceid_event,
1875 TP_PROTO(
1876 const struct nfs_client *clp,
1877 const struct nfs4_deviceid *deviceid
1878 ),
1879
1880 TP_ARGS(clp, deviceid),
1881
1882 TP_STRUCT__entry(
1883 __string(dstaddr, clp->cl_hostname)
1884 __array(unsigned char, deviceid, NFS4_DEVICEID4_SIZE)
1885 ),
1886
1887 TP_fast_assign(
1888 __assign_str(dstaddr, clp->cl_hostname);
1889 memcpy(__entry->deviceid, deviceid->data,
1890 NFS4_DEVICEID4_SIZE);
1891 ),
1892
1893 TP_printk(
1894 "deviceid=%s, dstaddr=%s",
1895 __print_hex(__entry->deviceid, NFS4_DEVICEID4_SIZE),
1896 __get_str(dstaddr)
1897 )
1898);
1899#define DEFINE_PNFS_DEVICEID_EVENT(name) \
1900 DEFINE_EVENT(nfs4_deviceid_event, name, \
1901 TP_PROTO(const struct nfs_client *clp, \
1902 const struct nfs4_deviceid *deviceid \
1903 ), \
1904 TP_ARGS(clp, deviceid))
1905DEFINE_PNFS_DEVICEID_EVENT(nfs4_deviceid_free);
1906
1907DECLARE_EVENT_CLASS(nfs4_deviceid_status,
1908 TP_PROTO(
1909 const struct nfs_server *server,
1910 const struct nfs4_deviceid *deviceid,
1911 int status
1912 ),
1913
1914 TP_ARGS(server, deviceid, status),
1915
1916 TP_STRUCT__entry(
1917 __field(dev_t, dev)
1918 __field(int, status)
1919 __string(dstaddr, server->nfs_client->cl_hostname)
1920 __array(unsigned char, deviceid, NFS4_DEVICEID4_SIZE)
1921 ),
1922
1923 TP_fast_assign(
1924 __entry->dev = server->s_dev;
1925 __entry->status = status;
1926 __assign_str(dstaddr, server->nfs_client->cl_hostname);
1927 memcpy(__entry->deviceid, deviceid->data,
1928 NFS4_DEVICEID4_SIZE);
1929 ),
1930
1931 TP_printk(
1932 "dev=%02x:%02x: deviceid=%s, dstaddr=%s, status=%d",
1933 MAJOR(__entry->dev), MINOR(__entry->dev),
1934 __print_hex(__entry->deviceid, NFS4_DEVICEID4_SIZE),
1935 __get_str(dstaddr),
1936 __entry->status
1937 )
1938);
1939#define DEFINE_PNFS_DEVICEID_STATUS(name) \
1940 DEFINE_EVENT(nfs4_deviceid_status, name, \
1941 TP_PROTO(const struct nfs_server *server, \
1942 const struct nfs4_deviceid *deviceid, \
1943 int status \
1944 ), \
1945 TP_ARGS(server, deviceid, status))
1946DEFINE_PNFS_DEVICEID_STATUS(nfs4_getdeviceinfo);
1947DEFINE_PNFS_DEVICEID_STATUS(nfs4_find_deviceid);
1948
Trond Myklebust088f3e62020-01-06 15:25:11 -05001949DECLARE_EVENT_CLASS(nfs4_flexfiles_io_event,
1950 TP_PROTO(
1951 const struct nfs_pgio_header *hdr
1952 ),
1953
1954 TP_ARGS(hdr),
1955
1956 TP_STRUCT__entry(
1957 __field(unsigned long, error)
1958 __field(dev_t, dev)
1959 __field(u32, fhandle)
1960 __field(u64, fileid)
1961 __field(loff_t, offset)
1962 __field(u32, count)
1963 __field(int, stateid_seq)
1964 __field(u32, stateid_hash)
1965 __string(dstaddr, hdr->ds_clp ?
1966 rpc_peeraddr2str(hdr->ds_clp->cl_rpcclient,
1967 RPC_DISPLAY_ADDR) : "unknown")
1968 ),
1969
1970 TP_fast_assign(
1971 const struct inode *inode = hdr->inode;
1972
1973 __entry->error = hdr->res.op_status;
1974 __entry->fhandle = nfs_fhandle_hash(hdr->args.fh);
1975 __entry->fileid = NFS_FILEID(inode);
1976 __entry->dev = inode->i_sb->s_dev;
1977 __entry->offset = hdr->args.offset;
1978 __entry->count = hdr->args.count;
1979 __entry->stateid_seq =
1980 be32_to_cpu(hdr->args.stateid.seqid);
1981 __entry->stateid_hash =
1982 nfs_stateid_hash(&hdr->args.stateid);
1983 __assign_str(dstaddr, hdr->ds_clp ?
1984 rpc_peeraddr2str(hdr->ds_clp->cl_rpcclient,
1985 RPC_DISPLAY_ADDR) : "unknown");
1986 ),
1987
1988 TP_printk(
1989 "error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1990 "offset=%llu count=%u stateid=%d:0x%08x dstaddr=%s",
1991 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -04001992 show_nfs4_status(__entry->error),
Trond Myklebust088f3e62020-01-06 15:25:11 -05001993 MAJOR(__entry->dev), MINOR(__entry->dev),
1994 (unsigned long long)__entry->fileid,
1995 __entry->fhandle,
1996 __entry->offset, __entry->count,
1997 __entry->stateid_seq, __entry->stateid_hash,
1998 __get_str(dstaddr)
1999 )
2000);
2001
2002#define DEFINE_NFS4_FLEXFILES_IO_EVENT(name) \
2003 DEFINE_EVENT(nfs4_flexfiles_io_event, name, \
2004 TP_PROTO( \
2005 const struct nfs_pgio_header *hdr \
2006 ), \
2007 TP_ARGS(hdr))
2008DEFINE_NFS4_FLEXFILES_IO_EVENT(ff_layout_read_error);
2009DEFINE_NFS4_FLEXFILES_IO_EVENT(ff_layout_write_error);
2010
2011TRACE_EVENT(ff_layout_commit_error,
2012 TP_PROTO(
2013 const struct nfs_commit_data *data
2014 ),
2015
2016 TP_ARGS(data),
2017
2018 TP_STRUCT__entry(
2019 __field(unsigned long, error)
2020 __field(dev_t, dev)
2021 __field(u32, fhandle)
2022 __field(u64, fileid)
2023 __field(loff_t, offset)
2024 __field(u32, count)
2025 __string(dstaddr, data->ds_clp ?
2026 rpc_peeraddr2str(data->ds_clp->cl_rpcclient,
2027 RPC_DISPLAY_ADDR) : "unknown")
2028 ),
2029
2030 TP_fast_assign(
2031 const struct inode *inode = data->inode;
2032
2033 __entry->error = data->res.op_status;
2034 __entry->fhandle = nfs_fhandle_hash(data->args.fh);
2035 __entry->fileid = NFS_FILEID(inode);
2036 __entry->dev = inode->i_sb->s_dev;
2037 __entry->offset = data->args.offset;
2038 __entry->count = data->args.count;
2039 __assign_str(dstaddr, data->ds_clp ?
2040 rpc_peeraddr2str(data->ds_clp->cl_rpcclient,
2041 RPC_DISPLAY_ADDR) : "unknown");
2042 ),
2043
2044 TP_printk(
2045 "error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
2046 "offset=%llu count=%u dstaddr=%s",
2047 -__entry->error,
Chuck Lever87915452021-10-22 16:17:03 -04002048 show_nfs4_status(__entry->error),
Trond Myklebust088f3e62020-01-06 15:25:11 -05002049 MAJOR(__entry->dev), MINOR(__entry->dev),
2050 (unsigned long long)__entry->fileid,
2051 __entry->fhandle,
2052 __entry->offset, __entry->count,
2053 __get_str(dstaddr)
2054 )
2055);
2056
Olga Kornievskaiaf628d462021-11-04 10:57:08 -04002057TRACE_DEFINE_ENUM(NFS4_CONTENT_DATA);
2058TRACE_DEFINE_ENUM(NFS4_CONTENT_HOLE);
2059
2060#define show_llseek_mode(what) \
2061 __print_symbolic(what, \
2062 { NFS4_CONTENT_DATA, "DATA" }, \
2063 { NFS4_CONTENT_HOLE, "HOLE" })
2064
2065#ifdef CONFIG_NFS_V4_2
2066TRACE_EVENT(nfs4_llseek,
2067 TP_PROTO(
2068 const struct inode *inode,
2069 const struct nfs42_seek_args *args,
2070 const struct nfs42_seek_res *res,
2071 int error
2072 ),
2073
2074 TP_ARGS(inode, args, res, error),
2075
2076 TP_STRUCT__entry(
2077 __field(unsigned long, error)
2078 __field(u32, fhandle)
2079 __field(u32, fileid)
2080 __field(dev_t, dev)
2081 __field(int, stateid_seq)
2082 __field(u32, stateid_hash)
2083 __field(loff_t, offset_s)
2084 __field(u32, what)
2085 __field(loff_t, offset_r)
2086 __field(u32, eof)
2087 ),
2088
2089 TP_fast_assign(
2090 const struct nfs_inode *nfsi = NFS_I(inode);
2091 const struct nfs_fh *fh = args->sa_fh;
2092
2093 __entry->fileid = nfsi->fileid;
2094 __entry->dev = inode->i_sb->s_dev;
2095 __entry->fhandle = nfs_fhandle_hash(fh);
2096 __entry->offset_s = args->sa_offset;
2097 __entry->stateid_seq =
2098 be32_to_cpu(args->sa_stateid.seqid);
2099 __entry->stateid_hash =
2100 nfs_stateid_hash(&args->sa_stateid);
2101 __entry->what = args->sa_what;
2102 if (error) {
2103 __entry->error = -error;
2104 __entry->offset_r = 0;
2105 __entry->eof = 0;
2106 } else {
2107 __entry->error = 0;
2108 __entry->offset_r = res->sr_offset;
2109 __entry->eof = res->sr_eof;
2110 }
2111 ),
2112
2113 TP_printk(
2114 "error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
2115 "stateid=%d:0x%08x offset_s=%llu what=%s "
2116 "offset_r=%llu eof=%u",
2117 -__entry->error,
2118 show_nfs4_status(__entry->error),
2119 MAJOR(__entry->dev), MINOR(__entry->dev),
2120 (unsigned long long)__entry->fileid,
2121 __entry->fhandle,
2122 __entry->stateid_seq, __entry->stateid_hash,
2123 __entry->offset_s,
2124 show_llseek_mode(__entry->what),
2125 __entry->offset_r,
2126 __entry->eof
2127 )
2128);
2129
2130#endif /* CONFIG_NFS_V4_2 */
Trond Myklebust088f3e62020-01-06 15:25:11 -05002131
Trond Myklebustcc668ab2013-08-14 15:31:28 -04002132#endif /* CONFIG_NFS_V4_1 */
2133
Trond Myklebustc6d01c62013-08-09 11:51:26 -04002134#endif /* _TRACE_NFS4_H */
2135
2136#undef TRACE_INCLUDE_PATH
2137#define TRACE_INCLUDE_PATH .
2138#define TRACE_INCLUDE_FILE nfs4trace
2139/* This part must be outside protection */
2140#include <trace/define_trace.h>