xref: /openbmc/linux/fs/nfs/nfs4trace.h (revision 8b235f2f)
1 /*
2  * Copyright (c) 2013 Trond Myklebust <Trond.Myklebust@netapp.com>
3  */
4 #undef TRACE_SYSTEM
5 #define TRACE_SYSTEM nfs4
6 
7 #if !defined(_TRACE_NFS4_H) || defined(TRACE_HEADER_MULTI_READ)
8 #define _TRACE_NFS4_H
9 
10 #include <linux/tracepoint.h>
11 
12 #define show_nfsv4_errors(error) \
13 	__print_symbolic(error, \
14 		{ NFS4_OK, "OK" }, \
15 		/* Mapped by nfs4_stat_to_errno() */ \
16 		{ -EPERM, "EPERM" }, \
17 		{ -ENOENT, "ENOENT" }, \
18 		{ -EIO, "EIO" }, \
19 		{ -ENXIO, "ENXIO" }, \
20 		{ -EACCES, "EACCES" }, \
21 		{ -EEXIST, "EEXIST" }, \
22 		{ -EXDEV, "EXDEV" }, \
23 		{ -ENOTDIR, "ENOTDIR" }, \
24 		{ -EISDIR, "EISDIR" }, \
25 		{ -EFBIG, "EFBIG" }, \
26 		{ -ENOSPC, "ENOSPC" }, \
27 		{ -EROFS, "EROFS" }, \
28 		{ -EMLINK, "EMLINK" }, \
29 		{ -ENAMETOOLONG, "ENAMETOOLONG" }, \
30 		{ -ENOTEMPTY, "ENOTEMPTY" }, \
31 		{ -EDQUOT, "EDQUOT" }, \
32 		{ -ESTALE, "ESTALE" }, \
33 		{ -EBADHANDLE, "EBADHANDLE" }, \
34 		{ -EBADCOOKIE, "EBADCOOKIE" }, \
35 		{ -ENOTSUPP, "ENOTSUPP" }, \
36 		{ -ETOOSMALL, "ETOOSMALL" }, \
37 		{ -EREMOTEIO, "EREMOTEIO" }, \
38 		{ -EBADTYPE, "EBADTYPE" }, \
39 		{ -EAGAIN, "EAGAIN" }, \
40 		{ -ELOOP, "ELOOP" }, \
41 		{ -EOPNOTSUPP, "EOPNOTSUPP" }, \
42 		{ -EDEADLK, "EDEADLK" }, \
43 		/* RPC errors */ \
44 		{ -ENOMEM, "ENOMEM" }, \
45 		{ -EKEYEXPIRED, "EKEYEXPIRED" }, \
46 		{ -ETIMEDOUT, "ETIMEDOUT" }, \
47 		{ -ERESTARTSYS, "ERESTARTSYS" }, \
48 		{ -ECONNREFUSED, "ECONNREFUSED" }, \
49 		{ -ECONNRESET, "ECONNRESET" }, \
50 		{ -ENETUNREACH, "ENETUNREACH" }, \
51 		{ -EHOSTUNREACH, "EHOSTUNREACH" }, \
52 		{ -EHOSTDOWN, "EHOSTDOWN" }, \
53 		{ -EPIPE, "EPIPE" }, \
54 		{ -EPFNOSUPPORT, "EPFNOSUPPORT" }, \
55 		{ -EPROTONOSUPPORT, "EPROTONOSUPPORT" }, \
56 		/* NFSv4 native errors */ \
57 		{ -NFS4ERR_ACCESS, "ACCESS" }, \
58 		{ -NFS4ERR_ATTRNOTSUPP, "ATTRNOTSUPP" }, \
59 		{ -NFS4ERR_ADMIN_REVOKED, "ADMIN_REVOKED" }, \
60 		{ -NFS4ERR_BACK_CHAN_BUSY, "BACK_CHAN_BUSY" }, \
61 		{ -NFS4ERR_BADCHAR, "BADCHAR" }, \
62 		{ -NFS4ERR_BADHANDLE, "BADHANDLE" }, \
63 		{ -NFS4ERR_BADIOMODE, "BADIOMODE" }, \
64 		{ -NFS4ERR_BADLAYOUT, "BADLAYOUT" }, \
65 		{ -NFS4ERR_BADLABEL, "BADLABEL" }, \
66 		{ -NFS4ERR_BADNAME, "BADNAME" }, \
67 		{ -NFS4ERR_BADOWNER, "BADOWNER" }, \
68 		{ -NFS4ERR_BADSESSION, "BADSESSION" }, \
69 		{ -NFS4ERR_BADSLOT, "BADSLOT" }, \
70 		{ -NFS4ERR_BADTYPE, "BADTYPE" }, \
71 		{ -NFS4ERR_BADXDR, "BADXDR" }, \
72 		{ -NFS4ERR_BAD_COOKIE, "BAD_COOKIE" }, \
73 		{ -NFS4ERR_BAD_HIGH_SLOT, "BAD_HIGH_SLOT" }, \
74 		{ -NFS4ERR_BAD_RANGE, "BAD_RANGE" }, \
75 		{ -NFS4ERR_BAD_SEQID, "BAD_SEQID" }, \
76 		{ -NFS4ERR_BAD_SESSION_DIGEST, "BAD_SESSION_DIGEST" }, \
77 		{ -NFS4ERR_BAD_STATEID, "BAD_STATEID" }, \
78 		{ -NFS4ERR_CB_PATH_DOWN, "CB_PATH_DOWN" }, \
79 		{ -NFS4ERR_CLID_INUSE, "CLID_INUSE" }, \
80 		{ -NFS4ERR_CLIENTID_BUSY, "CLIENTID_BUSY" }, \
81 		{ -NFS4ERR_COMPLETE_ALREADY, "COMPLETE_ALREADY" }, \
82 		{ -NFS4ERR_CONN_NOT_BOUND_TO_SESSION, \
83 			"CONN_NOT_BOUND_TO_SESSION" }, \
84 		{ -NFS4ERR_DEADLOCK, "DEADLOCK" }, \
85 		{ -NFS4ERR_DEADSESSION, "DEAD_SESSION" }, \
86 		{ -NFS4ERR_DELAY, "DELAY" }, \
87 		{ -NFS4ERR_DELEG_ALREADY_WANTED, \
88 			"DELEG_ALREADY_WANTED" }, \
89 		{ -NFS4ERR_DELEG_REVOKED, "DELEG_REVOKED" }, \
90 		{ -NFS4ERR_DENIED, "DENIED" }, \
91 		{ -NFS4ERR_DIRDELEG_UNAVAIL, "DIRDELEG_UNAVAIL" }, \
92 		{ -NFS4ERR_DQUOT, "DQUOT" }, \
93 		{ -NFS4ERR_ENCR_ALG_UNSUPP, "ENCR_ALG_UNSUPP" }, \
94 		{ -NFS4ERR_EXIST, "EXIST" }, \
95 		{ -NFS4ERR_EXPIRED, "EXPIRED" }, \
96 		{ -NFS4ERR_FBIG, "FBIG" }, \
97 		{ -NFS4ERR_FHEXPIRED, "FHEXPIRED" }, \
98 		{ -NFS4ERR_FILE_OPEN, "FILE_OPEN" }, \
99 		{ -NFS4ERR_GRACE, "GRACE" }, \
100 		{ -NFS4ERR_HASH_ALG_UNSUPP, "HASH_ALG_UNSUPP" }, \
101 		{ -NFS4ERR_INVAL, "INVAL" }, \
102 		{ -NFS4ERR_IO, "IO" }, \
103 		{ -NFS4ERR_ISDIR, "ISDIR" }, \
104 		{ -NFS4ERR_LAYOUTTRYLATER, "LAYOUTTRYLATER" }, \
105 		{ -NFS4ERR_LAYOUTUNAVAILABLE, "LAYOUTUNAVAILABLE" }, \
106 		{ -NFS4ERR_LEASE_MOVED, "LEASE_MOVED" }, \
107 		{ -NFS4ERR_LOCKED, "LOCKED" }, \
108 		{ -NFS4ERR_LOCKS_HELD, "LOCKS_HELD" }, \
109 		{ -NFS4ERR_LOCK_RANGE, "LOCK_RANGE" }, \
110 		{ -NFS4ERR_MINOR_VERS_MISMATCH, "MINOR_VERS_MISMATCH" }, \
111 		{ -NFS4ERR_MLINK, "MLINK" }, \
112 		{ -NFS4ERR_MOVED, "MOVED" }, \
113 		{ -NFS4ERR_NAMETOOLONG, "NAMETOOLONG" }, \
114 		{ -NFS4ERR_NOENT, "NOENT" }, \
115 		{ -NFS4ERR_NOFILEHANDLE, "NOFILEHANDLE" }, \
116 		{ -NFS4ERR_NOMATCHING_LAYOUT, "NOMATCHING_LAYOUT" }, \
117 		{ -NFS4ERR_NOSPC, "NOSPC" }, \
118 		{ -NFS4ERR_NOTDIR, "NOTDIR" }, \
119 		{ -NFS4ERR_NOTEMPTY, "NOTEMPTY" }, \
120 		{ -NFS4ERR_NOTSUPP, "NOTSUPP" }, \
121 		{ -NFS4ERR_NOT_ONLY_OP, "NOT_ONLY_OP" }, \
122 		{ -NFS4ERR_NOT_SAME, "NOT_SAME" }, \
123 		{ -NFS4ERR_NO_GRACE, "NO_GRACE" }, \
124 		{ -NFS4ERR_NXIO, "NXIO" }, \
125 		{ -NFS4ERR_OLD_STATEID, "OLD_STATEID" }, \
126 		{ -NFS4ERR_OPENMODE, "OPENMODE" }, \
127 		{ -NFS4ERR_OP_ILLEGAL, "OP_ILLEGAL" }, \
128 		{ -NFS4ERR_OP_NOT_IN_SESSION, "OP_NOT_IN_SESSION" }, \
129 		{ -NFS4ERR_PERM, "PERM" }, \
130 		{ -NFS4ERR_PNFS_IO_HOLE, "PNFS_IO_HOLE" }, \
131 		{ -NFS4ERR_PNFS_NO_LAYOUT, "PNFS_NO_LAYOUT" }, \
132 		{ -NFS4ERR_RECALLCONFLICT, "RECALLCONFLICT" }, \
133 		{ -NFS4ERR_RECLAIM_BAD, "RECLAIM_BAD" }, \
134 		{ -NFS4ERR_RECLAIM_CONFLICT, "RECLAIM_CONFLICT" }, \
135 		{ -NFS4ERR_REJECT_DELEG, "REJECT_DELEG" }, \
136 		{ -NFS4ERR_REP_TOO_BIG, "REP_TOO_BIG" }, \
137 		{ -NFS4ERR_REP_TOO_BIG_TO_CACHE, \
138 			"REP_TOO_BIG_TO_CACHE" }, \
139 		{ -NFS4ERR_REQ_TOO_BIG, "REQ_TOO_BIG" }, \
140 		{ -NFS4ERR_RESOURCE, "RESOURCE" }, \
141 		{ -NFS4ERR_RESTOREFH, "RESTOREFH" }, \
142 		{ -NFS4ERR_RETRY_UNCACHED_REP, "RETRY_UNCACHED_REP" }, \
143 		{ -NFS4ERR_RETURNCONFLICT, "RETURNCONFLICT" }, \
144 		{ -NFS4ERR_ROFS, "ROFS" }, \
145 		{ -NFS4ERR_SAME, "SAME" }, \
146 		{ -NFS4ERR_SHARE_DENIED, "SHARE_DENIED" }, \
147 		{ -NFS4ERR_SEQUENCE_POS, "SEQUENCE_POS" }, \
148 		{ -NFS4ERR_SEQ_FALSE_RETRY, "SEQ_FALSE_RETRY" }, \
149 		{ -NFS4ERR_SEQ_MISORDERED, "SEQ_MISORDERED" }, \
150 		{ -NFS4ERR_SERVERFAULT, "SERVERFAULT" }, \
151 		{ -NFS4ERR_STALE, "STALE" }, \
152 		{ -NFS4ERR_STALE_CLIENTID, "STALE_CLIENTID" }, \
153 		{ -NFS4ERR_STALE_STATEID, "STALE_STATEID" }, \
154 		{ -NFS4ERR_SYMLINK, "SYMLINK" }, \
155 		{ -NFS4ERR_TOOSMALL, "TOOSMALL" }, \
156 		{ -NFS4ERR_TOO_MANY_OPS, "TOO_MANY_OPS" }, \
157 		{ -NFS4ERR_UNKNOWN_LAYOUTTYPE, "UNKNOWN_LAYOUTTYPE" }, \
158 		{ -NFS4ERR_UNSAFE_COMPOUND, "UNSAFE_COMPOUND" }, \
159 		{ -NFS4ERR_WRONGSEC, "WRONGSEC" }, \
160 		{ -NFS4ERR_WRONG_CRED, "WRONG_CRED" }, \
161 		{ -NFS4ERR_WRONG_TYPE, "WRONG_TYPE" }, \
162 		{ -NFS4ERR_XDEV, "XDEV" })
163 
164 #define show_open_flags(flags) \
165 	__print_flags(flags, "|", \
166 		{ O_CREAT, "O_CREAT" }, \
167 		{ O_EXCL, "O_EXCL" }, \
168 		{ O_TRUNC, "O_TRUNC" }, \
169 		{ O_DIRECT, "O_DIRECT" })
170 
171 #define show_fmode_flags(mode) \
172 	__print_flags(mode, "|", \
173 		{ ((__force unsigned long)FMODE_READ), "READ" }, \
174 		{ ((__force unsigned long)FMODE_WRITE), "WRITE" }, \
175 		{ ((__force unsigned long)FMODE_EXEC), "EXEC" })
176 
177 #define show_nfs_fattr_flags(valid) \
178 	__print_flags((unsigned long)valid, "|", \
179 		{ NFS_ATTR_FATTR_TYPE, "TYPE" }, \
180 		{ NFS_ATTR_FATTR_MODE, "MODE" }, \
181 		{ NFS_ATTR_FATTR_NLINK, "NLINK" }, \
182 		{ NFS_ATTR_FATTR_OWNER, "OWNER" }, \
183 		{ NFS_ATTR_FATTR_GROUP, "GROUP" }, \
184 		{ NFS_ATTR_FATTR_RDEV, "RDEV" }, \
185 		{ NFS_ATTR_FATTR_SIZE, "SIZE" }, \
186 		{ NFS_ATTR_FATTR_FSID, "FSID" }, \
187 		{ NFS_ATTR_FATTR_FILEID, "FILEID" }, \
188 		{ NFS_ATTR_FATTR_ATIME, "ATIME" }, \
189 		{ NFS_ATTR_FATTR_MTIME, "MTIME" }, \
190 		{ NFS_ATTR_FATTR_CTIME, "CTIME" }, \
191 		{ NFS_ATTR_FATTR_CHANGE, "CHANGE" }, \
192 		{ NFS_ATTR_FATTR_OWNER_NAME, "OWNER_NAME" }, \
193 		{ NFS_ATTR_FATTR_GROUP_NAME, "GROUP_NAME" })
194 
195 DECLARE_EVENT_CLASS(nfs4_clientid_event,
196 		TP_PROTO(
197 			const struct nfs_client *clp,
198 			int error
199 		),
200 
201 		TP_ARGS(clp, error),
202 
203 		TP_STRUCT__entry(
204 			__string(dstaddr,
205 				rpc_peeraddr2str(clp->cl_rpcclient,
206 					RPC_DISPLAY_ADDR))
207 			__field(int, error)
208 		),
209 
210 		TP_fast_assign(
211 			__entry->error = error;
212 			__assign_str(dstaddr,
213 				rpc_peeraddr2str(clp->cl_rpcclient,
214 						RPC_DISPLAY_ADDR));
215 		),
216 
217 		TP_printk(
218 			"error=%d (%s) dstaddr=%s",
219 			__entry->error,
220 			show_nfsv4_errors(__entry->error),
221 			__get_str(dstaddr)
222 		)
223 );
224 #define DEFINE_NFS4_CLIENTID_EVENT(name) \
225 	DEFINE_EVENT(nfs4_clientid_event, name,	 \
226 			TP_PROTO( \
227 				const struct nfs_client *clp, \
228 				int error \
229 			), \
230 			TP_ARGS(clp, error))
231 DEFINE_NFS4_CLIENTID_EVENT(nfs4_setclientid);
232 DEFINE_NFS4_CLIENTID_EVENT(nfs4_setclientid_confirm);
233 DEFINE_NFS4_CLIENTID_EVENT(nfs4_renew);
234 DEFINE_NFS4_CLIENTID_EVENT(nfs4_renew_async);
235 #ifdef CONFIG_NFS_V4_1
236 DEFINE_NFS4_CLIENTID_EVENT(nfs4_exchange_id);
237 DEFINE_NFS4_CLIENTID_EVENT(nfs4_create_session);
238 DEFINE_NFS4_CLIENTID_EVENT(nfs4_destroy_session);
239 DEFINE_NFS4_CLIENTID_EVENT(nfs4_destroy_clientid);
240 DEFINE_NFS4_CLIENTID_EVENT(nfs4_bind_conn_to_session);
241 DEFINE_NFS4_CLIENTID_EVENT(nfs4_sequence);
242 DEFINE_NFS4_CLIENTID_EVENT(nfs4_reclaim_complete);
243 
244 TRACE_EVENT(nfs4_setup_sequence,
245 		TP_PROTO(
246 			const struct nfs4_session *session,
247 			const struct nfs4_sequence_args *args
248 		),
249 		TP_ARGS(session, args),
250 
251 		TP_STRUCT__entry(
252 			__field(unsigned int, session)
253 			__field(unsigned int, slot_nr)
254 			__field(unsigned int, seq_nr)
255 			__field(unsigned int, highest_used_slotid)
256 		),
257 
258 		TP_fast_assign(
259 			const struct nfs4_slot *sa_slot = args->sa_slot;
260 			__entry->session = nfs_session_id_hash(&session->sess_id);
261 			__entry->slot_nr = sa_slot->slot_nr;
262 			__entry->seq_nr = sa_slot->seq_nr;
263 			__entry->highest_used_slotid =
264 					sa_slot->table->highest_used_slotid;
265 		),
266 		TP_printk(
267 			"session=0x%08x slot_nr=%u seq_nr=%u "
268 			"highest_used_slotid=%u",
269 			__entry->session,
270 			__entry->slot_nr,
271 			__entry->seq_nr,
272 			__entry->highest_used_slotid
273 		)
274 );
275 
276 #define show_nfs4_sequence_status_flags(status) \
277 	__print_flags((unsigned long)status, "|", \
278 		{ SEQ4_STATUS_CB_PATH_DOWN, "CB_PATH_DOWN" }, \
279 		{ SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRING, \
280 			"CB_GSS_CONTEXTS_EXPIRING" }, \
281 		{ SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRED, \
282 			"CB_GSS_CONTEXTS_EXPIRED" }, \
283 		{ SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED, \
284 			"EXPIRED_ALL_STATE_REVOKED" }, \
285 		{ SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED, \
286 			"EXPIRED_SOME_STATE_REVOKED" }, \
287 		{ SEQ4_STATUS_ADMIN_STATE_REVOKED, \
288 			"ADMIN_STATE_REVOKED" }, \
289 		{ SEQ4_STATUS_RECALLABLE_STATE_REVOKED,	 \
290 			"RECALLABLE_STATE_REVOKED" }, \
291 		{ SEQ4_STATUS_LEASE_MOVED, "LEASE_MOVED" }, \
292 		{ SEQ4_STATUS_RESTART_RECLAIM_NEEDED, \
293 			"RESTART_RECLAIM_NEEDED" }, \
294 		{ SEQ4_STATUS_CB_PATH_DOWN_SESSION, \
295 			"CB_PATH_DOWN_SESSION" }, \
296 		{ SEQ4_STATUS_BACKCHANNEL_FAULT, \
297 			"BACKCHANNEL_FAULT" })
298 
299 TRACE_EVENT(nfs4_sequence_done,
300 		TP_PROTO(
301 			const struct nfs4_session *session,
302 			const struct nfs4_sequence_res *res
303 		),
304 		TP_ARGS(session, res),
305 
306 		TP_STRUCT__entry(
307 			__field(unsigned int, session)
308 			__field(unsigned int, slot_nr)
309 			__field(unsigned int, seq_nr)
310 			__field(unsigned int, highest_slotid)
311 			__field(unsigned int, target_highest_slotid)
312 			__field(unsigned int, status_flags)
313 			__field(int, error)
314 		),
315 
316 		TP_fast_assign(
317 			const struct nfs4_slot *sr_slot = res->sr_slot;
318 			__entry->session = nfs_session_id_hash(&session->sess_id);
319 			__entry->slot_nr = sr_slot->slot_nr;
320 			__entry->seq_nr = sr_slot->seq_nr;
321 			__entry->highest_slotid = res->sr_highest_slotid;
322 			__entry->target_highest_slotid =
323 					res->sr_target_highest_slotid;
324 			__entry->error = res->sr_status;
325 		),
326 		TP_printk(
327 			"error=%d (%s) session=0x%08x slot_nr=%u seq_nr=%u "
328 			"highest_slotid=%u target_highest_slotid=%u "
329 			"status_flags=%u (%s)",
330 			__entry->error,
331 			show_nfsv4_errors(__entry->error),
332 			__entry->session,
333 			__entry->slot_nr,
334 			__entry->seq_nr,
335 			__entry->highest_slotid,
336 			__entry->target_highest_slotid,
337 			__entry->status_flags,
338 			show_nfs4_sequence_status_flags(__entry->status_flags)
339 		)
340 );
341 
342 struct cb_sequenceargs;
343 struct cb_sequenceres;
344 
345 TRACE_EVENT(nfs4_cb_sequence,
346 		TP_PROTO(
347 			const struct cb_sequenceargs *args,
348 			const struct cb_sequenceres *res,
349 			__be32 status
350 		),
351 		TP_ARGS(args, res, status),
352 
353 		TP_STRUCT__entry(
354 			__field(unsigned int, session)
355 			__field(unsigned int, slot_nr)
356 			__field(unsigned int, seq_nr)
357 			__field(unsigned int, highest_slotid)
358 			__field(unsigned int, cachethis)
359 			__field(int, error)
360 		),
361 
362 		TP_fast_assign(
363 			__entry->session = nfs_session_id_hash(&args->csa_sessionid);
364 			__entry->slot_nr = args->csa_slotid;
365 			__entry->seq_nr = args->csa_sequenceid;
366 			__entry->highest_slotid = args->csa_highestslotid;
367 			__entry->cachethis = args->csa_cachethis;
368 			__entry->error = -be32_to_cpu(status);
369 		),
370 
371 		TP_printk(
372 			"error=%d (%s) session=0x%08x slot_nr=%u seq_nr=%u "
373 			"highest_slotid=%u",
374 			__entry->error,
375 			show_nfsv4_errors(__entry->error),
376 			__entry->session,
377 			__entry->slot_nr,
378 			__entry->seq_nr,
379 			__entry->highest_slotid
380 		)
381 );
382 #endif /* CONFIG_NFS_V4_1 */
383 
384 DECLARE_EVENT_CLASS(nfs4_open_event,
385 		TP_PROTO(
386 			const struct nfs_open_context *ctx,
387 			int flags,
388 			int error
389 		),
390 
391 		TP_ARGS(ctx, flags, error),
392 
393 		TP_STRUCT__entry(
394 			__field(int, error)
395 			__field(unsigned int, flags)
396 			__field(unsigned int, fmode)
397 			__field(dev_t, dev)
398 			__field(u32, fhandle)
399 			__field(u64, fileid)
400 			__field(u64, dir)
401 			__string(name, ctx->dentry->d_name.name)
402 		),
403 
404 		TP_fast_assign(
405 			const struct nfs4_state *state = ctx->state;
406 			const struct inode *inode = NULL;
407 
408 			__entry->error = error;
409 			__entry->flags = flags;
410 			__entry->fmode = (__force unsigned int)ctx->mode;
411 			__entry->dev = ctx->dentry->d_sb->s_dev;
412 			if (!IS_ERR(state))
413 				inode = state->inode;
414 			if (inode != NULL) {
415 				__entry->fileid = NFS_FILEID(inode);
416 				__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
417 			} else {
418 				__entry->fileid = 0;
419 				__entry->fhandle = 0;
420 			}
421 			__entry->dir = NFS_FILEID(d_inode(ctx->dentry->d_parent));
422 			__assign_str(name, ctx->dentry->d_name.name);
423 		),
424 
425 		TP_printk(
426 			"error=%d (%s) flags=%d (%s) fmode=%s "
427 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
428 			"name=%02x:%02x:%llu/%s",
429 			 __entry->error,
430 			 show_nfsv4_errors(__entry->error),
431 			 __entry->flags,
432 			 show_open_flags(__entry->flags),
433 			 show_fmode_flags(__entry->fmode),
434 			 MAJOR(__entry->dev), MINOR(__entry->dev),
435 			 (unsigned long long)__entry->fileid,
436 			 __entry->fhandle,
437 			 MAJOR(__entry->dev), MINOR(__entry->dev),
438 			 (unsigned long long)__entry->dir,
439 			 __get_str(name)
440 		)
441 );
442 
443 #define DEFINE_NFS4_OPEN_EVENT(name) \
444 	DEFINE_EVENT(nfs4_open_event, name, \
445 			TP_PROTO( \
446 				const struct nfs_open_context *ctx, \
447 				int flags, \
448 				int error \
449 			), \
450 			TP_ARGS(ctx, flags, error))
451 DEFINE_NFS4_OPEN_EVENT(nfs4_open_reclaim);
452 DEFINE_NFS4_OPEN_EVENT(nfs4_open_expired);
453 DEFINE_NFS4_OPEN_EVENT(nfs4_open_file);
454 
455 TRACE_EVENT(nfs4_close,
456 		TP_PROTO(
457 			const struct nfs4_state *state,
458 			const struct nfs_closeargs *args,
459 			const struct nfs_closeres *res,
460 			int error
461 		),
462 
463 		TP_ARGS(state, args, res, error),
464 
465 		TP_STRUCT__entry(
466 			__field(dev_t, dev)
467 			__field(u32, fhandle)
468 			__field(u64, fileid)
469 			__field(unsigned int, fmode)
470 			__field(int, error)
471 		),
472 
473 		TP_fast_assign(
474 			const struct inode *inode = state->inode;
475 
476 			__entry->dev = inode->i_sb->s_dev;
477 			__entry->fileid = NFS_FILEID(inode);
478 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
479 			__entry->fmode = (__force unsigned int)state->state;
480 			__entry->error = error;
481 		),
482 
483 		TP_printk(
484 			"error=%d (%s) fmode=%s fileid=%02x:%02x:%llu "
485 			"fhandle=0x%08x",
486 			__entry->error,
487 			show_nfsv4_errors(__entry->error),
488 			__entry->fmode ?  show_fmode_flags(__entry->fmode) :
489 					  "closed",
490 			MAJOR(__entry->dev), MINOR(__entry->dev),
491 			(unsigned long long)__entry->fileid,
492 			__entry->fhandle
493 		)
494 );
495 
496 #define show_lock_cmd(type) \
497 	__print_symbolic((int)type, \
498 		{ F_GETLK, "GETLK" }, \
499 		{ F_SETLK, "SETLK" }, \
500 		{ F_SETLKW, "SETLKW" })
501 #define show_lock_type(type) \
502 	__print_symbolic((int)type, \
503 		{ F_RDLCK, "RDLCK" }, \
504 		{ F_WRLCK, "WRLCK" }, \
505 		{ F_UNLCK, "UNLCK" })
506 
507 DECLARE_EVENT_CLASS(nfs4_lock_event,
508 		TP_PROTO(
509 			const struct file_lock *request,
510 			const struct nfs4_state *state,
511 			int cmd,
512 			int error
513 		),
514 
515 		TP_ARGS(request, state, cmd, error),
516 
517 		TP_STRUCT__entry(
518 			__field(int, error)
519 			__field(int, cmd)
520 			__field(char, type)
521 			__field(loff_t, start)
522 			__field(loff_t, end)
523 			__field(dev_t, dev)
524 			__field(u32, fhandle)
525 			__field(u64, fileid)
526 		),
527 
528 		TP_fast_assign(
529 			const struct inode *inode = state->inode;
530 
531 			__entry->error = error;
532 			__entry->cmd = cmd;
533 			__entry->type = request->fl_type;
534 			__entry->start = request->fl_start;
535 			__entry->end = request->fl_end;
536 			__entry->dev = inode->i_sb->s_dev;
537 			__entry->fileid = NFS_FILEID(inode);
538 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
539 		),
540 
541 		TP_printk(
542 			"error=%d (%s) cmd=%s:%s range=%lld:%lld "
543 			"fileid=%02x:%02x:%llu fhandle=0x%08x",
544 			__entry->error,
545 			show_nfsv4_errors(__entry->error),
546 			show_lock_cmd(__entry->cmd),
547 			show_lock_type(__entry->type),
548 			(long long)__entry->start,
549 			(long long)__entry->end,
550 			MAJOR(__entry->dev), MINOR(__entry->dev),
551 			(unsigned long long)__entry->fileid,
552 			__entry->fhandle
553 		)
554 );
555 
556 #define DEFINE_NFS4_LOCK_EVENT(name) \
557 	DEFINE_EVENT(nfs4_lock_event, name, \
558 			TP_PROTO( \
559 				const struct file_lock *request, \
560 				const struct nfs4_state *state, \
561 				int cmd, \
562 				int error \
563 			), \
564 			TP_ARGS(request, state, cmd, error))
565 DEFINE_NFS4_LOCK_EVENT(nfs4_get_lock);
566 DEFINE_NFS4_LOCK_EVENT(nfs4_set_lock);
567 DEFINE_NFS4_LOCK_EVENT(nfs4_lock_reclaim);
568 DEFINE_NFS4_LOCK_EVENT(nfs4_lock_expired);
569 DEFINE_NFS4_LOCK_EVENT(nfs4_unlock);
570 
571 DECLARE_EVENT_CLASS(nfs4_set_delegation_event,
572 		TP_PROTO(
573 			const struct inode *inode,
574 			fmode_t fmode
575 		),
576 
577 		TP_ARGS(inode, fmode),
578 
579 		TP_STRUCT__entry(
580 			__field(dev_t, dev)
581 			__field(u32, fhandle)
582 			__field(u64, fileid)
583 			__field(unsigned int, fmode)
584 		),
585 
586 		TP_fast_assign(
587 			__entry->dev = inode->i_sb->s_dev;
588 			__entry->fileid = NFS_FILEID(inode);
589 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
590 			__entry->fmode = (__force unsigned int)fmode;
591 		),
592 
593 		TP_printk(
594 			"fmode=%s fileid=%02x:%02x:%llu fhandle=0x%08x",
595 			show_fmode_flags(__entry->fmode),
596 			MAJOR(__entry->dev), MINOR(__entry->dev),
597 			(unsigned long long)__entry->fileid,
598 			__entry->fhandle
599 		)
600 );
601 #define DEFINE_NFS4_SET_DELEGATION_EVENT(name) \
602 	DEFINE_EVENT(nfs4_set_delegation_event, name, \
603 			TP_PROTO( \
604 				const struct inode *inode, \
605 				fmode_t fmode \
606 			), \
607 			TP_ARGS(inode, fmode))
608 DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_set_delegation);
609 DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_reclaim_delegation);
610 
611 TRACE_EVENT(nfs4_delegreturn_exit,
612 		TP_PROTO(
613 			const struct nfs4_delegreturnargs *args,
614 			const struct nfs4_delegreturnres *res,
615 			int error
616 		),
617 
618 		TP_ARGS(args, res, error),
619 
620 		TP_STRUCT__entry(
621 			__field(dev_t, dev)
622 			__field(u32, fhandle)
623 			__field(int, error)
624 		),
625 
626 		TP_fast_assign(
627 			__entry->dev = res->server->s_dev;
628 			__entry->fhandle = nfs_fhandle_hash(args->fhandle);
629 			__entry->error = error;
630 		),
631 
632 		TP_printk(
633 			"error=%d (%s) dev=%02x:%02x fhandle=0x%08x",
634 			__entry->error,
635 			show_nfsv4_errors(__entry->error),
636 			MAJOR(__entry->dev), MINOR(__entry->dev),
637 			__entry->fhandle
638 		)
639 );
640 
641 #ifdef CONFIG_NFS_V4_1
642 DECLARE_EVENT_CLASS(nfs4_test_stateid_event,
643 		TP_PROTO(
644 			const struct nfs4_state *state,
645 			const struct nfs4_lock_state *lsp,
646 			int error
647 		),
648 
649 		TP_ARGS(state, lsp, error),
650 
651 		TP_STRUCT__entry(
652 			__field(int, error)
653 			__field(dev_t, dev)
654 			__field(u32, fhandle)
655 			__field(u64, fileid)
656 		),
657 
658 		TP_fast_assign(
659 			const struct inode *inode = state->inode;
660 
661 			__entry->error = error;
662 			__entry->dev = inode->i_sb->s_dev;
663 			__entry->fileid = NFS_FILEID(inode);
664 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
665 		),
666 
667 		TP_printk(
668 			"error=%d (%s) fileid=%02x:%02x:%llu fhandle=0x%08x",
669 			__entry->error,
670 			show_nfsv4_errors(__entry->error),
671 			MAJOR(__entry->dev), MINOR(__entry->dev),
672 			(unsigned long long)__entry->fileid,
673 			__entry->fhandle
674 		)
675 );
676 
677 #define DEFINE_NFS4_TEST_STATEID_EVENT(name) \
678 	DEFINE_EVENT(nfs4_test_stateid_event, name, \
679 			TP_PROTO( \
680 				const struct nfs4_state *state, \
681 				const struct nfs4_lock_state *lsp, \
682 				int error \
683 			), \
684 			TP_ARGS(state, lsp, error))
685 DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_delegation_stateid);
686 DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_open_stateid);
687 DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_lock_stateid);
688 #endif /* CONFIG_NFS_V4_1 */
689 
690 DECLARE_EVENT_CLASS(nfs4_lookup_event,
691 		TP_PROTO(
692 			const struct inode *dir,
693 			const struct qstr *name,
694 			int error
695 		),
696 
697 		TP_ARGS(dir, name, error),
698 
699 		TP_STRUCT__entry(
700 			__field(dev_t, dev)
701 			__field(int, error)
702 			__field(u64, dir)
703 			__string(name, name->name)
704 		),
705 
706 		TP_fast_assign(
707 			__entry->dev = dir->i_sb->s_dev;
708 			__entry->dir = NFS_FILEID(dir);
709 			__entry->error = error;
710 			__assign_str(name, name->name);
711 		),
712 
713 		TP_printk(
714 			"error=%d (%s) name=%02x:%02x:%llu/%s",
715 			__entry->error,
716 			show_nfsv4_errors(__entry->error),
717 			MAJOR(__entry->dev), MINOR(__entry->dev),
718 			(unsigned long long)__entry->dir,
719 			__get_str(name)
720 		)
721 );
722 
723 #define DEFINE_NFS4_LOOKUP_EVENT(name) \
724 	DEFINE_EVENT(nfs4_lookup_event, name, \
725 			TP_PROTO( \
726 				const struct inode *dir, \
727 				const struct qstr *name, \
728 				int error \
729 			), \
730 			TP_ARGS(dir, name, error))
731 
732 DEFINE_NFS4_LOOKUP_EVENT(nfs4_lookup);
733 DEFINE_NFS4_LOOKUP_EVENT(nfs4_symlink);
734 DEFINE_NFS4_LOOKUP_EVENT(nfs4_mkdir);
735 DEFINE_NFS4_LOOKUP_EVENT(nfs4_mknod);
736 DEFINE_NFS4_LOOKUP_EVENT(nfs4_remove);
737 DEFINE_NFS4_LOOKUP_EVENT(nfs4_get_fs_locations);
738 DEFINE_NFS4_LOOKUP_EVENT(nfs4_secinfo);
739 
740 TRACE_EVENT(nfs4_rename,
741 		TP_PROTO(
742 			const struct inode *olddir,
743 			const struct qstr *oldname,
744 			const struct inode *newdir,
745 			const struct qstr *newname,
746 			int error
747 		),
748 
749 		TP_ARGS(olddir, oldname, newdir, newname, error),
750 
751 		TP_STRUCT__entry(
752 			__field(dev_t, dev)
753 			__field(int, error)
754 			__field(u64, olddir)
755 			__string(oldname, oldname->name)
756 			__field(u64, newdir)
757 			__string(newname, newname->name)
758 		),
759 
760 		TP_fast_assign(
761 			__entry->dev = olddir->i_sb->s_dev;
762 			__entry->olddir = NFS_FILEID(olddir);
763 			__entry->newdir = NFS_FILEID(newdir);
764 			__entry->error = error;
765 			__assign_str(oldname, oldname->name);
766 			__assign_str(newname, newname->name);
767 		),
768 
769 		TP_printk(
770 			"error=%d (%s) oldname=%02x:%02x:%llu/%s "
771 			"newname=%02x:%02x:%llu/%s",
772 			__entry->error,
773 			show_nfsv4_errors(__entry->error),
774 			MAJOR(__entry->dev), MINOR(__entry->dev),
775 			(unsigned long long)__entry->olddir,
776 			__get_str(oldname),
777 			MAJOR(__entry->dev), MINOR(__entry->dev),
778 			(unsigned long long)__entry->newdir,
779 			__get_str(newname)
780 		)
781 );
782 
783 DECLARE_EVENT_CLASS(nfs4_inode_event,
784 		TP_PROTO(
785 			const struct inode *inode,
786 			int error
787 		),
788 
789 		TP_ARGS(inode, error),
790 
791 		TP_STRUCT__entry(
792 			__field(dev_t, dev)
793 			__field(u32, fhandle)
794 			__field(u64, fileid)
795 			__field(int, error)
796 		),
797 
798 		TP_fast_assign(
799 			__entry->dev = inode->i_sb->s_dev;
800 			__entry->fileid = NFS_FILEID(inode);
801 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
802 			__entry->error = error;
803 		),
804 
805 		TP_printk(
806 			"error=%d (%s) fileid=%02x:%02x:%llu fhandle=0x%08x",
807 			__entry->error,
808 			show_nfsv4_errors(__entry->error),
809 			MAJOR(__entry->dev), MINOR(__entry->dev),
810 			(unsigned long long)__entry->fileid,
811 			__entry->fhandle
812 		)
813 );
814 
815 #define DEFINE_NFS4_INODE_EVENT(name) \
816 	DEFINE_EVENT(nfs4_inode_event, name, \
817 			TP_PROTO( \
818 				const struct inode *inode, \
819 				int error \
820 			), \
821 			TP_ARGS(inode, error))
822 
823 DEFINE_NFS4_INODE_EVENT(nfs4_setattr);
824 DEFINE_NFS4_INODE_EVENT(nfs4_access);
825 DEFINE_NFS4_INODE_EVENT(nfs4_readlink);
826 DEFINE_NFS4_INODE_EVENT(nfs4_readdir);
827 DEFINE_NFS4_INODE_EVENT(nfs4_get_acl);
828 DEFINE_NFS4_INODE_EVENT(nfs4_set_acl);
829 #ifdef CONFIG_NFS_V4_SECURITY_LABEL
830 DEFINE_NFS4_INODE_EVENT(nfs4_get_security_label);
831 DEFINE_NFS4_INODE_EVENT(nfs4_set_security_label);
832 #endif /* CONFIG_NFS_V4_SECURITY_LABEL */
833 DEFINE_NFS4_INODE_EVENT(nfs4_recall_delegation);
834 DEFINE_NFS4_INODE_EVENT(nfs4_delegreturn);
835 
836 DECLARE_EVENT_CLASS(nfs4_getattr_event,
837 		TP_PROTO(
838 			const struct nfs_server *server,
839 			const struct nfs_fh *fhandle,
840 			const struct nfs_fattr *fattr,
841 			int error
842 		),
843 
844 		TP_ARGS(server, fhandle, fattr, error),
845 
846 		TP_STRUCT__entry(
847 			__field(dev_t, dev)
848 			__field(u32, fhandle)
849 			__field(u64, fileid)
850 			__field(unsigned int, valid)
851 			__field(int, error)
852 		),
853 
854 		TP_fast_assign(
855 			__entry->dev = server->s_dev;
856 			__entry->valid = fattr->valid;
857 			__entry->fhandle = nfs_fhandle_hash(fhandle);
858 			__entry->fileid = (fattr->valid & NFS_ATTR_FATTR_FILEID) ? fattr->fileid : 0;
859 			__entry->error = error;
860 		),
861 
862 		TP_printk(
863 			"error=%d (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
864 			"valid=%s",
865 			__entry->error,
866 			show_nfsv4_errors(__entry->error),
867 			MAJOR(__entry->dev), MINOR(__entry->dev),
868 			(unsigned long long)__entry->fileid,
869 			__entry->fhandle,
870 			show_nfs_fattr_flags(__entry->valid)
871 		)
872 );
873 
874 #define DEFINE_NFS4_GETATTR_EVENT(name) \
875 	DEFINE_EVENT(nfs4_getattr_event, name, \
876 			TP_PROTO( \
877 				const struct nfs_server *server, \
878 				const struct nfs_fh *fhandle, \
879 				const struct nfs_fattr *fattr, \
880 				int error \
881 			), \
882 			TP_ARGS(server, fhandle, fattr, error))
883 DEFINE_NFS4_GETATTR_EVENT(nfs4_getattr);
884 DEFINE_NFS4_GETATTR_EVENT(nfs4_lookup_root);
885 DEFINE_NFS4_GETATTR_EVENT(nfs4_fsinfo);
886 
887 DECLARE_EVENT_CLASS(nfs4_inode_callback_event,
888 		TP_PROTO(
889 			const struct nfs_client *clp,
890 			const struct nfs_fh *fhandle,
891 			const struct inode *inode,
892 			int error
893 		),
894 
895 		TP_ARGS(clp, fhandle, inode, error),
896 
897 		TP_STRUCT__entry(
898 			__field(int, error)
899 			__field(dev_t, dev)
900 			__field(u32, fhandle)
901 			__field(u64, fileid)
902 			__string(dstaddr, clp ?
903 				rpc_peeraddr2str(clp->cl_rpcclient,
904 					RPC_DISPLAY_ADDR) : "unknown")
905 		),
906 
907 		TP_fast_assign(
908 			__entry->error = error;
909 			__entry->fhandle = nfs_fhandle_hash(fhandle);
910 			if (inode != NULL) {
911 				__entry->fileid = NFS_FILEID(inode);
912 				__entry->dev = inode->i_sb->s_dev;
913 			} else {
914 				__entry->fileid = 0;
915 				__entry->dev = 0;
916 			}
917 			__assign_str(dstaddr, clp ?
918 				rpc_peeraddr2str(clp->cl_rpcclient,
919 					RPC_DISPLAY_ADDR) : "unknown")
920 		),
921 
922 		TP_printk(
923 			"error=%d (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
924 			"dstaddr=%s",
925 			__entry->error,
926 			show_nfsv4_errors(__entry->error),
927 			MAJOR(__entry->dev), MINOR(__entry->dev),
928 			(unsigned long long)__entry->fileid,
929 			__entry->fhandle,
930 			__get_str(dstaddr)
931 		)
932 );
933 
934 #define DEFINE_NFS4_INODE_CALLBACK_EVENT(name) \
935 	DEFINE_EVENT(nfs4_inode_callback_event, name, \
936 			TP_PROTO( \
937 				const struct nfs_client *clp, \
938 				const struct nfs_fh *fhandle, \
939 				const struct inode *inode, \
940 				int error \
941 			), \
942 			TP_ARGS(clp, fhandle, inode, error))
943 DEFINE_NFS4_INODE_CALLBACK_EVENT(nfs4_cb_getattr);
944 DEFINE_NFS4_INODE_CALLBACK_EVENT(nfs4_cb_layoutrecall_inode);
945 
946 
947 DECLARE_EVENT_CLASS(nfs4_idmap_event,
948 		TP_PROTO(
949 			const char *name,
950 			int len,
951 			u32 id,
952 			int error
953 		),
954 
955 		TP_ARGS(name, len, id, error),
956 
957 		TP_STRUCT__entry(
958 			__field(int, error)
959 			__field(u32, id)
960 			__dynamic_array(char, name, len > 0 ? len + 1 : 1)
961 		),
962 
963 		TP_fast_assign(
964 			if (len < 0)
965 				len = 0;
966 			__entry->error = error < 0 ? error : 0;
967 			__entry->id = id;
968 			memcpy(__get_dynamic_array(name), name, len);
969 			((char *)__get_dynamic_array(name))[len] = 0;
970 		),
971 
972 		TP_printk(
973 			"error=%d id=%u name=%s",
974 			__entry->error,
975 			__entry->id,
976 			__get_str(name)
977 		)
978 );
979 #define DEFINE_NFS4_IDMAP_EVENT(name) \
980 	DEFINE_EVENT(nfs4_idmap_event, name, \
981 			TP_PROTO( \
982 				const char *name, \
983 				int len, \
984 				u32 id, \
985 				int error \
986 			), \
987 			TP_ARGS(name, len, id, error))
988 DEFINE_NFS4_IDMAP_EVENT(nfs4_map_name_to_uid);
989 DEFINE_NFS4_IDMAP_EVENT(nfs4_map_group_to_gid);
990 DEFINE_NFS4_IDMAP_EVENT(nfs4_map_uid_to_name);
991 DEFINE_NFS4_IDMAP_EVENT(nfs4_map_gid_to_group);
992 
993 DECLARE_EVENT_CLASS(nfs4_read_event,
994 		TP_PROTO(
995 			const struct nfs_pgio_header *hdr,
996 			int error
997 		),
998 
999 		TP_ARGS(hdr, error),
1000 
1001 		TP_STRUCT__entry(
1002 			__field(dev_t, dev)
1003 			__field(u32, fhandle)
1004 			__field(u64, fileid)
1005 			__field(loff_t, offset)
1006 			__field(size_t, count)
1007 			__field(int, error)
1008 		),
1009 
1010 		TP_fast_assign(
1011 			const struct inode *inode = hdr->inode;
1012 			__entry->dev = inode->i_sb->s_dev;
1013 			__entry->fileid = NFS_FILEID(inode);
1014 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1015 			__entry->offset = hdr->args.offset;
1016 			__entry->count = hdr->args.count;
1017 			__entry->error = error;
1018 		),
1019 
1020 		TP_printk(
1021 			"error=%d (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1022 			"offset=%lld count=%zu",
1023 			__entry->error,
1024 			show_nfsv4_errors(__entry->error),
1025 			MAJOR(__entry->dev), MINOR(__entry->dev),
1026 			(unsigned long long)__entry->fileid,
1027 			__entry->fhandle,
1028 			(long long)__entry->offset,
1029 			__entry->count
1030 		)
1031 );
1032 #define DEFINE_NFS4_READ_EVENT(name) \
1033 	DEFINE_EVENT(nfs4_read_event, name, \
1034 			TP_PROTO( \
1035 				const struct nfs_pgio_header *hdr, \
1036 				int error \
1037 			), \
1038 			TP_ARGS(hdr, error))
1039 DEFINE_NFS4_READ_EVENT(nfs4_read);
1040 #ifdef CONFIG_NFS_V4_1
1041 DEFINE_NFS4_READ_EVENT(nfs4_pnfs_read);
1042 #endif /* CONFIG_NFS_V4_1 */
1043 
1044 DECLARE_EVENT_CLASS(nfs4_write_event,
1045 		TP_PROTO(
1046 			const struct nfs_pgio_header *hdr,
1047 			int error
1048 		),
1049 
1050 		TP_ARGS(hdr, error),
1051 
1052 		TP_STRUCT__entry(
1053 			__field(dev_t, dev)
1054 			__field(u32, fhandle)
1055 			__field(u64, fileid)
1056 			__field(loff_t, offset)
1057 			__field(size_t, count)
1058 			__field(int, error)
1059 		),
1060 
1061 		TP_fast_assign(
1062 			const struct inode *inode = hdr->inode;
1063 			__entry->dev = inode->i_sb->s_dev;
1064 			__entry->fileid = NFS_FILEID(inode);
1065 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1066 			__entry->offset = hdr->args.offset;
1067 			__entry->count = hdr->args.count;
1068 			__entry->error = error;
1069 		),
1070 
1071 		TP_printk(
1072 			"error=%d (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1073 			"offset=%lld count=%zu",
1074 			__entry->error,
1075 			show_nfsv4_errors(__entry->error),
1076 			MAJOR(__entry->dev), MINOR(__entry->dev),
1077 			(unsigned long long)__entry->fileid,
1078 			__entry->fhandle,
1079 			(long long)__entry->offset,
1080 			__entry->count
1081 		)
1082 );
1083 
1084 #define DEFINE_NFS4_WRITE_EVENT(name) \
1085 	DEFINE_EVENT(nfs4_write_event, name, \
1086 			TP_PROTO( \
1087 				const struct nfs_pgio_header *hdr, \
1088 				int error \
1089 			), \
1090 			TP_ARGS(hdr, error))
1091 DEFINE_NFS4_WRITE_EVENT(nfs4_write);
1092 #ifdef CONFIG_NFS_V4_1
1093 DEFINE_NFS4_WRITE_EVENT(nfs4_pnfs_write);
1094 #endif /* CONFIG_NFS_V4_1 */
1095 
1096 DECLARE_EVENT_CLASS(nfs4_commit_event,
1097 		TP_PROTO(
1098 			const struct nfs_commit_data *data,
1099 			int error
1100 		),
1101 
1102 		TP_ARGS(data, error),
1103 
1104 		TP_STRUCT__entry(
1105 			__field(dev_t, dev)
1106 			__field(u32, fhandle)
1107 			__field(u64, fileid)
1108 			__field(loff_t, offset)
1109 			__field(size_t, count)
1110 			__field(int, error)
1111 		),
1112 
1113 		TP_fast_assign(
1114 			const struct inode *inode = data->inode;
1115 			__entry->dev = inode->i_sb->s_dev;
1116 			__entry->fileid = NFS_FILEID(inode);
1117 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1118 			__entry->offset = data->args.offset;
1119 			__entry->count = data->args.count;
1120 			__entry->error = error;
1121 		),
1122 
1123 		TP_printk(
1124 			"error=%d (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1125 			"offset=%lld count=%zu",
1126 			__entry->error,
1127 			show_nfsv4_errors(__entry->error),
1128 			MAJOR(__entry->dev), MINOR(__entry->dev),
1129 			(unsigned long long)__entry->fileid,
1130 			__entry->fhandle,
1131 			(long long)__entry->offset,
1132 			__entry->count
1133 		)
1134 );
1135 #define DEFINE_NFS4_COMMIT_EVENT(name) \
1136 	DEFINE_EVENT(nfs4_commit_event, name, \
1137 			TP_PROTO( \
1138 				const struct nfs_commit_data *data, \
1139 				int error \
1140 			), \
1141 			TP_ARGS(data, error))
1142 DEFINE_NFS4_COMMIT_EVENT(nfs4_commit);
1143 #ifdef CONFIG_NFS_V4_1
1144 DEFINE_NFS4_COMMIT_EVENT(nfs4_pnfs_commit_ds);
1145 
1146 #define show_pnfs_iomode(iomode) \
1147 	__print_symbolic(iomode, \
1148 		{ IOMODE_READ, "READ" }, \
1149 		{ IOMODE_RW, "RW" }, \
1150 		{ IOMODE_ANY, "ANY" })
1151 
1152 TRACE_EVENT(nfs4_layoutget,
1153 		TP_PROTO(
1154 			const struct nfs_open_context *ctx,
1155 			const struct pnfs_layout_range *args,
1156 			const struct pnfs_layout_range *res,
1157 			int error
1158 		),
1159 
1160 		TP_ARGS(ctx, args, res, error),
1161 
1162 		TP_STRUCT__entry(
1163 			__field(dev_t, dev)
1164 			__field(u32, fhandle)
1165 			__field(u64, fileid)
1166 			__field(u32, iomode)
1167 			__field(u64, offset)
1168 			__field(u64, count)
1169 			__field(int, error)
1170 		),
1171 
1172 		TP_fast_assign(
1173 			const struct inode *inode = d_inode(ctx->dentry);
1174 			__entry->dev = inode->i_sb->s_dev;
1175 			__entry->fileid = NFS_FILEID(inode);
1176 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1177 			__entry->iomode = args->iomode;
1178 			__entry->offset = args->offset;
1179 			__entry->count = args->length;
1180 			__entry->error = error;
1181 		),
1182 
1183 		TP_printk(
1184 			"error=%d (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1185 			"iomode=%s offset=%llu count=%llu",
1186 			__entry->error,
1187 			show_nfsv4_errors(__entry->error),
1188 			MAJOR(__entry->dev), MINOR(__entry->dev),
1189 			(unsigned long long)__entry->fileid,
1190 			__entry->fhandle,
1191 			show_pnfs_iomode(__entry->iomode),
1192 			(unsigned long long)__entry->offset,
1193 			(unsigned long long)__entry->count
1194 		)
1195 );
1196 
1197 DEFINE_NFS4_INODE_EVENT(nfs4_layoutcommit);
1198 DEFINE_NFS4_INODE_EVENT(nfs4_layoutreturn);
1199 DEFINE_NFS4_INODE_EVENT(nfs4_layoutreturn_on_close);
1200 
1201 #endif /* CONFIG_NFS_V4_1 */
1202 
1203 #endif /* _TRACE_NFS4_H */
1204 
1205 #undef TRACE_INCLUDE_PATH
1206 #define TRACE_INCLUDE_PATH .
1207 #define TRACE_INCLUDE_FILE nfs4trace
1208 /* This part must be outside protection */
1209 #include <trace/define_trace.h>
1210