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