xref: /linux/fs/nfs/nfs4trace.h (revision 4eb7ae7a301d3586c3351e81d5c3cfe2304a1a6a)
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 
13 TRACE_DEFINE_ENUM(EPERM);
14 TRACE_DEFINE_ENUM(ENOENT);
15 TRACE_DEFINE_ENUM(EIO);
16 TRACE_DEFINE_ENUM(ENXIO);
17 TRACE_DEFINE_ENUM(EACCES);
18 TRACE_DEFINE_ENUM(EEXIST);
19 TRACE_DEFINE_ENUM(EXDEV);
20 TRACE_DEFINE_ENUM(ENOTDIR);
21 TRACE_DEFINE_ENUM(EISDIR);
22 TRACE_DEFINE_ENUM(EFBIG);
23 TRACE_DEFINE_ENUM(ENOSPC);
24 TRACE_DEFINE_ENUM(EROFS);
25 TRACE_DEFINE_ENUM(EMLINK);
26 TRACE_DEFINE_ENUM(ENAMETOOLONG);
27 TRACE_DEFINE_ENUM(ENOTEMPTY);
28 TRACE_DEFINE_ENUM(EDQUOT);
29 TRACE_DEFINE_ENUM(ESTALE);
30 TRACE_DEFINE_ENUM(EBADHANDLE);
31 TRACE_DEFINE_ENUM(EBADCOOKIE);
32 TRACE_DEFINE_ENUM(ENOTSUPP);
33 TRACE_DEFINE_ENUM(ETOOSMALL);
34 TRACE_DEFINE_ENUM(EREMOTEIO);
35 TRACE_DEFINE_ENUM(EBADTYPE);
36 TRACE_DEFINE_ENUM(EAGAIN);
37 TRACE_DEFINE_ENUM(ELOOP);
38 TRACE_DEFINE_ENUM(EOPNOTSUPP);
39 TRACE_DEFINE_ENUM(EDEADLK);
40 TRACE_DEFINE_ENUM(ENOMEM);
41 TRACE_DEFINE_ENUM(EKEYEXPIRED);
42 TRACE_DEFINE_ENUM(ETIMEDOUT);
43 TRACE_DEFINE_ENUM(ERESTARTSYS);
44 TRACE_DEFINE_ENUM(ECONNREFUSED);
45 TRACE_DEFINE_ENUM(ECONNRESET);
46 TRACE_DEFINE_ENUM(ENETUNREACH);
47 TRACE_DEFINE_ENUM(EHOSTUNREACH);
48 TRACE_DEFINE_ENUM(EHOSTDOWN);
49 TRACE_DEFINE_ENUM(EPIPE);
50 TRACE_DEFINE_ENUM(EPFNOSUPPORT);
51 TRACE_DEFINE_ENUM(EPROTONOSUPPORT);
52 
53 TRACE_DEFINE_ENUM(NFS4_OK);
54 TRACE_DEFINE_ENUM(NFS4ERR_ACCESS);
55 TRACE_DEFINE_ENUM(NFS4ERR_ATTRNOTSUPP);
56 TRACE_DEFINE_ENUM(NFS4ERR_ADMIN_REVOKED);
57 TRACE_DEFINE_ENUM(NFS4ERR_BACK_CHAN_BUSY);
58 TRACE_DEFINE_ENUM(NFS4ERR_BADCHAR);
59 TRACE_DEFINE_ENUM(NFS4ERR_BADHANDLE);
60 TRACE_DEFINE_ENUM(NFS4ERR_BADIOMODE);
61 TRACE_DEFINE_ENUM(NFS4ERR_BADLAYOUT);
62 TRACE_DEFINE_ENUM(NFS4ERR_BADLABEL);
63 TRACE_DEFINE_ENUM(NFS4ERR_BADNAME);
64 TRACE_DEFINE_ENUM(NFS4ERR_BADOWNER);
65 TRACE_DEFINE_ENUM(NFS4ERR_BADSESSION);
66 TRACE_DEFINE_ENUM(NFS4ERR_BADSLOT);
67 TRACE_DEFINE_ENUM(NFS4ERR_BADTYPE);
68 TRACE_DEFINE_ENUM(NFS4ERR_BADXDR);
69 TRACE_DEFINE_ENUM(NFS4ERR_BAD_COOKIE);
70 TRACE_DEFINE_ENUM(NFS4ERR_BAD_HIGH_SLOT);
71 TRACE_DEFINE_ENUM(NFS4ERR_BAD_RANGE);
72 TRACE_DEFINE_ENUM(NFS4ERR_BAD_SEQID);
73 TRACE_DEFINE_ENUM(NFS4ERR_BAD_SESSION_DIGEST);
74 TRACE_DEFINE_ENUM(NFS4ERR_BAD_STATEID);
75 TRACE_DEFINE_ENUM(NFS4ERR_CB_PATH_DOWN);
76 TRACE_DEFINE_ENUM(NFS4ERR_CLID_INUSE);
77 TRACE_DEFINE_ENUM(NFS4ERR_CLIENTID_BUSY);
78 TRACE_DEFINE_ENUM(NFS4ERR_COMPLETE_ALREADY);
79 TRACE_DEFINE_ENUM(NFS4ERR_CONN_NOT_BOUND_TO_SESSION);
80 TRACE_DEFINE_ENUM(NFS4ERR_DEADLOCK);
81 TRACE_DEFINE_ENUM(NFS4ERR_DEADSESSION);
82 TRACE_DEFINE_ENUM(NFS4ERR_DELAY);
83 TRACE_DEFINE_ENUM(NFS4ERR_DELEG_ALREADY_WANTED);
84 TRACE_DEFINE_ENUM(NFS4ERR_DELEG_REVOKED);
85 TRACE_DEFINE_ENUM(NFS4ERR_DENIED);
86 TRACE_DEFINE_ENUM(NFS4ERR_DIRDELEG_UNAVAIL);
87 TRACE_DEFINE_ENUM(NFS4ERR_DQUOT);
88 TRACE_DEFINE_ENUM(NFS4ERR_ENCR_ALG_UNSUPP);
89 TRACE_DEFINE_ENUM(NFS4ERR_EXIST);
90 TRACE_DEFINE_ENUM(NFS4ERR_EXPIRED);
91 TRACE_DEFINE_ENUM(NFS4ERR_FBIG);
92 TRACE_DEFINE_ENUM(NFS4ERR_FHEXPIRED);
93 TRACE_DEFINE_ENUM(NFS4ERR_FILE_OPEN);
94 TRACE_DEFINE_ENUM(NFS4ERR_GRACE);
95 TRACE_DEFINE_ENUM(NFS4ERR_HASH_ALG_UNSUPP);
96 TRACE_DEFINE_ENUM(NFS4ERR_INVAL);
97 TRACE_DEFINE_ENUM(NFS4ERR_IO);
98 TRACE_DEFINE_ENUM(NFS4ERR_ISDIR);
99 TRACE_DEFINE_ENUM(NFS4ERR_LAYOUTTRYLATER);
100 TRACE_DEFINE_ENUM(NFS4ERR_LAYOUTUNAVAILABLE);
101 TRACE_DEFINE_ENUM(NFS4ERR_LEASE_MOVED);
102 TRACE_DEFINE_ENUM(NFS4ERR_LOCKED);
103 TRACE_DEFINE_ENUM(NFS4ERR_LOCKS_HELD);
104 TRACE_DEFINE_ENUM(NFS4ERR_LOCK_RANGE);
105 TRACE_DEFINE_ENUM(NFS4ERR_MINOR_VERS_MISMATCH);
106 TRACE_DEFINE_ENUM(NFS4ERR_MLINK);
107 TRACE_DEFINE_ENUM(NFS4ERR_MOVED);
108 TRACE_DEFINE_ENUM(NFS4ERR_NAMETOOLONG);
109 TRACE_DEFINE_ENUM(NFS4ERR_NOENT);
110 TRACE_DEFINE_ENUM(NFS4ERR_NOFILEHANDLE);
111 TRACE_DEFINE_ENUM(NFS4ERR_NOMATCHING_LAYOUT);
112 TRACE_DEFINE_ENUM(NFS4ERR_NOSPC);
113 TRACE_DEFINE_ENUM(NFS4ERR_NOTDIR);
114 TRACE_DEFINE_ENUM(NFS4ERR_NOTEMPTY);
115 TRACE_DEFINE_ENUM(NFS4ERR_NOTSUPP);
116 TRACE_DEFINE_ENUM(NFS4ERR_NOT_ONLY_OP);
117 TRACE_DEFINE_ENUM(NFS4ERR_NOT_SAME);
118 TRACE_DEFINE_ENUM(NFS4ERR_NO_GRACE);
119 TRACE_DEFINE_ENUM(NFS4ERR_NXIO);
120 TRACE_DEFINE_ENUM(NFS4ERR_OLD_STATEID);
121 TRACE_DEFINE_ENUM(NFS4ERR_OPENMODE);
122 TRACE_DEFINE_ENUM(NFS4ERR_OP_ILLEGAL);
123 TRACE_DEFINE_ENUM(NFS4ERR_OP_NOT_IN_SESSION);
124 TRACE_DEFINE_ENUM(NFS4ERR_PERM);
125 TRACE_DEFINE_ENUM(NFS4ERR_PNFS_IO_HOLE);
126 TRACE_DEFINE_ENUM(NFS4ERR_PNFS_NO_LAYOUT);
127 TRACE_DEFINE_ENUM(NFS4ERR_RECALLCONFLICT);
128 TRACE_DEFINE_ENUM(NFS4ERR_RECLAIM_BAD);
129 TRACE_DEFINE_ENUM(NFS4ERR_RECLAIM_CONFLICT);
130 TRACE_DEFINE_ENUM(NFS4ERR_REJECT_DELEG);
131 TRACE_DEFINE_ENUM(NFS4ERR_REP_TOO_BIG);
132 TRACE_DEFINE_ENUM(NFS4ERR_REP_TOO_BIG_TO_CACHE);
133 TRACE_DEFINE_ENUM(NFS4ERR_REQ_TOO_BIG);
134 TRACE_DEFINE_ENUM(NFS4ERR_RESOURCE);
135 TRACE_DEFINE_ENUM(NFS4ERR_RESTOREFH);
136 TRACE_DEFINE_ENUM(NFS4ERR_RETRY_UNCACHED_REP);
137 TRACE_DEFINE_ENUM(NFS4ERR_RETURNCONFLICT);
138 TRACE_DEFINE_ENUM(NFS4ERR_ROFS);
139 TRACE_DEFINE_ENUM(NFS4ERR_SAME);
140 TRACE_DEFINE_ENUM(NFS4ERR_SHARE_DENIED);
141 TRACE_DEFINE_ENUM(NFS4ERR_SEQUENCE_POS);
142 TRACE_DEFINE_ENUM(NFS4ERR_SEQ_FALSE_RETRY);
143 TRACE_DEFINE_ENUM(NFS4ERR_SEQ_MISORDERED);
144 TRACE_DEFINE_ENUM(NFS4ERR_SERVERFAULT);
145 TRACE_DEFINE_ENUM(NFS4ERR_STALE);
146 TRACE_DEFINE_ENUM(NFS4ERR_STALE_CLIENTID);
147 TRACE_DEFINE_ENUM(NFS4ERR_STALE_STATEID);
148 TRACE_DEFINE_ENUM(NFS4ERR_SYMLINK);
149 TRACE_DEFINE_ENUM(NFS4ERR_TOOSMALL);
150 TRACE_DEFINE_ENUM(NFS4ERR_TOO_MANY_OPS);
151 TRACE_DEFINE_ENUM(NFS4ERR_UNKNOWN_LAYOUTTYPE);
152 TRACE_DEFINE_ENUM(NFS4ERR_UNSAFE_COMPOUND);
153 TRACE_DEFINE_ENUM(NFS4ERR_WRONGSEC);
154 TRACE_DEFINE_ENUM(NFS4ERR_WRONG_CRED);
155 TRACE_DEFINE_ENUM(NFS4ERR_WRONG_TYPE);
156 TRACE_DEFINE_ENUM(NFS4ERR_XDEV);
157 
158 #define show_nfsv4_errors(error) \
159 	__print_symbolic(error, \
160 		{ NFS4_OK, "OK" }, \
161 		/* Mapped by nfs4_stat_to_errno() */ \
162 		{ EPERM, "EPERM" }, \
163 		{ ENOENT, "ENOENT" }, \
164 		{ EIO, "EIO" }, \
165 		{ ENXIO, "ENXIO" }, \
166 		{ EACCES, "EACCES" }, \
167 		{ EEXIST, "EEXIST" }, \
168 		{ EXDEV, "EXDEV" }, \
169 		{ ENOTDIR, "ENOTDIR" }, \
170 		{ EISDIR, "EISDIR" }, \
171 		{ EFBIG, "EFBIG" }, \
172 		{ ENOSPC, "ENOSPC" }, \
173 		{ EROFS, "EROFS" }, \
174 		{ EMLINK, "EMLINK" }, \
175 		{ ENAMETOOLONG, "ENAMETOOLONG" }, \
176 		{ ENOTEMPTY, "ENOTEMPTY" }, \
177 		{ EDQUOT, "EDQUOT" }, \
178 		{ ESTALE, "ESTALE" }, \
179 		{ EBADHANDLE, "EBADHANDLE" }, \
180 		{ EBADCOOKIE, "EBADCOOKIE" }, \
181 		{ ENOTSUPP, "ENOTSUPP" }, \
182 		{ ETOOSMALL, "ETOOSMALL" }, \
183 		{ EREMOTEIO, "EREMOTEIO" }, \
184 		{ EBADTYPE, "EBADTYPE" }, \
185 		{ EAGAIN, "EAGAIN" }, \
186 		{ ELOOP, "ELOOP" }, \
187 		{ EOPNOTSUPP, "EOPNOTSUPP" }, \
188 		{ EDEADLK, "EDEADLK" }, \
189 		/* RPC errors */ \
190 		{ ENOMEM, "ENOMEM" }, \
191 		{ EKEYEXPIRED, "EKEYEXPIRED" }, \
192 		{ ETIMEDOUT, "ETIMEDOUT" }, \
193 		{ ERESTARTSYS, "ERESTARTSYS" }, \
194 		{ ECONNREFUSED, "ECONNREFUSED" }, \
195 		{ ECONNRESET, "ECONNRESET" }, \
196 		{ ENETUNREACH, "ENETUNREACH" }, \
197 		{ EHOSTUNREACH, "EHOSTUNREACH" }, \
198 		{ EHOSTDOWN, "EHOSTDOWN" }, \
199 		{ EPIPE, "EPIPE" }, \
200 		{ EPFNOSUPPORT, "EPFNOSUPPORT" }, \
201 		{ EPROTONOSUPPORT, "EPROTONOSUPPORT" }, \
202 		/* NFSv4 native errors */ \
203 		{ NFS4ERR_ACCESS, "ACCESS" }, \
204 		{ NFS4ERR_ATTRNOTSUPP, "ATTRNOTSUPP" }, \
205 		{ NFS4ERR_ADMIN_REVOKED, "ADMIN_REVOKED" }, \
206 		{ NFS4ERR_BACK_CHAN_BUSY, "BACK_CHAN_BUSY" }, \
207 		{ NFS4ERR_BADCHAR, "BADCHAR" }, \
208 		{ NFS4ERR_BADHANDLE, "BADHANDLE" }, \
209 		{ NFS4ERR_BADIOMODE, "BADIOMODE" }, \
210 		{ NFS4ERR_BADLAYOUT, "BADLAYOUT" }, \
211 		{ NFS4ERR_BADLABEL, "BADLABEL" }, \
212 		{ NFS4ERR_BADNAME, "BADNAME" }, \
213 		{ NFS4ERR_BADOWNER, "BADOWNER" }, \
214 		{ NFS4ERR_BADSESSION, "BADSESSION" }, \
215 		{ NFS4ERR_BADSLOT, "BADSLOT" }, \
216 		{ NFS4ERR_BADTYPE, "BADTYPE" }, \
217 		{ NFS4ERR_BADXDR, "BADXDR" }, \
218 		{ NFS4ERR_BAD_COOKIE, "BAD_COOKIE" }, \
219 		{ NFS4ERR_BAD_HIGH_SLOT, "BAD_HIGH_SLOT" }, \
220 		{ NFS4ERR_BAD_RANGE, "BAD_RANGE" }, \
221 		{ NFS4ERR_BAD_SEQID, "BAD_SEQID" }, \
222 		{ NFS4ERR_BAD_SESSION_DIGEST, "BAD_SESSION_DIGEST" }, \
223 		{ NFS4ERR_BAD_STATEID, "BAD_STATEID" }, \
224 		{ NFS4ERR_CB_PATH_DOWN, "CB_PATH_DOWN" }, \
225 		{ NFS4ERR_CLID_INUSE, "CLID_INUSE" }, \
226 		{ NFS4ERR_CLIENTID_BUSY, "CLIENTID_BUSY" }, \
227 		{ NFS4ERR_COMPLETE_ALREADY, "COMPLETE_ALREADY" }, \
228 		{ NFS4ERR_CONN_NOT_BOUND_TO_SESSION, \
229 			"CONN_NOT_BOUND_TO_SESSION" }, \
230 		{ NFS4ERR_DEADLOCK, "DEADLOCK" }, \
231 		{ NFS4ERR_DEADSESSION, "DEAD_SESSION" }, \
232 		{ NFS4ERR_DELAY, "DELAY" }, \
233 		{ NFS4ERR_DELEG_ALREADY_WANTED, \
234 			"DELEG_ALREADY_WANTED" }, \
235 		{ NFS4ERR_DELEG_REVOKED, "DELEG_REVOKED" }, \
236 		{ NFS4ERR_DENIED, "DENIED" }, \
237 		{ NFS4ERR_DIRDELEG_UNAVAIL, "DIRDELEG_UNAVAIL" }, \
238 		{ NFS4ERR_DQUOT, "DQUOT" }, \
239 		{ NFS4ERR_ENCR_ALG_UNSUPP, "ENCR_ALG_UNSUPP" }, \
240 		{ NFS4ERR_EXIST, "EXIST" }, \
241 		{ NFS4ERR_EXPIRED, "EXPIRED" }, \
242 		{ NFS4ERR_FBIG, "FBIG" }, \
243 		{ NFS4ERR_FHEXPIRED, "FHEXPIRED" }, \
244 		{ NFS4ERR_FILE_OPEN, "FILE_OPEN" }, \
245 		{ NFS4ERR_GRACE, "GRACE" }, \
246 		{ NFS4ERR_HASH_ALG_UNSUPP, "HASH_ALG_UNSUPP" }, \
247 		{ NFS4ERR_INVAL, "INVAL" }, \
248 		{ NFS4ERR_IO, "IO" }, \
249 		{ NFS4ERR_ISDIR, "ISDIR" }, \
250 		{ NFS4ERR_LAYOUTTRYLATER, "LAYOUTTRYLATER" }, \
251 		{ NFS4ERR_LAYOUTUNAVAILABLE, "LAYOUTUNAVAILABLE" }, \
252 		{ NFS4ERR_LEASE_MOVED, "LEASE_MOVED" }, \
253 		{ NFS4ERR_LOCKED, "LOCKED" }, \
254 		{ NFS4ERR_LOCKS_HELD, "LOCKS_HELD" }, \
255 		{ NFS4ERR_LOCK_RANGE, "LOCK_RANGE" }, \
256 		{ NFS4ERR_MINOR_VERS_MISMATCH, "MINOR_VERS_MISMATCH" }, \
257 		{ NFS4ERR_MLINK, "MLINK" }, \
258 		{ NFS4ERR_MOVED, "MOVED" }, \
259 		{ NFS4ERR_NAMETOOLONG, "NAMETOOLONG" }, \
260 		{ NFS4ERR_NOENT, "NOENT" }, \
261 		{ NFS4ERR_NOFILEHANDLE, "NOFILEHANDLE" }, \
262 		{ NFS4ERR_NOMATCHING_LAYOUT, "NOMATCHING_LAYOUT" }, \
263 		{ NFS4ERR_NOSPC, "NOSPC" }, \
264 		{ NFS4ERR_NOTDIR, "NOTDIR" }, \
265 		{ NFS4ERR_NOTEMPTY, "NOTEMPTY" }, \
266 		{ NFS4ERR_NOTSUPP, "NOTSUPP" }, \
267 		{ NFS4ERR_NOT_ONLY_OP, "NOT_ONLY_OP" }, \
268 		{ NFS4ERR_NOT_SAME, "NOT_SAME" }, \
269 		{ NFS4ERR_NO_GRACE, "NO_GRACE" }, \
270 		{ NFS4ERR_NXIO, "NXIO" }, \
271 		{ NFS4ERR_OLD_STATEID, "OLD_STATEID" }, \
272 		{ NFS4ERR_OPENMODE, "OPENMODE" }, \
273 		{ NFS4ERR_OP_ILLEGAL, "OP_ILLEGAL" }, \
274 		{ NFS4ERR_OP_NOT_IN_SESSION, "OP_NOT_IN_SESSION" }, \
275 		{ NFS4ERR_PERM, "PERM" }, \
276 		{ NFS4ERR_PNFS_IO_HOLE, "PNFS_IO_HOLE" }, \
277 		{ NFS4ERR_PNFS_NO_LAYOUT, "PNFS_NO_LAYOUT" }, \
278 		{ NFS4ERR_RECALLCONFLICT, "RECALLCONFLICT" }, \
279 		{ NFS4ERR_RECLAIM_BAD, "RECLAIM_BAD" }, \
280 		{ NFS4ERR_RECLAIM_CONFLICT, "RECLAIM_CONFLICT" }, \
281 		{ NFS4ERR_REJECT_DELEG, "REJECT_DELEG" }, \
282 		{ NFS4ERR_REP_TOO_BIG, "REP_TOO_BIG" }, \
283 		{ NFS4ERR_REP_TOO_BIG_TO_CACHE, \
284 			"REP_TOO_BIG_TO_CACHE" }, \
285 		{ NFS4ERR_REQ_TOO_BIG, "REQ_TOO_BIG" }, \
286 		{ NFS4ERR_RESOURCE, "RESOURCE" }, \
287 		{ NFS4ERR_RESTOREFH, "RESTOREFH" }, \
288 		{ NFS4ERR_RETRY_UNCACHED_REP, "RETRY_UNCACHED_REP" }, \
289 		{ NFS4ERR_RETURNCONFLICT, "RETURNCONFLICT" }, \
290 		{ NFS4ERR_ROFS, "ROFS" }, \
291 		{ NFS4ERR_SAME, "SAME" }, \
292 		{ NFS4ERR_SHARE_DENIED, "SHARE_DENIED" }, \
293 		{ NFS4ERR_SEQUENCE_POS, "SEQUENCE_POS" }, \
294 		{ NFS4ERR_SEQ_FALSE_RETRY, "SEQ_FALSE_RETRY" }, \
295 		{ NFS4ERR_SEQ_MISORDERED, "SEQ_MISORDERED" }, \
296 		{ NFS4ERR_SERVERFAULT, "SERVERFAULT" }, \
297 		{ NFS4ERR_STALE, "STALE" }, \
298 		{ NFS4ERR_STALE_CLIENTID, "STALE_CLIENTID" }, \
299 		{ NFS4ERR_STALE_STATEID, "STALE_STATEID" }, \
300 		{ NFS4ERR_SYMLINK, "SYMLINK" }, \
301 		{ NFS4ERR_TOOSMALL, "TOOSMALL" }, \
302 		{ NFS4ERR_TOO_MANY_OPS, "TOO_MANY_OPS" }, \
303 		{ NFS4ERR_UNKNOWN_LAYOUTTYPE, "UNKNOWN_LAYOUTTYPE" }, \
304 		{ NFS4ERR_UNSAFE_COMPOUND, "UNSAFE_COMPOUND" }, \
305 		{ NFS4ERR_WRONGSEC, "WRONGSEC" }, \
306 		{ NFS4ERR_WRONG_CRED, "WRONG_CRED" }, \
307 		{ NFS4ERR_WRONG_TYPE, "WRONG_TYPE" }, \
308 		{ NFS4ERR_XDEV, "XDEV" })
309 
310 #define show_open_flags(flags) \
311 	__print_flags(flags, "|", \
312 		{ O_CREAT, "O_CREAT" }, \
313 		{ O_EXCL, "O_EXCL" }, \
314 		{ O_TRUNC, "O_TRUNC" }, \
315 		{ O_DIRECT, "O_DIRECT" })
316 
317 #define show_fmode_flags(mode) \
318 	__print_flags(mode, "|", \
319 		{ ((__force unsigned long)FMODE_READ), "READ" }, \
320 		{ ((__force unsigned long)FMODE_WRITE), "WRITE" }, \
321 		{ ((__force unsigned long)FMODE_EXEC), "EXEC" })
322 
323 #define show_nfs_fattr_flags(valid) \
324 	__print_flags((unsigned long)valid, "|", \
325 		{ NFS_ATTR_FATTR_TYPE, "TYPE" }, \
326 		{ NFS_ATTR_FATTR_MODE, "MODE" }, \
327 		{ NFS_ATTR_FATTR_NLINK, "NLINK" }, \
328 		{ NFS_ATTR_FATTR_OWNER, "OWNER" }, \
329 		{ NFS_ATTR_FATTR_GROUP, "GROUP" }, \
330 		{ NFS_ATTR_FATTR_RDEV, "RDEV" }, \
331 		{ NFS_ATTR_FATTR_SIZE, "SIZE" }, \
332 		{ NFS_ATTR_FATTR_FSID, "FSID" }, \
333 		{ NFS_ATTR_FATTR_FILEID, "FILEID" }, \
334 		{ NFS_ATTR_FATTR_ATIME, "ATIME" }, \
335 		{ NFS_ATTR_FATTR_MTIME, "MTIME" }, \
336 		{ NFS_ATTR_FATTR_CTIME, "CTIME" }, \
337 		{ NFS_ATTR_FATTR_CHANGE, "CHANGE" }, \
338 		{ NFS_ATTR_FATTR_OWNER_NAME, "OWNER_NAME" }, \
339 		{ NFS_ATTR_FATTR_GROUP_NAME, "GROUP_NAME" })
340 
341 DECLARE_EVENT_CLASS(nfs4_clientid_event,
342 		TP_PROTO(
343 			const struct nfs_client *clp,
344 			int error
345 		),
346 
347 		TP_ARGS(clp, error),
348 
349 		TP_STRUCT__entry(
350 			__string(dstaddr, clp->cl_hostname)
351 			__field(unsigned long, error)
352 		),
353 
354 		TP_fast_assign(
355 			__entry->error = error;
356 			__assign_str(dstaddr, clp->cl_hostname);
357 		),
358 
359 		TP_printk(
360 			"error=%ld (%s) dstaddr=%s",
361 			-__entry->error,
362 			show_nfsv4_errors(__entry->error),
363 			__get_str(dstaddr)
364 		)
365 );
366 #define DEFINE_NFS4_CLIENTID_EVENT(name) \
367 	DEFINE_EVENT(nfs4_clientid_event, name,	 \
368 			TP_PROTO( \
369 				const struct nfs_client *clp, \
370 				int error \
371 			), \
372 			TP_ARGS(clp, error))
373 DEFINE_NFS4_CLIENTID_EVENT(nfs4_setclientid);
374 DEFINE_NFS4_CLIENTID_EVENT(nfs4_setclientid_confirm);
375 DEFINE_NFS4_CLIENTID_EVENT(nfs4_renew);
376 DEFINE_NFS4_CLIENTID_EVENT(nfs4_renew_async);
377 #ifdef CONFIG_NFS_V4_1
378 DEFINE_NFS4_CLIENTID_EVENT(nfs4_exchange_id);
379 DEFINE_NFS4_CLIENTID_EVENT(nfs4_create_session);
380 DEFINE_NFS4_CLIENTID_EVENT(nfs4_destroy_session);
381 DEFINE_NFS4_CLIENTID_EVENT(nfs4_destroy_clientid);
382 DEFINE_NFS4_CLIENTID_EVENT(nfs4_bind_conn_to_session);
383 DEFINE_NFS4_CLIENTID_EVENT(nfs4_sequence);
384 DEFINE_NFS4_CLIENTID_EVENT(nfs4_reclaim_complete);
385 
386 #define show_nfs4_sequence_status_flags(status) \
387 	__print_flags((unsigned long)status, "|", \
388 		{ SEQ4_STATUS_CB_PATH_DOWN, "CB_PATH_DOWN" }, \
389 		{ SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRING, \
390 			"CB_GSS_CONTEXTS_EXPIRING" }, \
391 		{ SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRED, \
392 			"CB_GSS_CONTEXTS_EXPIRED" }, \
393 		{ SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED, \
394 			"EXPIRED_ALL_STATE_REVOKED" }, \
395 		{ SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED, \
396 			"EXPIRED_SOME_STATE_REVOKED" }, \
397 		{ SEQ4_STATUS_ADMIN_STATE_REVOKED, \
398 			"ADMIN_STATE_REVOKED" }, \
399 		{ SEQ4_STATUS_RECALLABLE_STATE_REVOKED,	 \
400 			"RECALLABLE_STATE_REVOKED" }, \
401 		{ SEQ4_STATUS_LEASE_MOVED, "LEASE_MOVED" }, \
402 		{ SEQ4_STATUS_RESTART_RECLAIM_NEEDED, \
403 			"RESTART_RECLAIM_NEEDED" }, \
404 		{ SEQ4_STATUS_CB_PATH_DOWN_SESSION, \
405 			"CB_PATH_DOWN_SESSION" }, \
406 		{ SEQ4_STATUS_BACKCHANNEL_FAULT, \
407 			"BACKCHANNEL_FAULT" })
408 
409 TRACE_EVENT(nfs4_sequence_done,
410 		TP_PROTO(
411 			const struct nfs4_session *session,
412 			const struct nfs4_sequence_res *res
413 		),
414 		TP_ARGS(session, res),
415 
416 		TP_STRUCT__entry(
417 			__field(unsigned int, session)
418 			__field(unsigned int, slot_nr)
419 			__field(unsigned int, seq_nr)
420 			__field(unsigned int, highest_slotid)
421 			__field(unsigned int, target_highest_slotid)
422 			__field(unsigned int, status_flags)
423 			__field(unsigned long, error)
424 		),
425 
426 		TP_fast_assign(
427 			const struct nfs4_slot *sr_slot = res->sr_slot;
428 			__entry->session = nfs_session_id_hash(&session->sess_id);
429 			__entry->slot_nr = sr_slot->slot_nr;
430 			__entry->seq_nr = sr_slot->seq_nr;
431 			__entry->highest_slotid = res->sr_highest_slotid;
432 			__entry->target_highest_slotid =
433 					res->sr_target_highest_slotid;
434 			__entry->status_flags = res->sr_status_flags;
435 			__entry->error = res->sr_status;
436 		),
437 		TP_printk(
438 			"error=%ld (%s) session=0x%08x slot_nr=%u seq_nr=%u "
439 			"highest_slotid=%u target_highest_slotid=%u "
440 			"status_flags=%u (%s)",
441 			-__entry->error,
442 			show_nfsv4_errors(__entry->error),
443 			__entry->session,
444 			__entry->slot_nr,
445 			__entry->seq_nr,
446 			__entry->highest_slotid,
447 			__entry->target_highest_slotid,
448 			__entry->status_flags,
449 			show_nfs4_sequence_status_flags(__entry->status_flags)
450 		)
451 );
452 
453 struct cb_sequenceargs;
454 struct cb_sequenceres;
455 
456 TRACE_EVENT(nfs4_cb_sequence,
457 		TP_PROTO(
458 			const struct cb_sequenceargs *args,
459 			const struct cb_sequenceres *res,
460 			__be32 status
461 		),
462 		TP_ARGS(args, res, status),
463 
464 		TP_STRUCT__entry(
465 			__field(unsigned int, session)
466 			__field(unsigned int, slot_nr)
467 			__field(unsigned int, seq_nr)
468 			__field(unsigned int, highest_slotid)
469 			__field(unsigned int, cachethis)
470 			__field(unsigned long, error)
471 		),
472 
473 		TP_fast_assign(
474 			__entry->session = nfs_session_id_hash(&args->csa_sessionid);
475 			__entry->slot_nr = args->csa_slotid;
476 			__entry->seq_nr = args->csa_sequenceid;
477 			__entry->highest_slotid = args->csa_highestslotid;
478 			__entry->cachethis = args->csa_cachethis;
479 			__entry->error = be32_to_cpu(status);
480 		),
481 
482 		TP_printk(
483 			"error=%ld (%s) session=0x%08x slot_nr=%u seq_nr=%u "
484 			"highest_slotid=%u",
485 			-__entry->error,
486 			show_nfsv4_errors(__entry->error),
487 			__entry->session,
488 			__entry->slot_nr,
489 			__entry->seq_nr,
490 			__entry->highest_slotid
491 		)
492 );
493 
494 TRACE_EVENT(nfs4_cb_seqid_err,
495 		TP_PROTO(
496 			const struct cb_sequenceargs *args,
497 			__be32 status
498 		),
499 		TP_ARGS(args, status),
500 
501 		TP_STRUCT__entry(
502 			__field(unsigned int, session)
503 			__field(unsigned int, slot_nr)
504 			__field(unsigned int, seq_nr)
505 			__field(unsigned int, highest_slotid)
506 			__field(unsigned int, cachethis)
507 			__field(unsigned long, error)
508 		),
509 
510 		TP_fast_assign(
511 			__entry->session = nfs_session_id_hash(&args->csa_sessionid);
512 			__entry->slot_nr = args->csa_slotid;
513 			__entry->seq_nr = args->csa_sequenceid;
514 			__entry->highest_slotid = args->csa_highestslotid;
515 			__entry->cachethis = args->csa_cachethis;
516 			__entry->error = be32_to_cpu(status);
517 		),
518 
519 		TP_printk(
520 			"error=%ld (%s) session=0x%08x slot_nr=%u seq_nr=%u "
521 			"highest_slotid=%u",
522 			-__entry->error,
523 			show_nfsv4_errors(__entry->error),
524 			__entry->session,
525 			__entry->slot_nr,
526 			__entry->seq_nr,
527 			__entry->highest_slotid
528 		)
529 );
530 
531 #endif /* CONFIG_NFS_V4_1 */
532 
533 TRACE_EVENT(nfs4_setup_sequence,
534 		TP_PROTO(
535 			const struct nfs4_session *session,
536 			const struct nfs4_sequence_args *args
537 		),
538 		TP_ARGS(session, args),
539 
540 		TP_STRUCT__entry(
541 			__field(unsigned int, session)
542 			__field(unsigned int, slot_nr)
543 			__field(unsigned int, seq_nr)
544 			__field(unsigned int, highest_used_slotid)
545 		),
546 
547 		TP_fast_assign(
548 			const struct nfs4_slot *sa_slot = args->sa_slot;
549 			__entry->session = session ? nfs_session_id_hash(&session->sess_id) : 0;
550 			__entry->slot_nr = sa_slot->slot_nr;
551 			__entry->seq_nr = sa_slot->seq_nr;
552 			__entry->highest_used_slotid =
553 					sa_slot->table->highest_used_slotid;
554 		),
555 		TP_printk(
556 			"session=0x%08x slot_nr=%u seq_nr=%u "
557 			"highest_used_slotid=%u",
558 			__entry->session,
559 			__entry->slot_nr,
560 			__entry->seq_nr,
561 			__entry->highest_used_slotid
562 		)
563 );
564 
565 TRACE_DEFINE_ENUM(NFS4CLNT_MANAGER_RUNNING);
566 TRACE_DEFINE_ENUM(NFS4CLNT_CHECK_LEASE);
567 TRACE_DEFINE_ENUM(NFS4CLNT_LEASE_EXPIRED);
568 TRACE_DEFINE_ENUM(NFS4CLNT_RECLAIM_REBOOT);
569 TRACE_DEFINE_ENUM(NFS4CLNT_RECLAIM_NOGRACE);
570 TRACE_DEFINE_ENUM(NFS4CLNT_DELEGRETURN);
571 TRACE_DEFINE_ENUM(NFS4CLNT_SESSION_RESET);
572 TRACE_DEFINE_ENUM(NFS4CLNT_LEASE_CONFIRM);
573 TRACE_DEFINE_ENUM(NFS4CLNT_SERVER_SCOPE_MISMATCH);
574 TRACE_DEFINE_ENUM(NFS4CLNT_PURGE_STATE);
575 TRACE_DEFINE_ENUM(NFS4CLNT_BIND_CONN_TO_SESSION);
576 TRACE_DEFINE_ENUM(NFS4CLNT_MOVED);
577 TRACE_DEFINE_ENUM(NFS4CLNT_LEASE_MOVED);
578 TRACE_DEFINE_ENUM(NFS4CLNT_DELEGATION_EXPIRED);
579 TRACE_DEFINE_ENUM(NFS4CLNT_RUN_MANAGER);
580 TRACE_DEFINE_ENUM(NFS4CLNT_DELEGRETURN_RUNNING);
581 
582 #define show_nfs4_clp_state(state) \
583 	__print_flags(state, "|", \
584 		{ NFS4CLNT_MANAGER_RUNNING,	"MANAGER_RUNNING" }, \
585 		{ NFS4CLNT_CHECK_LEASE,		"CHECK_LEASE" }, \
586 		{ NFS4CLNT_LEASE_EXPIRED,	"LEASE_EXPIRED" }, \
587 		{ NFS4CLNT_RECLAIM_REBOOT,	"RECLAIM_REBOOT" }, \
588 		{ NFS4CLNT_RECLAIM_NOGRACE,	"RECLAIM_NOGRACE" }, \
589 		{ NFS4CLNT_DELEGRETURN,		"DELEGRETURN" }, \
590 		{ NFS4CLNT_SESSION_RESET,	"SESSION_RESET" }, \
591 		{ NFS4CLNT_LEASE_CONFIRM,	"LEASE_CONFIRM" }, \
592 		{ NFS4CLNT_SERVER_SCOPE_MISMATCH, \
593 						"SERVER_SCOPE_MISMATCH" }, \
594 		{ NFS4CLNT_PURGE_STATE,		"PURGE_STATE" }, \
595 		{ NFS4CLNT_BIND_CONN_TO_SESSION, \
596 						"BIND_CONN_TO_SESSION" }, \
597 		{ NFS4CLNT_MOVED,		"MOVED" }, \
598 		{ NFS4CLNT_LEASE_MOVED,		"LEASE_MOVED" }, \
599 		{ NFS4CLNT_DELEGATION_EXPIRED,	"DELEGATION_EXPIRED" }, \
600 		{ NFS4CLNT_RUN_MANAGER,		"RUN_MANAGER" }, \
601 		{ NFS4CLNT_DELEGRETURN_RUNNING,	"DELEGRETURN_RUNNING" })
602 
603 TRACE_EVENT(nfs4_state_mgr,
604 		TP_PROTO(
605 			const struct nfs_client *clp
606 		),
607 
608 		TP_ARGS(clp),
609 
610 		TP_STRUCT__entry(
611 			__field(unsigned long, state)
612 			__string(hostname, clp->cl_hostname)
613 		),
614 
615 		TP_fast_assign(
616 			__entry->state = clp->cl_state;
617 			__assign_str(hostname, clp->cl_hostname)
618 		),
619 
620 		TP_printk(
621 			"hostname=%s clp state=%s", __get_str(hostname),
622 			show_nfs4_clp_state(__entry->state)
623 		)
624 )
625 
626 TRACE_EVENT(nfs4_state_mgr_failed,
627 		TP_PROTO(
628 			const struct nfs_client *clp,
629 			const char *section,
630 			int status
631 		),
632 
633 		TP_ARGS(clp, section, status),
634 
635 		TP_STRUCT__entry(
636 			__field(unsigned long, error)
637 			__field(unsigned long, state)
638 			__string(hostname, clp->cl_hostname)
639 			__string(section, section)
640 		),
641 
642 		TP_fast_assign(
643 			__entry->error = status;
644 			__entry->state = clp->cl_state;
645 			__assign_str(hostname, clp->cl_hostname);
646 			__assign_str(section, section);
647 		),
648 
649 		TP_printk(
650 			"hostname=%s clp state=%s error=%ld (%s) section=%s",
651 			__get_str(hostname),
652 			show_nfs4_clp_state(__entry->state), -__entry->error,
653 			show_nfsv4_errors(__entry->error), __get_str(section)
654 
655 		)
656 )
657 
658 TRACE_EVENT(nfs4_xdr_status,
659 		TP_PROTO(
660 			const struct xdr_stream *xdr,
661 			u32 op,
662 			int error
663 		),
664 
665 		TP_ARGS(xdr, op, error),
666 
667 		TP_STRUCT__entry(
668 			__field(unsigned int, task_id)
669 			__field(unsigned int, client_id)
670 			__field(u32, xid)
671 			__field(u32, op)
672 			__field(unsigned long, error)
673 		),
674 
675 		TP_fast_assign(
676 			const struct rpc_rqst *rqstp = xdr->rqst;
677 			const struct rpc_task *task = rqstp->rq_task;
678 
679 			__entry->task_id = task->tk_pid;
680 			__entry->client_id = task->tk_client->cl_clid;
681 			__entry->xid = be32_to_cpu(rqstp->rq_xid);
682 			__entry->op = op;
683 			__entry->error = error;
684 		),
685 
686 		TP_printk(
687 			"task:%u@%d xid=0x%08x error=%ld (%s) operation=%u",
688 			__entry->task_id, __entry->client_id, __entry->xid,
689 			-__entry->error, show_nfsv4_errors(__entry->error),
690 			__entry->op
691 		)
692 );
693 
694 DECLARE_EVENT_CLASS(nfs4_open_event,
695 		TP_PROTO(
696 			const struct nfs_open_context *ctx,
697 			int flags,
698 			int error
699 		),
700 
701 		TP_ARGS(ctx, flags, error),
702 
703 		TP_STRUCT__entry(
704 			__field(unsigned long, error)
705 			__field(unsigned int, flags)
706 			__field(unsigned int, fmode)
707 			__field(dev_t, dev)
708 			__field(u32, fhandle)
709 			__field(u64, fileid)
710 			__field(u64, dir)
711 			__string(name, ctx->dentry->d_name.name)
712 			__field(int, stateid_seq)
713 			__field(u32, stateid_hash)
714 			__field(int, openstateid_seq)
715 			__field(u32, openstateid_hash)
716 		),
717 
718 		TP_fast_assign(
719 			const struct nfs4_state *state = ctx->state;
720 			const struct inode *inode = NULL;
721 
722 			__entry->error = -error;
723 			__entry->flags = flags;
724 			__entry->fmode = (__force unsigned int)ctx->mode;
725 			__entry->dev = ctx->dentry->d_sb->s_dev;
726 			if (!IS_ERR_OR_NULL(state)) {
727 				inode = state->inode;
728 				__entry->stateid_seq =
729 					be32_to_cpu(state->stateid.seqid);
730 				__entry->stateid_hash =
731 					nfs_stateid_hash(&state->stateid);
732 				__entry->openstateid_seq =
733 					be32_to_cpu(state->open_stateid.seqid);
734 				__entry->openstateid_hash =
735 					nfs_stateid_hash(&state->open_stateid);
736 			} else {
737 				__entry->stateid_seq = 0;
738 				__entry->stateid_hash = 0;
739 				__entry->openstateid_seq = 0;
740 				__entry->openstateid_hash = 0;
741 			}
742 			if (inode != NULL) {
743 				__entry->fileid = NFS_FILEID(inode);
744 				__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
745 			} else {
746 				__entry->fileid = 0;
747 				__entry->fhandle = 0;
748 			}
749 			__entry->dir = NFS_FILEID(d_inode(ctx->dentry->d_parent));
750 			__assign_str(name, ctx->dentry->d_name.name);
751 		),
752 
753 		TP_printk(
754 			"error=%ld (%s) flags=%d (%s) fmode=%s "
755 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
756 			"name=%02x:%02x:%llu/%s stateid=%d:0x%08x "
757 			"openstateid=%d:0x%08x",
758 			 -__entry->error,
759 			 show_nfsv4_errors(__entry->error),
760 			 __entry->flags,
761 			 show_open_flags(__entry->flags),
762 			 show_fmode_flags(__entry->fmode),
763 			 MAJOR(__entry->dev), MINOR(__entry->dev),
764 			 (unsigned long long)__entry->fileid,
765 			 __entry->fhandle,
766 			 MAJOR(__entry->dev), MINOR(__entry->dev),
767 			 (unsigned long long)__entry->dir,
768 			 __get_str(name),
769 			 __entry->stateid_seq, __entry->stateid_hash,
770 			 __entry->openstateid_seq, __entry->openstateid_hash
771 		)
772 );
773 
774 #define DEFINE_NFS4_OPEN_EVENT(name) \
775 	DEFINE_EVENT(nfs4_open_event, name, \
776 			TP_PROTO( \
777 				const struct nfs_open_context *ctx, \
778 				int flags, \
779 				int error \
780 			), \
781 			TP_ARGS(ctx, flags, error))
782 DEFINE_NFS4_OPEN_EVENT(nfs4_open_reclaim);
783 DEFINE_NFS4_OPEN_EVENT(nfs4_open_expired);
784 DEFINE_NFS4_OPEN_EVENT(nfs4_open_file);
785 
786 TRACE_EVENT(nfs4_cached_open,
787 		TP_PROTO(
788 			const struct nfs4_state *state
789 		),
790 		TP_ARGS(state),
791 		TP_STRUCT__entry(
792 			__field(dev_t, dev)
793 			__field(u32, fhandle)
794 			__field(u64, fileid)
795 			__field(unsigned int, fmode)
796 			__field(int, stateid_seq)
797 			__field(u32, stateid_hash)
798 		),
799 
800 		TP_fast_assign(
801 			const struct inode *inode = state->inode;
802 
803 			__entry->dev = inode->i_sb->s_dev;
804 			__entry->fileid = NFS_FILEID(inode);
805 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
806 			__entry->fmode = (__force unsigned int)state->state;
807 			__entry->stateid_seq =
808 				be32_to_cpu(state->stateid.seqid);
809 			__entry->stateid_hash =
810 				nfs_stateid_hash(&state->stateid);
811 		),
812 
813 		TP_printk(
814 			"fmode=%s fileid=%02x:%02x:%llu "
815 			"fhandle=0x%08x stateid=%d:0x%08x",
816 			__entry->fmode ?  show_fmode_flags(__entry->fmode) :
817 					  "closed",
818 			MAJOR(__entry->dev), MINOR(__entry->dev),
819 			(unsigned long long)__entry->fileid,
820 			__entry->fhandle,
821 			__entry->stateid_seq, __entry->stateid_hash
822 		)
823 );
824 
825 TRACE_EVENT(nfs4_close,
826 		TP_PROTO(
827 			const struct nfs4_state *state,
828 			const struct nfs_closeargs *args,
829 			const struct nfs_closeres *res,
830 			int error
831 		),
832 
833 		TP_ARGS(state, args, res, error),
834 
835 		TP_STRUCT__entry(
836 			__field(dev_t, dev)
837 			__field(u32, fhandle)
838 			__field(u64, fileid)
839 			__field(unsigned int, fmode)
840 			__field(unsigned long, error)
841 			__field(int, stateid_seq)
842 			__field(u32, stateid_hash)
843 		),
844 
845 		TP_fast_assign(
846 			const struct inode *inode = state->inode;
847 
848 			__entry->dev = inode->i_sb->s_dev;
849 			__entry->fileid = NFS_FILEID(inode);
850 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
851 			__entry->fmode = (__force unsigned int)state->state;
852 			__entry->error = error;
853 			__entry->stateid_seq =
854 				be32_to_cpu(args->stateid.seqid);
855 			__entry->stateid_hash =
856 				nfs_stateid_hash(&args->stateid);
857 		),
858 
859 		TP_printk(
860 			"error=%ld (%s) fmode=%s fileid=%02x:%02x:%llu "
861 			"fhandle=0x%08x openstateid=%d:0x%08x",
862 			-__entry->error,
863 			show_nfsv4_errors(__entry->error),
864 			__entry->fmode ?  show_fmode_flags(__entry->fmode) :
865 					  "closed",
866 			MAJOR(__entry->dev), MINOR(__entry->dev),
867 			(unsigned long long)__entry->fileid,
868 			__entry->fhandle,
869 			__entry->stateid_seq, __entry->stateid_hash
870 		)
871 );
872 
873 TRACE_DEFINE_ENUM(F_GETLK);
874 TRACE_DEFINE_ENUM(F_SETLK);
875 TRACE_DEFINE_ENUM(F_SETLKW);
876 TRACE_DEFINE_ENUM(F_RDLCK);
877 TRACE_DEFINE_ENUM(F_WRLCK);
878 TRACE_DEFINE_ENUM(F_UNLCK);
879 
880 #define show_lock_cmd(type) \
881 	__print_symbolic((int)type, \
882 		{ F_GETLK, "GETLK" }, \
883 		{ F_SETLK, "SETLK" }, \
884 		{ F_SETLKW, "SETLKW" })
885 #define show_lock_type(type) \
886 	__print_symbolic((int)type, \
887 		{ F_RDLCK, "RDLCK" }, \
888 		{ F_WRLCK, "WRLCK" }, \
889 		{ F_UNLCK, "UNLCK" })
890 
891 DECLARE_EVENT_CLASS(nfs4_lock_event,
892 		TP_PROTO(
893 			const struct file_lock *request,
894 			const struct nfs4_state *state,
895 			int cmd,
896 			int error
897 		),
898 
899 		TP_ARGS(request, state, cmd, error),
900 
901 		TP_STRUCT__entry(
902 			__field(unsigned long, error)
903 			__field(int, cmd)
904 			__field(char, type)
905 			__field(loff_t, start)
906 			__field(loff_t, end)
907 			__field(dev_t, dev)
908 			__field(u32, fhandle)
909 			__field(u64, fileid)
910 			__field(int, stateid_seq)
911 			__field(u32, stateid_hash)
912 		),
913 
914 		TP_fast_assign(
915 			const struct inode *inode = state->inode;
916 
917 			__entry->error = error;
918 			__entry->cmd = cmd;
919 			__entry->type = request->fl_type;
920 			__entry->start = request->fl_start;
921 			__entry->end = request->fl_end;
922 			__entry->dev = inode->i_sb->s_dev;
923 			__entry->fileid = NFS_FILEID(inode);
924 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
925 			__entry->stateid_seq =
926 				be32_to_cpu(state->stateid.seqid);
927 			__entry->stateid_hash =
928 				nfs_stateid_hash(&state->stateid);
929 		),
930 
931 		TP_printk(
932 			"error=%ld (%s) cmd=%s:%s range=%lld:%lld "
933 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
934 			"stateid=%d:0x%08x",
935 			-__entry->error,
936 			show_nfsv4_errors(__entry->error),
937 			show_lock_cmd(__entry->cmd),
938 			show_lock_type(__entry->type),
939 			(long long)__entry->start,
940 			(long long)__entry->end,
941 			MAJOR(__entry->dev), MINOR(__entry->dev),
942 			(unsigned long long)__entry->fileid,
943 			__entry->fhandle,
944 			__entry->stateid_seq, __entry->stateid_hash
945 		)
946 );
947 
948 #define DEFINE_NFS4_LOCK_EVENT(name) \
949 	DEFINE_EVENT(nfs4_lock_event, name, \
950 			TP_PROTO( \
951 				const struct file_lock *request, \
952 				const struct nfs4_state *state, \
953 				int cmd, \
954 				int error \
955 			), \
956 			TP_ARGS(request, state, cmd, error))
957 DEFINE_NFS4_LOCK_EVENT(nfs4_get_lock);
958 DEFINE_NFS4_LOCK_EVENT(nfs4_unlock);
959 
960 TRACE_EVENT(nfs4_set_lock,
961 		TP_PROTO(
962 			const struct file_lock *request,
963 			const struct nfs4_state *state,
964 			const nfs4_stateid *lockstateid,
965 			int cmd,
966 			int error
967 		),
968 
969 		TP_ARGS(request, state, lockstateid, cmd, error),
970 
971 		TP_STRUCT__entry(
972 			__field(unsigned long, error)
973 			__field(int, cmd)
974 			__field(char, type)
975 			__field(loff_t, start)
976 			__field(loff_t, end)
977 			__field(dev_t, dev)
978 			__field(u32, fhandle)
979 			__field(u64, fileid)
980 			__field(int, stateid_seq)
981 			__field(u32, stateid_hash)
982 			__field(int, lockstateid_seq)
983 			__field(u32, lockstateid_hash)
984 		),
985 
986 		TP_fast_assign(
987 			const struct inode *inode = state->inode;
988 
989 			__entry->error = error;
990 			__entry->cmd = cmd;
991 			__entry->type = request->fl_type;
992 			__entry->start = request->fl_start;
993 			__entry->end = request->fl_end;
994 			__entry->dev = inode->i_sb->s_dev;
995 			__entry->fileid = NFS_FILEID(inode);
996 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
997 			__entry->stateid_seq =
998 				be32_to_cpu(state->stateid.seqid);
999 			__entry->stateid_hash =
1000 				nfs_stateid_hash(&state->stateid);
1001 			__entry->lockstateid_seq =
1002 				be32_to_cpu(lockstateid->seqid);
1003 			__entry->lockstateid_hash =
1004 				nfs_stateid_hash(lockstateid);
1005 		),
1006 
1007 		TP_printk(
1008 			"error=%ld (%s) cmd=%s:%s range=%lld:%lld "
1009 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1010 			"stateid=%d:0x%08x lockstateid=%d:0x%08x",
1011 			-__entry->error,
1012 			show_nfsv4_errors(__entry->error),
1013 			show_lock_cmd(__entry->cmd),
1014 			show_lock_type(__entry->type),
1015 			(long long)__entry->start,
1016 			(long long)__entry->end,
1017 			MAJOR(__entry->dev), MINOR(__entry->dev),
1018 			(unsigned long long)__entry->fileid,
1019 			__entry->fhandle,
1020 			__entry->stateid_seq, __entry->stateid_hash,
1021 			__entry->lockstateid_seq, __entry->lockstateid_hash
1022 		)
1023 );
1024 
1025 TRACE_DEFINE_ENUM(LK_STATE_IN_USE);
1026 TRACE_DEFINE_ENUM(NFS_DELEGATED_STATE);
1027 TRACE_DEFINE_ENUM(NFS_OPEN_STATE);
1028 TRACE_DEFINE_ENUM(NFS_O_RDONLY_STATE);
1029 TRACE_DEFINE_ENUM(NFS_O_WRONLY_STATE);
1030 TRACE_DEFINE_ENUM(NFS_O_RDWR_STATE);
1031 TRACE_DEFINE_ENUM(NFS_STATE_RECLAIM_REBOOT);
1032 TRACE_DEFINE_ENUM(NFS_STATE_RECLAIM_NOGRACE);
1033 TRACE_DEFINE_ENUM(NFS_STATE_POSIX_LOCKS);
1034 TRACE_DEFINE_ENUM(NFS_STATE_RECOVERY_FAILED);
1035 TRACE_DEFINE_ENUM(NFS_STATE_MAY_NOTIFY_LOCK);
1036 TRACE_DEFINE_ENUM(NFS_STATE_CHANGE_WAIT);
1037 TRACE_DEFINE_ENUM(NFS_CLNT_DST_SSC_COPY_STATE);
1038 TRACE_DEFINE_ENUM(NFS_CLNT_SRC_SSC_COPY_STATE);
1039 TRACE_DEFINE_ENUM(NFS_SRV_SSC_COPY_STATE);
1040 
1041 #define show_nfs4_state_flags(flags) \
1042 	__print_flags(flags, "|", \
1043 		{ LK_STATE_IN_USE,		"IN_USE" }, \
1044 		{ NFS_DELEGATED_STATE,		"DELEGATED" }, \
1045 		{ NFS_OPEN_STATE,		"OPEN" }, \
1046 		{ NFS_O_RDONLY_STATE,		"O_RDONLY" }, \
1047 		{ NFS_O_WRONLY_STATE,		"O_WRONLY" }, \
1048 		{ NFS_O_RDWR_STATE,		"O_RDWR" }, \
1049 		{ NFS_STATE_RECLAIM_REBOOT,	"RECLAIM_REBOOT" }, \
1050 		{ NFS_STATE_RECLAIM_NOGRACE,	"RECLAIM_NOGRACE" }, \
1051 		{ NFS_STATE_POSIX_LOCKS,	"POSIX_LOCKS" }, \
1052 		{ NFS_STATE_RECOVERY_FAILED,	"RECOVERY_FAILED" }, \
1053 		{ NFS_STATE_MAY_NOTIFY_LOCK,	"MAY_NOTIFY_LOCK" }, \
1054 		{ NFS_STATE_CHANGE_WAIT,	"CHANGE_WAIT" }, \
1055 		{ NFS_CLNT_DST_SSC_COPY_STATE,	"CLNT_DST_SSC_COPY" }, \
1056 		{ NFS_CLNT_SRC_SSC_COPY_STATE,	"CLNT_SRC_SSC_COPY" }, \
1057 		{ NFS_SRV_SSC_COPY_STATE,	"SRV_SSC_COPY" })
1058 
1059 #define show_nfs4_lock_flags(flags) \
1060 	__print_flags(flags, "|", \
1061 		{ BIT(NFS_LOCK_INITIALIZED),	"INITIALIZED" }, \
1062 		{ BIT(NFS_LOCK_LOST),		"LOST" })
1063 
1064 TRACE_EVENT(nfs4_state_lock_reclaim,
1065 		TP_PROTO(
1066 			const struct nfs4_state *state,
1067 			const struct nfs4_lock_state *lock
1068 		),
1069 
1070 		TP_ARGS(state, lock),
1071 
1072 		TP_STRUCT__entry(
1073 			__field(dev_t, dev)
1074 			__field(u32, fhandle)
1075 			__field(u64, fileid)
1076 			__field(unsigned long, state_flags)
1077 			__field(unsigned long, lock_flags)
1078 			__field(int, stateid_seq)
1079 			__field(u32, stateid_hash)
1080 		),
1081 
1082 		TP_fast_assign(
1083 			const struct inode *inode = state->inode;
1084 
1085 			__entry->dev = inode->i_sb->s_dev;
1086 			__entry->fileid = NFS_FILEID(inode);
1087 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1088 			__entry->state_flags = state->flags;
1089 			__entry->lock_flags = lock->ls_flags;
1090 			__entry->stateid_seq =
1091 				be32_to_cpu(state->stateid.seqid);
1092 			__entry->stateid_hash =
1093 				nfs_stateid_hash(&state->stateid);
1094 		),
1095 
1096 		TP_printk(
1097 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1098 			"stateid=%d:0x%08x state_flags=%s lock_flags=%s",
1099 			MAJOR(__entry->dev), MINOR(__entry->dev),
1100 			(unsigned long long)__entry->fileid, __entry->fhandle,
1101 			__entry->stateid_seq, __entry->stateid_hash,
1102 			show_nfs4_state_flags(__entry->state_flags),
1103 			show_nfs4_lock_flags(__entry->lock_flags)
1104 		)
1105 )
1106 
1107 DECLARE_EVENT_CLASS(nfs4_set_delegation_event,
1108 		TP_PROTO(
1109 			const struct inode *inode,
1110 			fmode_t fmode
1111 		),
1112 
1113 		TP_ARGS(inode, fmode),
1114 
1115 		TP_STRUCT__entry(
1116 			__field(dev_t, dev)
1117 			__field(u32, fhandle)
1118 			__field(u64, fileid)
1119 			__field(unsigned int, fmode)
1120 		),
1121 
1122 		TP_fast_assign(
1123 			__entry->dev = inode->i_sb->s_dev;
1124 			__entry->fileid = NFS_FILEID(inode);
1125 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1126 			__entry->fmode = (__force unsigned int)fmode;
1127 		),
1128 
1129 		TP_printk(
1130 			"fmode=%s fileid=%02x:%02x:%llu fhandle=0x%08x",
1131 			show_fmode_flags(__entry->fmode),
1132 			MAJOR(__entry->dev), MINOR(__entry->dev),
1133 			(unsigned long long)__entry->fileid,
1134 			__entry->fhandle
1135 		)
1136 );
1137 #define DEFINE_NFS4_SET_DELEGATION_EVENT(name) \
1138 	DEFINE_EVENT(nfs4_set_delegation_event, name, \
1139 			TP_PROTO( \
1140 				const struct inode *inode, \
1141 				fmode_t fmode \
1142 			), \
1143 			TP_ARGS(inode, fmode))
1144 DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_set_delegation);
1145 DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_reclaim_delegation);
1146 
1147 TRACE_EVENT(nfs4_delegreturn_exit,
1148 		TP_PROTO(
1149 			const struct nfs4_delegreturnargs *args,
1150 			const struct nfs4_delegreturnres *res,
1151 			int error
1152 		),
1153 
1154 		TP_ARGS(args, res, error),
1155 
1156 		TP_STRUCT__entry(
1157 			__field(dev_t, dev)
1158 			__field(u32, fhandle)
1159 			__field(unsigned long, error)
1160 			__field(int, stateid_seq)
1161 			__field(u32, stateid_hash)
1162 		),
1163 
1164 		TP_fast_assign(
1165 			__entry->dev = res->server->s_dev;
1166 			__entry->fhandle = nfs_fhandle_hash(args->fhandle);
1167 			__entry->error = error;
1168 			__entry->stateid_seq =
1169 				be32_to_cpu(args->stateid->seqid);
1170 			__entry->stateid_hash =
1171 				nfs_stateid_hash(args->stateid);
1172 		),
1173 
1174 		TP_printk(
1175 			"error=%ld (%s) dev=%02x:%02x fhandle=0x%08x "
1176 			"stateid=%d:0x%08x",
1177 			-__entry->error,
1178 			show_nfsv4_errors(__entry->error),
1179 			MAJOR(__entry->dev), MINOR(__entry->dev),
1180 			__entry->fhandle,
1181 			__entry->stateid_seq, __entry->stateid_hash
1182 		)
1183 );
1184 
1185 #ifdef CONFIG_NFS_V4_1
1186 DECLARE_EVENT_CLASS(nfs4_test_stateid_event,
1187 		TP_PROTO(
1188 			const struct nfs4_state *state,
1189 			const struct nfs4_lock_state *lsp,
1190 			int error
1191 		),
1192 
1193 		TP_ARGS(state, lsp, error),
1194 
1195 		TP_STRUCT__entry(
1196 			__field(unsigned long, error)
1197 			__field(dev_t, dev)
1198 			__field(u32, fhandle)
1199 			__field(u64, fileid)
1200 			__field(int, stateid_seq)
1201 			__field(u32, stateid_hash)
1202 		),
1203 
1204 		TP_fast_assign(
1205 			const struct inode *inode = state->inode;
1206 
1207 			__entry->error = error;
1208 			__entry->dev = inode->i_sb->s_dev;
1209 			__entry->fileid = NFS_FILEID(inode);
1210 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1211 			__entry->stateid_seq =
1212 				be32_to_cpu(state->stateid.seqid);
1213 			__entry->stateid_hash =
1214 				nfs_stateid_hash(&state->stateid);
1215 		),
1216 
1217 		TP_printk(
1218 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1219 			"stateid=%d:0x%08x",
1220 			-__entry->error,
1221 			show_nfsv4_errors(__entry->error),
1222 			MAJOR(__entry->dev), MINOR(__entry->dev),
1223 			(unsigned long long)__entry->fileid,
1224 			__entry->fhandle,
1225 			__entry->stateid_seq, __entry->stateid_hash
1226 		)
1227 );
1228 
1229 #define DEFINE_NFS4_TEST_STATEID_EVENT(name) \
1230 	DEFINE_EVENT(nfs4_test_stateid_event, name, \
1231 			TP_PROTO( \
1232 				const struct nfs4_state *state, \
1233 				const struct nfs4_lock_state *lsp, \
1234 				int error \
1235 			), \
1236 			TP_ARGS(state, lsp, error))
1237 DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_delegation_stateid);
1238 DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_open_stateid);
1239 DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_lock_stateid);
1240 #endif /* CONFIG_NFS_V4_1 */
1241 
1242 DECLARE_EVENT_CLASS(nfs4_lookup_event,
1243 		TP_PROTO(
1244 			const struct inode *dir,
1245 			const struct qstr *name,
1246 			int error
1247 		),
1248 
1249 		TP_ARGS(dir, name, error),
1250 
1251 		TP_STRUCT__entry(
1252 			__field(dev_t, dev)
1253 			__field(unsigned long, error)
1254 			__field(u64, dir)
1255 			__string(name, name->name)
1256 		),
1257 
1258 		TP_fast_assign(
1259 			__entry->dev = dir->i_sb->s_dev;
1260 			__entry->dir = NFS_FILEID(dir);
1261 			__entry->error = -error;
1262 			__assign_str(name, name->name);
1263 		),
1264 
1265 		TP_printk(
1266 			"error=%ld (%s) name=%02x:%02x:%llu/%s",
1267 			-__entry->error,
1268 			show_nfsv4_errors(__entry->error),
1269 			MAJOR(__entry->dev), MINOR(__entry->dev),
1270 			(unsigned long long)__entry->dir,
1271 			__get_str(name)
1272 		)
1273 );
1274 
1275 #define DEFINE_NFS4_LOOKUP_EVENT(name) \
1276 	DEFINE_EVENT(nfs4_lookup_event, name, \
1277 			TP_PROTO( \
1278 				const struct inode *dir, \
1279 				const struct qstr *name, \
1280 				int error \
1281 			), \
1282 			TP_ARGS(dir, name, error))
1283 
1284 DEFINE_NFS4_LOOKUP_EVENT(nfs4_lookup);
1285 DEFINE_NFS4_LOOKUP_EVENT(nfs4_symlink);
1286 DEFINE_NFS4_LOOKUP_EVENT(nfs4_mkdir);
1287 DEFINE_NFS4_LOOKUP_EVENT(nfs4_mknod);
1288 DEFINE_NFS4_LOOKUP_EVENT(nfs4_remove);
1289 DEFINE_NFS4_LOOKUP_EVENT(nfs4_get_fs_locations);
1290 DEFINE_NFS4_LOOKUP_EVENT(nfs4_secinfo);
1291 
1292 TRACE_EVENT(nfs4_lookupp,
1293 		TP_PROTO(
1294 			const struct inode *inode,
1295 			int error
1296 		),
1297 
1298 		TP_ARGS(inode, error),
1299 
1300 		TP_STRUCT__entry(
1301 			__field(dev_t, dev)
1302 			__field(u64, ino)
1303 			__field(unsigned long, error)
1304 		),
1305 
1306 		TP_fast_assign(
1307 			__entry->dev = inode->i_sb->s_dev;
1308 			__entry->ino = NFS_FILEID(inode);
1309 			__entry->error = error;
1310 		),
1311 
1312 		TP_printk(
1313 			"error=%ld (%s) inode=%02x:%02x:%llu",
1314 			-__entry->error,
1315 			show_nfsv4_errors(__entry->error),
1316 			MAJOR(__entry->dev), MINOR(__entry->dev),
1317 			(unsigned long long)__entry->ino
1318 		)
1319 );
1320 
1321 TRACE_EVENT(nfs4_rename,
1322 		TP_PROTO(
1323 			const struct inode *olddir,
1324 			const struct qstr *oldname,
1325 			const struct inode *newdir,
1326 			const struct qstr *newname,
1327 			int error
1328 		),
1329 
1330 		TP_ARGS(olddir, oldname, newdir, newname, error),
1331 
1332 		TP_STRUCT__entry(
1333 			__field(dev_t, dev)
1334 			__field(unsigned long, error)
1335 			__field(u64, olddir)
1336 			__string(oldname, oldname->name)
1337 			__field(u64, newdir)
1338 			__string(newname, newname->name)
1339 		),
1340 
1341 		TP_fast_assign(
1342 			__entry->dev = olddir->i_sb->s_dev;
1343 			__entry->olddir = NFS_FILEID(olddir);
1344 			__entry->newdir = NFS_FILEID(newdir);
1345 			__entry->error = error;
1346 			__assign_str(oldname, oldname->name);
1347 			__assign_str(newname, newname->name);
1348 		),
1349 
1350 		TP_printk(
1351 			"error=%ld (%s) oldname=%02x:%02x:%llu/%s "
1352 			"newname=%02x:%02x:%llu/%s",
1353 			-__entry->error,
1354 			show_nfsv4_errors(__entry->error),
1355 			MAJOR(__entry->dev), MINOR(__entry->dev),
1356 			(unsigned long long)__entry->olddir,
1357 			__get_str(oldname),
1358 			MAJOR(__entry->dev), MINOR(__entry->dev),
1359 			(unsigned long long)__entry->newdir,
1360 			__get_str(newname)
1361 		)
1362 );
1363 
1364 DECLARE_EVENT_CLASS(nfs4_inode_event,
1365 		TP_PROTO(
1366 			const struct inode *inode,
1367 			int error
1368 		),
1369 
1370 		TP_ARGS(inode, error),
1371 
1372 		TP_STRUCT__entry(
1373 			__field(dev_t, dev)
1374 			__field(u32, fhandle)
1375 			__field(u64, fileid)
1376 			__field(unsigned long, error)
1377 		),
1378 
1379 		TP_fast_assign(
1380 			__entry->dev = inode->i_sb->s_dev;
1381 			__entry->fileid = NFS_FILEID(inode);
1382 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1383 			__entry->error = error < 0 ? -error : 0;
1384 		),
1385 
1386 		TP_printk(
1387 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x",
1388 			-__entry->error,
1389 			show_nfsv4_errors(__entry->error),
1390 			MAJOR(__entry->dev), MINOR(__entry->dev),
1391 			(unsigned long long)__entry->fileid,
1392 			__entry->fhandle
1393 		)
1394 );
1395 
1396 #define DEFINE_NFS4_INODE_EVENT(name) \
1397 	DEFINE_EVENT(nfs4_inode_event, name, \
1398 			TP_PROTO( \
1399 				const struct inode *inode, \
1400 				int error \
1401 			), \
1402 			TP_ARGS(inode, error))
1403 
1404 DEFINE_NFS4_INODE_EVENT(nfs4_access);
1405 DEFINE_NFS4_INODE_EVENT(nfs4_readlink);
1406 DEFINE_NFS4_INODE_EVENT(nfs4_readdir);
1407 DEFINE_NFS4_INODE_EVENT(nfs4_get_acl);
1408 DEFINE_NFS4_INODE_EVENT(nfs4_set_acl);
1409 #ifdef CONFIG_NFS_V4_SECURITY_LABEL
1410 DEFINE_NFS4_INODE_EVENT(nfs4_get_security_label);
1411 DEFINE_NFS4_INODE_EVENT(nfs4_set_security_label);
1412 #endif /* CONFIG_NFS_V4_SECURITY_LABEL */
1413 
1414 DECLARE_EVENT_CLASS(nfs4_inode_stateid_event,
1415 		TP_PROTO(
1416 			const struct inode *inode,
1417 			const nfs4_stateid *stateid,
1418 			int error
1419 		),
1420 
1421 		TP_ARGS(inode, stateid, error),
1422 
1423 		TP_STRUCT__entry(
1424 			__field(dev_t, dev)
1425 			__field(u32, fhandle)
1426 			__field(u64, fileid)
1427 			__field(unsigned long, error)
1428 			__field(int, stateid_seq)
1429 			__field(u32, stateid_hash)
1430 		),
1431 
1432 		TP_fast_assign(
1433 			__entry->dev = inode->i_sb->s_dev;
1434 			__entry->fileid = NFS_FILEID(inode);
1435 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1436 			__entry->error = error;
1437 			__entry->stateid_seq =
1438 				be32_to_cpu(stateid->seqid);
1439 			__entry->stateid_hash =
1440 				nfs_stateid_hash(stateid);
1441 		),
1442 
1443 		TP_printk(
1444 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1445 			"stateid=%d:0x%08x",
1446 			-__entry->error,
1447 			show_nfsv4_errors(__entry->error),
1448 			MAJOR(__entry->dev), MINOR(__entry->dev),
1449 			(unsigned long long)__entry->fileid,
1450 			__entry->fhandle,
1451 			__entry->stateid_seq, __entry->stateid_hash
1452 		)
1453 );
1454 
1455 #define DEFINE_NFS4_INODE_STATEID_EVENT(name) \
1456 	DEFINE_EVENT(nfs4_inode_stateid_event, name, \
1457 			TP_PROTO( \
1458 				const struct inode *inode, \
1459 				const nfs4_stateid *stateid, \
1460 				int error \
1461 			), \
1462 			TP_ARGS(inode, stateid, error))
1463 
1464 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_setattr);
1465 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_delegreturn);
1466 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_open_stateid_update);
1467 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_open_stateid_update_wait);
1468 
1469 DECLARE_EVENT_CLASS(nfs4_getattr_event,
1470 		TP_PROTO(
1471 			const struct nfs_server *server,
1472 			const struct nfs_fh *fhandle,
1473 			const struct nfs_fattr *fattr,
1474 			int error
1475 		),
1476 
1477 		TP_ARGS(server, fhandle, fattr, error),
1478 
1479 		TP_STRUCT__entry(
1480 			__field(dev_t, dev)
1481 			__field(u32, fhandle)
1482 			__field(u64, fileid)
1483 			__field(unsigned int, valid)
1484 			__field(unsigned long, error)
1485 		),
1486 
1487 		TP_fast_assign(
1488 			__entry->dev = server->s_dev;
1489 			__entry->valid = fattr->valid;
1490 			__entry->fhandle = nfs_fhandle_hash(fhandle);
1491 			__entry->fileid = (fattr->valid & NFS_ATTR_FATTR_FILEID) ? fattr->fileid : 0;
1492 			__entry->error = error;
1493 		),
1494 
1495 		TP_printk(
1496 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1497 			"valid=%s",
1498 			-__entry->error,
1499 			show_nfsv4_errors(__entry->error),
1500 			MAJOR(__entry->dev), MINOR(__entry->dev),
1501 			(unsigned long long)__entry->fileid,
1502 			__entry->fhandle,
1503 			show_nfs_fattr_flags(__entry->valid)
1504 		)
1505 );
1506 
1507 #define DEFINE_NFS4_GETATTR_EVENT(name) \
1508 	DEFINE_EVENT(nfs4_getattr_event, name, \
1509 			TP_PROTO( \
1510 				const struct nfs_server *server, \
1511 				const struct nfs_fh *fhandle, \
1512 				const struct nfs_fattr *fattr, \
1513 				int error \
1514 			), \
1515 			TP_ARGS(server, fhandle, fattr, error))
1516 DEFINE_NFS4_GETATTR_EVENT(nfs4_getattr);
1517 DEFINE_NFS4_GETATTR_EVENT(nfs4_lookup_root);
1518 DEFINE_NFS4_GETATTR_EVENT(nfs4_fsinfo);
1519 
1520 DECLARE_EVENT_CLASS(nfs4_inode_callback_event,
1521 		TP_PROTO(
1522 			const struct nfs_client *clp,
1523 			const struct nfs_fh *fhandle,
1524 			const struct inode *inode,
1525 			int error
1526 		),
1527 
1528 		TP_ARGS(clp, fhandle, inode, error),
1529 
1530 		TP_STRUCT__entry(
1531 			__field(unsigned long, error)
1532 			__field(dev_t, dev)
1533 			__field(u32, fhandle)
1534 			__field(u64, fileid)
1535 			__string(dstaddr, clp ? clp->cl_hostname : "unknown")
1536 		),
1537 
1538 		TP_fast_assign(
1539 			__entry->error = error;
1540 			__entry->fhandle = nfs_fhandle_hash(fhandle);
1541 			if (!IS_ERR_OR_NULL(inode)) {
1542 				__entry->fileid = NFS_FILEID(inode);
1543 				__entry->dev = inode->i_sb->s_dev;
1544 			} else {
1545 				__entry->fileid = 0;
1546 				__entry->dev = 0;
1547 			}
1548 			__assign_str(dstaddr, clp ? clp->cl_hostname : "unknown")
1549 		),
1550 
1551 		TP_printk(
1552 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1553 			"dstaddr=%s",
1554 			-__entry->error,
1555 			show_nfsv4_errors(__entry->error),
1556 			MAJOR(__entry->dev), MINOR(__entry->dev),
1557 			(unsigned long long)__entry->fileid,
1558 			__entry->fhandle,
1559 			__get_str(dstaddr)
1560 		)
1561 );
1562 
1563 #define DEFINE_NFS4_INODE_CALLBACK_EVENT(name) \
1564 	DEFINE_EVENT(nfs4_inode_callback_event, name, \
1565 			TP_PROTO( \
1566 				const struct nfs_client *clp, \
1567 				const struct nfs_fh *fhandle, \
1568 				const struct inode *inode, \
1569 				int error \
1570 			), \
1571 			TP_ARGS(clp, fhandle, inode, error))
1572 DEFINE_NFS4_INODE_CALLBACK_EVENT(nfs4_cb_getattr);
1573 
1574 DECLARE_EVENT_CLASS(nfs4_inode_stateid_callback_event,
1575 		TP_PROTO(
1576 			const struct nfs_client *clp,
1577 			const struct nfs_fh *fhandle,
1578 			const struct inode *inode,
1579 			const nfs4_stateid *stateid,
1580 			int error
1581 		),
1582 
1583 		TP_ARGS(clp, fhandle, inode, stateid, error),
1584 
1585 		TP_STRUCT__entry(
1586 			__field(unsigned long, error)
1587 			__field(dev_t, dev)
1588 			__field(u32, fhandle)
1589 			__field(u64, fileid)
1590 			__string(dstaddr, clp ? clp->cl_hostname : "unknown")
1591 			__field(int, stateid_seq)
1592 			__field(u32, stateid_hash)
1593 		),
1594 
1595 		TP_fast_assign(
1596 			__entry->error = error;
1597 			__entry->fhandle = nfs_fhandle_hash(fhandle);
1598 			if (!IS_ERR_OR_NULL(inode)) {
1599 				__entry->fileid = NFS_FILEID(inode);
1600 				__entry->dev = inode->i_sb->s_dev;
1601 			} else {
1602 				__entry->fileid = 0;
1603 				__entry->dev = 0;
1604 			}
1605 			__assign_str(dstaddr, clp ? clp->cl_hostname : "unknown")
1606 			__entry->stateid_seq =
1607 				be32_to_cpu(stateid->seqid);
1608 			__entry->stateid_hash =
1609 				nfs_stateid_hash(stateid);
1610 		),
1611 
1612 		TP_printk(
1613 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1614 			"stateid=%d:0x%08x dstaddr=%s",
1615 			-__entry->error,
1616 			show_nfsv4_errors(__entry->error),
1617 			MAJOR(__entry->dev), MINOR(__entry->dev),
1618 			(unsigned long long)__entry->fileid,
1619 			__entry->fhandle,
1620 			__entry->stateid_seq, __entry->stateid_hash,
1621 			__get_str(dstaddr)
1622 		)
1623 );
1624 
1625 #define DEFINE_NFS4_INODE_STATEID_CALLBACK_EVENT(name) \
1626 	DEFINE_EVENT(nfs4_inode_stateid_callback_event, name, \
1627 			TP_PROTO( \
1628 				const struct nfs_client *clp, \
1629 				const struct nfs_fh *fhandle, \
1630 				const struct inode *inode, \
1631 				const nfs4_stateid *stateid, \
1632 				int error \
1633 			), \
1634 			TP_ARGS(clp, fhandle, inode, stateid, error))
1635 DEFINE_NFS4_INODE_STATEID_CALLBACK_EVENT(nfs4_cb_recall);
1636 DEFINE_NFS4_INODE_STATEID_CALLBACK_EVENT(nfs4_cb_layoutrecall_file);
1637 
1638 DECLARE_EVENT_CLASS(nfs4_idmap_event,
1639 		TP_PROTO(
1640 			const char *name,
1641 			int len,
1642 			u32 id,
1643 			int error
1644 		),
1645 
1646 		TP_ARGS(name, len, id, error),
1647 
1648 		TP_STRUCT__entry(
1649 			__field(unsigned long, error)
1650 			__field(u32, id)
1651 			__dynamic_array(char, name, len > 0 ? len + 1 : 1)
1652 		),
1653 
1654 		TP_fast_assign(
1655 			if (len < 0)
1656 				len = 0;
1657 			__entry->error = error < 0 ? error : 0;
1658 			__entry->id = id;
1659 			memcpy(__get_str(name), name, len);
1660 			__get_str(name)[len] = 0;
1661 		),
1662 
1663 		TP_printk(
1664 			"error=%ld (%s) id=%u name=%s",
1665 			-__entry->error, show_nfsv4_errors(__entry->error),
1666 			__entry->id,
1667 			__get_str(name)
1668 		)
1669 );
1670 #define DEFINE_NFS4_IDMAP_EVENT(name) \
1671 	DEFINE_EVENT(nfs4_idmap_event, name, \
1672 			TP_PROTO( \
1673 				const char *name, \
1674 				int len, \
1675 				u32 id, \
1676 				int error \
1677 			), \
1678 			TP_ARGS(name, len, id, error))
1679 DEFINE_NFS4_IDMAP_EVENT(nfs4_map_name_to_uid);
1680 DEFINE_NFS4_IDMAP_EVENT(nfs4_map_group_to_gid);
1681 DEFINE_NFS4_IDMAP_EVENT(nfs4_map_uid_to_name);
1682 DEFINE_NFS4_IDMAP_EVENT(nfs4_map_gid_to_group);
1683 
1684 DECLARE_EVENT_CLASS(nfs4_read_event,
1685 		TP_PROTO(
1686 			const struct nfs_pgio_header *hdr,
1687 			int error
1688 		),
1689 
1690 		TP_ARGS(hdr, error),
1691 
1692 		TP_STRUCT__entry(
1693 			__field(dev_t, dev)
1694 			__field(u32, fhandle)
1695 			__field(u64, fileid)
1696 			__field(loff_t, offset)
1697 			__field(size_t, count)
1698 			__field(unsigned long, error)
1699 			__field(int, stateid_seq)
1700 			__field(u32, stateid_hash)
1701 		),
1702 
1703 		TP_fast_assign(
1704 			const struct inode *inode = hdr->inode;
1705 			const struct nfs4_state *state =
1706 				hdr->args.context->state;
1707 			__entry->dev = inode->i_sb->s_dev;
1708 			__entry->fileid = NFS_FILEID(inode);
1709 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1710 			__entry->offset = hdr->args.offset;
1711 			__entry->count = hdr->args.count;
1712 			__entry->error = error < 0 ? -error : 0;
1713 			__entry->stateid_seq =
1714 				be32_to_cpu(state->stateid.seqid);
1715 			__entry->stateid_hash =
1716 				nfs_stateid_hash(&state->stateid);
1717 		),
1718 
1719 		TP_printk(
1720 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1721 			"offset=%lld count=%zu stateid=%d:0x%08x",
1722 			-__entry->error,
1723 			show_nfsv4_errors(__entry->error),
1724 			MAJOR(__entry->dev), MINOR(__entry->dev),
1725 			(unsigned long long)__entry->fileid,
1726 			__entry->fhandle,
1727 			(long long)__entry->offset,
1728 			__entry->count,
1729 			__entry->stateid_seq, __entry->stateid_hash
1730 		)
1731 );
1732 #define DEFINE_NFS4_READ_EVENT(name) \
1733 	DEFINE_EVENT(nfs4_read_event, name, \
1734 			TP_PROTO( \
1735 				const struct nfs_pgio_header *hdr, \
1736 				int error \
1737 			), \
1738 			TP_ARGS(hdr, error))
1739 DEFINE_NFS4_READ_EVENT(nfs4_read);
1740 #ifdef CONFIG_NFS_V4_1
1741 DEFINE_NFS4_READ_EVENT(nfs4_pnfs_read);
1742 #endif /* CONFIG_NFS_V4_1 */
1743 
1744 DECLARE_EVENT_CLASS(nfs4_write_event,
1745 		TP_PROTO(
1746 			const struct nfs_pgio_header *hdr,
1747 			int error
1748 		),
1749 
1750 		TP_ARGS(hdr, error),
1751 
1752 		TP_STRUCT__entry(
1753 			__field(dev_t, dev)
1754 			__field(u32, fhandle)
1755 			__field(u64, fileid)
1756 			__field(loff_t, offset)
1757 			__field(size_t, count)
1758 			__field(unsigned long, error)
1759 			__field(int, stateid_seq)
1760 			__field(u32, stateid_hash)
1761 		),
1762 
1763 		TP_fast_assign(
1764 			const struct inode *inode = hdr->inode;
1765 			const struct nfs4_state *state =
1766 				hdr->args.context->state;
1767 			__entry->dev = inode->i_sb->s_dev;
1768 			__entry->fileid = NFS_FILEID(inode);
1769 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1770 			__entry->offset = hdr->args.offset;
1771 			__entry->count = hdr->args.count;
1772 			__entry->error = error < 0 ? -error : 0;
1773 			__entry->stateid_seq =
1774 				be32_to_cpu(state->stateid.seqid);
1775 			__entry->stateid_hash =
1776 				nfs_stateid_hash(&state->stateid);
1777 		),
1778 
1779 		TP_printk(
1780 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1781 			"offset=%lld count=%zu stateid=%d:0x%08x",
1782 			-__entry->error,
1783 			show_nfsv4_errors(__entry->error),
1784 			MAJOR(__entry->dev), MINOR(__entry->dev),
1785 			(unsigned long long)__entry->fileid,
1786 			__entry->fhandle,
1787 			(long long)__entry->offset,
1788 			__entry->count,
1789 			__entry->stateid_seq, __entry->stateid_hash
1790 		)
1791 );
1792 
1793 #define DEFINE_NFS4_WRITE_EVENT(name) \
1794 	DEFINE_EVENT(nfs4_write_event, name, \
1795 			TP_PROTO( \
1796 				const struct nfs_pgio_header *hdr, \
1797 				int error \
1798 			), \
1799 			TP_ARGS(hdr, error))
1800 DEFINE_NFS4_WRITE_EVENT(nfs4_write);
1801 #ifdef CONFIG_NFS_V4_1
1802 DEFINE_NFS4_WRITE_EVENT(nfs4_pnfs_write);
1803 #endif /* CONFIG_NFS_V4_1 */
1804 
1805 DECLARE_EVENT_CLASS(nfs4_commit_event,
1806 		TP_PROTO(
1807 			const struct nfs_commit_data *data,
1808 			int error
1809 		),
1810 
1811 		TP_ARGS(data, error),
1812 
1813 		TP_STRUCT__entry(
1814 			__field(dev_t, dev)
1815 			__field(u32, fhandle)
1816 			__field(u64, fileid)
1817 			__field(loff_t, offset)
1818 			__field(size_t, count)
1819 			__field(unsigned long, error)
1820 		),
1821 
1822 		TP_fast_assign(
1823 			const struct inode *inode = data->inode;
1824 			__entry->dev = inode->i_sb->s_dev;
1825 			__entry->fileid = NFS_FILEID(inode);
1826 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1827 			__entry->offset = data->args.offset;
1828 			__entry->count = data->args.count;
1829 			__entry->error = error;
1830 		),
1831 
1832 		TP_printk(
1833 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1834 			"offset=%lld count=%zu",
1835 			-__entry->error,
1836 			show_nfsv4_errors(__entry->error),
1837 			MAJOR(__entry->dev), MINOR(__entry->dev),
1838 			(unsigned long long)__entry->fileid,
1839 			__entry->fhandle,
1840 			(long long)__entry->offset,
1841 			__entry->count
1842 		)
1843 );
1844 #define DEFINE_NFS4_COMMIT_EVENT(name) \
1845 	DEFINE_EVENT(nfs4_commit_event, name, \
1846 			TP_PROTO( \
1847 				const struct nfs_commit_data *data, \
1848 				int error \
1849 			), \
1850 			TP_ARGS(data, error))
1851 DEFINE_NFS4_COMMIT_EVENT(nfs4_commit);
1852 #ifdef CONFIG_NFS_V4_1
1853 DEFINE_NFS4_COMMIT_EVENT(nfs4_pnfs_commit_ds);
1854 
1855 TRACE_DEFINE_ENUM(IOMODE_READ);
1856 TRACE_DEFINE_ENUM(IOMODE_RW);
1857 TRACE_DEFINE_ENUM(IOMODE_ANY);
1858 
1859 #define show_pnfs_iomode(iomode) \
1860 	__print_symbolic(iomode, \
1861 		{ IOMODE_READ, "READ" }, \
1862 		{ IOMODE_RW, "RW" }, \
1863 		{ IOMODE_ANY, "ANY" })
1864 
1865 TRACE_EVENT(nfs4_layoutget,
1866 		TP_PROTO(
1867 			const struct nfs_open_context *ctx,
1868 			const struct pnfs_layout_range *args,
1869 			const struct pnfs_layout_range *res,
1870 			const nfs4_stateid *layout_stateid,
1871 			int error
1872 		),
1873 
1874 		TP_ARGS(ctx, args, res, layout_stateid, error),
1875 
1876 		TP_STRUCT__entry(
1877 			__field(dev_t, dev)
1878 			__field(u32, fhandle)
1879 			__field(u64, fileid)
1880 			__field(u32, iomode)
1881 			__field(u64, offset)
1882 			__field(u64, count)
1883 			__field(unsigned long, error)
1884 			__field(int, stateid_seq)
1885 			__field(u32, stateid_hash)
1886 			__field(int, layoutstateid_seq)
1887 			__field(u32, layoutstateid_hash)
1888 		),
1889 
1890 		TP_fast_assign(
1891 			const struct inode *inode = d_inode(ctx->dentry);
1892 			const struct nfs4_state *state = ctx->state;
1893 			__entry->dev = inode->i_sb->s_dev;
1894 			__entry->fileid = NFS_FILEID(inode);
1895 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1896 			__entry->iomode = args->iomode;
1897 			__entry->offset = args->offset;
1898 			__entry->count = args->length;
1899 			__entry->error = error;
1900 			__entry->stateid_seq =
1901 				be32_to_cpu(state->stateid.seqid);
1902 			__entry->stateid_hash =
1903 				nfs_stateid_hash(&state->stateid);
1904 			if (!error) {
1905 				__entry->layoutstateid_seq =
1906 				be32_to_cpu(layout_stateid->seqid);
1907 				__entry->layoutstateid_hash =
1908 				nfs_stateid_hash(layout_stateid);
1909 			} else {
1910 				__entry->layoutstateid_seq = 0;
1911 				__entry->layoutstateid_hash = 0;
1912 			}
1913 		),
1914 
1915 		TP_printk(
1916 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1917 			"iomode=%s offset=%llu count=%llu stateid=%d:0x%08x "
1918 			"layoutstateid=%d:0x%08x",
1919 			-__entry->error,
1920 			show_nfsv4_errors(__entry->error),
1921 			MAJOR(__entry->dev), MINOR(__entry->dev),
1922 			(unsigned long long)__entry->fileid,
1923 			__entry->fhandle,
1924 			show_pnfs_iomode(__entry->iomode),
1925 			(unsigned long long)__entry->offset,
1926 			(unsigned long long)__entry->count,
1927 			__entry->stateid_seq, __entry->stateid_hash,
1928 			__entry->layoutstateid_seq, __entry->layoutstateid_hash
1929 		)
1930 );
1931 
1932 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layoutcommit);
1933 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layoutreturn);
1934 DEFINE_NFS4_INODE_EVENT(nfs4_layoutreturn_on_close);
1935 
1936 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_UNKNOWN);
1937 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_NO_PNFS);
1938 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_RD_ZEROLEN);
1939 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_MDSTHRESH);
1940 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_NOMEM);
1941 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_BULK_RECALL);
1942 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_IO_TEST_FAIL);
1943 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_FOUND_CACHED);
1944 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_RETURN);
1945 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_BLOCKED);
1946 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_INVALID_OPEN);
1947 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_RETRY);
1948 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_SEND_LAYOUTGET);
1949 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_EXIT);
1950 
1951 #define show_pnfs_update_layout_reason(reason)				\
1952 	__print_symbolic(reason,					\
1953 		{ PNFS_UPDATE_LAYOUT_UNKNOWN, "unknown" },		\
1954 		{ PNFS_UPDATE_LAYOUT_NO_PNFS, "no pnfs" },		\
1955 		{ PNFS_UPDATE_LAYOUT_RD_ZEROLEN, "read+zerolen" },	\
1956 		{ PNFS_UPDATE_LAYOUT_MDSTHRESH, "mdsthresh" },		\
1957 		{ PNFS_UPDATE_LAYOUT_NOMEM, "nomem" },			\
1958 		{ PNFS_UPDATE_LAYOUT_BULK_RECALL, "bulk recall" },	\
1959 		{ PNFS_UPDATE_LAYOUT_IO_TEST_FAIL, "io test fail" },	\
1960 		{ PNFS_UPDATE_LAYOUT_FOUND_CACHED, "found cached" },	\
1961 		{ PNFS_UPDATE_LAYOUT_RETURN, "layoutreturn" },		\
1962 		{ PNFS_UPDATE_LAYOUT_BLOCKED, "layouts blocked" },	\
1963 		{ PNFS_UPDATE_LAYOUT_INVALID_OPEN, "invalid open" },	\
1964 		{ PNFS_UPDATE_LAYOUT_RETRY, "retrying" },	\
1965 		{ PNFS_UPDATE_LAYOUT_SEND_LAYOUTGET, "sent layoutget" }, \
1966 		{ PNFS_UPDATE_LAYOUT_EXIT, "exit" })
1967 
1968 TRACE_EVENT(pnfs_update_layout,
1969 		TP_PROTO(struct inode *inode,
1970 			loff_t pos,
1971 			u64 count,
1972 			enum pnfs_iomode iomode,
1973 			struct pnfs_layout_hdr *lo,
1974 			struct pnfs_layout_segment *lseg,
1975 			enum pnfs_update_layout_reason reason
1976 		),
1977 		TP_ARGS(inode, pos, count, iomode, lo, lseg, reason),
1978 		TP_STRUCT__entry(
1979 			__field(dev_t, dev)
1980 			__field(u64, fileid)
1981 			__field(u32, fhandle)
1982 			__field(loff_t, pos)
1983 			__field(u64, count)
1984 			__field(enum pnfs_iomode, iomode)
1985 			__field(int, layoutstateid_seq)
1986 			__field(u32, layoutstateid_hash)
1987 			__field(long, lseg)
1988 			__field(enum pnfs_update_layout_reason, reason)
1989 		),
1990 		TP_fast_assign(
1991 			__entry->dev = inode->i_sb->s_dev;
1992 			__entry->fileid = NFS_FILEID(inode);
1993 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1994 			__entry->pos = pos;
1995 			__entry->count = count;
1996 			__entry->iomode = iomode;
1997 			__entry->reason = reason;
1998 			if (lo != NULL) {
1999 				__entry->layoutstateid_seq =
2000 				be32_to_cpu(lo->plh_stateid.seqid);
2001 				__entry->layoutstateid_hash =
2002 				nfs_stateid_hash(&lo->plh_stateid);
2003 			} else {
2004 				__entry->layoutstateid_seq = 0;
2005 				__entry->layoutstateid_hash = 0;
2006 			}
2007 			__entry->lseg = (long)lseg;
2008 		),
2009 		TP_printk(
2010 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
2011 			"iomode=%s pos=%llu count=%llu "
2012 			"layoutstateid=%d:0x%08x lseg=0x%lx (%s)",
2013 			MAJOR(__entry->dev), MINOR(__entry->dev),
2014 			(unsigned long long)__entry->fileid,
2015 			__entry->fhandle,
2016 			show_pnfs_iomode(__entry->iomode),
2017 			(unsigned long long)__entry->pos,
2018 			(unsigned long long)__entry->count,
2019 			__entry->layoutstateid_seq, __entry->layoutstateid_hash,
2020 			__entry->lseg,
2021 			show_pnfs_update_layout_reason(__entry->reason)
2022 		)
2023 );
2024 
2025 DECLARE_EVENT_CLASS(pnfs_layout_event,
2026 		TP_PROTO(struct inode *inode,
2027 			loff_t pos,
2028 			u64 count,
2029 			enum pnfs_iomode iomode,
2030 			struct pnfs_layout_hdr *lo,
2031 			struct pnfs_layout_segment *lseg
2032 		),
2033 		TP_ARGS(inode, pos, count, iomode, lo, lseg),
2034 		TP_STRUCT__entry(
2035 			__field(dev_t, dev)
2036 			__field(u64, fileid)
2037 			__field(u32, fhandle)
2038 			__field(loff_t, pos)
2039 			__field(u64, count)
2040 			__field(enum pnfs_iomode, iomode)
2041 			__field(int, layoutstateid_seq)
2042 			__field(u32, layoutstateid_hash)
2043 			__field(long, lseg)
2044 		),
2045 		TP_fast_assign(
2046 			__entry->dev = inode->i_sb->s_dev;
2047 			__entry->fileid = NFS_FILEID(inode);
2048 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
2049 			__entry->pos = pos;
2050 			__entry->count = count;
2051 			__entry->iomode = iomode;
2052 			if (lo != NULL) {
2053 				__entry->layoutstateid_seq =
2054 				be32_to_cpu(lo->plh_stateid.seqid);
2055 				__entry->layoutstateid_hash =
2056 				nfs_stateid_hash(&lo->plh_stateid);
2057 			} else {
2058 				__entry->layoutstateid_seq = 0;
2059 				__entry->layoutstateid_hash = 0;
2060 			}
2061 			__entry->lseg = (long)lseg;
2062 		),
2063 		TP_printk(
2064 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
2065 			"iomode=%s pos=%llu count=%llu "
2066 			"layoutstateid=%d:0x%08x lseg=0x%lx",
2067 			MAJOR(__entry->dev), MINOR(__entry->dev),
2068 			(unsigned long long)__entry->fileid,
2069 			__entry->fhandle,
2070 			show_pnfs_iomode(__entry->iomode),
2071 			(unsigned long long)__entry->pos,
2072 			(unsigned long long)__entry->count,
2073 			__entry->layoutstateid_seq, __entry->layoutstateid_hash,
2074 			__entry->lseg
2075 		)
2076 );
2077 
2078 #define DEFINE_PNFS_LAYOUT_EVENT(name) \
2079 	DEFINE_EVENT(pnfs_layout_event, name, \
2080 		TP_PROTO(struct inode *inode, \
2081 			loff_t pos, \
2082 			u64 count, \
2083 			enum pnfs_iomode iomode, \
2084 			struct pnfs_layout_hdr *lo, \
2085 			struct pnfs_layout_segment *lseg \
2086 		), \
2087 		TP_ARGS(inode, pos, count, iomode, lo, lseg))
2088 
2089 DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_pg_init_read);
2090 DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_pg_init_write);
2091 DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_pg_get_mirror_count);
2092 DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_read_done);
2093 DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_write_done);
2094 DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_read_pagelist);
2095 DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_write_pagelist);
2096 
2097 #endif /* CONFIG_NFS_V4_1 */
2098 
2099 #endif /* _TRACE_NFS4_H */
2100 
2101 #undef TRACE_INCLUDE_PATH
2102 #define TRACE_INCLUDE_PATH .
2103 #define TRACE_INCLUDE_FILE nfs4trace
2104 /* This part must be outside protection */
2105 #include <trace/define_trace.h>
2106