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