xref: /openbmc/linux/fs/nfs/nfs4trace.h (revision 323dd2c3)
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_EVENT(nfs4_xdr_status,
566 		TP_PROTO(
567 			const struct xdr_stream *xdr,
568 			u32 op,
569 			int error
570 		),
571 
572 		TP_ARGS(xdr, op, error),
573 
574 		TP_STRUCT__entry(
575 			__field(unsigned int, task_id)
576 			__field(unsigned int, client_id)
577 			__field(u32, xid)
578 			__field(u32, op)
579 			__field(unsigned long, error)
580 		),
581 
582 		TP_fast_assign(
583 			const struct rpc_rqst *rqstp = xdr->rqst;
584 			const struct rpc_task *task = rqstp->rq_task;
585 
586 			__entry->task_id = task->tk_pid;
587 			__entry->client_id = task->tk_client->cl_clid;
588 			__entry->xid = be32_to_cpu(rqstp->rq_xid);
589 			__entry->op = op;
590 			__entry->error = error;
591 		),
592 
593 		TP_printk(
594 			"task:%u@%d xid=0x%08x error=%ld (%s) operation=%u",
595 			__entry->task_id, __entry->client_id, __entry->xid,
596 			-__entry->error, show_nfsv4_errors(__entry->error),
597 			__entry->op
598 		)
599 );
600 
601 DECLARE_EVENT_CLASS(nfs4_open_event,
602 		TP_PROTO(
603 			const struct nfs_open_context *ctx,
604 			int flags,
605 			int error
606 		),
607 
608 		TP_ARGS(ctx, flags, error),
609 
610 		TP_STRUCT__entry(
611 			__field(unsigned long, error)
612 			__field(unsigned int, flags)
613 			__field(unsigned int, fmode)
614 			__field(dev_t, dev)
615 			__field(u32, fhandle)
616 			__field(u64, fileid)
617 			__field(u64, dir)
618 			__string(name, ctx->dentry->d_name.name)
619 			__field(int, stateid_seq)
620 			__field(u32, stateid_hash)
621 			__field(int, openstateid_seq)
622 			__field(u32, openstateid_hash)
623 		),
624 
625 		TP_fast_assign(
626 			const struct nfs4_state *state = ctx->state;
627 			const struct inode *inode = NULL;
628 
629 			__entry->error = -error;
630 			__entry->flags = flags;
631 			__entry->fmode = (__force unsigned int)ctx->mode;
632 			__entry->dev = ctx->dentry->d_sb->s_dev;
633 			if (!IS_ERR_OR_NULL(state)) {
634 				inode = state->inode;
635 				__entry->stateid_seq =
636 					be32_to_cpu(state->stateid.seqid);
637 				__entry->stateid_hash =
638 					nfs_stateid_hash(&state->stateid);
639 				__entry->openstateid_seq =
640 					be32_to_cpu(state->open_stateid.seqid);
641 				__entry->openstateid_hash =
642 					nfs_stateid_hash(&state->open_stateid);
643 			} else {
644 				__entry->stateid_seq = 0;
645 				__entry->stateid_hash = 0;
646 				__entry->openstateid_seq = 0;
647 				__entry->openstateid_hash = 0;
648 			}
649 			if (inode != NULL) {
650 				__entry->fileid = NFS_FILEID(inode);
651 				__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
652 			} else {
653 				__entry->fileid = 0;
654 				__entry->fhandle = 0;
655 			}
656 			__entry->dir = NFS_FILEID(d_inode(ctx->dentry->d_parent));
657 			__assign_str(name, ctx->dentry->d_name.name);
658 		),
659 
660 		TP_printk(
661 			"error=%ld (%s) flags=%d (%s) fmode=%s "
662 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
663 			"name=%02x:%02x:%llu/%s stateid=%d:0x%08x "
664 			"openstateid=%d:0x%08x",
665 			 -__entry->error,
666 			 show_nfsv4_errors(__entry->error),
667 			 __entry->flags,
668 			 show_open_flags(__entry->flags),
669 			 show_fmode_flags(__entry->fmode),
670 			 MAJOR(__entry->dev), MINOR(__entry->dev),
671 			 (unsigned long long)__entry->fileid,
672 			 __entry->fhandle,
673 			 MAJOR(__entry->dev), MINOR(__entry->dev),
674 			 (unsigned long long)__entry->dir,
675 			 __get_str(name),
676 			 __entry->stateid_seq, __entry->stateid_hash,
677 			 __entry->openstateid_seq, __entry->openstateid_hash
678 		)
679 );
680 
681 #define DEFINE_NFS4_OPEN_EVENT(name) \
682 	DEFINE_EVENT(nfs4_open_event, name, \
683 			TP_PROTO( \
684 				const struct nfs_open_context *ctx, \
685 				int flags, \
686 				int error \
687 			), \
688 			TP_ARGS(ctx, flags, error))
689 DEFINE_NFS4_OPEN_EVENT(nfs4_open_reclaim);
690 DEFINE_NFS4_OPEN_EVENT(nfs4_open_expired);
691 DEFINE_NFS4_OPEN_EVENT(nfs4_open_file);
692 
693 TRACE_EVENT(nfs4_cached_open,
694 		TP_PROTO(
695 			const struct nfs4_state *state
696 		),
697 		TP_ARGS(state),
698 		TP_STRUCT__entry(
699 			__field(dev_t, dev)
700 			__field(u32, fhandle)
701 			__field(u64, fileid)
702 			__field(unsigned int, fmode)
703 			__field(int, stateid_seq)
704 			__field(u32, stateid_hash)
705 		),
706 
707 		TP_fast_assign(
708 			const struct inode *inode = state->inode;
709 
710 			__entry->dev = inode->i_sb->s_dev;
711 			__entry->fileid = NFS_FILEID(inode);
712 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
713 			__entry->fmode = (__force unsigned int)state->state;
714 			__entry->stateid_seq =
715 				be32_to_cpu(state->stateid.seqid);
716 			__entry->stateid_hash =
717 				nfs_stateid_hash(&state->stateid);
718 		),
719 
720 		TP_printk(
721 			"fmode=%s fileid=%02x:%02x:%llu "
722 			"fhandle=0x%08x stateid=%d:0x%08x",
723 			__entry->fmode ?  show_fmode_flags(__entry->fmode) :
724 					  "closed",
725 			MAJOR(__entry->dev), MINOR(__entry->dev),
726 			(unsigned long long)__entry->fileid,
727 			__entry->fhandle,
728 			__entry->stateid_seq, __entry->stateid_hash
729 		)
730 );
731 
732 TRACE_EVENT(nfs4_close,
733 		TP_PROTO(
734 			const struct nfs4_state *state,
735 			const struct nfs_closeargs *args,
736 			const struct nfs_closeres *res,
737 			int error
738 		),
739 
740 		TP_ARGS(state, args, res, error),
741 
742 		TP_STRUCT__entry(
743 			__field(dev_t, dev)
744 			__field(u32, fhandle)
745 			__field(u64, fileid)
746 			__field(unsigned int, fmode)
747 			__field(unsigned long, error)
748 			__field(int, stateid_seq)
749 			__field(u32, stateid_hash)
750 		),
751 
752 		TP_fast_assign(
753 			const struct inode *inode = state->inode;
754 
755 			__entry->dev = inode->i_sb->s_dev;
756 			__entry->fileid = NFS_FILEID(inode);
757 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
758 			__entry->fmode = (__force unsigned int)state->state;
759 			__entry->error = error;
760 			__entry->stateid_seq =
761 				be32_to_cpu(args->stateid.seqid);
762 			__entry->stateid_hash =
763 				nfs_stateid_hash(&args->stateid);
764 		),
765 
766 		TP_printk(
767 			"error=%ld (%s) fmode=%s fileid=%02x:%02x:%llu "
768 			"fhandle=0x%08x openstateid=%d:0x%08x",
769 			-__entry->error,
770 			show_nfsv4_errors(__entry->error),
771 			__entry->fmode ?  show_fmode_flags(__entry->fmode) :
772 					  "closed",
773 			MAJOR(__entry->dev), MINOR(__entry->dev),
774 			(unsigned long long)__entry->fileid,
775 			__entry->fhandle,
776 			__entry->stateid_seq, __entry->stateid_hash
777 		)
778 );
779 
780 TRACE_DEFINE_ENUM(F_GETLK);
781 TRACE_DEFINE_ENUM(F_SETLK);
782 TRACE_DEFINE_ENUM(F_SETLKW);
783 TRACE_DEFINE_ENUM(F_RDLCK);
784 TRACE_DEFINE_ENUM(F_WRLCK);
785 TRACE_DEFINE_ENUM(F_UNLCK);
786 
787 #define show_lock_cmd(type) \
788 	__print_symbolic((int)type, \
789 		{ F_GETLK, "GETLK" }, \
790 		{ F_SETLK, "SETLK" }, \
791 		{ F_SETLKW, "SETLKW" })
792 #define show_lock_type(type) \
793 	__print_symbolic((int)type, \
794 		{ F_RDLCK, "RDLCK" }, \
795 		{ F_WRLCK, "WRLCK" }, \
796 		{ F_UNLCK, "UNLCK" })
797 
798 DECLARE_EVENT_CLASS(nfs4_lock_event,
799 		TP_PROTO(
800 			const struct file_lock *request,
801 			const struct nfs4_state *state,
802 			int cmd,
803 			int error
804 		),
805 
806 		TP_ARGS(request, state, cmd, error),
807 
808 		TP_STRUCT__entry(
809 			__field(unsigned long, error)
810 			__field(int, cmd)
811 			__field(char, type)
812 			__field(loff_t, start)
813 			__field(loff_t, end)
814 			__field(dev_t, dev)
815 			__field(u32, fhandle)
816 			__field(u64, fileid)
817 			__field(int, stateid_seq)
818 			__field(u32, stateid_hash)
819 		),
820 
821 		TP_fast_assign(
822 			const struct inode *inode = state->inode;
823 
824 			__entry->error = error;
825 			__entry->cmd = cmd;
826 			__entry->type = request->fl_type;
827 			__entry->start = request->fl_start;
828 			__entry->end = request->fl_end;
829 			__entry->dev = inode->i_sb->s_dev;
830 			__entry->fileid = NFS_FILEID(inode);
831 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
832 			__entry->stateid_seq =
833 				be32_to_cpu(state->stateid.seqid);
834 			__entry->stateid_hash =
835 				nfs_stateid_hash(&state->stateid);
836 		),
837 
838 		TP_printk(
839 			"error=%ld (%s) cmd=%s:%s range=%lld:%lld "
840 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
841 			"stateid=%d:0x%08x",
842 			-__entry->error,
843 			show_nfsv4_errors(__entry->error),
844 			show_lock_cmd(__entry->cmd),
845 			show_lock_type(__entry->type),
846 			(long long)__entry->start,
847 			(long long)__entry->end,
848 			MAJOR(__entry->dev), MINOR(__entry->dev),
849 			(unsigned long long)__entry->fileid,
850 			__entry->fhandle,
851 			__entry->stateid_seq, __entry->stateid_hash
852 		)
853 );
854 
855 #define DEFINE_NFS4_LOCK_EVENT(name) \
856 	DEFINE_EVENT(nfs4_lock_event, name, \
857 			TP_PROTO( \
858 				const struct file_lock *request, \
859 				const struct nfs4_state *state, \
860 				int cmd, \
861 				int error \
862 			), \
863 			TP_ARGS(request, state, cmd, error))
864 DEFINE_NFS4_LOCK_EVENT(nfs4_get_lock);
865 DEFINE_NFS4_LOCK_EVENT(nfs4_unlock);
866 
867 TRACE_EVENT(nfs4_set_lock,
868 		TP_PROTO(
869 			const struct file_lock *request,
870 			const struct nfs4_state *state,
871 			const nfs4_stateid *lockstateid,
872 			int cmd,
873 			int error
874 		),
875 
876 		TP_ARGS(request, state, lockstateid, cmd, error),
877 
878 		TP_STRUCT__entry(
879 			__field(unsigned long, error)
880 			__field(int, cmd)
881 			__field(char, type)
882 			__field(loff_t, start)
883 			__field(loff_t, end)
884 			__field(dev_t, dev)
885 			__field(u32, fhandle)
886 			__field(u64, fileid)
887 			__field(int, stateid_seq)
888 			__field(u32, stateid_hash)
889 			__field(int, lockstateid_seq)
890 			__field(u32, lockstateid_hash)
891 		),
892 
893 		TP_fast_assign(
894 			const struct inode *inode = state->inode;
895 
896 			__entry->error = error;
897 			__entry->cmd = cmd;
898 			__entry->type = request->fl_type;
899 			__entry->start = request->fl_start;
900 			__entry->end = request->fl_end;
901 			__entry->dev = inode->i_sb->s_dev;
902 			__entry->fileid = NFS_FILEID(inode);
903 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
904 			__entry->stateid_seq =
905 				be32_to_cpu(state->stateid.seqid);
906 			__entry->stateid_hash =
907 				nfs_stateid_hash(&state->stateid);
908 			__entry->lockstateid_seq =
909 				be32_to_cpu(lockstateid->seqid);
910 			__entry->lockstateid_hash =
911 				nfs_stateid_hash(lockstateid);
912 		),
913 
914 		TP_printk(
915 			"error=%ld (%s) cmd=%s:%s range=%lld:%lld "
916 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
917 			"stateid=%d:0x%08x lockstateid=%d:0x%08x",
918 			-__entry->error,
919 			show_nfsv4_errors(__entry->error),
920 			show_lock_cmd(__entry->cmd),
921 			show_lock_type(__entry->type),
922 			(long long)__entry->start,
923 			(long long)__entry->end,
924 			MAJOR(__entry->dev), MINOR(__entry->dev),
925 			(unsigned long long)__entry->fileid,
926 			__entry->fhandle,
927 			__entry->stateid_seq, __entry->stateid_hash,
928 			__entry->lockstateid_seq, __entry->lockstateid_hash
929 		)
930 );
931 
932 DECLARE_EVENT_CLASS(nfs4_set_delegation_event,
933 		TP_PROTO(
934 			const struct inode *inode,
935 			fmode_t fmode
936 		),
937 
938 		TP_ARGS(inode, fmode),
939 
940 		TP_STRUCT__entry(
941 			__field(dev_t, dev)
942 			__field(u32, fhandle)
943 			__field(u64, fileid)
944 			__field(unsigned int, fmode)
945 		),
946 
947 		TP_fast_assign(
948 			__entry->dev = inode->i_sb->s_dev;
949 			__entry->fileid = NFS_FILEID(inode);
950 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
951 			__entry->fmode = (__force unsigned int)fmode;
952 		),
953 
954 		TP_printk(
955 			"fmode=%s fileid=%02x:%02x:%llu fhandle=0x%08x",
956 			show_fmode_flags(__entry->fmode),
957 			MAJOR(__entry->dev), MINOR(__entry->dev),
958 			(unsigned long long)__entry->fileid,
959 			__entry->fhandle
960 		)
961 );
962 #define DEFINE_NFS4_SET_DELEGATION_EVENT(name) \
963 	DEFINE_EVENT(nfs4_set_delegation_event, name, \
964 			TP_PROTO( \
965 				const struct inode *inode, \
966 				fmode_t fmode \
967 			), \
968 			TP_ARGS(inode, fmode))
969 DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_set_delegation);
970 DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_reclaim_delegation);
971 
972 TRACE_EVENT(nfs4_delegreturn_exit,
973 		TP_PROTO(
974 			const struct nfs4_delegreturnargs *args,
975 			const struct nfs4_delegreturnres *res,
976 			int error
977 		),
978 
979 		TP_ARGS(args, res, error),
980 
981 		TP_STRUCT__entry(
982 			__field(dev_t, dev)
983 			__field(u32, fhandle)
984 			__field(unsigned long, error)
985 			__field(int, stateid_seq)
986 			__field(u32, stateid_hash)
987 		),
988 
989 		TP_fast_assign(
990 			__entry->dev = res->server->s_dev;
991 			__entry->fhandle = nfs_fhandle_hash(args->fhandle);
992 			__entry->error = error;
993 			__entry->stateid_seq =
994 				be32_to_cpu(args->stateid->seqid);
995 			__entry->stateid_hash =
996 				nfs_stateid_hash(args->stateid);
997 		),
998 
999 		TP_printk(
1000 			"error=%ld (%s) dev=%02x:%02x fhandle=0x%08x "
1001 			"stateid=%d:0x%08x",
1002 			-__entry->error,
1003 			show_nfsv4_errors(__entry->error),
1004 			MAJOR(__entry->dev), MINOR(__entry->dev),
1005 			__entry->fhandle,
1006 			__entry->stateid_seq, __entry->stateid_hash
1007 		)
1008 );
1009 
1010 #ifdef CONFIG_NFS_V4_1
1011 DECLARE_EVENT_CLASS(nfs4_test_stateid_event,
1012 		TP_PROTO(
1013 			const struct nfs4_state *state,
1014 			const struct nfs4_lock_state *lsp,
1015 			int error
1016 		),
1017 
1018 		TP_ARGS(state, lsp, error),
1019 
1020 		TP_STRUCT__entry(
1021 			__field(unsigned long, error)
1022 			__field(dev_t, dev)
1023 			__field(u32, fhandle)
1024 			__field(u64, fileid)
1025 			__field(int, stateid_seq)
1026 			__field(u32, stateid_hash)
1027 		),
1028 
1029 		TP_fast_assign(
1030 			const struct inode *inode = state->inode;
1031 
1032 			__entry->error = error;
1033 			__entry->dev = inode->i_sb->s_dev;
1034 			__entry->fileid = NFS_FILEID(inode);
1035 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1036 			__entry->stateid_seq =
1037 				be32_to_cpu(state->stateid.seqid);
1038 			__entry->stateid_hash =
1039 				nfs_stateid_hash(&state->stateid);
1040 		),
1041 
1042 		TP_printk(
1043 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1044 			"stateid=%d:0x%08x",
1045 			-__entry->error,
1046 			show_nfsv4_errors(__entry->error),
1047 			MAJOR(__entry->dev), MINOR(__entry->dev),
1048 			(unsigned long long)__entry->fileid,
1049 			__entry->fhandle,
1050 			__entry->stateid_seq, __entry->stateid_hash
1051 		)
1052 );
1053 
1054 #define DEFINE_NFS4_TEST_STATEID_EVENT(name) \
1055 	DEFINE_EVENT(nfs4_test_stateid_event, name, \
1056 			TP_PROTO( \
1057 				const struct nfs4_state *state, \
1058 				const struct nfs4_lock_state *lsp, \
1059 				int error \
1060 			), \
1061 			TP_ARGS(state, lsp, error))
1062 DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_delegation_stateid);
1063 DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_open_stateid);
1064 DEFINE_NFS4_TEST_STATEID_EVENT(nfs4_test_lock_stateid);
1065 #endif /* CONFIG_NFS_V4_1 */
1066 
1067 DECLARE_EVENT_CLASS(nfs4_lookup_event,
1068 		TP_PROTO(
1069 			const struct inode *dir,
1070 			const struct qstr *name,
1071 			int error
1072 		),
1073 
1074 		TP_ARGS(dir, name, error),
1075 
1076 		TP_STRUCT__entry(
1077 			__field(dev_t, dev)
1078 			__field(unsigned long, error)
1079 			__field(u64, dir)
1080 			__string(name, name->name)
1081 		),
1082 
1083 		TP_fast_assign(
1084 			__entry->dev = dir->i_sb->s_dev;
1085 			__entry->dir = NFS_FILEID(dir);
1086 			__entry->error = -error;
1087 			__assign_str(name, name->name);
1088 		),
1089 
1090 		TP_printk(
1091 			"error=%ld (%s) name=%02x:%02x:%llu/%s",
1092 			-__entry->error,
1093 			show_nfsv4_errors(__entry->error),
1094 			MAJOR(__entry->dev), MINOR(__entry->dev),
1095 			(unsigned long long)__entry->dir,
1096 			__get_str(name)
1097 		)
1098 );
1099 
1100 #define DEFINE_NFS4_LOOKUP_EVENT(name) \
1101 	DEFINE_EVENT(nfs4_lookup_event, name, \
1102 			TP_PROTO( \
1103 				const struct inode *dir, \
1104 				const struct qstr *name, \
1105 				int error \
1106 			), \
1107 			TP_ARGS(dir, name, error))
1108 
1109 DEFINE_NFS4_LOOKUP_EVENT(nfs4_lookup);
1110 DEFINE_NFS4_LOOKUP_EVENT(nfs4_symlink);
1111 DEFINE_NFS4_LOOKUP_EVENT(nfs4_mkdir);
1112 DEFINE_NFS4_LOOKUP_EVENT(nfs4_mknod);
1113 DEFINE_NFS4_LOOKUP_EVENT(nfs4_remove);
1114 DEFINE_NFS4_LOOKUP_EVENT(nfs4_get_fs_locations);
1115 DEFINE_NFS4_LOOKUP_EVENT(nfs4_secinfo);
1116 
1117 TRACE_EVENT(nfs4_lookupp,
1118 		TP_PROTO(
1119 			const struct inode *inode,
1120 			int error
1121 		),
1122 
1123 		TP_ARGS(inode, error),
1124 
1125 		TP_STRUCT__entry(
1126 			__field(dev_t, dev)
1127 			__field(u64, ino)
1128 			__field(unsigned long, error)
1129 		),
1130 
1131 		TP_fast_assign(
1132 			__entry->dev = inode->i_sb->s_dev;
1133 			__entry->ino = NFS_FILEID(inode);
1134 			__entry->error = error;
1135 		),
1136 
1137 		TP_printk(
1138 			"error=%ld (%s) inode=%02x:%02x:%llu",
1139 			-__entry->error,
1140 			show_nfsv4_errors(__entry->error),
1141 			MAJOR(__entry->dev), MINOR(__entry->dev),
1142 			(unsigned long long)__entry->ino
1143 		)
1144 );
1145 
1146 TRACE_EVENT(nfs4_rename,
1147 		TP_PROTO(
1148 			const struct inode *olddir,
1149 			const struct qstr *oldname,
1150 			const struct inode *newdir,
1151 			const struct qstr *newname,
1152 			int error
1153 		),
1154 
1155 		TP_ARGS(olddir, oldname, newdir, newname, error),
1156 
1157 		TP_STRUCT__entry(
1158 			__field(dev_t, dev)
1159 			__field(unsigned long, error)
1160 			__field(u64, olddir)
1161 			__string(oldname, oldname->name)
1162 			__field(u64, newdir)
1163 			__string(newname, newname->name)
1164 		),
1165 
1166 		TP_fast_assign(
1167 			__entry->dev = olddir->i_sb->s_dev;
1168 			__entry->olddir = NFS_FILEID(olddir);
1169 			__entry->newdir = NFS_FILEID(newdir);
1170 			__entry->error = error;
1171 			__assign_str(oldname, oldname->name);
1172 			__assign_str(newname, newname->name);
1173 		),
1174 
1175 		TP_printk(
1176 			"error=%ld (%s) oldname=%02x:%02x:%llu/%s "
1177 			"newname=%02x:%02x:%llu/%s",
1178 			-__entry->error,
1179 			show_nfsv4_errors(__entry->error),
1180 			MAJOR(__entry->dev), MINOR(__entry->dev),
1181 			(unsigned long long)__entry->olddir,
1182 			__get_str(oldname),
1183 			MAJOR(__entry->dev), MINOR(__entry->dev),
1184 			(unsigned long long)__entry->newdir,
1185 			__get_str(newname)
1186 		)
1187 );
1188 
1189 DECLARE_EVENT_CLASS(nfs4_inode_event,
1190 		TP_PROTO(
1191 			const struct inode *inode,
1192 			int error
1193 		),
1194 
1195 		TP_ARGS(inode, error),
1196 
1197 		TP_STRUCT__entry(
1198 			__field(dev_t, dev)
1199 			__field(u32, fhandle)
1200 			__field(u64, fileid)
1201 			__field(unsigned long, error)
1202 		),
1203 
1204 		TP_fast_assign(
1205 			__entry->dev = inode->i_sb->s_dev;
1206 			__entry->fileid = NFS_FILEID(inode);
1207 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1208 			__entry->error = error < 0 ? -error : 0;
1209 		),
1210 
1211 		TP_printk(
1212 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x",
1213 			-__entry->error,
1214 			show_nfsv4_errors(__entry->error),
1215 			MAJOR(__entry->dev), MINOR(__entry->dev),
1216 			(unsigned long long)__entry->fileid,
1217 			__entry->fhandle
1218 		)
1219 );
1220 
1221 #define DEFINE_NFS4_INODE_EVENT(name) \
1222 	DEFINE_EVENT(nfs4_inode_event, name, \
1223 			TP_PROTO( \
1224 				const struct inode *inode, \
1225 				int error \
1226 			), \
1227 			TP_ARGS(inode, error))
1228 
1229 DEFINE_NFS4_INODE_EVENT(nfs4_access);
1230 DEFINE_NFS4_INODE_EVENT(nfs4_readlink);
1231 DEFINE_NFS4_INODE_EVENT(nfs4_readdir);
1232 DEFINE_NFS4_INODE_EVENT(nfs4_get_acl);
1233 DEFINE_NFS4_INODE_EVENT(nfs4_set_acl);
1234 #ifdef CONFIG_NFS_V4_SECURITY_LABEL
1235 DEFINE_NFS4_INODE_EVENT(nfs4_get_security_label);
1236 DEFINE_NFS4_INODE_EVENT(nfs4_set_security_label);
1237 #endif /* CONFIG_NFS_V4_SECURITY_LABEL */
1238 
1239 DECLARE_EVENT_CLASS(nfs4_inode_stateid_event,
1240 		TP_PROTO(
1241 			const struct inode *inode,
1242 			const nfs4_stateid *stateid,
1243 			int error
1244 		),
1245 
1246 		TP_ARGS(inode, stateid, error),
1247 
1248 		TP_STRUCT__entry(
1249 			__field(dev_t, dev)
1250 			__field(u32, fhandle)
1251 			__field(u64, fileid)
1252 			__field(unsigned long, error)
1253 			__field(int, stateid_seq)
1254 			__field(u32, stateid_hash)
1255 		),
1256 
1257 		TP_fast_assign(
1258 			__entry->dev = inode->i_sb->s_dev;
1259 			__entry->fileid = NFS_FILEID(inode);
1260 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1261 			__entry->error = error;
1262 			__entry->stateid_seq =
1263 				be32_to_cpu(stateid->seqid);
1264 			__entry->stateid_hash =
1265 				nfs_stateid_hash(stateid);
1266 		),
1267 
1268 		TP_printk(
1269 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1270 			"stateid=%d:0x%08x",
1271 			-__entry->error,
1272 			show_nfsv4_errors(__entry->error),
1273 			MAJOR(__entry->dev), MINOR(__entry->dev),
1274 			(unsigned long long)__entry->fileid,
1275 			__entry->fhandle,
1276 			__entry->stateid_seq, __entry->stateid_hash
1277 		)
1278 );
1279 
1280 #define DEFINE_NFS4_INODE_STATEID_EVENT(name) \
1281 	DEFINE_EVENT(nfs4_inode_stateid_event, name, \
1282 			TP_PROTO( \
1283 				const struct inode *inode, \
1284 				const nfs4_stateid *stateid, \
1285 				int error \
1286 			), \
1287 			TP_ARGS(inode, stateid, error))
1288 
1289 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_setattr);
1290 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_delegreturn);
1291 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_open_stateid_update);
1292 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_open_stateid_update_wait);
1293 
1294 DECLARE_EVENT_CLASS(nfs4_getattr_event,
1295 		TP_PROTO(
1296 			const struct nfs_server *server,
1297 			const struct nfs_fh *fhandle,
1298 			const struct nfs_fattr *fattr,
1299 			int error
1300 		),
1301 
1302 		TP_ARGS(server, fhandle, fattr, error),
1303 
1304 		TP_STRUCT__entry(
1305 			__field(dev_t, dev)
1306 			__field(u32, fhandle)
1307 			__field(u64, fileid)
1308 			__field(unsigned int, valid)
1309 			__field(unsigned long, error)
1310 		),
1311 
1312 		TP_fast_assign(
1313 			__entry->dev = server->s_dev;
1314 			__entry->valid = fattr->valid;
1315 			__entry->fhandle = nfs_fhandle_hash(fhandle);
1316 			__entry->fileid = (fattr->valid & NFS_ATTR_FATTR_FILEID) ? fattr->fileid : 0;
1317 			__entry->error = error;
1318 		),
1319 
1320 		TP_printk(
1321 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1322 			"valid=%s",
1323 			-__entry->error,
1324 			show_nfsv4_errors(__entry->error),
1325 			MAJOR(__entry->dev), MINOR(__entry->dev),
1326 			(unsigned long long)__entry->fileid,
1327 			__entry->fhandle,
1328 			show_nfs_fattr_flags(__entry->valid)
1329 		)
1330 );
1331 
1332 #define DEFINE_NFS4_GETATTR_EVENT(name) \
1333 	DEFINE_EVENT(nfs4_getattr_event, name, \
1334 			TP_PROTO( \
1335 				const struct nfs_server *server, \
1336 				const struct nfs_fh *fhandle, \
1337 				const struct nfs_fattr *fattr, \
1338 				int error \
1339 			), \
1340 			TP_ARGS(server, fhandle, fattr, error))
1341 DEFINE_NFS4_GETATTR_EVENT(nfs4_getattr);
1342 DEFINE_NFS4_GETATTR_EVENT(nfs4_lookup_root);
1343 DEFINE_NFS4_GETATTR_EVENT(nfs4_fsinfo);
1344 
1345 DECLARE_EVENT_CLASS(nfs4_inode_callback_event,
1346 		TP_PROTO(
1347 			const struct nfs_client *clp,
1348 			const struct nfs_fh *fhandle,
1349 			const struct inode *inode,
1350 			int error
1351 		),
1352 
1353 		TP_ARGS(clp, fhandle, inode, error),
1354 
1355 		TP_STRUCT__entry(
1356 			__field(unsigned long, error)
1357 			__field(dev_t, dev)
1358 			__field(u32, fhandle)
1359 			__field(u64, fileid)
1360 			__string(dstaddr, clp ? clp->cl_hostname : "unknown")
1361 		),
1362 
1363 		TP_fast_assign(
1364 			__entry->error = error;
1365 			__entry->fhandle = nfs_fhandle_hash(fhandle);
1366 			if (!IS_ERR_OR_NULL(inode)) {
1367 				__entry->fileid = NFS_FILEID(inode);
1368 				__entry->dev = inode->i_sb->s_dev;
1369 			} else {
1370 				__entry->fileid = 0;
1371 				__entry->dev = 0;
1372 			}
1373 			__assign_str(dstaddr, clp ? clp->cl_hostname : "unknown")
1374 		),
1375 
1376 		TP_printk(
1377 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1378 			"dstaddr=%s",
1379 			-__entry->error,
1380 			show_nfsv4_errors(__entry->error),
1381 			MAJOR(__entry->dev), MINOR(__entry->dev),
1382 			(unsigned long long)__entry->fileid,
1383 			__entry->fhandle,
1384 			__get_str(dstaddr)
1385 		)
1386 );
1387 
1388 #define DEFINE_NFS4_INODE_CALLBACK_EVENT(name) \
1389 	DEFINE_EVENT(nfs4_inode_callback_event, name, \
1390 			TP_PROTO( \
1391 				const struct nfs_client *clp, \
1392 				const struct nfs_fh *fhandle, \
1393 				const struct inode *inode, \
1394 				int error \
1395 			), \
1396 			TP_ARGS(clp, fhandle, inode, error))
1397 DEFINE_NFS4_INODE_CALLBACK_EVENT(nfs4_cb_getattr);
1398 
1399 DECLARE_EVENT_CLASS(nfs4_inode_stateid_callback_event,
1400 		TP_PROTO(
1401 			const struct nfs_client *clp,
1402 			const struct nfs_fh *fhandle,
1403 			const struct inode *inode,
1404 			const nfs4_stateid *stateid,
1405 			int error
1406 		),
1407 
1408 		TP_ARGS(clp, fhandle, inode, stateid, error),
1409 
1410 		TP_STRUCT__entry(
1411 			__field(unsigned long, error)
1412 			__field(dev_t, dev)
1413 			__field(u32, fhandle)
1414 			__field(u64, fileid)
1415 			__string(dstaddr, clp ? clp->cl_hostname : "unknown")
1416 			__field(int, stateid_seq)
1417 			__field(u32, stateid_hash)
1418 		),
1419 
1420 		TP_fast_assign(
1421 			__entry->error = error;
1422 			__entry->fhandle = nfs_fhandle_hash(fhandle);
1423 			if (!IS_ERR_OR_NULL(inode)) {
1424 				__entry->fileid = NFS_FILEID(inode);
1425 				__entry->dev = inode->i_sb->s_dev;
1426 			} else {
1427 				__entry->fileid = 0;
1428 				__entry->dev = 0;
1429 			}
1430 			__assign_str(dstaddr, clp ? clp->cl_hostname : "unknown")
1431 			__entry->stateid_seq =
1432 				be32_to_cpu(stateid->seqid);
1433 			__entry->stateid_hash =
1434 				nfs_stateid_hash(stateid);
1435 		),
1436 
1437 		TP_printk(
1438 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1439 			"stateid=%d:0x%08x dstaddr=%s",
1440 			-__entry->error,
1441 			show_nfsv4_errors(__entry->error),
1442 			MAJOR(__entry->dev), MINOR(__entry->dev),
1443 			(unsigned long long)__entry->fileid,
1444 			__entry->fhandle,
1445 			__entry->stateid_seq, __entry->stateid_hash,
1446 			__get_str(dstaddr)
1447 		)
1448 );
1449 
1450 #define DEFINE_NFS4_INODE_STATEID_CALLBACK_EVENT(name) \
1451 	DEFINE_EVENT(nfs4_inode_stateid_callback_event, name, \
1452 			TP_PROTO( \
1453 				const struct nfs_client *clp, \
1454 				const struct nfs_fh *fhandle, \
1455 				const struct inode *inode, \
1456 				const nfs4_stateid *stateid, \
1457 				int error \
1458 			), \
1459 			TP_ARGS(clp, fhandle, inode, stateid, error))
1460 DEFINE_NFS4_INODE_STATEID_CALLBACK_EVENT(nfs4_cb_recall);
1461 DEFINE_NFS4_INODE_STATEID_CALLBACK_EVENT(nfs4_cb_layoutrecall_file);
1462 
1463 DECLARE_EVENT_CLASS(nfs4_idmap_event,
1464 		TP_PROTO(
1465 			const char *name,
1466 			int len,
1467 			u32 id,
1468 			int error
1469 		),
1470 
1471 		TP_ARGS(name, len, id, error),
1472 
1473 		TP_STRUCT__entry(
1474 			__field(unsigned long, error)
1475 			__field(u32, id)
1476 			__dynamic_array(char, name, len > 0 ? len + 1 : 1)
1477 		),
1478 
1479 		TP_fast_assign(
1480 			if (len < 0)
1481 				len = 0;
1482 			__entry->error = error < 0 ? error : 0;
1483 			__entry->id = id;
1484 			memcpy(__get_str(name), name, len);
1485 			__get_str(name)[len] = 0;
1486 		),
1487 
1488 		TP_printk(
1489 			"error=%ld (%s) id=%u name=%s",
1490 			-__entry->error, show_nfsv4_errors(__entry->error),
1491 			__entry->id,
1492 			__get_str(name)
1493 		)
1494 );
1495 #define DEFINE_NFS4_IDMAP_EVENT(name) \
1496 	DEFINE_EVENT(nfs4_idmap_event, name, \
1497 			TP_PROTO( \
1498 				const char *name, \
1499 				int len, \
1500 				u32 id, \
1501 				int error \
1502 			), \
1503 			TP_ARGS(name, len, id, error))
1504 DEFINE_NFS4_IDMAP_EVENT(nfs4_map_name_to_uid);
1505 DEFINE_NFS4_IDMAP_EVENT(nfs4_map_group_to_gid);
1506 DEFINE_NFS4_IDMAP_EVENT(nfs4_map_uid_to_name);
1507 DEFINE_NFS4_IDMAP_EVENT(nfs4_map_gid_to_group);
1508 
1509 DECLARE_EVENT_CLASS(nfs4_read_event,
1510 		TP_PROTO(
1511 			const struct nfs_pgio_header *hdr,
1512 			int error
1513 		),
1514 
1515 		TP_ARGS(hdr, error),
1516 
1517 		TP_STRUCT__entry(
1518 			__field(dev_t, dev)
1519 			__field(u32, fhandle)
1520 			__field(u64, fileid)
1521 			__field(loff_t, offset)
1522 			__field(size_t, count)
1523 			__field(unsigned long, error)
1524 			__field(int, stateid_seq)
1525 			__field(u32, stateid_hash)
1526 		),
1527 
1528 		TP_fast_assign(
1529 			const struct inode *inode = hdr->inode;
1530 			const struct nfs4_state *state =
1531 				hdr->args.context->state;
1532 			__entry->dev = inode->i_sb->s_dev;
1533 			__entry->fileid = NFS_FILEID(inode);
1534 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1535 			__entry->offset = hdr->args.offset;
1536 			__entry->count = hdr->args.count;
1537 			__entry->error = error < 0 ? -error : 0;
1538 			__entry->stateid_seq =
1539 				be32_to_cpu(state->stateid.seqid);
1540 			__entry->stateid_hash =
1541 				nfs_stateid_hash(&state->stateid);
1542 		),
1543 
1544 		TP_printk(
1545 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1546 			"offset=%lld count=%zu stateid=%d:0x%08x",
1547 			-__entry->error,
1548 			show_nfsv4_errors(__entry->error),
1549 			MAJOR(__entry->dev), MINOR(__entry->dev),
1550 			(unsigned long long)__entry->fileid,
1551 			__entry->fhandle,
1552 			(long long)__entry->offset,
1553 			__entry->count,
1554 			__entry->stateid_seq, __entry->stateid_hash
1555 		)
1556 );
1557 #define DEFINE_NFS4_READ_EVENT(name) \
1558 	DEFINE_EVENT(nfs4_read_event, name, \
1559 			TP_PROTO( \
1560 				const struct nfs_pgio_header *hdr, \
1561 				int error \
1562 			), \
1563 			TP_ARGS(hdr, error))
1564 DEFINE_NFS4_READ_EVENT(nfs4_read);
1565 #ifdef CONFIG_NFS_V4_1
1566 DEFINE_NFS4_READ_EVENT(nfs4_pnfs_read);
1567 #endif /* CONFIG_NFS_V4_1 */
1568 
1569 DECLARE_EVENT_CLASS(nfs4_write_event,
1570 		TP_PROTO(
1571 			const struct nfs_pgio_header *hdr,
1572 			int error
1573 		),
1574 
1575 		TP_ARGS(hdr, error),
1576 
1577 		TP_STRUCT__entry(
1578 			__field(dev_t, dev)
1579 			__field(u32, fhandle)
1580 			__field(u64, fileid)
1581 			__field(loff_t, offset)
1582 			__field(size_t, count)
1583 			__field(unsigned long, error)
1584 			__field(int, stateid_seq)
1585 			__field(u32, stateid_hash)
1586 		),
1587 
1588 		TP_fast_assign(
1589 			const struct inode *inode = hdr->inode;
1590 			const struct nfs4_state *state =
1591 				hdr->args.context->state;
1592 			__entry->dev = inode->i_sb->s_dev;
1593 			__entry->fileid = NFS_FILEID(inode);
1594 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1595 			__entry->offset = hdr->args.offset;
1596 			__entry->count = hdr->args.count;
1597 			__entry->error = error < 0 ? -error : 0;
1598 			__entry->stateid_seq =
1599 				be32_to_cpu(state->stateid.seqid);
1600 			__entry->stateid_hash =
1601 				nfs_stateid_hash(&state->stateid);
1602 		),
1603 
1604 		TP_printk(
1605 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1606 			"offset=%lld count=%zu stateid=%d:0x%08x",
1607 			-__entry->error,
1608 			show_nfsv4_errors(__entry->error),
1609 			MAJOR(__entry->dev), MINOR(__entry->dev),
1610 			(unsigned long long)__entry->fileid,
1611 			__entry->fhandle,
1612 			(long long)__entry->offset,
1613 			__entry->count,
1614 			__entry->stateid_seq, __entry->stateid_hash
1615 		)
1616 );
1617 
1618 #define DEFINE_NFS4_WRITE_EVENT(name) \
1619 	DEFINE_EVENT(nfs4_write_event, name, \
1620 			TP_PROTO( \
1621 				const struct nfs_pgio_header *hdr, \
1622 				int error \
1623 			), \
1624 			TP_ARGS(hdr, error))
1625 DEFINE_NFS4_WRITE_EVENT(nfs4_write);
1626 #ifdef CONFIG_NFS_V4_1
1627 DEFINE_NFS4_WRITE_EVENT(nfs4_pnfs_write);
1628 #endif /* CONFIG_NFS_V4_1 */
1629 
1630 DECLARE_EVENT_CLASS(nfs4_commit_event,
1631 		TP_PROTO(
1632 			const struct nfs_commit_data *data,
1633 			int error
1634 		),
1635 
1636 		TP_ARGS(data, error),
1637 
1638 		TP_STRUCT__entry(
1639 			__field(dev_t, dev)
1640 			__field(u32, fhandle)
1641 			__field(u64, fileid)
1642 			__field(loff_t, offset)
1643 			__field(size_t, count)
1644 			__field(unsigned long, error)
1645 		),
1646 
1647 		TP_fast_assign(
1648 			const struct inode *inode = data->inode;
1649 			__entry->dev = inode->i_sb->s_dev;
1650 			__entry->fileid = NFS_FILEID(inode);
1651 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1652 			__entry->offset = data->args.offset;
1653 			__entry->count = data->args.count;
1654 			__entry->error = error;
1655 		),
1656 
1657 		TP_printk(
1658 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1659 			"offset=%lld count=%zu",
1660 			-__entry->error,
1661 			show_nfsv4_errors(__entry->error),
1662 			MAJOR(__entry->dev), MINOR(__entry->dev),
1663 			(unsigned long long)__entry->fileid,
1664 			__entry->fhandle,
1665 			(long long)__entry->offset,
1666 			__entry->count
1667 		)
1668 );
1669 #define DEFINE_NFS4_COMMIT_EVENT(name) \
1670 	DEFINE_EVENT(nfs4_commit_event, name, \
1671 			TP_PROTO( \
1672 				const struct nfs_commit_data *data, \
1673 				int error \
1674 			), \
1675 			TP_ARGS(data, error))
1676 DEFINE_NFS4_COMMIT_EVENT(nfs4_commit);
1677 #ifdef CONFIG_NFS_V4_1
1678 DEFINE_NFS4_COMMIT_EVENT(nfs4_pnfs_commit_ds);
1679 
1680 TRACE_DEFINE_ENUM(IOMODE_READ);
1681 TRACE_DEFINE_ENUM(IOMODE_RW);
1682 TRACE_DEFINE_ENUM(IOMODE_ANY);
1683 
1684 #define show_pnfs_iomode(iomode) \
1685 	__print_symbolic(iomode, \
1686 		{ IOMODE_READ, "READ" }, \
1687 		{ IOMODE_RW, "RW" }, \
1688 		{ IOMODE_ANY, "ANY" })
1689 
1690 TRACE_EVENT(nfs4_layoutget,
1691 		TP_PROTO(
1692 			const struct nfs_open_context *ctx,
1693 			const struct pnfs_layout_range *args,
1694 			const struct pnfs_layout_range *res,
1695 			const nfs4_stateid *layout_stateid,
1696 			int error
1697 		),
1698 
1699 		TP_ARGS(ctx, args, res, layout_stateid, error),
1700 
1701 		TP_STRUCT__entry(
1702 			__field(dev_t, dev)
1703 			__field(u32, fhandle)
1704 			__field(u64, fileid)
1705 			__field(u32, iomode)
1706 			__field(u64, offset)
1707 			__field(u64, count)
1708 			__field(unsigned long, error)
1709 			__field(int, stateid_seq)
1710 			__field(u32, stateid_hash)
1711 			__field(int, layoutstateid_seq)
1712 			__field(u32, layoutstateid_hash)
1713 		),
1714 
1715 		TP_fast_assign(
1716 			const struct inode *inode = d_inode(ctx->dentry);
1717 			const struct nfs4_state *state = ctx->state;
1718 			__entry->dev = inode->i_sb->s_dev;
1719 			__entry->fileid = NFS_FILEID(inode);
1720 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1721 			__entry->iomode = args->iomode;
1722 			__entry->offset = args->offset;
1723 			__entry->count = args->length;
1724 			__entry->error = error;
1725 			__entry->stateid_seq =
1726 				be32_to_cpu(state->stateid.seqid);
1727 			__entry->stateid_hash =
1728 				nfs_stateid_hash(&state->stateid);
1729 			if (!error) {
1730 				__entry->layoutstateid_seq =
1731 				be32_to_cpu(layout_stateid->seqid);
1732 				__entry->layoutstateid_hash =
1733 				nfs_stateid_hash(layout_stateid);
1734 			} else {
1735 				__entry->layoutstateid_seq = 0;
1736 				__entry->layoutstateid_hash = 0;
1737 			}
1738 		),
1739 
1740 		TP_printk(
1741 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
1742 			"iomode=%s offset=%llu count=%llu stateid=%d:0x%08x "
1743 			"layoutstateid=%d:0x%08x",
1744 			-__entry->error,
1745 			show_nfsv4_errors(__entry->error),
1746 			MAJOR(__entry->dev), MINOR(__entry->dev),
1747 			(unsigned long long)__entry->fileid,
1748 			__entry->fhandle,
1749 			show_pnfs_iomode(__entry->iomode),
1750 			(unsigned long long)__entry->offset,
1751 			(unsigned long long)__entry->count,
1752 			__entry->stateid_seq, __entry->stateid_hash,
1753 			__entry->layoutstateid_seq, __entry->layoutstateid_hash
1754 		)
1755 );
1756 
1757 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layoutcommit);
1758 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_layoutreturn);
1759 DEFINE_NFS4_INODE_EVENT(nfs4_layoutreturn_on_close);
1760 
1761 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_UNKNOWN);
1762 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_NO_PNFS);
1763 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_RD_ZEROLEN);
1764 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_MDSTHRESH);
1765 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_NOMEM);
1766 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_BULK_RECALL);
1767 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_IO_TEST_FAIL);
1768 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_FOUND_CACHED);
1769 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_RETURN);
1770 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_BLOCKED);
1771 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_INVALID_OPEN);
1772 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_RETRY);
1773 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_SEND_LAYOUTGET);
1774 TRACE_DEFINE_ENUM(PNFS_UPDATE_LAYOUT_EXIT);
1775 
1776 #define show_pnfs_update_layout_reason(reason)				\
1777 	__print_symbolic(reason,					\
1778 		{ PNFS_UPDATE_LAYOUT_UNKNOWN, "unknown" },		\
1779 		{ PNFS_UPDATE_LAYOUT_NO_PNFS, "no pnfs" },		\
1780 		{ PNFS_UPDATE_LAYOUT_RD_ZEROLEN, "read+zerolen" },	\
1781 		{ PNFS_UPDATE_LAYOUT_MDSTHRESH, "mdsthresh" },		\
1782 		{ PNFS_UPDATE_LAYOUT_NOMEM, "nomem" },			\
1783 		{ PNFS_UPDATE_LAYOUT_BULK_RECALL, "bulk recall" },	\
1784 		{ PNFS_UPDATE_LAYOUT_IO_TEST_FAIL, "io test fail" },	\
1785 		{ PNFS_UPDATE_LAYOUT_FOUND_CACHED, "found cached" },	\
1786 		{ PNFS_UPDATE_LAYOUT_RETURN, "layoutreturn" },		\
1787 		{ PNFS_UPDATE_LAYOUT_BLOCKED, "layouts blocked" },	\
1788 		{ PNFS_UPDATE_LAYOUT_INVALID_OPEN, "invalid open" },	\
1789 		{ PNFS_UPDATE_LAYOUT_RETRY, "retrying" },	\
1790 		{ PNFS_UPDATE_LAYOUT_SEND_LAYOUTGET, "sent layoutget" }, \
1791 		{ PNFS_UPDATE_LAYOUT_EXIT, "exit" })
1792 
1793 TRACE_EVENT(pnfs_update_layout,
1794 		TP_PROTO(struct inode *inode,
1795 			loff_t pos,
1796 			u64 count,
1797 			enum pnfs_iomode iomode,
1798 			struct pnfs_layout_hdr *lo,
1799 			struct pnfs_layout_segment *lseg,
1800 			enum pnfs_update_layout_reason reason
1801 		),
1802 		TP_ARGS(inode, pos, count, iomode, lo, lseg, reason),
1803 		TP_STRUCT__entry(
1804 			__field(dev_t, dev)
1805 			__field(u64, fileid)
1806 			__field(u32, fhandle)
1807 			__field(loff_t, pos)
1808 			__field(u64, count)
1809 			__field(enum pnfs_iomode, iomode)
1810 			__field(int, layoutstateid_seq)
1811 			__field(u32, layoutstateid_hash)
1812 			__field(long, lseg)
1813 			__field(enum pnfs_update_layout_reason, reason)
1814 		),
1815 		TP_fast_assign(
1816 			__entry->dev = inode->i_sb->s_dev;
1817 			__entry->fileid = NFS_FILEID(inode);
1818 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1819 			__entry->pos = pos;
1820 			__entry->count = count;
1821 			__entry->iomode = iomode;
1822 			__entry->reason = reason;
1823 			if (lo != NULL) {
1824 				__entry->layoutstateid_seq =
1825 				be32_to_cpu(lo->plh_stateid.seqid);
1826 				__entry->layoutstateid_hash =
1827 				nfs_stateid_hash(&lo->plh_stateid);
1828 			} else {
1829 				__entry->layoutstateid_seq = 0;
1830 				__entry->layoutstateid_hash = 0;
1831 			}
1832 			__entry->lseg = (long)lseg;
1833 		),
1834 		TP_printk(
1835 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1836 			"iomode=%s pos=%llu count=%llu "
1837 			"layoutstateid=%d:0x%08x lseg=0x%lx (%s)",
1838 			MAJOR(__entry->dev), MINOR(__entry->dev),
1839 			(unsigned long long)__entry->fileid,
1840 			__entry->fhandle,
1841 			show_pnfs_iomode(__entry->iomode),
1842 			(unsigned long long)__entry->pos,
1843 			(unsigned long long)__entry->count,
1844 			__entry->layoutstateid_seq, __entry->layoutstateid_hash,
1845 			__entry->lseg,
1846 			show_pnfs_update_layout_reason(__entry->reason)
1847 		)
1848 );
1849 
1850 DECLARE_EVENT_CLASS(pnfs_layout_event,
1851 		TP_PROTO(struct inode *inode,
1852 			loff_t pos,
1853 			u64 count,
1854 			enum pnfs_iomode iomode,
1855 			struct pnfs_layout_hdr *lo,
1856 			struct pnfs_layout_segment *lseg
1857 		),
1858 		TP_ARGS(inode, pos, count, iomode, lo, lseg),
1859 		TP_STRUCT__entry(
1860 			__field(dev_t, dev)
1861 			__field(u64, fileid)
1862 			__field(u32, fhandle)
1863 			__field(loff_t, pos)
1864 			__field(u64, count)
1865 			__field(enum pnfs_iomode, iomode)
1866 			__field(int, layoutstateid_seq)
1867 			__field(u32, layoutstateid_hash)
1868 			__field(long, lseg)
1869 		),
1870 		TP_fast_assign(
1871 			__entry->dev = inode->i_sb->s_dev;
1872 			__entry->fileid = NFS_FILEID(inode);
1873 			__entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
1874 			__entry->pos = pos;
1875 			__entry->count = count;
1876 			__entry->iomode = iomode;
1877 			if (lo != NULL) {
1878 				__entry->layoutstateid_seq =
1879 				be32_to_cpu(lo->plh_stateid.seqid);
1880 				__entry->layoutstateid_hash =
1881 				nfs_stateid_hash(&lo->plh_stateid);
1882 			} else {
1883 				__entry->layoutstateid_seq = 0;
1884 				__entry->layoutstateid_hash = 0;
1885 			}
1886 			__entry->lseg = (long)lseg;
1887 		),
1888 		TP_printk(
1889 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1890 			"iomode=%s pos=%llu count=%llu "
1891 			"layoutstateid=%d:0x%08x lseg=0x%lx",
1892 			MAJOR(__entry->dev), MINOR(__entry->dev),
1893 			(unsigned long long)__entry->fileid,
1894 			__entry->fhandle,
1895 			show_pnfs_iomode(__entry->iomode),
1896 			(unsigned long long)__entry->pos,
1897 			(unsigned long long)__entry->count,
1898 			__entry->layoutstateid_seq, __entry->layoutstateid_hash,
1899 			__entry->lseg
1900 		)
1901 );
1902 
1903 #define DEFINE_PNFS_LAYOUT_EVENT(name) \
1904 	DEFINE_EVENT(pnfs_layout_event, name, \
1905 		TP_PROTO(struct inode *inode, \
1906 			loff_t pos, \
1907 			u64 count, \
1908 			enum pnfs_iomode iomode, \
1909 			struct pnfs_layout_hdr *lo, \
1910 			struct pnfs_layout_segment *lseg \
1911 		), \
1912 		TP_ARGS(inode, pos, count, iomode, lo, lseg))
1913 
1914 DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_pg_init_read);
1915 DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_pg_init_write);
1916 DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_pg_get_mirror_count);
1917 DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_read_done);
1918 DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_write_done);
1919 DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_read_pagelist);
1920 DEFINE_PNFS_LAYOUT_EVENT(pnfs_mds_fallback_write_pagelist);
1921 
1922 #endif /* CONFIG_NFS_V4_1 */
1923 
1924 #endif /* _TRACE_NFS4_H */
1925 
1926 #undef TRACE_INCLUDE_PATH
1927 #define TRACE_INCLUDE_PATH .
1928 #define TRACE_INCLUDE_FILE nfs4trace
1929 /* This part must be outside protection */
1930 #include <trace/define_trace.h>
1931