xref: /openbmc/linux/fs/nfs/nfs4trace.h (revision b46d80bd)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
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>
12 #include <trace/misc/sunrpc.h>
13 
14 #include <trace/misc/fs.h>
15 #include <trace/misc/nfs.h>
16 
17 #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 
35 DECLARE_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(
44 			__string(dstaddr, clp->cl_hostname)
45 			__field(unsigned long, error)
46 		),
47 
48 		TP_fast_assign(
49 			__entry->error = error < 0 ? -error : 0;
50 			__assign_str(dstaddr, clp->cl_hostname);
51 		),
52 
53 		TP_printk(
54 			"error=%ld (%s) dstaddr=%s",
55 			-__entry->error,
56 			show_nfs4_status(__entry->error),
57 			__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))
67 DEFINE_NFS4_CLIENTID_EVENT(nfs4_setclientid);
68 DEFINE_NFS4_CLIENTID_EVENT(nfs4_setclientid_confirm);
69 DEFINE_NFS4_CLIENTID_EVENT(nfs4_renew);
70 DEFINE_NFS4_CLIENTID_EVENT(nfs4_renew_async);
71 #ifdef CONFIG_NFS_V4_1
72 DEFINE_NFS4_CLIENTID_EVENT(nfs4_exchange_id);
73 DEFINE_NFS4_CLIENTID_EVENT(nfs4_create_session);
74 DEFINE_NFS4_CLIENTID_EVENT(nfs4_destroy_session);
75 DEFINE_NFS4_CLIENTID_EVENT(nfs4_destroy_clientid);
76 DEFINE_NFS4_CLIENTID_EVENT(nfs4_bind_conn_to_session);
77 DEFINE_NFS4_CLIENTID_EVENT(nfs4_sequence);
78 DEFINE_NFS4_CLIENTID_EVENT(nfs4_reclaim_complete);
79 
80 TRACE_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)
93 			__field(unsigned long, status_flags)
94 			__field(unsigned long, error)
95 		),
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;
105 			__entry->status_flags = res->sr_status_flags;
106 			__entry->error = res->sr_status < 0 ?
107 					-res->sr_status : 0;
108 		),
109 		TP_printk(
110 			"error=%ld (%s) session=0x%08x slot_nr=%u seq_nr=%u "
111 			"highest_slotid=%u target_highest_slotid=%u "
112 			"status_flags=0x%lx (%s)",
113 			-__entry->error,
114 			show_nfs4_status(__entry->error),
115 			__entry->session,
116 			__entry->slot_nr,
117 			__entry->seq_nr,
118 			__entry->highest_slotid,
119 			__entry->target_highest_slotid,
120 			__entry->status_flags,
121 			show_nfs4_seq4_status(__entry->status_flags)
122 		)
123 );
124 
125 struct cb_sequenceargs;
126 struct cb_sequenceres;
127 
128 TRACE_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)
142 			__field(unsigned long, error)
143 		),
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;
151 			__entry->error = be32_to_cpu(status);
152 		),
153 
154 		TP_printk(
155 			"error=%ld (%s) session=0x%08x slot_nr=%u seq_nr=%u "
156 			"highest_slotid=%u",
157 			-__entry->error,
158 			show_nfs4_status(__entry->error),
159 			__entry->session,
160 			__entry->slot_nr,
161 			__entry->seq_nr,
162 			__entry->highest_slotid
163 		)
164 );
165 
166 TRACE_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)
179 			__field(unsigned long, error)
180 		),
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;
188 			__entry->error = be32_to_cpu(status);
189 		),
190 
191 		TP_printk(
192 			"error=%ld (%s) session=0x%08x slot_nr=%u seq_nr=%u "
193 			"highest_slotid=%u",
194 			-__entry->error,
195 			show_nfs4_status(__entry->error),
196 			__entry->session,
197 			__entry->slot_nr,
198 			__entry->seq_nr,
199 			__entry->highest_slotid
200 		)
201 );
202 
203 TRACE_EVENT(nfs4_cb_offload,
204 		TP_PROTO(
205 			const struct nfs_fh *cb_fh,
206 			const nfs4_stateid *cb_stateid,
207 			uint64_t cb_count,
208 			int cb_error,
209 			int cb_how_stable
210 		),
211 
212 		TP_ARGS(cb_fh, cb_stateid, cb_count, cb_error,
213 			cb_how_stable),
214 
215 		TP_STRUCT__entry(
216 			__field(unsigned long, error)
217 			__field(u32, fhandle)
218 			__field(loff_t, cb_count)
219 			__field(int, cb_how)
220 			__field(int, cb_stateid_seq)
221 			__field(u32, cb_stateid_hash)
222 		),
223 
224 		TP_fast_assign(
225 			__entry->error = cb_error < 0 ? -cb_error : 0;
226 			__entry->fhandle = nfs_fhandle_hash(cb_fh);
227 			__entry->cb_stateid_seq =
228 				be32_to_cpu(cb_stateid->seqid);
229 			__entry->cb_stateid_hash =
230 				nfs_stateid_hash(cb_stateid);
231 			__entry->cb_count = cb_count;
232 			__entry->cb_how = cb_how_stable;
233 		),
234 
235 		TP_printk(
236 			"error=%ld (%s) fhandle=0x%08x cb_stateid=%d:0x%08x "
237 			"cb_count=%llu cb_how=%s",
238 			-__entry->error,
239 			show_nfs4_status(__entry->error),
240 			__entry->fhandle,
241 			__entry->cb_stateid_seq, __entry->cb_stateid_hash,
242 			__entry->cb_count,
243 			show_nfs_stable_how(__entry->cb_how)
244 		)
245 );
246 #endif /* CONFIG_NFS_V4_1 */
247 
248 TRACE_EVENT(nfs4_setup_sequence,
249 		TP_PROTO(
250 			const struct nfs4_session *session,
251 			const struct nfs4_sequence_args *args
252 		),
253 		TP_ARGS(session, args),
254 
255 		TP_STRUCT__entry(
256 			__field(unsigned int, session)
257 			__field(unsigned int, slot_nr)
258 			__field(unsigned int, seq_nr)
259 			__field(unsigned int, highest_used_slotid)
260 		),
261 
262 		TP_fast_assign(
263 			const struct nfs4_slot *sa_slot = args->sa_slot;
264 			__entry->session = session ? nfs_session_id_hash(&session->sess_id) : 0;
265 			__entry->slot_nr = sa_slot->slot_nr;
266 			__entry->seq_nr = sa_slot->seq_nr;
267 			__entry->highest_used_slotid =
268 					sa_slot->table->highest_used_slotid;
269 		),
270 		TP_printk(
271 			"session=0x%08x slot_nr=%u seq_nr=%u "
272 			"highest_used_slotid=%u",
273 			__entry->session,
274 			__entry->slot_nr,
275 			__entry->seq_nr,
276 			__entry->highest_used_slotid
277 		)
278 );
279 
280 TRACE_DEFINE_ENUM(NFS4CLNT_MANAGER_RUNNING);
281 TRACE_DEFINE_ENUM(NFS4CLNT_CHECK_LEASE);
282 TRACE_DEFINE_ENUM(NFS4CLNT_LEASE_EXPIRED);
283 TRACE_DEFINE_ENUM(NFS4CLNT_RECLAIM_REBOOT);
284 TRACE_DEFINE_ENUM(NFS4CLNT_RECLAIM_NOGRACE);
285 TRACE_DEFINE_ENUM(NFS4CLNT_DELEGRETURN);
286 TRACE_DEFINE_ENUM(NFS4CLNT_SESSION_RESET);
287 TRACE_DEFINE_ENUM(NFS4CLNT_LEASE_CONFIRM);
288 TRACE_DEFINE_ENUM(NFS4CLNT_SERVER_SCOPE_MISMATCH);
289 TRACE_DEFINE_ENUM(NFS4CLNT_PURGE_STATE);
290 TRACE_DEFINE_ENUM(NFS4CLNT_BIND_CONN_TO_SESSION);
291 TRACE_DEFINE_ENUM(NFS4CLNT_MOVED);
292 TRACE_DEFINE_ENUM(NFS4CLNT_LEASE_MOVED);
293 TRACE_DEFINE_ENUM(NFS4CLNT_DELEGATION_EXPIRED);
294 TRACE_DEFINE_ENUM(NFS4CLNT_RUN_MANAGER);
295 TRACE_DEFINE_ENUM(NFS4CLNT_MANAGER_AVAILABLE);
296 TRACE_DEFINE_ENUM(NFS4CLNT_RECALL_RUNNING);
297 TRACE_DEFINE_ENUM(NFS4CLNT_RECALL_ANY_LAYOUT_READ);
298 TRACE_DEFINE_ENUM(NFS4CLNT_RECALL_ANY_LAYOUT_RW);
299 TRACE_DEFINE_ENUM(NFS4CLNT_DELEGRETURN_DELAYED);
300 
301 #define show_nfs4_clp_state(state) \
302 	__print_flags(state, "|", \
303 	{ BIT(NFS4CLNT_MANAGER_RUNNING),	"MANAGER_RUNNING" }, \
304 	{ BIT(NFS4CLNT_CHECK_LEASE),		"CHECK_LEASE" }, \
305 	{ BIT(NFS4CLNT_LEASE_EXPIRED),	"LEASE_EXPIRED" }, \
306 	{ BIT(NFS4CLNT_RECLAIM_REBOOT),	"RECLAIM_REBOOT" }, \
307 	{ BIT(NFS4CLNT_RECLAIM_NOGRACE),	"RECLAIM_NOGRACE" }, \
308 	{ BIT(NFS4CLNT_DELEGRETURN),		"DELEGRETURN" }, \
309 	{ BIT(NFS4CLNT_SESSION_RESET),	"SESSION_RESET" }, \
310 	{ BIT(NFS4CLNT_LEASE_CONFIRM),	"LEASE_CONFIRM" }, \
311 	{ BIT(NFS4CLNT_SERVER_SCOPE_MISMATCH),	"SERVER_SCOPE_MISMATCH" }, \
312 	{ BIT(NFS4CLNT_PURGE_STATE),		"PURGE_STATE" }, \
313 	{ BIT(NFS4CLNT_BIND_CONN_TO_SESSION),	"BIND_CONN_TO_SESSION" }, \
314 	{ BIT(NFS4CLNT_MOVED),		"MOVED" }, \
315 	{ BIT(NFS4CLNT_LEASE_MOVED),		"LEASE_MOVED" }, \
316 	{ BIT(NFS4CLNT_DELEGATION_EXPIRED),	"DELEGATION_EXPIRED" }, \
317 	{ BIT(NFS4CLNT_RUN_MANAGER),		"RUN_MANAGER" }, \
318 	{ BIT(NFS4CLNT_MANAGER_AVAILABLE), "MANAGER_AVAILABLE" }, \
319 	{ BIT(NFS4CLNT_RECALL_RUNNING),	"RECALL_RUNNING" }, \
320 	{ BIT(NFS4CLNT_RECALL_ANY_LAYOUT_READ), "RECALL_ANY_LAYOUT_READ" }, \
321 	{ BIT(NFS4CLNT_RECALL_ANY_LAYOUT_RW), "RECALL_ANY_LAYOUT_RW" }, \
322 	{ BIT(NFS4CLNT_DELEGRETURN_DELAYED), "DELERETURN_DELAYED" })
323 
324 TRACE_EVENT(nfs4_state_mgr,
325 		TP_PROTO(
326 			const struct nfs_client *clp
327 		),
328 
329 		TP_ARGS(clp),
330 
331 		TP_STRUCT__entry(
332 			__field(unsigned long, state)
333 			__string(hostname, clp->cl_hostname)
334 		),
335 
336 		TP_fast_assign(
337 			__entry->state = clp->cl_state;
338 			__assign_str(hostname, clp->cl_hostname);
339 		),
340 
341 		TP_printk(
342 			"hostname=%s clp state=%s", __get_str(hostname),
343 			show_nfs4_clp_state(__entry->state)
344 		)
345 )
346 
347 TRACE_EVENT(nfs4_state_mgr_failed,
348 		TP_PROTO(
349 			const struct nfs_client *clp,
350 			const char *section,
351 			int status
352 		),
353 
354 		TP_ARGS(clp, section, status),
355 
356 		TP_STRUCT__entry(
357 			__field(unsigned long, error)
358 			__field(unsigned long, state)
359 			__string(hostname, clp->cl_hostname)
360 			__string(section, section)
361 		),
362 
363 		TP_fast_assign(
364 			__entry->error = status < 0 ? -status : 0;
365 			__entry->state = clp->cl_state;
366 			__assign_str(hostname, clp->cl_hostname);
367 			__assign_str(section, section);
368 		),
369 
370 		TP_printk(
371 			"hostname=%s clp state=%s error=%ld (%s) section=%s",
372 			__get_str(hostname),
373 			show_nfs4_clp_state(__entry->state), -__entry->error,
374 			show_nfs4_status(__entry->error), __get_str(section)
375 
376 		)
377 )
378 
379 TRACE_EVENT(nfs4_xdr_bad_operation,
380 		TP_PROTO(
381 			const struct xdr_stream *xdr,
382 			u32 op,
383 			u32 expected
384 		),
385 
386 		TP_ARGS(xdr, op, expected),
387 
388 		TP_STRUCT__entry(
389 			__field(unsigned int, task_id)
390 			__field(unsigned int, client_id)
391 			__field(u32, xid)
392 			__field(u32, op)
393 			__field(u32, expected)
394 		),
395 
396 		TP_fast_assign(
397 			const struct rpc_rqst *rqstp = xdr->rqst;
398 			const struct rpc_task *task = rqstp->rq_task;
399 
400 			__entry->task_id = task->tk_pid;
401 			__entry->client_id = task->tk_client->cl_clid;
402 			__entry->xid = be32_to_cpu(rqstp->rq_xid);
403 			__entry->op = op;
404 			__entry->expected = expected;
405 		),
406 
407 		TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
408 			  " xid=0x%08x operation=%u, expected=%u",
409 			__entry->task_id, __entry->client_id, __entry->xid,
410 			__entry->op, __entry->expected
411 		)
412 );
413 
414 DECLARE_EVENT_CLASS(nfs4_xdr_event,
415 		TP_PROTO(
416 			const struct xdr_stream *xdr,
417 			u32 op,
418 			u32 error
419 		),
420 
421 		TP_ARGS(xdr, op, error),
422 
423 		TP_STRUCT__entry(
424 			__field(unsigned int, task_id)
425 			__field(unsigned int, client_id)
426 			__field(u32, xid)
427 			__field(u32, op)
428 			__field(unsigned long, error)
429 		),
430 
431 		TP_fast_assign(
432 			const struct rpc_rqst *rqstp = xdr->rqst;
433 			const struct rpc_task *task = rqstp->rq_task;
434 
435 			__entry->task_id = task->tk_pid;
436 			__entry->client_id = task->tk_client->cl_clid;
437 			__entry->xid = be32_to_cpu(rqstp->rq_xid);
438 			__entry->op = op;
439 			__entry->error = error;
440 		),
441 
442 		TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
443 			  " xid=0x%08x error=%ld (%s) operation=%u",
444 			__entry->task_id, __entry->client_id, __entry->xid,
445 			-__entry->error, show_nfs4_status(__entry->error),
446 			__entry->op
447 		)
448 );
449 #define DEFINE_NFS4_XDR_EVENT(name) \
450 	DEFINE_EVENT(nfs4_xdr_event, name, \
451 			TP_PROTO( \
452 				const struct xdr_stream *xdr, \
453 				u32 op, \
454 				u32 error \
455 			), \
456 			TP_ARGS(xdr, op, error))
457 DEFINE_NFS4_XDR_EVENT(nfs4_xdr_status);
458 DEFINE_NFS4_XDR_EVENT(nfs4_xdr_bad_filehandle);
459 
460 DECLARE_EVENT_CLASS(nfs4_cb_error_class,
461 		TP_PROTO(
462 			__be32 xid,
463 			u32 cb_ident
464 		),
465 
466 		TP_ARGS(xid, cb_ident),
467 
468 		TP_STRUCT__entry(
469 			__field(u32, xid)
470 			__field(u32, cbident)
471 		),
472 
473 		TP_fast_assign(
474 			__entry->xid = be32_to_cpu(xid);
475 			__entry->cbident = cb_ident;
476 		),
477 
478 		TP_printk(
479 			"xid=0x%08x cb_ident=0x%08x",
480 			__entry->xid, __entry->cbident
481 		)
482 );
483 
484 #define DEFINE_CB_ERROR_EVENT(name) \
485 	DEFINE_EVENT(nfs4_cb_error_class, nfs_cb_##name, \
486 			TP_PROTO( \
487 				__be32 xid, \
488 				u32 cb_ident \
489 			), \
490 			TP_ARGS(xid, cb_ident))
491 
492 DEFINE_CB_ERROR_EVENT(no_clp);
493 DEFINE_CB_ERROR_EVENT(badprinc);
494 
495 DECLARE_EVENT_CLASS(nfs4_open_event,
496 		TP_PROTO(
497 			const struct nfs_open_context *ctx,
498 			int flags,
499 			int error
500 		),
501 
502 		TP_ARGS(ctx, flags, error),
503 
504 		TP_STRUCT__entry(
505 			__field(unsigned long, error)
506 			__field(unsigned long, flags)
507 			__field(unsigned long, fmode)
508 			__field(dev_t, dev)
509 			__field(u32, fhandle)
510 			__field(u64, fileid)
511 			__field(u64, dir)
512 			__string(name, ctx->dentry->d_name.name)
513 			__field(int, stateid_seq)
514 			__field(u32, stateid_hash)
515 			__field(int, openstateid_seq)
516 			__field(u32, openstateid_hash)
517 		),
518 
519 		TP_fast_assign(
520 			const struct nfs4_state *state = ctx->state;
521 			const struct inode *inode = NULL;
522 
523 			__entry->error = -error;
524 			__entry->flags = flags;
525 			__entry->fmode = (__force unsigned long)ctx->mode;
526 			__entry->dev = ctx->dentry->d_sb->s_dev;
527 			if (!IS_ERR_OR_NULL(state)) {
528 				inode = state->inode;
529 				__entry->stateid_seq =
530 					be32_to_cpu(state->stateid.seqid);
531 				__entry->stateid_hash =
532 					nfs_stateid_hash(&state->stateid);
533 				__entry->openstateid_seq =
534 					be32_to_cpu(state->open_stateid.seqid);
535 				__entry->openstateid_hash =
536 					nfs_stateid_hash(&state->open_stateid);
537 			} else {
538 				__entry->stateid_seq = 0;
539 				__entry->stateid_hash = 0;
540 				__entry->openstateid_seq = 0;
541 				__entry->openstateid_hash = 0;
542 			}
543 			if (inode != NULL) {
544 				__entry->fileid = NFS_FILEID(inode);
545 				__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
546 			} else {
547 				__entry->fileid = 0;
548 				__entry->fhandle = 0;
549 			}
550 			__entry->dir = NFS_FILEID(d_inode(ctx->dentry->d_parent));
551 			__assign_str(name, ctx->dentry->d_name.name);
552 		),
553 
554 		TP_printk(
555 			"error=%ld (%s) flags=%lu (%s) fmode=%s "
556 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
557 			"name=%02x:%02x:%llu/%s stateid=%d:0x%08x "
558 			"openstateid=%d:0x%08x",
559 			 -__entry->error,
560 			 show_nfs4_status(__entry->error),
561 			 __entry->flags,
562 			 show_fs_fcntl_open_flags(__entry->flags),
563 			 show_fs_fmode_flags(__entry->fmode),
564 			 MAJOR(__entry->dev), MINOR(__entry->dev),
565 			 (unsigned long long)__entry->fileid,
566 			 __entry->fhandle,
567 			 MAJOR(__entry->dev), MINOR(__entry->dev),
568 			 (unsigned long long)__entry->dir,
569 			 __get_str(name),
570 			 __entry->stateid_seq, __entry->stateid_hash,
571 			 __entry->openstateid_seq, __entry->openstateid_hash
572 		)
573 );
574 
575 #define DEFINE_NFS4_OPEN_EVENT(name) \
576 	DEFINE_EVENT(nfs4_open_event, name, \
577 			TP_PROTO( \
578 				const struct nfs_open_context *ctx, \
579 				int flags, \
580 				int error \
581 			), \
582 			TP_ARGS(ctx, flags, error))
583 DEFINE_NFS4_OPEN_EVENT(nfs4_open_reclaim);
584 DEFINE_NFS4_OPEN_EVENT(nfs4_open_expired);
585 DEFINE_NFS4_OPEN_EVENT(nfs4_open_file);
586 
587 TRACE_EVENT(nfs4_cached_open,
588 		TP_PROTO(
589 			const struct nfs4_state *state
590 		),
591 		TP_ARGS(state),
592 		TP_STRUCT__entry(
593 			__field(dev_t, dev)
594 			__field(u32, fhandle)
595 			__field(u64, fileid)
596 			__field(unsigned int, fmode)
597 			__field(int, stateid_seq)
598 			__field(u32, stateid_hash)
599 		),
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;
608 			__entry->stateid_seq =
609 				be32_to_cpu(state->stateid.seqid);
610 			__entry->stateid_hash =
611 				nfs_stateid_hash(&state->stateid);
612 		),
613 
614 		TP_printk(
615 			"fmode=%s fileid=%02x:%02x:%llu "
616 			"fhandle=0x%08x stateid=%d:0x%08x",
617 			__entry->fmode ?  show_fs_fmode_flags(__entry->fmode) :
618 					  "closed",
619 			MAJOR(__entry->dev), MINOR(__entry->dev),
620 			(unsigned long long)__entry->fileid,
621 			__entry->fhandle,
622 			__entry->stateid_seq, __entry->stateid_hash
623 		)
624 );
625 
626 TRACE_EVENT(nfs4_close,
627 		TP_PROTO(
628 			const struct nfs4_state *state,
629 			const struct nfs_closeargs *args,
630 			const struct nfs_closeres *res,
631 			int error
632 		),
633 
634 		TP_ARGS(state, args, res, error),
635 
636 		TP_STRUCT__entry(
637 			__field(dev_t, dev)
638 			__field(u32, fhandle)
639 			__field(u64, fileid)
640 			__field(unsigned int, fmode)
641 			__field(unsigned long, error)
642 			__field(int, stateid_seq)
643 			__field(u32, stateid_hash)
644 		),
645 
646 		TP_fast_assign(
647 			const struct inode *inode = state->inode;
648 
649 			__entry->dev = inode->i_sb->s_dev;
650 			__entry->fileid = NFS_FILEID(inode);
651 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
652 			__entry->fmode = (__force unsigned int)state->state;
653 			__entry->error = error < 0 ? -error : 0;
654 			__entry->stateid_seq =
655 				be32_to_cpu(args->stateid.seqid);
656 			__entry->stateid_hash =
657 				nfs_stateid_hash(&args->stateid);
658 		),
659 
660 		TP_printk(
661 			"error=%ld (%s) fmode=%s fileid=%02x:%02x:%llu "
662 			"fhandle=0x%08x openstateid=%d:0x%08x",
663 			-__entry->error,
664 			show_nfs4_status(__entry->error),
665 			__entry->fmode ?  show_fs_fmode_flags(__entry->fmode) :
666 					  "closed",
667 			MAJOR(__entry->dev), MINOR(__entry->dev),
668 			(unsigned long long)__entry->fileid,
669 			__entry->fhandle,
670 			__entry->stateid_seq, __entry->stateid_hash
671 		)
672 );
673 
674 DECLARE_EVENT_CLASS(nfs4_lock_event,
675 		TP_PROTO(
676 			const struct file_lock *request,
677 			const struct nfs4_state *state,
678 			int cmd,
679 			int error
680 		),
681 
682 		TP_ARGS(request, state, cmd, error),
683 
684 		TP_STRUCT__entry(
685 			__field(unsigned long, error)
686 			__field(unsigned long, cmd)
687 			__field(unsigned long, type)
688 			__field(loff_t, start)
689 			__field(loff_t, end)
690 			__field(dev_t, dev)
691 			__field(u32, fhandle)
692 			__field(u64, fileid)
693 			__field(int, stateid_seq)
694 			__field(u32, stateid_hash)
695 		),
696 
697 		TP_fast_assign(
698 			const struct inode *inode = state->inode;
699 
700 			__entry->error = error < 0 ? -error : 0;
701 			__entry->cmd = cmd;
702 			__entry->type = request->fl_type;
703 			__entry->start = request->fl_start;
704 			__entry->end = request->fl_end;
705 			__entry->dev = inode->i_sb->s_dev;
706 			__entry->fileid = NFS_FILEID(inode);
707 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
708 			__entry->stateid_seq =
709 				be32_to_cpu(state->stateid.seqid);
710 			__entry->stateid_hash =
711 				nfs_stateid_hash(&state->stateid);
712 		),
713 
714 		TP_printk(
715 			"error=%ld (%s) cmd=%s:%s range=%lld:%lld "
716 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
717 			"stateid=%d:0x%08x",
718 			-__entry->error,
719 			show_nfs4_status(__entry->error),
720 			show_fs_fcntl_cmd(__entry->cmd),
721 			show_fs_fcntl_lock_type(__entry->type),
722 			(long long)__entry->start,
723 			(long long)__entry->end,
724 			MAJOR(__entry->dev), MINOR(__entry->dev),
725 			(unsigned long long)__entry->fileid,
726 			__entry->fhandle,
727 			__entry->stateid_seq, __entry->stateid_hash
728 		)
729 );
730 
731 #define DEFINE_NFS4_LOCK_EVENT(name) \
732 	DEFINE_EVENT(nfs4_lock_event, name, \
733 			TP_PROTO( \
734 				const struct file_lock *request, \
735 				const struct nfs4_state *state, \
736 				int cmd, \
737 				int error \
738 			), \
739 			TP_ARGS(request, state, cmd, error))
740 DEFINE_NFS4_LOCK_EVENT(nfs4_get_lock);
741 DEFINE_NFS4_LOCK_EVENT(nfs4_unlock);
742 
743 TRACE_EVENT(nfs4_set_lock,
744 		TP_PROTO(
745 			const struct file_lock *request,
746 			const struct nfs4_state *state,
747 			const nfs4_stateid *lockstateid,
748 			int cmd,
749 			int error
750 		),
751 
752 		TP_ARGS(request, state, lockstateid, cmd, error),
753 
754 		TP_STRUCT__entry(
755 			__field(unsigned long, error)
756 			__field(unsigned long, cmd)
757 			__field(unsigned long, type)
758 			__field(loff_t, start)
759 			__field(loff_t, end)
760 			__field(dev_t, dev)
761 			__field(u32, fhandle)
762 			__field(u64, fileid)
763 			__field(int, stateid_seq)
764 			__field(u32, stateid_hash)
765 			__field(int, lockstateid_seq)
766 			__field(u32, lockstateid_hash)
767 		),
768 
769 		TP_fast_assign(
770 			const struct inode *inode = state->inode;
771 
772 			__entry->error = error < 0 ? -error : 0;
773 			__entry->cmd = cmd;
774 			__entry->type = request->fl_type;
775 			__entry->start = request->fl_start;
776 			__entry->end = request->fl_end;
777 			__entry->dev = inode->i_sb->s_dev;
778 			__entry->fileid = NFS_FILEID(inode);
779 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
780 			__entry->stateid_seq =
781 				be32_to_cpu(state->stateid.seqid);
782 			__entry->stateid_hash =
783 				nfs_stateid_hash(&state->stateid);
784 			__entry->lockstateid_seq =
785 				be32_to_cpu(lockstateid->seqid);
786 			__entry->lockstateid_hash =
787 				nfs_stateid_hash(lockstateid);
788 		),
789 
790 		TP_printk(
791 			"error=%ld (%s) cmd=%s:%s range=%lld:%lld "
792 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
793 			"stateid=%d:0x%08x lockstateid=%d:0x%08x",
794 			-__entry->error,
795 			show_nfs4_status(__entry->error),
796 			show_fs_fcntl_cmd(__entry->cmd),
797 			show_fs_fcntl_lock_type(__entry->type),
798 			(long long)__entry->start,
799 			(long long)__entry->end,
800 			MAJOR(__entry->dev), MINOR(__entry->dev),
801 			(unsigned long long)__entry->fileid,
802 			__entry->fhandle,
803 			__entry->stateid_seq, __entry->stateid_hash,
804 			__entry->lockstateid_seq, __entry->lockstateid_hash
805 		)
806 );
807 
808 TRACE_DEFINE_ENUM(LK_STATE_IN_USE);
809 TRACE_DEFINE_ENUM(NFS_DELEGATED_STATE);
810 TRACE_DEFINE_ENUM(NFS_OPEN_STATE);
811 TRACE_DEFINE_ENUM(NFS_O_RDONLY_STATE);
812 TRACE_DEFINE_ENUM(NFS_O_WRONLY_STATE);
813 TRACE_DEFINE_ENUM(NFS_O_RDWR_STATE);
814 TRACE_DEFINE_ENUM(NFS_STATE_RECLAIM_REBOOT);
815 TRACE_DEFINE_ENUM(NFS_STATE_RECLAIM_NOGRACE);
816 TRACE_DEFINE_ENUM(NFS_STATE_POSIX_LOCKS);
817 TRACE_DEFINE_ENUM(NFS_STATE_RECOVERY_FAILED);
818 TRACE_DEFINE_ENUM(NFS_STATE_MAY_NOTIFY_LOCK);
819 TRACE_DEFINE_ENUM(NFS_STATE_CHANGE_WAIT);
820 TRACE_DEFINE_ENUM(NFS_CLNT_DST_SSC_COPY_STATE);
821 TRACE_DEFINE_ENUM(NFS_CLNT_SRC_SSC_COPY_STATE);
822 TRACE_DEFINE_ENUM(NFS_SRV_SSC_COPY_STATE);
823 
824 #define show_nfs4_state_flags(flags) \
825 	__print_flags(flags, "|", \
826 		{ LK_STATE_IN_USE,		"IN_USE" }, \
827 		{ NFS_DELEGATED_STATE,		"DELEGATED" }, \
828 		{ NFS_OPEN_STATE,		"OPEN" }, \
829 		{ NFS_O_RDONLY_STATE,		"O_RDONLY" }, \
830 		{ NFS_O_WRONLY_STATE,		"O_WRONLY" }, \
831 		{ NFS_O_RDWR_STATE,		"O_RDWR" }, \
832 		{ NFS_STATE_RECLAIM_REBOOT,	"RECLAIM_REBOOT" }, \
833 		{ NFS_STATE_RECLAIM_NOGRACE,	"RECLAIM_NOGRACE" }, \
834 		{ NFS_STATE_POSIX_LOCKS,	"POSIX_LOCKS" }, \
835 		{ NFS_STATE_RECOVERY_FAILED,	"RECOVERY_FAILED" }, \
836 		{ NFS_STATE_MAY_NOTIFY_LOCK,	"MAY_NOTIFY_LOCK" }, \
837 		{ NFS_STATE_CHANGE_WAIT,	"CHANGE_WAIT" }, \
838 		{ NFS_CLNT_DST_SSC_COPY_STATE,	"CLNT_DST_SSC_COPY" }, \
839 		{ NFS_CLNT_SRC_SSC_COPY_STATE,	"CLNT_SRC_SSC_COPY" }, \
840 		{ NFS_SRV_SSC_COPY_STATE,	"SRV_SSC_COPY" })
841 
842 #define show_nfs4_lock_flags(flags) \
843 	__print_flags(flags, "|", \
844 		{ BIT(NFS_LOCK_INITIALIZED),	"INITIALIZED" }, \
845 		{ BIT(NFS_LOCK_LOST),		"LOST" })
846 
847 TRACE_EVENT(nfs4_state_lock_reclaim,
848 		TP_PROTO(
849 			const struct nfs4_state *state,
850 			const struct nfs4_lock_state *lock
851 		),
852 
853 		TP_ARGS(state, lock),
854 
855 		TP_STRUCT__entry(
856 			__field(dev_t, dev)
857 			__field(u32, fhandle)
858 			__field(u64, fileid)
859 			__field(unsigned long, state_flags)
860 			__field(unsigned long, lock_flags)
861 			__field(int, stateid_seq)
862 			__field(u32, stateid_hash)
863 		),
864 
865 		TP_fast_assign(
866 			const struct inode *inode = state->inode;
867 
868 			__entry->dev = inode->i_sb->s_dev;
869 			__entry->fileid = NFS_FILEID(inode);
870 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
871 			__entry->state_flags = state->flags;
872 			__entry->lock_flags = lock->ls_flags;
873 			__entry->stateid_seq =
874 				be32_to_cpu(state->stateid.seqid);
875 			__entry->stateid_hash =
876 				nfs_stateid_hash(&state->stateid);
877 		),
878 
879 		TP_printk(
880 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
881 			"stateid=%d:0x%08x state_flags=%s lock_flags=%s",
882 			MAJOR(__entry->dev), MINOR(__entry->dev),
883 			(unsigned long long)__entry->fileid, __entry->fhandle,
884 			__entry->stateid_seq, __entry->stateid_hash,
885 			show_nfs4_state_flags(__entry->state_flags),
886 			show_nfs4_lock_flags(__entry->lock_flags)
887 		)
888 )
889 
890 DECLARE_EVENT_CLASS(nfs4_set_delegation_event,
891 		TP_PROTO(
892 			const struct inode *inode,
893 			fmode_t fmode
894 		),
895 
896 		TP_ARGS(inode, fmode),
897 
898 		TP_STRUCT__entry(
899 			__field(dev_t, dev)
900 			__field(u32, fhandle)
901 			__field(u64, fileid)
902 			__field(unsigned int, fmode)
903 		),
904 
905 		TP_fast_assign(
906 			__entry->dev = inode->i_sb->s_dev;
907 			__entry->fileid = NFS_FILEID(inode);
908 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
909 			__entry->fmode = (__force unsigned int)fmode;
910 		),
911 
912 		TP_printk(
913 			"fmode=%s fileid=%02x:%02x:%llu fhandle=0x%08x",
914 			show_fs_fmode_flags(__entry->fmode),
915 			MAJOR(__entry->dev), MINOR(__entry->dev),
916 			(unsigned long long)__entry->fileid,
917 			__entry->fhandle
918 		)
919 );
920 #define DEFINE_NFS4_SET_DELEGATION_EVENT(name) \
921 	DEFINE_EVENT(nfs4_set_delegation_event, name, \
922 			TP_PROTO( \
923 				const struct inode *inode, \
924 				fmode_t fmode \
925 			), \
926 			TP_ARGS(inode, fmode))
927 DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_set_delegation);
928 DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_reclaim_delegation);
929 
930 TRACE_EVENT(nfs4_delegreturn_exit,
931 		TP_PROTO(
932 			const struct nfs4_delegreturnargs *args,
933 			const struct nfs4_delegreturnres *res,
934 			int error
935 		),
936 
937 		TP_ARGS(args, res, error),
938 
939 		TP_STRUCT__entry(
940 			__field(dev_t, dev)
941 			__field(u32, fhandle)
942 			__field(unsigned long, error)
943 			__field(int, stateid_seq)
944 			__field(u32, stateid_hash)
945 		),
946 
947 		TP_fast_assign(
948 			__entry->dev = res->server->s_dev;
949 			__entry->fhandle = nfs_fhandle_hash(args->fhandle);
950 			__entry->error = error < 0 ? -error : 0;
951 			__entry->stateid_seq =
952 				be32_to_cpu(args->stateid->seqid);
953 			__entry->stateid_hash =
954 				nfs_stateid_hash(args->stateid);
955 		),
956 
957 		TP_printk(
958 			"error=%ld (%s) dev=%02x:%02x fhandle=0x%08x "
959 			"stateid=%d:0x%08x",
960 			-__entry->error,
961 			show_nfs4_status(__entry->error),
962 			MAJOR(__entry->dev), MINOR(__entry->dev),
963 			__entry->fhandle,
964 			__entry->stateid_seq, __entry->stateid_hash
965 		)
966 );
967 
968 #ifdef CONFIG_NFS_V4_1
969 DECLARE_EVENT_CLASS(nfs4_test_stateid_event,
970 		TP_PROTO(
971 			const struct nfs4_state *state,
972 			const struct nfs4_lock_state *lsp,
973 			int error
974 		),
975 
976 		TP_ARGS(state, lsp, error),
977 
978 		TP_STRUCT__entry(
979 			__field(unsigned long, error)
980 			__field(dev_t, dev)
981 			__field(u32, fhandle)
982 			__field(u64, fileid)
983 			__field(int, stateid_seq)
984 			__field(u32, stateid_hash)
985 		),
986 
987 		TP_fast_assign(
988 			const struct inode *inode = state->inode;
989 
990 			__entry->error = error < 0 ? -error : 0;
991 			__entry->dev = inode->i_sb->s_dev;
992 			__entry->fileid = NFS_FILEID(inode);
993 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
994 			__entry->stateid_seq =
995 				be32_to_cpu(state->stateid.seqid);
996 			__entry->stateid_hash =
997 				nfs_stateid_hash(&state->stateid);
998 		),
999 
1000 		TP_printk(
1001 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1002 			"stateid=%d:0x%08x",
1003 			-__entry->error,
1004 			show_nfs4_status(__entry->error),
1005 			MAJOR(__entry->dev), MINOR(__entry->dev),
1006 			(unsigned long long)__entry->fileid,
1007 			__entry->fhandle,
1008 			__entry->stateid_seq, __entry->stateid_hash
1009 		)
1010 );
1011 
1012 #define DEFINE_NFS4_TEST_STATEID_EVENT(name) \
1013 	DEFINE_EVENT(nfs4_test_stateid_event, name, \
1014 			TP_PROTO( \
1015 				const struct nfs4_state *state, \
1016 				const struct nfs4_lock_state *lsp, \
1017 				int error \
1018 			), \
1019 			TP_ARGS(state, lsp, error))
1020 DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_delegation_stateid);
1021 DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_open_stateid);
1022 DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_lock_stateid);
1023 #endif /* CONFIG_NFS_V4_1 */
1024 
1025 DECLARE_EVENT_CLASS(nfs4_lookup_event,
1026 		TP_PROTO(
1027 			const struct inode *dir,
1028 			const struct qstr *name,
1029 			int error
1030 		),
1031 
1032 		TP_ARGS(dir, name, error),
1033 
1034 		TP_STRUCT__entry(
1035 			__field(dev_t, dev)
1036 			__field(unsigned long, error)
1037 			__field(u64, dir)
1038 			__string(name, name->name)
1039 		),
1040 
1041 		TP_fast_assign(
1042 			__entry->dev = dir->i_sb->s_dev;
1043 			__entry->dir = NFS_FILEID(dir);
1044 			__entry->error = -error;
1045 			__assign_str(name, name->name);
1046 		),
1047 
1048 		TP_printk(
1049 			"error=%ld (%s) name=%02x:%02x:%llu/%s",
1050 			-__entry->error,
1051 			show_nfs4_status(__entry->error),
1052 			MAJOR(__entry->dev), MINOR(__entry->dev),
1053 			(unsigned long long)__entry->dir,
1054 			__get_str(name)
1055 		)
1056 );
1057 
1058 #define DEFINE_NFS4_LOOKUP_EVENT(name) \
1059 	DEFINE_EVENT(nfs4_lookup_event, name, \
1060 			TP_PROTO( \
1061 				const struct inode *dir, \
1062 				const struct qstr *name, \
1063 				int error \
1064 			), \
1065 			TP_ARGS(dir, name, error))
1066 
1067 DEFINE_NFS4_LOOKUP_EVENT(nfs4_lookup);
1068 DEFINE_NFS4_LOOKUP_EVENT(nfs4_symlink);
1069 DEFINE_NFS4_LOOKUP_EVENT(nfs4_mkdir);
1070 DEFINE_NFS4_LOOKUP_EVENT(nfs4_mknod);
1071 DEFINE_NFS4_LOOKUP_EVENT(nfs4_remove);
1072 DEFINE_NFS4_LOOKUP_EVENT(nfs4_get_fs_locations);
1073 DEFINE_NFS4_LOOKUP_EVENT(nfs4_secinfo);
1074 
1075 TRACE_EVENT(nfs4_lookupp,
1076 		TP_PROTO(
1077 			const struct inode *inode,
1078 			int error
1079 		),
1080 
1081 		TP_ARGS(inode, error),
1082 
1083 		TP_STRUCT__entry(
1084 			__field(dev_t, dev)
1085 			__field(u64, ino)
1086 			__field(unsigned long, error)
1087 		),
1088 
1089 		TP_fast_assign(
1090 			__entry->dev = inode->i_sb->s_dev;
1091 			__entry->ino = NFS_FILEID(inode);
1092 			__entry->error = error < 0 ? -error : 0;
1093 		),
1094 
1095 		TP_printk(
1096 			"error=%ld (%s) inode=%02x:%02x:%llu",
1097 			-__entry->error,
1098 			show_nfs4_status(__entry->error),
1099 			MAJOR(__entry->dev), MINOR(__entry->dev),
1100 			(unsigned long long)__entry->ino
1101 		)
1102 );
1103 
1104 TRACE_EVENT(nfs4_rename,
1105 		TP_PROTO(
1106 			const struct inode *olddir,
1107 			const struct qstr *oldname,
1108 			const struct inode *newdir,
1109 			const struct qstr *newname,
1110 			int error
1111 		),
1112 
1113 		TP_ARGS(olddir, oldname, newdir, newname, error),
1114 
1115 		TP_STRUCT__entry(
1116 			__field(dev_t, dev)
1117 			__field(unsigned long, error)
1118 			__field(u64, olddir)
1119 			__string(oldname, oldname->name)
1120 			__field(u64, newdir)
1121 			__string(newname, newname->name)
1122 		),
1123 
1124 		TP_fast_assign(
1125 			__entry->dev = olddir->i_sb->s_dev;
1126 			__entry->olddir = NFS_FILEID(olddir);
1127 			__entry->newdir = NFS_FILEID(newdir);
1128 			__entry->error = error < 0 ? -error : 0;
1129 			__assign_str(oldname, oldname->name);
1130 			__assign_str(newname, newname->name);
1131 		),
1132 
1133 		TP_printk(
1134 			"error=%ld (%s) oldname=%02x:%02x:%llu/%s "
1135 			"newname=%02x:%02x:%llu/%s",
1136 			-__entry->error,
1137 			show_nfs4_status(__entry->error),
1138 			MAJOR(__entry->dev), MINOR(__entry->dev),
1139 			(unsigned long long)__entry->olddir,
1140 			__get_str(oldname),
1141 			MAJOR(__entry->dev), MINOR(__entry->dev),
1142 			(unsigned long long)__entry->newdir,
1143 			__get_str(newname)
1144 		)
1145 );
1146 
1147 DECLARE_EVENT_CLASS(nfs4_inode_event,
1148 		TP_PROTO(
1149 			const struct inode *inode,
1150 			int error
1151 		),
1152 
1153 		TP_ARGS(inode, error),
1154 
1155 		TP_STRUCT__entry(
1156 			__field(dev_t, dev)
1157 			__field(u32, fhandle)
1158 			__field(u64, fileid)
1159 			__field(unsigned long, error)
1160 		),
1161 
1162 		TP_fast_assign(
1163 			__entry->dev = inode->i_sb->s_dev;
1164 			__entry->fileid = NFS_FILEID(inode);
1165 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1166 			__entry->error = error < 0 ? -error : 0;
1167 		),
1168 
1169 		TP_printk(
1170 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x",
1171 			-__entry->error,
1172 			show_nfs4_status(__entry->error),
1173 			MAJOR(__entry->dev), MINOR(__entry->dev),
1174 			(unsigned long long)__entry->fileid,
1175 			__entry->fhandle
1176 		)
1177 );
1178 
1179 #define DEFINE_NFS4_INODE_EVENT(name) \
1180 	DEFINE_EVENT(nfs4_inode_event, name, \
1181 			TP_PROTO( \
1182 				const struct inode *inode, \
1183 				int error \
1184 			), \
1185 			TP_ARGS(inode, error))
1186 
1187 DEFINE_NFS4_INODE_EVENT(nfs4_access);
1188 DEFINE_NFS4_INODE_EVENT(nfs4_readlink);
1189 DEFINE_NFS4_INODE_EVENT(nfs4_readdir);
1190 DEFINE_NFS4_INODE_EVENT(nfs4_get_acl);
1191 DEFINE_NFS4_INODE_EVENT(nfs4_set_acl);
1192 #ifdef CONFIG_NFS_V4_SECURITY_LABEL
1193 DEFINE_NFS4_INODE_EVENT(nfs4_get_security_label);
1194 DEFINE_NFS4_INODE_EVENT(nfs4_set_security_label);
1195 #endif /* CONFIG_NFS_V4_SECURITY_LABEL */
1196 
1197 DECLARE_EVENT_CLASS(nfs4_inode_stateid_event,
1198 		TP_PROTO(
1199 			const struct inode *inode,
1200 			const nfs4_stateid *stateid,
1201 			int error
1202 		),
1203 
1204 		TP_ARGS(inode, stateid, error),
1205 
1206 		TP_STRUCT__entry(
1207 			__field(dev_t, dev)
1208 			__field(u32, fhandle)
1209 			__field(u64, fileid)
1210 			__field(unsigned long, error)
1211 			__field(int, stateid_seq)
1212 			__field(u32, stateid_hash)
1213 		),
1214 
1215 		TP_fast_assign(
1216 			__entry->dev = inode->i_sb->s_dev;
1217 			__entry->fileid = NFS_FILEID(inode);
1218 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1219 			__entry->error = error < 0 ? -error : 0;
1220 			__entry->stateid_seq =
1221 				be32_to_cpu(stateid->seqid);
1222 			__entry->stateid_hash =
1223 				nfs_stateid_hash(stateid);
1224 		),
1225 
1226 		TP_printk(
1227 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1228 			"stateid=%d:0x%08x",
1229 			-__entry->error,
1230 			show_nfs4_status(__entry->error),
1231 			MAJOR(__entry->dev), MINOR(__entry->dev),
1232 			(unsigned long long)__entry->fileid,
1233 			__entry->fhandle,
1234 			__entry->stateid_seq, __entry->stateid_hash
1235 		)
1236 );
1237 
1238 #define DEFINE_NFS4_INODE_STATEID_EVENT(name) \
1239 	DEFINE_EVENT(nfs4_inode_stateid_event, name, \
1240 			TP_PROTO( \
1241 				const struct inode *inode, \
1242 				const nfs4_stateid *stateid, \
1243 				int error \
1244 			), \
1245 			TP_ARGS(inode, stateid, error))
1246 
1247 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_setattr);
1248 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_delegreturn);
1249 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_open_stateid_update);
1250 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_open_stateid_update_wait);
1251 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_close_stateid_update_wait);
1252 
1253 DECLARE_EVENT_CLASS(nfs4_getattr_event,
1254 		TP_PROTO(
1255 			const struct nfs_server *server,
1256 			const struct nfs_fh *fhandle,
1257 			const struct nfs_fattr *fattr,
1258 			int error
1259 		),
1260 
1261 		TP_ARGS(server, fhandle, fattr, error),
1262 
1263 		TP_STRUCT__entry(
1264 			__field(dev_t, dev)
1265 			__field(u32, fhandle)
1266 			__field(u64, fileid)
1267 			__field(unsigned int, valid)
1268 			__field(unsigned long, error)
1269 		),
1270 
1271 		TP_fast_assign(
1272 			__entry->dev = server->s_dev;
1273 			__entry->valid = fattr->valid;
1274 			__entry->fhandle = nfs_fhandle_hash(fhandle);
1275 			__entry->fileid = (fattr->valid & NFS_ATTR_FATTR_FILEID) ? fattr->fileid : 0;
1276 			__entry->error = error < 0 ? -error : 0;
1277 		),
1278 
1279 		TP_printk(
1280 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1281 			"valid=%s",
1282 			-__entry->error,
1283 			show_nfs4_status(__entry->error),
1284 			MAJOR(__entry->dev), MINOR(__entry->dev),
1285 			(unsigned long long)__entry->fileid,
1286 			__entry->fhandle,
1287 			show_nfs_fattr_flags(__entry->valid)
1288 		)
1289 );
1290 
1291 #define DEFINE_NFS4_GETATTR_EVENT(name) \
1292 	DEFINE_EVENT(nfs4_getattr_event, name, \
1293 			TP_PROTO( \
1294 				const struct nfs_server *server, \
1295 				const struct nfs_fh *fhandle, \
1296 				const struct nfs_fattr *fattr, \
1297 				int error \
1298 			), \
1299 			TP_ARGS(server, fhandle, fattr, error))
1300 DEFINE_NFS4_GETATTR_EVENT(nfs4_getattr);
1301 DEFINE_NFS4_GETATTR_EVENT(nfs4_lookup_root);
1302 DEFINE_NFS4_GETATTR_EVENT(nfs4_fsinfo);
1303 
1304 DECLARE_EVENT_CLASS(nfs4_inode_callback_event,
1305 		TP_PROTO(
1306 			const struct nfs_client *clp,
1307 			const struct nfs_fh *fhandle,
1308 			const struct inode *inode,
1309 			int error
1310 		),
1311 
1312 		TP_ARGS(clp, fhandle, inode, error),
1313 
1314 		TP_STRUCT__entry(
1315 			__field(unsigned long, error)
1316 			__field(dev_t, dev)
1317 			__field(u32, fhandle)
1318 			__field(u64, fileid)
1319 			__string(dstaddr, clp ? clp->cl_hostname : "unknown")
1320 		),
1321 
1322 		TP_fast_assign(
1323 			__entry->error = error < 0 ? -error : 0;
1324 			__entry->fhandle = nfs_fhandle_hash(fhandle);
1325 			if (!IS_ERR_OR_NULL(inode)) {
1326 				__entry->fileid = NFS_FILEID(inode);
1327 				__entry->dev = inode->i_sb->s_dev;
1328 			} else {
1329 				__entry->fileid = 0;
1330 				__entry->dev = 0;
1331 			}
1332 			__assign_str(dstaddr, clp ? clp->cl_hostname : "unknown");
1333 		),
1334 
1335 		TP_printk(
1336 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1337 			"dstaddr=%s",
1338 			-__entry->error,
1339 			show_nfs4_status(__entry->error),
1340 			MAJOR(__entry->dev), MINOR(__entry->dev),
1341 			(unsigned long long)__entry->fileid,
1342 			__entry->fhandle,
1343 			__get_str(dstaddr)
1344 		)
1345 );
1346 
1347 #define DEFINE_NFS4_INODE_CALLBACK_EVENT(name) \
1348 	DEFINE_EVENT(nfs4_inode_callback_event, name, \
1349 			TP_PROTO( \
1350 				const struct nfs_client *clp, \
1351 				const struct nfs_fh *fhandle, \
1352 				const struct inode *inode, \
1353 				int error \
1354 			), \
1355 			TP_ARGS(clp, fhandle, inode, error))
1356 DEFINE_NFS4_INODE_CALLBACK_EVENT(nfs4_cb_getattr);
1357 
1358 DECLARE_EVENT_CLASS(nfs4_inode_stateid_callback_event,
1359 		TP_PROTO(
1360 			const struct nfs_client *clp,
1361 			const struct nfs_fh *fhandle,
1362 			const struct inode *inode,
1363 			const nfs4_stateid *stateid,
1364 			int error
1365 		),
1366 
1367 		TP_ARGS(clp, fhandle, inode, stateid, error),
1368 
1369 		TP_STRUCT__entry(
1370 			__field(unsigned long, error)
1371 			__field(dev_t, dev)
1372 			__field(u32, fhandle)
1373 			__field(u64, fileid)
1374 			__string(dstaddr, clp ? clp->cl_hostname : "unknown")
1375 			__field(int, stateid_seq)
1376 			__field(u32, stateid_hash)
1377 		),
1378 
1379 		TP_fast_assign(
1380 			__entry->error = error < 0 ? -error : 0;
1381 			__entry->fhandle = nfs_fhandle_hash(fhandle);
1382 			if (!IS_ERR_OR_NULL(inode)) {
1383 				__entry->fileid = NFS_FILEID(inode);
1384 				__entry->dev = inode->i_sb->s_dev;
1385 			} else {
1386 				__entry->fileid = 0;
1387 				__entry->dev = 0;
1388 			}
1389 			__assign_str(dstaddr, clp ? clp->cl_hostname : "unknown");
1390 			__entry->stateid_seq =
1391 				be32_to_cpu(stateid->seqid);
1392 			__entry->stateid_hash =
1393 				nfs_stateid_hash(stateid);
1394 		),
1395 
1396 		TP_printk(
1397 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1398 			"stateid=%d:0x%08x dstaddr=%s",
1399 			-__entry->error,
1400 			show_nfs4_status(__entry->error),
1401 			MAJOR(__entry->dev), MINOR(__entry->dev),
1402 			(unsigned long long)__entry->fileid,
1403 			__entry->fhandle,
1404 			__entry->stateid_seq, __entry->stateid_hash,
1405 			__get_str(dstaddr)
1406 		)
1407 );
1408 
1409 #define DEFINE_NFS4_INODE_STATEID_CALLBACK_EVENT(name) \
1410 	DEFINE_EVENT(nfs4_inode_stateid_callback_event, name, \
1411 			TP_PROTO( \
1412 				const struct nfs_client *clp, \
1413 				const struct nfs_fh *fhandle, \
1414 				const struct inode *inode, \
1415 				const nfs4_stateid *stateid, \
1416 				int error \
1417 			), \
1418 			TP_ARGS(clp, fhandle, inode, stateid, error))
1419 DEFINE_NFS4_INODE_STATEID_CALLBACK_EVENT(nfs4_cb_recall);
1420 DEFINE_NFS4_INODE_STATEID_CALLBACK_EVENT(nfs4_cb_layoutrecall_file);
1421 
1422 DECLARE_EVENT_CLASS(nfs4_idmap_event,
1423 		TP_PROTO(
1424 			const char *name,
1425 			int len,
1426 			u32 id,
1427 			int error
1428 		),
1429 
1430 		TP_ARGS(name, len, id, error),
1431 
1432 		TP_STRUCT__entry(
1433 			__field(unsigned long, error)
1434 			__field(u32, id)
1435 			__dynamic_array(char, name, len > 0 ? len + 1 : 1)
1436 		),
1437 
1438 		TP_fast_assign(
1439 			if (len < 0)
1440 				len = 0;
1441 			__entry->error = error < 0 ? error : 0;
1442 			__entry->id = id;
1443 			memcpy(__get_str(name), name, len);
1444 			__get_str(name)[len] = 0;
1445 		),
1446 
1447 		TP_printk(
1448 			"error=%ld (%s) id=%u name=%s",
1449 			-__entry->error, show_nfs4_status(__entry->error),
1450 			__entry->id,
1451 			__get_str(name)
1452 		)
1453 );
1454 #define DEFINE_NFS4_IDMAP_EVENT(name) \
1455 	DEFINE_EVENT(nfs4_idmap_event, name, \
1456 			TP_PROTO( \
1457 				const char *name, \
1458 				int len, \
1459 				u32 id, \
1460 				int error \
1461 			), \
1462 			TP_ARGS(name, len, id, error))
1463 DEFINE_NFS4_IDMAP_EVENT(nfs4_map_name_to_uid);
1464 DEFINE_NFS4_IDMAP_EVENT(nfs4_map_group_to_gid);
1465 DEFINE_NFS4_IDMAP_EVENT(nfs4_map_uid_to_name);
1466 DEFINE_NFS4_IDMAP_EVENT(nfs4_map_gid_to_group);
1467 
1468 #ifdef CONFIG_NFS_V4_1
1469 #define NFS4_LSEG_LAYOUT_STATEID_HASH(lseg) \
1470 	(lseg ? nfs_stateid_hash(&lseg->pls_layout->plh_stateid) : 0)
1471 #else
1472 #define NFS4_LSEG_LAYOUT_STATEID_HASH(lseg) (0)
1473 #endif
1474 
1475 DECLARE_EVENT_CLASS(nfs4_read_event,
1476 		TP_PROTO(
1477 			const struct nfs_pgio_header *hdr,
1478 			int error
1479 		),
1480 
1481 		TP_ARGS(hdr, error),
1482 
1483 		TP_STRUCT__entry(
1484 			__field(dev_t, dev)
1485 			__field(u32, fhandle)
1486 			__field(u64, fileid)
1487 			__field(loff_t, offset)
1488 			__field(u32, arg_count)
1489 			__field(u32, res_count)
1490 			__field(unsigned long, error)
1491 			__field(int, stateid_seq)
1492 			__field(u32, stateid_hash)
1493 			__field(int, layoutstateid_seq)
1494 			__field(u32, layoutstateid_hash)
1495 		),
1496 
1497 		TP_fast_assign(
1498 			const struct inode *inode = hdr->inode;
1499 			const struct nfs_inode *nfsi = NFS_I(inode);
1500 			const struct nfs_fh *fh = hdr->args.fh ?
1501 						  hdr->args.fh : &nfsi->fh;
1502 			const struct nfs4_state *state =
1503 				hdr->args.context->state;
1504 			const struct pnfs_layout_segment *lseg = hdr->lseg;
1505 
1506 			__entry->dev = inode->i_sb->s_dev;
1507 			__entry->fileid = nfsi->fileid;
1508 			__entry->fhandle = nfs_fhandle_hash(fh);
1509 			__entry->offset = hdr->args.offset;
1510 			__entry->arg_count = hdr->args.count;
1511 			__entry->res_count = hdr->res.count;
1512 			__entry->error = error < 0 ? -error : 0;
1513 			__entry->stateid_seq =
1514 				be32_to_cpu(state->stateid.seqid);
1515 			__entry->stateid_hash =
1516 				nfs_stateid_hash(&state->stateid);
1517 			__entry->layoutstateid_seq = lseg ? lseg->pls_seq : 0;
1518 			__entry->layoutstateid_hash =
1519 				NFS4_LSEG_LAYOUT_STATEID_HASH(lseg);
1520 		),
1521 
1522 		TP_printk(
1523 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1524 			"offset=%lld count=%u res=%u stateid=%d:0x%08x "
1525 			"layoutstateid=%d:0x%08x",
1526 			-__entry->error,
1527 			show_nfs4_status(__entry->error),
1528 			MAJOR(__entry->dev), MINOR(__entry->dev),
1529 			(unsigned long long)__entry->fileid,
1530 			__entry->fhandle,
1531 			(long long)__entry->offset,
1532 			__entry->arg_count, __entry->res_count,
1533 			__entry->stateid_seq, __entry->stateid_hash,
1534 			__entry->layoutstateid_seq, __entry->layoutstateid_hash
1535 		)
1536 );
1537 #define DEFINE_NFS4_READ_EVENT(name) \
1538 	DEFINE_EVENT(nfs4_read_event, name, \
1539 			TP_PROTO( \
1540 				const struct nfs_pgio_header *hdr, \
1541 				int error \
1542 			), \
1543 			TP_ARGS(hdr, error))
1544 DEFINE_NFS4_READ_EVENT(nfs4_read);
1545 #ifdef CONFIG_NFS_V4_1
1546 DEFINE_NFS4_READ_EVENT(nfs4_pnfs_read);
1547 #endif /* CONFIG_NFS_V4_1 */
1548 
1549 DECLARE_EVENT_CLASS(nfs4_write_event,
1550 		TP_PROTO(
1551 			const struct nfs_pgio_header *hdr,
1552 			int error
1553 		),
1554 
1555 		TP_ARGS(hdr, error),
1556 
1557 		TP_STRUCT__entry(
1558 			__field(dev_t, dev)
1559 			__field(u32, fhandle)
1560 			__field(u64, fileid)
1561 			__field(loff_t, offset)
1562 			__field(u32, arg_count)
1563 			__field(u32, res_count)
1564 			__field(unsigned long, error)
1565 			__field(int, stateid_seq)
1566 			__field(u32, stateid_hash)
1567 			__field(int, layoutstateid_seq)
1568 			__field(u32, layoutstateid_hash)
1569 		),
1570 
1571 		TP_fast_assign(
1572 			const struct inode *inode = hdr->inode;
1573 			const struct nfs_inode *nfsi = NFS_I(inode);
1574 			const struct nfs_fh *fh = hdr->args.fh ?
1575 						  hdr->args.fh : &nfsi->fh;
1576 			const struct nfs4_state *state =
1577 				hdr->args.context->state;
1578 			const struct pnfs_layout_segment *lseg = hdr->lseg;
1579 
1580 			__entry->dev = inode->i_sb->s_dev;
1581 			__entry->fileid = nfsi->fileid;
1582 			__entry->fhandle = nfs_fhandle_hash(fh);
1583 			__entry->offset = hdr->args.offset;
1584 			__entry->arg_count = hdr->args.count;
1585 			__entry->res_count = hdr->res.count;
1586 			__entry->error = error < 0 ? -error : 0;
1587 			__entry->stateid_seq =
1588 				be32_to_cpu(state->stateid.seqid);
1589 			__entry->stateid_hash =
1590 				nfs_stateid_hash(&state->stateid);
1591 			__entry->layoutstateid_seq = lseg ? lseg->pls_seq : 0;
1592 			__entry->layoutstateid_hash =
1593 				NFS4_LSEG_LAYOUT_STATEID_HASH(lseg);
1594 		),
1595 
1596 		TP_printk(
1597 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1598 			"offset=%lld count=%u res=%u stateid=%d:0x%08x "
1599 			"layoutstateid=%d:0x%08x",
1600 			-__entry->error,
1601 			show_nfs4_status(__entry->error),
1602 			MAJOR(__entry->dev), MINOR(__entry->dev),
1603 			(unsigned long long)__entry->fileid,
1604 			__entry->fhandle,
1605 			(long long)__entry->offset,
1606 			__entry->arg_count, __entry->res_count,
1607 			__entry->stateid_seq, __entry->stateid_hash,
1608 			__entry->layoutstateid_seq, __entry->layoutstateid_hash
1609 		)
1610 );
1611 
1612 #define DEFINE_NFS4_WRITE_EVENT(name) \
1613 	DEFINE_EVENT(nfs4_write_event, name, \
1614 			TP_PROTO( \
1615 				const struct nfs_pgio_header *hdr, \
1616 				int error \
1617 			), \
1618 			TP_ARGS(hdr, error))
1619 DEFINE_NFS4_WRITE_EVENT(nfs4_write);
1620 #ifdef CONFIG_NFS_V4_1
1621 DEFINE_NFS4_WRITE_EVENT(nfs4_pnfs_write);
1622 #endif /* CONFIG_NFS_V4_1 */
1623 
1624 DECLARE_EVENT_CLASS(nfs4_commit_event,
1625 		TP_PROTO(
1626 			const struct nfs_commit_data *data,
1627 			int error
1628 		),
1629 
1630 		TP_ARGS(data, error),
1631 
1632 		TP_STRUCT__entry(
1633 			__field(dev_t, dev)
1634 			__field(u32, fhandle)
1635 			__field(u64, fileid)
1636 			__field(unsigned long, error)
1637 			__field(loff_t, offset)
1638 			__field(u32, count)
1639 			__field(int, layoutstateid_seq)
1640 			__field(u32, layoutstateid_hash)
1641 		),
1642 
1643 		TP_fast_assign(
1644 			const struct inode *inode = data->inode;
1645 			const struct nfs_inode *nfsi = NFS_I(inode);
1646 			const struct nfs_fh *fh = data->args.fh ?
1647 						  data->args.fh : &nfsi->fh;
1648 			const struct pnfs_layout_segment *lseg = data->lseg;
1649 
1650 			__entry->dev = inode->i_sb->s_dev;
1651 			__entry->fileid = nfsi->fileid;
1652 			__entry->fhandle = nfs_fhandle_hash(fh);
1653 			__entry->offset = data->args.offset;
1654 			__entry->count = data->args.count;
1655 			__entry->error = error < 0 ? -error : 0;
1656 			__entry->layoutstateid_seq = lseg ? lseg->pls_seq : 0;
1657 			__entry->layoutstateid_hash =
1658 				NFS4_LSEG_LAYOUT_STATEID_HASH(lseg);
1659 		),
1660 
1661 		TP_printk(
1662 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1663 			"offset=%lld count=%u layoutstateid=%d:0x%08x",
1664 			-__entry->error,
1665 			show_nfs4_status(__entry->error),
1666 			MAJOR(__entry->dev), MINOR(__entry->dev),
1667 			(unsigned long long)__entry->fileid,
1668 			__entry->fhandle,
1669 			(long long)__entry->offset,
1670 			__entry->count,
1671 			__entry->layoutstateid_seq, __entry->layoutstateid_hash
1672 		)
1673 );
1674 #define DEFINE_NFS4_COMMIT_EVENT(name) \
1675 	DEFINE_EVENT(nfs4_commit_event, name, \
1676 			TP_PROTO( \
1677 				const struct nfs_commit_data *data, \
1678 				int error \
1679 			), \
1680 			TP_ARGS(data, error))
1681 DEFINE_NFS4_COMMIT_EVENT(nfs4_commit);
1682 #ifdef CONFIG_NFS_V4_1
1683 DEFINE_NFS4_COMMIT_EVENT(nfs4_pnfs_commit_ds);
1684 
1685 TRACE_EVENT(nfs4_layoutget,
1686 		TP_PROTO(
1687 			const struct nfs_open_context *ctx,
1688 			const struct pnfs_layout_range *args,
1689 			const struct pnfs_layout_range *res,
1690 			const nfs4_stateid *layout_stateid,
1691 			int error
1692 		),
1693 
1694 		TP_ARGS(ctx, args, res, layout_stateid, error),
1695 
1696 		TP_STRUCT__entry(
1697 			__field(dev_t, dev)
1698 			__field(u32, fhandle)
1699 			__field(u64, fileid)
1700 			__field(u32, iomode)
1701 			__field(u64, offset)
1702 			__field(u64, count)
1703 			__field(unsigned long, error)
1704 			__field(int, stateid_seq)
1705 			__field(u32, stateid_hash)
1706 			__field(int, layoutstateid_seq)
1707 			__field(u32, layoutstateid_hash)
1708 		),
1709 
1710 		TP_fast_assign(
1711 			const struct inode *inode = d_inode(ctx->dentry);
1712 			const struct nfs4_state *state = ctx->state;
1713 			__entry->dev = inode->i_sb->s_dev;
1714 			__entry->fileid = NFS_FILEID(inode);
1715 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1716 			__entry->iomode = args->iomode;
1717 			__entry->offset = args->offset;
1718 			__entry->count = args->length;
1719 			__entry->error = error < 0 ? -error : 0;
1720 			__entry->stateid_seq =
1721 				be32_to_cpu(state->stateid.seqid);
1722 			__entry->stateid_hash =
1723 				nfs_stateid_hash(&state->stateid);
1724 			if (!error) {
1725 				__entry->layoutstateid_seq =
1726 				be32_to_cpu(layout_stateid->seqid);
1727 				__entry->layoutstateid_hash =
1728 				nfs_stateid_hash(layout_stateid);
1729 			} else {
1730 				__entry->layoutstateid_seq = 0;
1731 				__entry->layoutstateid_hash = 0;
1732 			}
1733 		),
1734 
1735 		TP_printk(
1736 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1737 			"iomode=%s offset=%llu count=%llu stateid=%d:0x%08x "
1738 			"layoutstateid=%d:0x%08x",
1739 			-__entry->error,
1740 			show_nfs4_status(__entry->error),
1741 			MAJOR(__entry->dev), MINOR(__entry->dev),
1742 			(unsigned long long)__entry->fileid,
1743 			__entry->fhandle,
1744 			show_pnfs_layout_iomode(__entry->iomode),
1745 			(unsigned long long)__entry->offset,
1746 			(unsigned long long)__entry->count,
1747 			__entry->stateid_seq, __entry->stateid_hash,
1748 			__entry->layoutstateid_seq, __entry->layoutstateid_hash
1749 		)
1750 );
1751 
1752 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layoutcommit);
1753 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layoutreturn);
1754 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layoutreturn_on_close);
1755 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layouterror);
1756 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layoutstats);
1757 
1758 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_UNKNOWN);
1759 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_NO_PNFS);
1760 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_RD_ZEROLEN);
1761 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_MDSTHRESH);
1762 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_NOMEM);
1763 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_BULK_RECALL);
1764 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_IO_TEST_FAIL);
1765 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_FOUND_CACHED);
1766 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_RETURN);
1767 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_BLOCKED);
1768 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_INVALID_OPEN);
1769 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_RETRY);
1770 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_SEND_LAYOUTGET);
1771 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_EXIT);
1772 
1773 #define show_pnfs_update_layout_reason(reason)				\
1774 	__print_symbolic(reason,					\
1775 		{ PNFS_UPDATE_LAYOUT_UNKNOWN, "unknown" },		\
1776 		{ PNFS_UPDATE_LAYOUT_NO_PNFS, "no pnfs" },		\
1777 		{ PNFS_UPDATE_LAYOUT_RD_ZEROLEN, "read+zerolen" },	\
1778 		{ PNFS_UPDATE_LAYOUT_MDSTHRESH, "mdsthresh" },		\
1779 		{ PNFS_UPDATE_LAYOUT_NOMEM, "nomem" },			\
1780 		{ PNFS_UPDATE_LAYOUT_BULK_RECALL, "bulk recall" },	\
1781 		{ PNFS_UPDATE_LAYOUT_IO_TEST_FAIL, "io test fail" },	\
1782 		{ PNFS_UPDATE_LAYOUT_FOUND_CACHED, "found cached" },	\
1783 		{ PNFS_UPDATE_LAYOUT_RETURN, "layoutreturn" },		\
1784 		{ PNFS_UPDATE_LAYOUT_BLOCKED, "layouts blocked" },	\
1785 		{ PNFS_UPDATE_LAYOUT_INVALID_OPEN, "invalid open" },	\
1786 		{ PNFS_UPDATE_LAYOUT_RETRY, "retrying" },	\
1787 		{ PNFS_UPDATE_LAYOUT_SEND_LAYOUTGET, "sent layoutget" }, \
1788 		{ PNFS_UPDATE_LAYOUT_EXIT, "exit" })
1789 
1790 TRACE_EVENT(pnfs_update_layout,
1791 		TP_PROTO(struct inode *inode,
1792 			loff_t pos,
1793 			u64 count,
1794 			enum pnfs_iomode iomode,
1795 			struct pnfs_layout_hdr *lo,
1796 			struct pnfs_layout_segment *lseg,
1797 			enum pnfs_update_layout_reason reason
1798 		),
1799 		TP_ARGS(inode, pos, count, iomode, lo, lseg, reason),
1800 		TP_STRUCT__entry(
1801 			__field(dev_t, dev)
1802 			__field(u64, fileid)
1803 			__field(u32, fhandle)
1804 			__field(loff_t, pos)
1805 			__field(u64, count)
1806 			__field(enum pnfs_iomode, iomode)
1807 			__field(int, layoutstateid_seq)
1808 			__field(u32, layoutstateid_hash)
1809 			__field(long, lseg)
1810 			__field(enum pnfs_update_layout_reason, reason)
1811 		),
1812 		TP_fast_assign(
1813 			__entry->dev = inode->i_sb->s_dev;
1814 			__entry->fileid = NFS_FILEID(inode);
1815 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1816 			__entry->pos = pos;
1817 			__entry->count = count;
1818 			__entry->iomode = iomode;
1819 			__entry->reason = reason;
1820 			if (lo != NULL && pnfs_layout_is_valid(lo)) {
1821 				__entry->layoutstateid_seq =
1822 				be32_to_cpu(lo->plh_stateid.seqid);
1823 				__entry->layoutstateid_hash =
1824 				nfs_stateid_hash(&lo->plh_stateid);
1825 			} else {
1826 				__entry->layoutstateid_seq = 0;
1827 				__entry->layoutstateid_hash = 0;
1828 			}
1829 			__entry->lseg = (long)lseg;
1830 		),
1831 		TP_printk(
1832 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1833 			"iomode=%s pos=%llu count=%llu "
1834 			"layoutstateid=%d:0x%08x lseg=0x%lx (%s)",
1835 			MAJOR(__entry->dev), MINOR(__entry->dev),
1836 			(unsigned long long)__entry->fileid,
1837 			__entry->fhandle,
1838 			show_pnfs_layout_iomode(__entry->iomode),
1839 			(unsigned long long)__entry->pos,
1840 			(unsigned long long)__entry->count,
1841 			__entry->layoutstateid_seq, __entry->layoutstateid_hash,
1842 			__entry->lseg,
1843 			show_pnfs_update_layout_reason(__entry->reason)
1844 		)
1845 );
1846 
1847 DECLARE_EVENT_CLASS(pnfs_layout_event,
1848 		TP_PROTO(struct inode *inode,
1849 			loff_t pos,
1850 			u64 count,
1851 			enum pnfs_iomode iomode,
1852 			struct pnfs_layout_hdr *lo,
1853 			struct pnfs_layout_segment *lseg
1854 		),
1855 		TP_ARGS(inode, pos, count, iomode, lo, lseg),
1856 		TP_STRUCT__entry(
1857 			__field(dev_t, dev)
1858 			__field(u64, fileid)
1859 			__field(u32, fhandle)
1860 			__field(loff_t, pos)
1861 			__field(u64, count)
1862 			__field(enum pnfs_iomode, iomode)
1863 			__field(int, layoutstateid_seq)
1864 			__field(u32, layoutstateid_hash)
1865 			__field(long, lseg)
1866 		),
1867 		TP_fast_assign(
1868 			__entry->dev = inode->i_sb->s_dev;
1869 			__entry->fileid = NFS_FILEID(inode);
1870 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1871 			__entry->pos = pos;
1872 			__entry->count = count;
1873 			__entry->iomode = iomode;
1874 			if (lo != NULL && pnfs_layout_is_valid(lo)) {
1875 				__entry->layoutstateid_seq =
1876 				be32_to_cpu(lo->plh_stateid.seqid);
1877 				__entry->layoutstateid_hash =
1878 				nfs_stateid_hash(&lo->plh_stateid);
1879 			} else {
1880 				__entry->layoutstateid_seq = 0;
1881 				__entry->layoutstateid_hash = 0;
1882 			}
1883 			__entry->lseg = (long)lseg;
1884 		),
1885 		TP_printk(
1886 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1887 			"iomode=%s pos=%llu count=%llu "
1888 			"layoutstateid=%d:0x%08x lseg=0x%lx",
1889 			MAJOR(__entry->dev), MINOR(__entry->dev),
1890 			(unsigned long long)__entry->fileid,
1891 			__entry->fhandle,
1892 			show_pnfs_layout_iomode(__entry->iomode),
1893 			(unsigned long long)__entry->pos,
1894 			(unsigned long long)__entry->count,
1895 			__entry->layoutstateid_seq, __entry->layoutstateid_hash,
1896 			__entry->lseg
1897 		)
1898 );
1899 
1900 #define DEFINE_PNFS_LAYOUT_EVENT(name) \
1901 	DEFINE_EVENT(pnfs_layout_event, name, \
1902 		TP_PROTO(struct inode *inode, \
1903 			loff_t pos, \
1904 			u64 count, \
1905 			enum pnfs_iomode iomode, \
1906 			struct pnfs_layout_hdr *lo, \
1907 			struct pnfs_layout_segment *lseg \
1908 		), \
1909 		TP_ARGS(inode, pos, count, iomode, lo, lseg))
1910 
1911 DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_pg_init_read);
1912 DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_pg_init_write);
1913 DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_pg_get_mirror_count);
1914 DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_read_done);
1915 DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_write_done);
1916 DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_read_pagelist);
1917 DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_write_pagelist);
1918 
1919 DECLARE_EVENT_CLASS(nfs4_deviceid_event,
1920 		TP_PROTO(
1921 			const struct nfs_client *clp,
1922 			const struct nfs4_deviceid *deviceid
1923 		),
1924 
1925 		TP_ARGS(clp, deviceid),
1926 
1927 		TP_STRUCT__entry(
1928 			__string(dstaddr, clp->cl_hostname)
1929 			__array(unsigned char, deviceid, NFS4_DEVICEID4_SIZE)
1930 		),
1931 
1932 		TP_fast_assign(
1933 			__assign_str(dstaddr, clp->cl_hostname);
1934 			memcpy(__entry->deviceid, deviceid->data,
1935 			       NFS4_DEVICEID4_SIZE);
1936 		),
1937 
1938 		TP_printk(
1939 			"deviceid=%s, dstaddr=%s",
1940 			__print_hex(__entry->deviceid, NFS4_DEVICEID4_SIZE),
1941 			__get_str(dstaddr)
1942 		)
1943 );
1944 #define DEFINE_PNFS_DEVICEID_EVENT(name) \
1945 	DEFINE_EVENT(nfs4_deviceid_event, name, \
1946 			TP_PROTO(const struct nfs_client *clp, \
1947 				const struct nfs4_deviceid *deviceid \
1948 			), \
1949 			TP_ARGS(clp, deviceid))
1950 DEFINE_PNFS_DEVICEID_EVENT(nfs4_deviceid_free);
1951 
1952 DECLARE_EVENT_CLASS(nfs4_deviceid_status,
1953 		TP_PROTO(
1954 			const struct nfs_server *server,
1955 			const struct nfs4_deviceid *deviceid,
1956 			int status
1957 		),
1958 
1959 		TP_ARGS(server, deviceid, status),
1960 
1961 		TP_STRUCT__entry(
1962 			__field(dev_t, dev)
1963 			__field(int, status)
1964 			__string(dstaddr, server->nfs_client->cl_hostname)
1965 			__array(unsigned char, deviceid, NFS4_DEVICEID4_SIZE)
1966 		),
1967 
1968 		TP_fast_assign(
1969 			__entry->dev = server->s_dev;
1970 			__entry->status = status;
1971 			__assign_str(dstaddr, server->nfs_client->cl_hostname);
1972 			memcpy(__entry->deviceid, deviceid->data,
1973 			       NFS4_DEVICEID4_SIZE);
1974 		),
1975 
1976 		TP_printk(
1977 			"dev=%02x:%02x: deviceid=%s, dstaddr=%s, status=%d",
1978 			MAJOR(__entry->dev), MINOR(__entry->dev),
1979 			__print_hex(__entry->deviceid, NFS4_DEVICEID4_SIZE),
1980 			__get_str(dstaddr),
1981 			__entry->status
1982 		)
1983 );
1984 #define DEFINE_PNFS_DEVICEID_STATUS(name) \
1985 	DEFINE_EVENT(nfs4_deviceid_status, name, \
1986 			TP_PROTO(const struct nfs_server *server, \
1987 				const struct nfs4_deviceid *deviceid, \
1988 				int status \
1989 			), \
1990 			TP_ARGS(server, deviceid, status))
1991 DEFINE_PNFS_DEVICEID_STATUS(nfs4_getdeviceinfo);
1992 DEFINE_PNFS_DEVICEID_STATUS(nfs4_find_deviceid);
1993 
1994 DECLARE_EVENT_CLASS(nfs4_flexfiles_io_event,
1995 		TP_PROTO(
1996 			const struct nfs_pgio_header *hdr
1997 		),
1998 
1999 		TP_ARGS(hdr),
2000 
2001 		TP_STRUCT__entry(
2002 			__field(unsigned long, error)
2003 			__field(dev_t, dev)
2004 			__field(u32, fhandle)
2005 			__field(u64, fileid)
2006 			__field(loff_t, offset)
2007 			__field(u32, count)
2008 			__field(int, stateid_seq)
2009 			__field(u32, stateid_hash)
2010 			__string(dstaddr, hdr->ds_clp ?
2011 				rpc_peeraddr2str(hdr->ds_clp->cl_rpcclient,
2012 					RPC_DISPLAY_ADDR) : "unknown")
2013 		),
2014 
2015 		TP_fast_assign(
2016 			const struct inode *inode = hdr->inode;
2017 
2018 			__entry->error = hdr->res.op_status;
2019 			__entry->fhandle = nfs_fhandle_hash(hdr->args.fh);
2020 			__entry->fileid = NFS_FILEID(inode);
2021 			__entry->dev = inode->i_sb->s_dev;
2022 			__entry->offset = hdr->args.offset;
2023 			__entry->count = hdr->args.count;
2024 			__entry->stateid_seq =
2025 				be32_to_cpu(hdr->args.stateid.seqid);
2026 			__entry->stateid_hash =
2027 				nfs_stateid_hash(&hdr->args.stateid);
2028 			__assign_str(dstaddr, hdr->ds_clp ?
2029 				rpc_peeraddr2str(hdr->ds_clp->cl_rpcclient,
2030 					RPC_DISPLAY_ADDR) : "unknown");
2031 		),
2032 
2033 		TP_printk(
2034 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
2035 			"offset=%llu count=%u stateid=%d:0x%08x dstaddr=%s",
2036 			-__entry->error,
2037 			show_nfs4_status(__entry->error),
2038 			MAJOR(__entry->dev), MINOR(__entry->dev),
2039 			(unsigned long long)__entry->fileid,
2040 			__entry->fhandle,
2041 			__entry->offset, __entry->count,
2042 			__entry->stateid_seq, __entry->stateid_hash,
2043 			__get_str(dstaddr)
2044 		)
2045 );
2046 
2047 #define DEFINE_NFS4_FLEXFILES_IO_EVENT(name) \
2048 	DEFINE_EVENT(nfs4_flexfiles_io_event, name, \
2049 			TP_PROTO( \
2050 				const struct nfs_pgio_header *hdr \
2051 			), \
2052 			TP_ARGS(hdr))
2053 DEFINE_NFS4_FLEXFILES_IO_EVENT(ff_layout_read_error);
2054 DEFINE_NFS4_FLEXFILES_IO_EVENT(ff_layout_write_error);
2055 
2056 TRACE_EVENT(ff_layout_commit_error,
2057 		TP_PROTO(
2058 			const struct nfs_commit_data *data
2059 		),
2060 
2061 		TP_ARGS(data),
2062 
2063 		TP_STRUCT__entry(
2064 			__field(unsigned long, error)
2065 			__field(dev_t, dev)
2066 			__field(u32, fhandle)
2067 			__field(u64, fileid)
2068 			__field(loff_t, offset)
2069 			__field(u32, count)
2070 			__string(dstaddr, data->ds_clp ?
2071 				rpc_peeraddr2str(data->ds_clp->cl_rpcclient,
2072 					RPC_DISPLAY_ADDR) : "unknown")
2073 		),
2074 
2075 		TP_fast_assign(
2076 			const struct inode *inode = data->inode;
2077 
2078 			__entry->error = data->res.op_status;
2079 			__entry->fhandle = nfs_fhandle_hash(data->args.fh);
2080 			__entry->fileid = NFS_FILEID(inode);
2081 			__entry->dev = inode->i_sb->s_dev;
2082 			__entry->offset = data->args.offset;
2083 			__entry->count = data->args.count;
2084 			__assign_str(dstaddr, data->ds_clp ?
2085 				rpc_peeraddr2str(data->ds_clp->cl_rpcclient,
2086 					RPC_DISPLAY_ADDR) : "unknown");
2087 		),
2088 
2089 		TP_printk(
2090 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
2091 			"offset=%llu count=%u dstaddr=%s",
2092 			-__entry->error,
2093 			show_nfs4_status(__entry->error),
2094 			MAJOR(__entry->dev), MINOR(__entry->dev),
2095 			(unsigned long long)__entry->fileid,
2096 			__entry->fhandle,
2097 			__entry->offset, __entry->count,
2098 			__get_str(dstaddr)
2099 		)
2100 );
2101 
2102 #ifdef CONFIG_NFS_V4_2
2103 TRACE_DEFINE_ENUM(NFS4_CONTENT_DATA);
2104 TRACE_DEFINE_ENUM(NFS4_CONTENT_HOLE);
2105 
2106 #define show_llseek_mode(what)			\
2107 	__print_symbolic(what,			\
2108 		{ NFS4_CONTENT_DATA, "DATA" },		\
2109 		{ NFS4_CONTENT_HOLE, "HOLE" })
2110 
2111 TRACE_EVENT(nfs4_llseek,
2112 		TP_PROTO(
2113 			const struct inode *inode,
2114 			const struct nfs42_seek_args *args,
2115 			const struct nfs42_seek_res *res,
2116 			int error
2117 		),
2118 
2119 		TP_ARGS(inode, args, res, error),
2120 
2121 		TP_STRUCT__entry(
2122 			__field(unsigned long, error)
2123 			__field(u32, fhandle)
2124 			__field(u32, fileid)
2125 			__field(dev_t, dev)
2126 			__field(int, stateid_seq)
2127 			__field(u32, stateid_hash)
2128 			__field(loff_t, offset_s)
2129 			__field(u32, what)
2130 			__field(loff_t, offset_r)
2131 			__field(u32, eof)
2132 		),
2133 
2134 		TP_fast_assign(
2135 			const struct nfs_inode *nfsi = NFS_I(inode);
2136 			const struct nfs_fh *fh = args->sa_fh;
2137 
2138 			__entry->fileid = nfsi->fileid;
2139 			__entry->dev = inode->i_sb->s_dev;
2140 			__entry->fhandle = nfs_fhandle_hash(fh);
2141 			__entry->offset_s = args->sa_offset;
2142 			__entry->stateid_seq =
2143 				be32_to_cpu(args->sa_stateid.seqid);
2144 			__entry->stateid_hash =
2145 				nfs_stateid_hash(&args->sa_stateid);
2146 			__entry->what = args->sa_what;
2147 			if (error) {
2148 				__entry->error = -error;
2149 				__entry->offset_r = 0;
2150 				__entry->eof = 0;
2151 			} else {
2152 				__entry->error = 0;
2153 				__entry->offset_r = res->sr_offset;
2154 				__entry->eof = res->sr_eof;
2155 			}
2156 		),
2157 
2158 		TP_printk(
2159 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
2160 			"stateid=%d:0x%08x offset_s=%llu what=%s "
2161 			"offset_r=%llu eof=%u",
2162 			-__entry->error,
2163 			show_nfs4_status(__entry->error),
2164 			MAJOR(__entry->dev), MINOR(__entry->dev),
2165 			(unsigned long long)__entry->fileid,
2166 			__entry->fhandle,
2167 			__entry->stateid_seq, __entry->stateid_hash,
2168 			__entry->offset_s,
2169 			show_llseek_mode(__entry->what),
2170 			__entry->offset_r,
2171 			__entry->eof
2172 		)
2173 );
2174 
2175 DECLARE_EVENT_CLASS(nfs4_sparse_event,
2176 		TP_PROTO(
2177 			const struct inode *inode,
2178 			const struct nfs42_falloc_args *args,
2179 			int error
2180 		),
2181 
2182 		TP_ARGS(inode, args, error),
2183 
2184 		TP_STRUCT__entry(
2185 			__field(unsigned long, error)
2186 			__field(loff_t, offset)
2187 			__field(loff_t, len)
2188 			__field(dev_t, dev)
2189 			__field(u32, fhandle)
2190 			__field(u64, fileid)
2191 			__field(int, stateid_seq)
2192 			__field(u32, stateid_hash)
2193 		),
2194 
2195 		TP_fast_assign(
2196 			__entry->error = error < 0 ? -error : 0;
2197 			__entry->offset = args->falloc_offset;
2198 			__entry->len = args->falloc_length;
2199 			__entry->dev = inode->i_sb->s_dev;
2200 			__entry->fileid = NFS_FILEID(inode);
2201 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
2202 			__entry->stateid_seq =
2203 				be32_to_cpu(args->falloc_stateid.seqid);
2204 			__entry->stateid_hash =
2205 				nfs_stateid_hash(&args->falloc_stateid);
2206 		),
2207 
2208 		TP_printk(
2209 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
2210 			"stateid=%d:0x%08x offset=%llu len=%llu",
2211 			-__entry->error,
2212 			show_nfs4_status(__entry->error),
2213 			MAJOR(__entry->dev), MINOR(__entry->dev),
2214 			(unsigned long long)__entry->fileid,
2215 			__entry->fhandle,
2216 			__entry->stateid_seq, __entry->stateid_hash,
2217 			(long long)__entry->offset,
2218 			(long long)__entry->len
2219 		)
2220 );
2221 #define DEFINE_NFS4_SPARSE_EVENT(name) \
2222 	DEFINE_EVENT(nfs4_sparse_event, name, \
2223 			TP_PROTO( \
2224 				const struct inode *inode, \
2225 				const struct nfs42_falloc_args *args, \
2226 				int error \
2227 			), \
2228 			TP_ARGS(inode, args, error))
2229 DEFINE_NFS4_SPARSE_EVENT(nfs4_fallocate);
2230 DEFINE_NFS4_SPARSE_EVENT(nfs4_deallocate);
2231 
2232 TRACE_EVENT(nfs4_copy,
2233 		TP_PROTO(
2234 			const struct inode *src_inode,
2235 			const struct inode *dst_inode,
2236 			const struct nfs42_copy_args *args,
2237 			const struct nfs42_copy_res *res,
2238 			const struct nl4_server *nss,
2239 			int error
2240 		),
2241 
2242 		TP_ARGS(src_inode, dst_inode, args, res, nss, error),
2243 
2244 		TP_STRUCT__entry(
2245 			__field(unsigned long, error)
2246 			__field(u32, src_fhandle)
2247 			__field(u32, src_fileid)
2248 			__field(u32, dst_fhandle)
2249 			__field(u32, dst_fileid)
2250 			__field(dev_t, src_dev)
2251 			__field(dev_t, dst_dev)
2252 			__field(int, src_stateid_seq)
2253 			__field(u32, src_stateid_hash)
2254 			__field(int, dst_stateid_seq)
2255 			__field(u32, dst_stateid_hash)
2256 			__field(loff_t, src_offset)
2257 			__field(loff_t, dst_offset)
2258 			__field(bool, sync)
2259 			__field(loff_t, len)
2260 			__field(int, res_stateid_seq)
2261 			__field(u32, res_stateid_hash)
2262 			__field(loff_t, res_count)
2263 			__field(bool, res_sync)
2264 			__field(bool, res_cons)
2265 			__field(bool, intra)
2266 		),
2267 
2268 		TP_fast_assign(
2269 			const struct nfs_inode *src_nfsi = NFS_I(src_inode);
2270 			const struct nfs_inode *dst_nfsi = NFS_I(dst_inode);
2271 
2272 			__entry->src_fileid = src_nfsi->fileid;
2273 			__entry->src_dev = src_inode->i_sb->s_dev;
2274 			__entry->src_fhandle = nfs_fhandle_hash(args->src_fh);
2275 			__entry->src_offset = args->src_pos;
2276 			__entry->dst_fileid = dst_nfsi->fileid;
2277 			__entry->dst_dev = dst_inode->i_sb->s_dev;
2278 			__entry->dst_fhandle = nfs_fhandle_hash(args->dst_fh);
2279 			__entry->dst_offset = args->dst_pos;
2280 			__entry->len = args->count;
2281 			__entry->sync = args->sync;
2282 			__entry->src_stateid_seq =
2283 				be32_to_cpu(args->src_stateid.seqid);
2284 			__entry->src_stateid_hash =
2285 				nfs_stateid_hash(&args->src_stateid);
2286 			__entry->dst_stateid_seq =
2287 				be32_to_cpu(args->dst_stateid.seqid);
2288 			__entry->dst_stateid_hash =
2289 				nfs_stateid_hash(&args->dst_stateid);
2290 			__entry->intra = nss ? 0 : 1;
2291 			if (error) {
2292 				__entry->error = -error;
2293 				__entry->res_stateid_seq = 0;
2294 				__entry->res_stateid_hash = 0;
2295 				__entry->res_count = 0;
2296 				__entry->res_sync = 0;
2297 				__entry->res_cons = 0;
2298 			} else {
2299 				__entry->error = 0;
2300 				__entry->res_stateid_seq =
2301 					be32_to_cpu(res->write_res.stateid.seqid);
2302 				__entry->res_stateid_hash =
2303 					nfs_stateid_hash(&res->write_res.stateid);
2304 				__entry->res_count = res->write_res.count;
2305 				__entry->res_sync = res->synchronous;
2306 				__entry->res_cons = res->consecutive;
2307 			}
2308 		),
2309 
2310 		TP_printk(
2311 			"error=%ld (%s) intra=%d src_fileid=%02x:%02x:%llu "
2312 			"src_fhandle=0x%08x dst_fileid=%02x:%02x:%llu "
2313 			"dst_fhandle=0x%08x src_stateid=%d:0x%08x "
2314 			"dst_stateid=%d:0x%08x src_offset=%llu dst_offset=%llu "
2315 			"len=%llu sync=%d cb_stateid=%d:0x%08x res_sync=%d "
2316 			"res_cons=%d res_count=%llu",
2317 			-__entry->error,
2318 			show_nfs4_status(__entry->error),
2319 			__entry->intra,
2320 			MAJOR(__entry->src_dev), MINOR(__entry->src_dev),
2321 			(unsigned long long)__entry->src_fileid,
2322 			__entry->src_fhandle,
2323 			MAJOR(__entry->dst_dev), MINOR(__entry->dst_dev),
2324 			(unsigned long long)__entry->dst_fileid,
2325 			__entry->dst_fhandle,
2326 			__entry->src_stateid_seq, __entry->src_stateid_hash,
2327 			__entry->dst_stateid_seq, __entry->dst_stateid_hash,
2328 			__entry->src_offset,
2329 			__entry->dst_offset,
2330 			__entry->len,
2331 			__entry->sync,
2332 			__entry->res_stateid_seq, __entry->res_stateid_hash,
2333 			__entry->res_sync,
2334 			__entry->res_cons,
2335 			__entry->res_count
2336 		)
2337 );
2338 
2339 TRACE_EVENT(nfs4_clone,
2340 		TP_PROTO(
2341 			const struct inode *src_inode,
2342 			const struct inode *dst_inode,
2343 			const struct nfs42_clone_args *args,
2344 			int error
2345 		),
2346 
2347 		TP_ARGS(src_inode, dst_inode, args, error),
2348 
2349 		TP_STRUCT__entry(
2350 			__field(unsigned long, error)
2351 			__field(u32, src_fhandle)
2352 			__field(u32, src_fileid)
2353 			__field(u32, dst_fhandle)
2354 			__field(u32, dst_fileid)
2355 			__field(dev_t, src_dev)
2356 			__field(dev_t, dst_dev)
2357 			__field(loff_t, src_offset)
2358 			__field(loff_t, dst_offset)
2359 			__field(int, src_stateid_seq)
2360 			__field(u32, src_stateid_hash)
2361 			__field(int, dst_stateid_seq)
2362 			__field(u32, dst_stateid_hash)
2363 			__field(loff_t, len)
2364 		),
2365 
2366 		TP_fast_assign(
2367 			const struct nfs_inode *src_nfsi = NFS_I(src_inode);
2368 			const struct nfs_inode *dst_nfsi = NFS_I(dst_inode);
2369 
2370 			__entry->src_fileid = src_nfsi->fileid;
2371 			__entry->src_dev = src_inode->i_sb->s_dev;
2372 			__entry->src_fhandle = nfs_fhandle_hash(args->src_fh);
2373 			__entry->src_offset = args->src_offset;
2374 			__entry->dst_fileid = dst_nfsi->fileid;
2375 			__entry->dst_dev = dst_inode->i_sb->s_dev;
2376 			__entry->dst_fhandle = nfs_fhandle_hash(args->dst_fh);
2377 			__entry->dst_offset = args->dst_offset;
2378 			__entry->len = args->count;
2379 			__entry->error = error < 0 ? -error : 0;
2380 			__entry->src_stateid_seq =
2381 				be32_to_cpu(args->src_stateid.seqid);
2382 			__entry->src_stateid_hash =
2383 				nfs_stateid_hash(&args->src_stateid);
2384 			__entry->dst_stateid_seq =
2385 				be32_to_cpu(args->dst_stateid.seqid);
2386 			__entry->dst_stateid_hash =
2387 				nfs_stateid_hash(&args->dst_stateid);
2388 		),
2389 
2390 		TP_printk(
2391 			"error=%ld (%s) src_fileid=%02x:%02x:%llu "
2392 			"src_fhandle=0x%08x dst_fileid=%02x:%02x:%llu "
2393 			"dst_fhandle=0x%08x src_stateid=%d:0x%08x "
2394 			"dst_stateid=%d:0x%08x src_offset=%llu "
2395 			"dst_offset=%llu len=%llu",
2396 			-__entry->error,
2397 			show_nfs4_status(__entry->error),
2398 			MAJOR(__entry->src_dev), MINOR(__entry->src_dev),
2399 			(unsigned long long)__entry->src_fileid,
2400 			__entry->src_fhandle,
2401 			MAJOR(__entry->dst_dev), MINOR(__entry->dst_dev),
2402 			(unsigned long long)__entry->dst_fileid,
2403 			__entry->dst_fhandle,
2404 			__entry->src_stateid_seq, __entry->src_stateid_hash,
2405 			__entry->dst_stateid_seq, __entry->dst_stateid_hash,
2406 			__entry->src_offset,
2407 			__entry->dst_offset,
2408 			__entry->len
2409 		)
2410 );
2411 
2412 TRACE_EVENT(nfs4_copy_notify,
2413 		TP_PROTO(
2414 			const struct inode *inode,
2415 			const struct nfs42_copy_notify_args *args,
2416 			const struct nfs42_copy_notify_res *res,
2417 			int error
2418 		),
2419 
2420 		TP_ARGS(inode, args, res, error),
2421 
2422 		TP_STRUCT__entry(
2423 			__field(unsigned long, error)
2424 			__field(u32, fhandle)
2425 			__field(u32, fileid)
2426 			__field(dev_t, dev)
2427 			__field(int, stateid_seq)
2428 			__field(u32, stateid_hash)
2429 			__field(int, res_stateid_seq)
2430 			__field(u32, res_stateid_hash)
2431 		),
2432 
2433 		TP_fast_assign(
2434 			const struct nfs_inode *nfsi = NFS_I(inode);
2435 
2436 			__entry->fileid = nfsi->fileid;
2437 			__entry->dev = inode->i_sb->s_dev;
2438 			__entry->fhandle = nfs_fhandle_hash(args->cna_src_fh);
2439 			__entry->stateid_seq =
2440 				be32_to_cpu(args->cna_src_stateid.seqid);
2441 			__entry->stateid_hash =
2442 				nfs_stateid_hash(&args->cna_src_stateid);
2443 			if (error) {
2444 				__entry->error = -error;
2445 				__entry->res_stateid_seq = 0;
2446 				__entry->res_stateid_hash = 0;
2447 			} else {
2448 				__entry->error = 0;
2449 				__entry->res_stateid_seq =
2450 					be32_to_cpu(res->cnr_stateid.seqid);
2451 				__entry->res_stateid_hash =
2452 					nfs_stateid_hash(&res->cnr_stateid);
2453 			}
2454 		),
2455 
2456 		TP_printk(
2457 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
2458 			"stateid=%d:0x%08x res_stateid=%d:0x%08x",
2459 			-__entry->error,
2460 			show_nfs4_status(__entry->error),
2461 			MAJOR(__entry->dev), MINOR(__entry->dev),
2462 			(unsigned long long)__entry->fileid,
2463 			__entry->fhandle,
2464 			__entry->stateid_seq, __entry->stateid_hash,
2465 			__entry->res_stateid_seq, __entry->res_stateid_hash
2466 		)
2467 );
2468 
2469 TRACE_EVENT(nfs4_offload_cancel,
2470 		TP_PROTO(
2471 			const struct nfs42_offload_status_args *args,
2472 			int error
2473 		),
2474 
2475 		TP_ARGS(args, error),
2476 
2477 		TP_STRUCT__entry(
2478 			__field(unsigned long, error)
2479 			__field(u32, fhandle)
2480 			__field(int, stateid_seq)
2481 			__field(u32, stateid_hash)
2482 		),
2483 
2484 		TP_fast_assign(
2485 			__entry->fhandle = nfs_fhandle_hash(args->osa_src_fh);
2486 			__entry->error = error < 0 ? -error : 0;
2487 			__entry->stateid_seq =
2488 				be32_to_cpu(args->osa_stateid.seqid);
2489 			__entry->stateid_hash =
2490 				nfs_stateid_hash(&args->osa_stateid);
2491 		),
2492 
2493 		TP_printk(
2494 			"error=%ld (%s) fhandle=0x%08x stateid=%d:0x%08x",
2495 			-__entry->error,
2496 			show_nfs4_status(__entry->error),
2497 			__entry->fhandle,
2498 			__entry->stateid_seq, __entry->stateid_hash
2499 		)
2500 );
2501 
2502 DECLARE_EVENT_CLASS(nfs4_xattr_event,
2503 		TP_PROTO(
2504 			const struct inode *inode,
2505 			const char *name,
2506 			int error
2507 		),
2508 
2509 		TP_ARGS(inode, name, error),
2510 
2511 		TP_STRUCT__entry(
2512 			__field(unsigned long, error)
2513 			__field(dev_t, dev)
2514 			__field(u32, fhandle)
2515 			__field(u64, fileid)
2516 			__string(name, name)
2517 		),
2518 
2519 		TP_fast_assign(
2520 			__entry->error = error < 0 ? -error : 0;
2521 			__entry->dev = inode->i_sb->s_dev;
2522 			__entry->fileid = NFS_FILEID(inode);
2523 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
2524 			__assign_str(name, name);
2525 		),
2526 
2527 		TP_printk(
2528 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
2529 			"name=%s",
2530 			-__entry->error, show_nfs4_status(__entry->error),
2531 			MAJOR(__entry->dev), MINOR(__entry->dev),
2532 			(unsigned long long)__entry->fileid,
2533 			__entry->fhandle, __get_str(name)
2534 		)
2535 );
2536 #define DEFINE_NFS4_XATTR_EVENT(name) \
2537 	DEFINE_EVENT(nfs4_xattr_event, name,  \
2538 			TP_PROTO( \
2539 				const struct inode *inode, \
2540 				const char *name, \
2541 				int error \
2542 			), \
2543 			TP_ARGS(inode, name, error))
2544 DEFINE_NFS4_XATTR_EVENT(nfs4_getxattr);
2545 DEFINE_NFS4_XATTR_EVENT(nfs4_setxattr);
2546 DEFINE_NFS4_XATTR_EVENT(nfs4_removexattr);
2547 
2548 DEFINE_NFS4_INODE_EVENT(nfs4_listxattr);
2549 #endif /* CONFIG_NFS_V4_2 */
2550 
2551 #endif /* CONFIG_NFS_V4_1 */
2552 
2553 #endif /* _TRACE_NFS4_H */
2554 
2555 #undef TRACE_INCLUDE_PATH
2556 #define TRACE_INCLUDE_PATH .
2557 #define TRACE_INCLUDE_FILE nfs4trace
2558 /* This part must be outside protection */
2559 #include <trace/define_trace.h>
2560