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