xref: /openbmc/linux/fs/nfs/nfstrace.h (revision 8ec90bfd)
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 nfs
7 
8 #if !defined(_TRACE_NFS_H) || defined(TRACE_HEADER_MULTI_READ)
9 #define _TRACE_NFS_H
10 
11 #include <linux/tracepoint.h>
12 #include <linux/iversion.h>
13 
14 TRACE_DEFINE_ENUM(DT_UNKNOWN);
15 TRACE_DEFINE_ENUM(DT_FIFO);
16 TRACE_DEFINE_ENUM(DT_CHR);
17 TRACE_DEFINE_ENUM(DT_DIR);
18 TRACE_DEFINE_ENUM(DT_BLK);
19 TRACE_DEFINE_ENUM(DT_REG);
20 TRACE_DEFINE_ENUM(DT_LNK);
21 TRACE_DEFINE_ENUM(DT_SOCK);
22 TRACE_DEFINE_ENUM(DT_WHT);
23 
24 #define nfs_show_file_type(ftype) \
25 	__print_symbolic(ftype, \
26 			{ DT_UNKNOWN, "UNKNOWN" }, \
27 			{ DT_FIFO, "FIFO" }, \
28 			{ DT_CHR, "CHR" }, \
29 			{ DT_DIR, "DIR" }, \
30 			{ DT_BLK, "BLK" }, \
31 			{ DT_REG, "REG" }, \
32 			{ DT_LNK, "LNK" }, \
33 			{ DT_SOCK, "SOCK" }, \
34 			{ DT_WHT, "WHT" })
35 
36 TRACE_DEFINE_ENUM(NFS_INO_INVALID_DATA);
37 TRACE_DEFINE_ENUM(NFS_INO_INVALID_ATIME);
38 TRACE_DEFINE_ENUM(NFS_INO_INVALID_ACCESS);
39 TRACE_DEFINE_ENUM(NFS_INO_INVALID_ACL);
40 TRACE_DEFINE_ENUM(NFS_INO_REVAL_PAGECACHE);
41 TRACE_DEFINE_ENUM(NFS_INO_REVAL_FORCED);
42 TRACE_DEFINE_ENUM(NFS_INO_INVALID_LABEL);
43 TRACE_DEFINE_ENUM(NFS_INO_INVALID_CHANGE);
44 TRACE_DEFINE_ENUM(NFS_INO_INVALID_CTIME);
45 TRACE_DEFINE_ENUM(NFS_INO_INVALID_MTIME);
46 TRACE_DEFINE_ENUM(NFS_INO_INVALID_SIZE);
47 TRACE_DEFINE_ENUM(NFS_INO_INVALID_OTHER);
48 
49 #define nfs_show_cache_validity(v) \
50 	__print_flags(v, "|", \
51 			{ NFS_INO_INVALID_DATA, "INVALID_DATA" }, \
52 			{ NFS_INO_INVALID_ATIME, "INVALID_ATIME" }, \
53 			{ NFS_INO_INVALID_ACCESS, "INVALID_ACCESS" }, \
54 			{ NFS_INO_INVALID_ACL, "INVALID_ACL" }, \
55 			{ NFS_INO_REVAL_PAGECACHE, "REVAL_PAGECACHE" }, \
56 			{ NFS_INO_REVAL_FORCED, "REVAL_FORCED" }, \
57 			{ NFS_INO_INVALID_LABEL, "INVALID_LABEL" }, \
58 			{ NFS_INO_INVALID_CHANGE, "INVALID_CHANGE" }, \
59 			{ NFS_INO_INVALID_CTIME, "INVALID_CTIME" }, \
60 			{ NFS_INO_INVALID_MTIME, "INVALID_MTIME" }, \
61 			{ NFS_INO_INVALID_SIZE, "INVALID_SIZE" }, \
62 			{ NFS_INO_INVALID_OTHER, "INVALID_OTHER" }, \
63 			{ NFS_INO_INVALID_XATTR, "INVALID_XATTR" })
64 
65 TRACE_DEFINE_ENUM(NFS_INO_ADVISE_RDPLUS);
66 TRACE_DEFINE_ENUM(NFS_INO_STALE);
67 TRACE_DEFINE_ENUM(NFS_INO_ACL_LRU_SET);
68 TRACE_DEFINE_ENUM(NFS_INO_INVALIDATING);
69 TRACE_DEFINE_ENUM(NFS_INO_FSCACHE);
70 TRACE_DEFINE_ENUM(NFS_INO_FSCACHE_LOCK);
71 TRACE_DEFINE_ENUM(NFS_INO_LAYOUTCOMMIT);
72 TRACE_DEFINE_ENUM(NFS_INO_LAYOUTCOMMITTING);
73 TRACE_DEFINE_ENUM(NFS_INO_LAYOUTSTATS);
74 TRACE_DEFINE_ENUM(NFS_INO_ODIRECT);
75 
76 #define nfs_show_nfsi_flags(v) \
77 	__print_flags(v, "|", \
78 			{ BIT(NFS_INO_ADVISE_RDPLUS), "ADVISE_RDPLUS" }, \
79 			{ BIT(NFS_INO_STALE), "STALE" }, \
80 			{ BIT(NFS_INO_ACL_LRU_SET), "ACL_LRU_SET" }, \
81 			{ BIT(NFS_INO_INVALIDATING), "INVALIDATING" }, \
82 			{ BIT(NFS_INO_FSCACHE), "FSCACHE" }, \
83 			{ BIT(NFS_INO_FSCACHE_LOCK), "FSCACHE_LOCK" }, \
84 			{ BIT(NFS_INO_LAYOUTCOMMIT), "NEED_LAYOUTCOMMIT" }, \
85 			{ BIT(NFS_INO_LAYOUTCOMMITTING), "LAYOUTCOMMIT" }, \
86 			{ BIT(NFS_INO_LAYOUTSTATS), "LAYOUTSTATS" }, \
87 			{ BIT(NFS_INO_ODIRECT), "ODIRECT" })
88 
89 DECLARE_EVENT_CLASS(nfs_inode_event,
90 		TP_PROTO(
91 			const struct inode *inode
92 		),
93 
94 		TP_ARGS(inode),
95 
96 		TP_STRUCT__entry(
97 			__field(dev_t, dev)
98 			__field(u32, fhandle)
99 			__field(u64, fileid)
100 			__field(u64, version)
101 		),
102 
103 		TP_fast_assign(
104 			const struct nfs_inode *nfsi = NFS_I(inode);
105 			__entry->dev = inode->i_sb->s_dev;
106 			__entry->fileid = nfsi->fileid;
107 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
108 			__entry->version = inode_peek_iversion_raw(inode);
109 		),
110 
111 		TP_printk(
112 			"fileid=%02x:%02x:%llu fhandle=0x%08x version=%llu ",
113 			MAJOR(__entry->dev), MINOR(__entry->dev),
114 			(unsigned long long)__entry->fileid,
115 			__entry->fhandle,
116 			(unsigned long long)__entry->version
117 		)
118 );
119 
120 DECLARE_EVENT_CLASS(nfs_inode_event_done,
121 		TP_PROTO(
122 			const struct inode *inode,
123 			int error
124 		),
125 
126 		TP_ARGS(inode, error),
127 
128 		TP_STRUCT__entry(
129 			__field(unsigned long, error)
130 			__field(dev_t, dev)
131 			__field(u32, fhandle)
132 			__field(unsigned char, type)
133 			__field(u64, fileid)
134 			__field(u64, version)
135 			__field(loff_t, size)
136 			__field(unsigned long, nfsi_flags)
137 			__field(unsigned long, cache_validity)
138 		),
139 
140 		TP_fast_assign(
141 			const struct nfs_inode *nfsi = NFS_I(inode);
142 			__entry->error = error < 0 ? -error : 0;
143 			__entry->dev = inode->i_sb->s_dev;
144 			__entry->fileid = nfsi->fileid;
145 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
146 			__entry->type = nfs_umode_to_dtype(inode->i_mode);
147 			__entry->version = inode_peek_iversion_raw(inode);
148 			__entry->size = i_size_read(inode);
149 			__entry->nfsi_flags = nfsi->flags;
150 			__entry->cache_validity = nfsi->cache_validity;
151 		),
152 
153 		TP_printk(
154 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
155 			"type=%u (%s) version=%llu size=%lld "
156 			"cache_validity=0x%lx (%s) nfs_flags=0x%lx (%s)",
157 			-__entry->error, nfs_show_status(__entry->error),
158 			MAJOR(__entry->dev), MINOR(__entry->dev),
159 			(unsigned long long)__entry->fileid,
160 			__entry->fhandle,
161 			__entry->type,
162 			nfs_show_file_type(__entry->type),
163 			(unsigned long long)__entry->version,
164 			(long long)__entry->size,
165 			__entry->cache_validity,
166 			nfs_show_cache_validity(__entry->cache_validity),
167 			__entry->nfsi_flags,
168 			nfs_show_nfsi_flags(__entry->nfsi_flags)
169 		)
170 );
171 
172 #define DEFINE_NFS_INODE_EVENT(name) \
173 	DEFINE_EVENT(nfs_inode_event, name, \
174 			TP_PROTO( \
175 				const struct inode *inode \
176 			), \
177 			TP_ARGS(inode))
178 #define DEFINE_NFS_INODE_EVENT_DONE(name) \
179 	DEFINE_EVENT(nfs_inode_event_done, name, \
180 			TP_PROTO( \
181 				const struct inode *inode, \
182 				int error \
183 			), \
184 			TP_ARGS(inode, error))
185 DEFINE_NFS_INODE_EVENT(nfs_set_inode_stale);
186 DEFINE_NFS_INODE_EVENT(nfs_refresh_inode_enter);
187 DEFINE_NFS_INODE_EVENT_DONE(nfs_refresh_inode_exit);
188 DEFINE_NFS_INODE_EVENT(nfs_revalidate_inode_enter);
189 DEFINE_NFS_INODE_EVENT_DONE(nfs_revalidate_inode_exit);
190 DEFINE_NFS_INODE_EVENT(nfs_invalidate_mapping_enter);
191 DEFINE_NFS_INODE_EVENT_DONE(nfs_invalidate_mapping_exit);
192 DEFINE_NFS_INODE_EVENT(nfs_getattr_enter);
193 DEFINE_NFS_INODE_EVENT_DONE(nfs_getattr_exit);
194 DEFINE_NFS_INODE_EVENT(nfs_setattr_enter);
195 DEFINE_NFS_INODE_EVENT_DONE(nfs_setattr_exit);
196 DEFINE_NFS_INODE_EVENT(nfs_writeback_page_enter);
197 DEFINE_NFS_INODE_EVENT_DONE(nfs_writeback_page_exit);
198 DEFINE_NFS_INODE_EVENT(nfs_writeback_inode_enter);
199 DEFINE_NFS_INODE_EVENT_DONE(nfs_writeback_inode_exit);
200 DEFINE_NFS_INODE_EVENT(nfs_fsync_enter);
201 DEFINE_NFS_INODE_EVENT_DONE(nfs_fsync_exit);
202 DEFINE_NFS_INODE_EVENT(nfs_access_enter);
203 
204 TRACE_EVENT(nfs_access_exit,
205 		TP_PROTO(
206 			const struct inode *inode,
207 			unsigned int mask,
208 			unsigned int permitted,
209 			int error
210 		),
211 
212 		TP_ARGS(inode, mask, permitted, error),
213 
214 		TP_STRUCT__entry(
215 			__field(unsigned long, error)
216 			__field(dev_t, dev)
217 			__field(u32, fhandle)
218 			__field(unsigned char, type)
219 			__field(u64, fileid)
220 			__field(u64, version)
221 			__field(loff_t, size)
222 			__field(unsigned long, nfsi_flags)
223 			__field(unsigned long, cache_validity)
224 			__field(unsigned int, mask)
225 			__field(unsigned int, permitted)
226 		),
227 
228 		TP_fast_assign(
229 			const struct nfs_inode *nfsi = NFS_I(inode);
230 			__entry->error = error < 0 ? -error : 0;
231 			__entry->dev = inode->i_sb->s_dev;
232 			__entry->fileid = nfsi->fileid;
233 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
234 			__entry->type = nfs_umode_to_dtype(inode->i_mode);
235 			__entry->version = inode_peek_iversion_raw(inode);
236 			__entry->size = i_size_read(inode);
237 			__entry->nfsi_flags = nfsi->flags;
238 			__entry->cache_validity = nfsi->cache_validity;
239 			__entry->mask = mask;
240 			__entry->permitted = permitted;
241 		),
242 
243 		TP_printk(
244 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
245 			"type=%u (%s) version=%llu size=%lld "
246 			"cache_validity=0x%lx (%s) nfs_flags=0x%lx (%s) "
247 			"mask=0x%x permitted=0x%x",
248 			-__entry->error, nfs_show_status(__entry->error),
249 			MAJOR(__entry->dev), MINOR(__entry->dev),
250 			(unsigned long long)__entry->fileid,
251 			__entry->fhandle,
252 			__entry->type,
253 			nfs_show_file_type(__entry->type),
254 			(unsigned long long)__entry->version,
255 			(long long)__entry->size,
256 			__entry->cache_validity,
257 			nfs_show_cache_validity(__entry->cache_validity),
258 			__entry->nfsi_flags,
259 			nfs_show_nfsi_flags(__entry->nfsi_flags),
260 			__entry->mask, __entry->permitted
261 		)
262 );
263 
264 TRACE_DEFINE_ENUM(LOOKUP_FOLLOW);
265 TRACE_DEFINE_ENUM(LOOKUP_DIRECTORY);
266 TRACE_DEFINE_ENUM(LOOKUP_AUTOMOUNT);
267 TRACE_DEFINE_ENUM(LOOKUP_PARENT);
268 TRACE_DEFINE_ENUM(LOOKUP_REVAL);
269 TRACE_DEFINE_ENUM(LOOKUP_RCU);
270 TRACE_DEFINE_ENUM(LOOKUP_OPEN);
271 TRACE_DEFINE_ENUM(LOOKUP_CREATE);
272 TRACE_DEFINE_ENUM(LOOKUP_EXCL);
273 TRACE_DEFINE_ENUM(LOOKUP_RENAME_TARGET);
274 TRACE_DEFINE_ENUM(LOOKUP_JUMPED);
275 TRACE_DEFINE_ENUM(LOOKUP_ROOT);
276 TRACE_DEFINE_ENUM(LOOKUP_EMPTY);
277 TRACE_DEFINE_ENUM(LOOKUP_DOWN);
278 
279 #define show_lookup_flags(flags) \
280 	__print_flags(flags, "|", \
281 			{ LOOKUP_FOLLOW, "FOLLOW" }, \
282 			{ LOOKUP_DIRECTORY, "DIRECTORY" }, \
283 			{ LOOKUP_AUTOMOUNT, "AUTOMOUNT" }, \
284 			{ LOOKUP_PARENT, "PARENT" }, \
285 			{ LOOKUP_REVAL, "REVAL" }, \
286 			{ LOOKUP_RCU, "RCU" }, \
287 			{ LOOKUP_OPEN, "OPEN" }, \
288 			{ LOOKUP_CREATE, "CREATE" }, \
289 			{ LOOKUP_EXCL, "EXCL" }, \
290 			{ LOOKUP_RENAME_TARGET, "RENAME_TARGET" }, \
291 			{ LOOKUP_JUMPED, "JUMPED" }, \
292 			{ LOOKUP_ROOT, "ROOT" }, \
293 			{ LOOKUP_EMPTY, "EMPTY" }, \
294 			{ LOOKUP_DOWN, "DOWN" })
295 
296 DECLARE_EVENT_CLASS(nfs_lookup_event,
297 		TP_PROTO(
298 			const struct inode *dir,
299 			const struct dentry *dentry,
300 			unsigned int flags
301 		),
302 
303 		TP_ARGS(dir, dentry, flags),
304 
305 		TP_STRUCT__entry(
306 			__field(unsigned long, flags)
307 			__field(dev_t, dev)
308 			__field(u64, dir)
309 			__string(name, dentry->d_name.name)
310 		),
311 
312 		TP_fast_assign(
313 			__entry->dev = dir->i_sb->s_dev;
314 			__entry->dir = NFS_FILEID(dir);
315 			__entry->flags = flags;
316 			__assign_str(name, dentry->d_name.name);
317 		),
318 
319 		TP_printk(
320 			"flags=0x%lx (%s) name=%02x:%02x:%llu/%s",
321 			__entry->flags,
322 			show_lookup_flags(__entry->flags),
323 			MAJOR(__entry->dev), MINOR(__entry->dev),
324 			(unsigned long long)__entry->dir,
325 			__get_str(name)
326 		)
327 );
328 
329 #define DEFINE_NFS_LOOKUP_EVENT(name) \
330 	DEFINE_EVENT(nfs_lookup_event, name, \
331 			TP_PROTO( \
332 				const struct inode *dir, \
333 				const struct dentry *dentry, \
334 				unsigned int flags \
335 			), \
336 			TP_ARGS(dir, dentry, flags))
337 
338 DECLARE_EVENT_CLASS(nfs_lookup_event_done,
339 		TP_PROTO(
340 			const struct inode *dir,
341 			const struct dentry *dentry,
342 			unsigned int flags,
343 			int error
344 		),
345 
346 		TP_ARGS(dir, dentry, flags, error),
347 
348 		TP_STRUCT__entry(
349 			__field(unsigned long, error)
350 			__field(unsigned long, flags)
351 			__field(dev_t, dev)
352 			__field(u64, dir)
353 			__string(name, dentry->d_name.name)
354 		),
355 
356 		TP_fast_assign(
357 			__entry->dev = dir->i_sb->s_dev;
358 			__entry->dir = NFS_FILEID(dir);
359 			__entry->error = error < 0 ? -error : 0;
360 			__entry->flags = flags;
361 			__assign_str(name, dentry->d_name.name);
362 		),
363 
364 		TP_printk(
365 			"error=%ld (%s) flags=0x%lx (%s) name=%02x:%02x:%llu/%s",
366 			-__entry->error, nfs_show_status(__entry->error),
367 			__entry->flags,
368 			show_lookup_flags(__entry->flags),
369 			MAJOR(__entry->dev), MINOR(__entry->dev),
370 			(unsigned long long)__entry->dir,
371 			__get_str(name)
372 		)
373 );
374 
375 #define DEFINE_NFS_LOOKUP_EVENT_DONE(name) \
376 	DEFINE_EVENT(nfs_lookup_event_done, name, \
377 			TP_PROTO( \
378 				const struct inode *dir, \
379 				const struct dentry *dentry, \
380 				unsigned int flags, \
381 				int error \
382 			), \
383 			TP_ARGS(dir, dentry, flags, error))
384 
385 DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_enter);
386 DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_lookup_exit);
387 DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_revalidate_enter);
388 DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_lookup_revalidate_exit);
389 
390 TRACE_DEFINE_ENUM(O_WRONLY);
391 TRACE_DEFINE_ENUM(O_RDWR);
392 TRACE_DEFINE_ENUM(O_CREAT);
393 TRACE_DEFINE_ENUM(O_EXCL);
394 TRACE_DEFINE_ENUM(O_NOCTTY);
395 TRACE_DEFINE_ENUM(O_TRUNC);
396 TRACE_DEFINE_ENUM(O_APPEND);
397 TRACE_DEFINE_ENUM(O_NONBLOCK);
398 TRACE_DEFINE_ENUM(O_DSYNC);
399 TRACE_DEFINE_ENUM(O_DIRECT);
400 TRACE_DEFINE_ENUM(O_LARGEFILE);
401 TRACE_DEFINE_ENUM(O_DIRECTORY);
402 TRACE_DEFINE_ENUM(O_NOFOLLOW);
403 TRACE_DEFINE_ENUM(O_NOATIME);
404 TRACE_DEFINE_ENUM(O_CLOEXEC);
405 
406 #define show_open_flags(flags) \
407 	__print_flags(flags, "|", \
408 		{ O_WRONLY, "O_WRONLY" }, \
409 		{ O_RDWR, "O_RDWR" }, \
410 		{ O_CREAT, "O_CREAT" }, \
411 		{ O_EXCL, "O_EXCL" }, \
412 		{ O_NOCTTY, "O_NOCTTY" }, \
413 		{ O_TRUNC, "O_TRUNC" }, \
414 		{ O_APPEND, "O_APPEND" }, \
415 		{ O_NONBLOCK, "O_NONBLOCK" }, \
416 		{ O_DSYNC, "O_DSYNC" }, \
417 		{ O_DIRECT, "O_DIRECT" }, \
418 		{ O_LARGEFILE, "O_LARGEFILE" }, \
419 		{ O_DIRECTORY, "O_DIRECTORY" }, \
420 		{ O_NOFOLLOW, "O_NOFOLLOW" }, \
421 		{ O_NOATIME, "O_NOATIME" }, \
422 		{ O_CLOEXEC, "O_CLOEXEC" })
423 
424 TRACE_DEFINE_ENUM(FMODE_READ);
425 TRACE_DEFINE_ENUM(FMODE_WRITE);
426 TRACE_DEFINE_ENUM(FMODE_EXEC);
427 
428 #define show_fmode_flags(mode) \
429 	__print_flags(mode, "|", \
430 		{ ((__force unsigned long)FMODE_READ), "READ" }, \
431 		{ ((__force unsigned long)FMODE_WRITE), "WRITE" }, \
432 		{ ((__force unsigned long)FMODE_EXEC), "EXEC" })
433 
434 TRACE_EVENT(nfs_atomic_open_enter,
435 		TP_PROTO(
436 			const struct inode *dir,
437 			const struct nfs_open_context *ctx,
438 			unsigned int flags
439 		),
440 
441 		TP_ARGS(dir, ctx, flags),
442 
443 		TP_STRUCT__entry(
444 			__field(unsigned long, flags)
445 			__field(unsigned int, fmode)
446 			__field(dev_t, dev)
447 			__field(u64, dir)
448 			__string(name, ctx->dentry->d_name.name)
449 		),
450 
451 		TP_fast_assign(
452 			__entry->dev = dir->i_sb->s_dev;
453 			__entry->dir = NFS_FILEID(dir);
454 			__entry->flags = flags;
455 			__entry->fmode = (__force unsigned int)ctx->mode;
456 			__assign_str(name, ctx->dentry->d_name.name);
457 		),
458 
459 		TP_printk(
460 			"flags=0x%lx (%s) fmode=%s name=%02x:%02x:%llu/%s",
461 			__entry->flags,
462 			show_open_flags(__entry->flags),
463 			show_fmode_flags(__entry->fmode),
464 			MAJOR(__entry->dev), MINOR(__entry->dev),
465 			(unsigned long long)__entry->dir,
466 			__get_str(name)
467 		)
468 );
469 
470 TRACE_EVENT(nfs_atomic_open_exit,
471 		TP_PROTO(
472 			const struct inode *dir,
473 			const struct nfs_open_context *ctx,
474 			unsigned int flags,
475 			int error
476 		),
477 
478 		TP_ARGS(dir, ctx, flags, error),
479 
480 		TP_STRUCT__entry(
481 			__field(unsigned long, error)
482 			__field(unsigned long, flags)
483 			__field(unsigned int, fmode)
484 			__field(dev_t, dev)
485 			__field(u64, dir)
486 			__string(name, ctx->dentry->d_name.name)
487 		),
488 
489 		TP_fast_assign(
490 			__entry->error = -error;
491 			__entry->dev = dir->i_sb->s_dev;
492 			__entry->dir = NFS_FILEID(dir);
493 			__entry->flags = flags;
494 			__entry->fmode = (__force unsigned int)ctx->mode;
495 			__assign_str(name, ctx->dentry->d_name.name);
496 		),
497 
498 		TP_printk(
499 			"error=%ld (%s) flags=0x%lx (%s) fmode=%s "
500 			"name=%02x:%02x:%llu/%s",
501 			-__entry->error, nfs_show_status(__entry->error),
502 			__entry->flags,
503 			show_open_flags(__entry->flags),
504 			show_fmode_flags(__entry->fmode),
505 			MAJOR(__entry->dev), MINOR(__entry->dev),
506 			(unsigned long long)__entry->dir,
507 			__get_str(name)
508 		)
509 );
510 
511 TRACE_EVENT(nfs_create_enter,
512 		TP_PROTO(
513 			const struct inode *dir,
514 			const struct dentry *dentry,
515 			unsigned int flags
516 		),
517 
518 		TP_ARGS(dir, dentry, flags),
519 
520 		TP_STRUCT__entry(
521 			__field(unsigned long, flags)
522 			__field(dev_t, dev)
523 			__field(u64, dir)
524 			__string(name, dentry->d_name.name)
525 		),
526 
527 		TP_fast_assign(
528 			__entry->dev = dir->i_sb->s_dev;
529 			__entry->dir = NFS_FILEID(dir);
530 			__entry->flags = flags;
531 			__assign_str(name, dentry->d_name.name);
532 		),
533 
534 		TP_printk(
535 			"flags=0x%lx (%s) name=%02x:%02x:%llu/%s",
536 			__entry->flags,
537 			show_open_flags(__entry->flags),
538 			MAJOR(__entry->dev), MINOR(__entry->dev),
539 			(unsigned long long)__entry->dir,
540 			__get_str(name)
541 		)
542 );
543 
544 TRACE_EVENT(nfs_create_exit,
545 		TP_PROTO(
546 			const struct inode *dir,
547 			const struct dentry *dentry,
548 			unsigned int flags,
549 			int error
550 		),
551 
552 		TP_ARGS(dir, dentry, flags, error),
553 
554 		TP_STRUCT__entry(
555 			__field(unsigned long, error)
556 			__field(unsigned long, flags)
557 			__field(dev_t, dev)
558 			__field(u64, dir)
559 			__string(name, dentry->d_name.name)
560 		),
561 
562 		TP_fast_assign(
563 			__entry->error = -error;
564 			__entry->dev = dir->i_sb->s_dev;
565 			__entry->dir = NFS_FILEID(dir);
566 			__entry->flags = flags;
567 			__assign_str(name, dentry->d_name.name);
568 		),
569 
570 		TP_printk(
571 			"error=%ld (%s) flags=0x%lx (%s) name=%02x:%02x:%llu/%s",
572 			-__entry->error, nfs_show_status(__entry->error),
573 			__entry->flags,
574 			show_open_flags(__entry->flags),
575 			MAJOR(__entry->dev), MINOR(__entry->dev),
576 			(unsigned long long)__entry->dir,
577 			__get_str(name)
578 		)
579 );
580 
581 DECLARE_EVENT_CLASS(nfs_directory_event,
582 		TP_PROTO(
583 			const struct inode *dir,
584 			const struct dentry *dentry
585 		),
586 
587 		TP_ARGS(dir, dentry),
588 
589 		TP_STRUCT__entry(
590 			__field(dev_t, dev)
591 			__field(u64, dir)
592 			__string(name, dentry->d_name.name)
593 		),
594 
595 		TP_fast_assign(
596 			__entry->dev = dir->i_sb->s_dev;
597 			__entry->dir = NFS_FILEID(dir);
598 			__assign_str(name, dentry->d_name.name);
599 		),
600 
601 		TP_printk(
602 			"name=%02x:%02x:%llu/%s",
603 			MAJOR(__entry->dev), MINOR(__entry->dev),
604 			(unsigned long long)__entry->dir,
605 			__get_str(name)
606 		)
607 );
608 
609 #define DEFINE_NFS_DIRECTORY_EVENT(name) \
610 	DEFINE_EVENT(nfs_directory_event, name, \
611 			TP_PROTO( \
612 				const struct inode *dir, \
613 				const struct dentry *dentry \
614 			), \
615 			TP_ARGS(dir, dentry))
616 
617 DECLARE_EVENT_CLASS(nfs_directory_event_done,
618 		TP_PROTO(
619 			const struct inode *dir,
620 			const struct dentry *dentry,
621 			int error
622 		),
623 
624 		TP_ARGS(dir, dentry, error),
625 
626 		TP_STRUCT__entry(
627 			__field(unsigned long, error)
628 			__field(dev_t, dev)
629 			__field(u64, dir)
630 			__string(name, dentry->d_name.name)
631 		),
632 
633 		TP_fast_assign(
634 			__entry->dev = dir->i_sb->s_dev;
635 			__entry->dir = NFS_FILEID(dir);
636 			__entry->error = error < 0 ? -error : 0;
637 			__assign_str(name, dentry->d_name.name);
638 		),
639 
640 		TP_printk(
641 			"error=%ld (%s) name=%02x:%02x:%llu/%s",
642 			-__entry->error, nfs_show_status(__entry->error),
643 			MAJOR(__entry->dev), MINOR(__entry->dev),
644 			(unsigned long long)__entry->dir,
645 			__get_str(name)
646 		)
647 );
648 
649 #define DEFINE_NFS_DIRECTORY_EVENT_DONE(name) \
650 	DEFINE_EVENT(nfs_directory_event_done, name, \
651 			TP_PROTO( \
652 				const struct inode *dir, \
653 				const struct dentry *dentry, \
654 				int error \
655 			), \
656 			TP_ARGS(dir, dentry, error))
657 
658 DEFINE_NFS_DIRECTORY_EVENT(nfs_mknod_enter);
659 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_mknod_exit);
660 DEFINE_NFS_DIRECTORY_EVENT(nfs_mkdir_enter);
661 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_mkdir_exit);
662 DEFINE_NFS_DIRECTORY_EVENT(nfs_rmdir_enter);
663 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_rmdir_exit);
664 DEFINE_NFS_DIRECTORY_EVENT(nfs_remove_enter);
665 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_remove_exit);
666 DEFINE_NFS_DIRECTORY_EVENT(nfs_unlink_enter);
667 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_unlink_exit);
668 DEFINE_NFS_DIRECTORY_EVENT(nfs_symlink_enter);
669 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_symlink_exit);
670 
671 TRACE_EVENT(nfs_link_enter,
672 		TP_PROTO(
673 			const struct inode *inode,
674 			const struct inode *dir,
675 			const struct dentry *dentry
676 		),
677 
678 		TP_ARGS(inode, dir, dentry),
679 
680 		TP_STRUCT__entry(
681 			__field(dev_t, dev)
682 			__field(u64, fileid)
683 			__field(u64, dir)
684 			__string(name, dentry->d_name.name)
685 		),
686 
687 		TP_fast_assign(
688 			__entry->dev = inode->i_sb->s_dev;
689 			__entry->fileid = NFS_FILEID(inode);
690 			__entry->dir = NFS_FILEID(dir);
691 			__assign_str(name, dentry->d_name.name);
692 		),
693 
694 		TP_printk(
695 			"fileid=%02x:%02x:%llu name=%02x:%02x:%llu/%s",
696 			MAJOR(__entry->dev), MINOR(__entry->dev),
697 			__entry->fileid,
698 			MAJOR(__entry->dev), MINOR(__entry->dev),
699 			(unsigned long long)__entry->dir,
700 			__get_str(name)
701 		)
702 );
703 
704 TRACE_EVENT(nfs_link_exit,
705 		TP_PROTO(
706 			const struct inode *inode,
707 			const struct inode *dir,
708 			const struct dentry *dentry,
709 			int error
710 		),
711 
712 		TP_ARGS(inode, dir, dentry, error),
713 
714 		TP_STRUCT__entry(
715 			__field(unsigned long, error)
716 			__field(dev_t, dev)
717 			__field(u64, fileid)
718 			__field(u64, dir)
719 			__string(name, dentry->d_name.name)
720 		),
721 
722 		TP_fast_assign(
723 			__entry->dev = inode->i_sb->s_dev;
724 			__entry->fileid = NFS_FILEID(inode);
725 			__entry->dir = NFS_FILEID(dir);
726 			__entry->error = error < 0 ? -error : 0;
727 			__assign_str(name, dentry->d_name.name);
728 		),
729 
730 		TP_printk(
731 			"error=%ld (%s) fileid=%02x:%02x:%llu name=%02x:%02x:%llu/%s",
732 			-__entry->error, nfs_show_status(__entry->error),
733 			MAJOR(__entry->dev), MINOR(__entry->dev),
734 			__entry->fileid,
735 			MAJOR(__entry->dev), MINOR(__entry->dev),
736 			(unsigned long long)__entry->dir,
737 			__get_str(name)
738 		)
739 );
740 
741 DECLARE_EVENT_CLASS(nfs_rename_event,
742 		TP_PROTO(
743 			const struct inode *old_dir,
744 			const struct dentry *old_dentry,
745 			const struct inode *new_dir,
746 			const struct dentry *new_dentry
747 		),
748 
749 		TP_ARGS(old_dir, old_dentry, new_dir, new_dentry),
750 
751 		TP_STRUCT__entry(
752 			__field(dev_t, dev)
753 			__field(u64, old_dir)
754 			__field(u64, new_dir)
755 			__string(old_name, old_dentry->d_name.name)
756 			__string(new_name, new_dentry->d_name.name)
757 		),
758 
759 		TP_fast_assign(
760 			__entry->dev = old_dir->i_sb->s_dev;
761 			__entry->old_dir = NFS_FILEID(old_dir);
762 			__entry->new_dir = NFS_FILEID(new_dir);
763 			__assign_str(old_name, old_dentry->d_name.name);
764 			__assign_str(new_name, new_dentry->d_name.name);
765 		),
766 
767 		TP_printk(
768 			"old_name=%02x:%02x:%llu/%s new_name=%02x:%02x:%llu/%s",
769 			MAJOR(__entry->dev), MINOR(__entry->dev),
770 			(unsigned long long)__entry->old_dir,
771 			__get_str(old_name),
772 			MAJOR(__entry->dev), MINOR(__entry->dev),
773 			(unsigned long long)__entry->new_dir,
774 			__get_str(new_name)
775 		)
776 );
777 #define DEFINE_NFS_RENAME_EVENT(name) \
778 	DEFINE_EVENT(nfs_rename_event, name, \
779 			TP_PROTO( \
780 				const struct inode *old_dir, \
781 				const struct dentry *old_dentry, \
782 				const struct inode *new_dir, \
783 				const struct dentry *new_dentry \
784 			), \
785 			TP_ARGS(old_dir, old_dentry, new_dir, new_dentry))
786 
787 DECLARE_EVENT_CLASS(nfs_rename_event_done,
788 		TP_PROTO(
789 			const struct inode *old_dir,
790 			const struct dentry *old_dentry,
791 			const struct inode *new_dir,
792 			const struct dentry *new_dentry,
793 			int error
794 		),
795 
796 		TP_ARGS(old_dir, old_dentry, new_dir, new_dentry, error),
797 
798 		TP_STRUCT__entry(
799 			__field(dev_t, dev)
800 			__field(unsigned long, error)
801 			__field(u64, old_dir)
802 			__string(old_name, old_dentry->d_name.name)
803 			__field(u64, new_dir)
804 			__string(new_name, new_dentry->d_name.name)
805 		),
806 
807 		TP_fast_assign(
808 			__entry->dev = old_dir->i_sb->s_dev;
809 			__entry->error = -error;
810 			__entry->old_dir = NFS_FILEID(old_dir);
811 			__entry->new_dir = NFS_FILEID(new_dir);
812 			__assign_str(old_name, old_dentry->d_name.name);
813 			__assign_str(new_name, new_dentry->d_name.name);
814 		),
815 
816 		TP_printk(
817 			"error=%ld (%s) old_name=%02x:%02x:%llu/%s "
818 			"new_name=%02x:%02x:%llu/%s",
819 			-__entry->error, nfs_show_status(__entry->error),
820 			MAJOR(__entry->dev), MINOR(__entry->dev),
821 			(unsigned long long)__entry->old_dir,
822 			__get_str(old_name),
823 			MAJOR(__entry->dev), MINOR(__entry->dev),
824 			(unsigned long long)__entry->new_dir,
825 			__get_str(new_name)
826 		)
827 );
828 #define DEFINE_NFS_RENAME_EVENT_DONE(name) \
829 	DEFINE_EVENT(nfs_rename_event_done, name, \
830 			TP_PROTO( \
831 				const struct inode *old_dir, \
832 				const struct dentry *old_dentry, \
833 				const struct inode *new_dir, \
834 				const struct dentry *new_dentry, \
835 				int error \
836 			), \
837 			TP_ARGS(old_dir, old_dentry, new_dir, \
838 				new_dentry, error))
839 
840 DEFINE_NFS_RENAME_EVENT(nfs_rename_enter);
841 DEFINE_NFS_RENAME_EVENT_DONE(nfs_rename_exit);
842 
843 DEFINE_NFS_RENAME_EVENT_DONE(nfs_sillyrename_rename);
844 
845 TRACE_EVENT(nfs_sillyrename_unlink,
846 		TP_PROTO(
847 			const struct nfs_unlinkdata *data,
848 			int error
849 		),
850 
851 		TP_ARGS(data, error),
852 
853 		TP_STRUCT__entry(
854 			__field(dev_t, dev)
855 			__field(unsigned long, error)
856 			__field(u64, dir)
857 			__dynamic_array(char, name, data->args.name.len + 1)
858 		),
859 
860 		TP_fast_assign(
861 			struct inode *dir = d_inode(data->dentry->d_parent);
862 			size_t len = data->args.name.len;
863 			__entry->dev = dir->i_sb->s_dev;
864 			__entry->dir = NFS_FILEID(dir);
865 			__entry->error = -error;
866 			memcpy(__get_str(name),
867 				data->args.name.name, len);
868 			__get_str(name)[len] = 0;
869 		),
870 
871 		TP_printk(
872 			"error=%ld (%s) name=%02x:%02x:%llu/%s",
873 			-__entry->error, nfs_show_status(__entry->error),
874 			MAJOR(__entry->dev), MINOR(__entry->dev),
875 			(unsigned long long)__entry->dir,
876 			__get_str(name)
877 		)
878 );
879 
880 TRACE_EVENT(nfs_initiate_read,
881 		TP_PROTO(
882 			const struct nfs_pgio_header *hdr
883 		),
884 
885 		TP_ARGS(hdr),
886 
887 		TP_STRUCT__entry(
888 			__field(dev_t, dev)
889 			__field(u32, fhandle)
890 			__field(u64, fileid)
891 			__field(loff_t, offset)
892 			__field(u32, count)
893 		),
894 
895 		TP_fast_assign(
896 			const struct inode *inode = hdr->inode;
897 			const struct nfs_inode *nfsi = NFS_I(inode);
898 			const struct nfs_fh *fh = hdr->args.fh ?
899 						  hdr->args.fh : &nfsi->fh;
900 
901 			__entry->offset = hdr->args.offset;
902 			__entry->count = hdr->args.count;
903 			__entry->dev = inode->i_sb->s_dev;
904 			__entry->fileid = nfsi->fileid;
905 			__entry->fhandle = nfs_fhandle_hash(fh);
906 		),
907 
908 		TP_printk(
909 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
910 			"offset=%lld count=%u",
911 			MAJOR(__entry->dev), MINOR(__entry->dev),
912 			(unsigned long long)__entry->fileid,
913 			__entry->fhandle,
914 			(long long)__entry->offset, __entry->count
915 		)
916 );
917 
918 TRACE_EVENT(nfs_readpage_done,
919 		TP_PROTO(
920 			const struct rpc_task *task,
921 			const struct nfs_pgio_header *hdr
922 		),
923 
924 		TP_ARGS(task, hdr),
925 
926 		TP_STRUCT__entry(
927 			__field(dev_t, dev)
928 			__field(u32, fhandle)
929 			__field(u64, fileid)
930 			__field(loff_t, offset)
931 			__field(u32, arg_count)
932 			__field(u32, res_count)
933 			__field(bool, eof)
934 			__field(int, status)
935 		),
936 
937 		TP_fast_assign(
938 			const struct inode *inode = hdr->inode;
939 			const struct nfs_inode *nfsi = NFS_I(inode);
940 			const struct nfs_fh *fh = hdr->args.fh ?
941 						  hdr->args.fh : &nfsi->fh;
942 
943 			__entry->status = task->tk_status;
944 			__entry->offset = hdr->args.offset;
945 			__entry->arg_count = hdr->args.count;
946 			__entry->res_count = hdr->res.count;
947 			__entry->eof = hdr->res.eof;
948 			__entry->dev = inode->i_sb->s_dev;
949 			__entry->fileid = nfsi->fileid;
950 			__entry->fhandle = nfs_fhandle_hash(fh);
951 		),
952 
953 		TP_printk(
954 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
955 			"offset=%lld count=%u res=%u status=%d%s",
956 			MAJOR(__entry->dev), MINOR(__entry->dev),
957 			(unsigned long long)__entry->fileid,
958 			__entry->fhandle,
959 			(long long)__entry->offset, __entry->arg_count,
960 			__entry->res_count, __entry->status,
961 			__entry->eof ? " eof" : ""
962 		)
963 );
964 
965 TRACE_EVENT(nfs_readpage_short,
966 		TP_PROTO(
967 			const struct rpc_task *task,
968 			const struct nfs_pgio_header *hdr
969 		),
970 
971 		TP_ARGS(task, hdr),
972 
973 		TP_STRUCT__entry(
974 			__field(dev_t, dev)
975 			__field(u32, fhandle)
976 			__field(u64, fileid)
977 			__field(loff_t, offset)
978 			__field(u32, arg_count)
979 			__field(u32, res_count)
980 			__field(bool, eof)
981 			__field(int, status)
982 		),
983 
984 		TP_fast_assign(
985 			const struct inode *inode = hdr->inode;
986 			const struct nfs_inode *nfsi = NFS_I(inode);
987 			const struct nfs_fh *fh = hdr->args.fh ?
988 						  hdr->args.fh : &nfsi->fh;
989 
990 			__entry->status = task->tk_status;
991 			__entry->offset = hdr->args.offset;
992 			__entry->arg_count = hdr->args.count;
993 			__entry->res_count = hdr->res.count;
994 			__entry->eof = hdr->res.eof;
995 			__entry->dev = inode->i_sb->s_dev;
996 			__entry->fileid = nfsi->fileid;
997 			__entry->fhandle = nfs_fhandle_hash(fh);
998 		),
999 
1000 		TP_printk(
1001 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1002 			"offset=%lld count=%u res=%u status=%d%s",
1003 			MAJOR(__entry->dev), MINOR(__entry->dev),
1004 			(unsigned long long)__entry->fileid,
1005 			__entry->fhandle,
1006 			(long long)__entry->offset, __entry->arg_count,
1007 			__entry->res_count, __entry->status,
1008 			__entry->eof ? " eof" : ""
1009 		)
1010 );
1011 
1012 TRACE_EVENT(nfs_pgio_error,
1013 	TP_PROTO(
1014 		const struct nfs_pgio_header *hdr,
1015 		int error,
1016 		loff_t pos
1017 	),
1018 
1019 	TP_ARGS(hdr, error, pos),
1020 
1021 	TP_STRUCT__entry(
1022 		__field(dev_t, dev)
1023 		__field(u32, fhandle)
1024 		__field(u64, fileid)
1025 		__field(loff_t, offset)
1026 		__field(u32, arg_count)
1027 		__field(u32, res_count)
1028 		__field(loff_t, pos)
1029 		__field(int, status)
1030 	),
1031 
1032 	TP_fast_assign(
1033 		const struct inode *inode = hdr->inode;
1034 		const struct nfs_inode *nfsi = NFS_I(inode);
1035 		const struct nfs_fh *fh = hdr->args.fh ?
1036 					  hdr->args.fh : &nfsi->fh;
1037 
1038 		__entry->status = error;
1039 		__entry->offset = hdr->args.offset;
1040 		__entry->arg_count = hdr->args.count;
1041 		__entry->res_count = hdr->res.count;
1042 		__entry->dev = inode->i_sb->s_dev;
1043 		__entry->fileid = nfsi->fileid;
1044 		__entry->fhandle = nfs_fhandle_hash(fh);
1045 	),
1046 
1047 	TP_printk("fileid=%02x:%02x:%llu fhandle=0x%08x "
1048 		  "offset=%lld count=%u res=%u pos=%llu status=%d",
1049 		MAJOR(__entry->dev), MINOR(__entry->dev),
1050 		(unsigned long long)__entry->fileid, __entry->fhandle,
1051 		(long long)__entry->offset, __entry->arg_count, __entry->res_count,
1052 		__entry->pos, __entry->status
1053 	)
1054 );
1055 
1056 TRACE_DEFINE_ENUM(NFS_UNSTABLE);
1057 TRACE_DEFINE_ENUM(NFS_DATA_SYNC);
1058 TRACE_DEFINE_ENUM(NFS_FILE_SYNC);
1059 
1060 #define nfs_show_stable(stable) \
1061 	__print_symbolic(stable, \
1062 			{ NFS_UNSTABLE, "UNSTABLE" }, \
1063 			{ NFS_DATA_SYNC, "DATA_SYNC" }, \
1064 			{ NFS_FILE_SYNC, "FILE_SYNC" })
1065 
1066 TRACE_EVENT(nfs_initiate_write,
1067 		TP_PROTO(
1068 			const struct nfs_pgio_header *hdr
1069 		),
1070 
1071 		TP_ARGS(hdr),
1072 
1073 		TP_STRUCT__entry(
1074 			__field(dev_t, dev)
1075 			__field(u32, fhandle)
1076 			__field(u64, fileid)
1077 			__field(loff_t, offset)
1078 			__field(u32, count)
1079 			__field(enum nfs3_stable_how, stable)
1080 		),
1081 
1082 		TP_fast_assign(
1083 			const struct inode *inode = hdr->inode;
1084 			const struct nfs_inode *nfsi = NFS_I(inode);
1085 			const struct nfs_fh *fh = hdr->args.fh ?
1086 						  hdr->args.fh : &nfsi->fh;
1087 
1088 			__entry->offset = hdr->args.offset;
1089 			__entry->count = hdr->args.count;
1090 			__entry->stable = hdr->args.stable;
1091 			__entry->dev = inode->i_sb->s_dev;
1092 			__entry->fileid = nfsi->fileid;
1093 			__entry->fhandle = nfs_fhandle_hash(fh);
1094 		),
1095 
1096 		TP_printk(
1097 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1098 			"offset=%lld count=%u stable=%s",
1099 			MAJOR(__entry->dev), MINOR(__entry->dev),
1100 			(unsigned long long)__entry->fileid,
1101 			__entry->fhandle,
1102 			(long long)__entry->offset, __entry->count,
1103 			nfs_show_stable(__entry->stable)
1104 		)
1105 );
1106 
1107 TRACE_EVENT(nfs_writeback_done,
1108 		TP_PROTO(
1109 			const struct rpc_task *task,
1110 			const struct nfs_pgio_header *hdr
1111 		),
1112 
1113 		TP_ARGS(task, hdr),
1114 
1115 		TP_STRUCT__entry(
1116 			__field(dev_t, dev)
1117 			__field(u32, fhandle)
1118 			__field(u64, fileid)
1119 			__field(loff_t, offset)
1120 			__field(u32, arg_count)
1121 			__field(u32, res_count)
1122 			__field(int, status)
1123 			__field(enum nfs3_stable_how, stable)
1124 			__array(char, verifier, NFS4_VERIFIER_SIZE)
1125 		),
1126 
1127 		TP_fast_assign(
1128 			const struct inode *inode = hdr->inode;
1129 			const struct nfs_inode *nfsi = NFS_I(inode);
1130 			const struct nfs_fh *fh = hdr->args.fh ?
1131 						  hdr->args.fh : &nfsi->fh;
1132 			const struct nfs_writeverf *verf = hdr->res.verf;
1133 
1134 			__entry->status = task->tk_status;
1135 			__entry->offset = hdr->args.offset;
1136 			__entry->arg_count = hdr->args.count;
1137 			__entry->res_count = hdr->res.count;
1138 			__entry->stable = verf->committed;
1139 			memcpy(__entry->verifier,
1140 				&verf->verifier,
1141 				NFS4_VERIFIER_SIZE);
1142 			__entry->dev = inode->i_sb->s_dev;
1143 			__entry->fileid = nfsi->fileid;
1144 			__entry->fhandle = nfs_fhandle_hash(fh);
1145 		),
1146 
1147 		TP_printk(
1148 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1149 			"offset=%lld count=%u res=%u status=%d stable=%s "
1150 			"verifier=%s",
1151 			MAJOR(__entry->dev), MINOR(__entry->dev),
1152 			(unsigned long long)__entry->fileid,
1153 			__entry->fhandle,
1154 			(long long)__entry->offset, __entry->arg_count,
1155 			__entry->res_count, __entry->status,
1156 			nfs_show_stable(__entry->stable),
1157 			__print_hex_str(__entry->verifier, NFS4_VERIFIER_SIZE)
1158 		)
1159 );
1160 
1161 DECLARE_EVENT_CLASS(nfs_page_error_class,
1162 		TP_PROTO(
1163 			const struct nfs_page *req,
1164 			int error
1165 		),
1166 
1167 		TP_ARGS(req, error),
1168 
1169 		TP_STRUCT__entry(
1170 			__field(const void *, req)
1171 			__field(pgoff_t, index)
1172 			__field(unsigned int, offset)
1173 			__field(unsigned int, pgbase)
1174 			__field(unsigned int, bytes)
1175 			__field(int, error)
1176 		),
1177 
1178 		TP_fast_assign(
1179 			__entry->req = req;
1180 			__entry->index = req->wb_index;
1181 			__entry->offset = req->wb_offset;
1182 			__entry->pgbase = req->wb_pgbase;
1183 			__entry->bytes = req->wb_bytes;
1184 			__entry->error = error;
1185 		),
1186 
1187 		TP_printk(
1188 			"req=%p index=%lu offset=%u pgbase=%u bytes=%u error=%d",
1189 			__entry->req, __entry->index, __entry->offset,
1190 			__entry->pgbase, __entry->bytes, __entry->error
1191 		)
1192 );
1193 
1194 #define DEFINE_NFS_PAGEERR_EVENT(name) \
1195 	DEFINE_EVENT(nfs_page_error_class, name, \
1196 			TP_PROTO( \
1197 				const struct nfs_page *req, \
1198 				int error \
1199 			), \
1200 			TP_ARGS(req, error))
1201 
1202 DEFINE_NFS_PAGEERR_EVENT(nfs_write_error);
1203 DEFINE_NFS_PAGEERR_EVENT(nfs_comp_error);
1204 DEFINE_NFS_PAGEERR_EVENT(nfs_commit_error);
1205 
1206 TRACE_EVENT(nfs_initiate_commit,
1207 		TP_PROTO(
1208 			const struct nfs_commit_data *data
1209 		),
1210 
1211 		TP_ARGS(data),
1212 
1213 		TP_STRUCT__entry(
1214 			__field(dev_t, dev)
1215 			__field(u32, fhandle)
1216 			__field(u64, fileid)
1217 			__field(loff_t, offset)
1218 			__field(u32, count)
1219 		),
1220 
1221 		TP_fast_assign(
1222 			const struct inode *inode = data->inode;
1223 			const struct nfs_inode *nfsi = NFS_I(inode);
1224 			const struct nfs_fh *fh = data->args.fh ?
1225 						  data->args.fh : &nfsi->fh;
1226 
1227 			__entry->offset = data->args.offset;
1228 			__entry->count = data->args.count;
1229 			__entry->dev = inode->i_sb->s_dev;
1230 			__entry->fileid = nfsi->fileid;
1231 			__entry->fhandle = nfs_fhandle_hash(fh);
1232 		),
1233 
1234 		TP_printk(
1235 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1236 			"offset=%lld count=%u",
1237 			MAJOR(__entry->dev), MINOR(__entry->dev),
1238 			(unsigned long long)__entry->fileid,
1239 			__entry->fhandle,
1240 			(long long)__entry->offset, __entry->count
1241 		)
1242 );
1243 
1244 TRACE_EVENT(nfs_commit_done,
1245 		TP_PROTO(
1246 			const struct rpc_task *task,
1247 			const struct nfs_commit_data *data
1248 		),
1249 
1250 		TP_ARGS(task, data),
1251 
1252 		TP_STRUCT__entry(
1253 			__field(dev_t, dev)
1254 			__field(u32, fhandle)
1255 			__field(u64, fileid)
1256 			__field(loff_t, offset)
1257 			__field(int, status)
1258 			__field(enum nfs3_stable_how, stable)
1259 			__array(char, verifier, NFS4_VERIFIER_SIZE)
1260 		),
1261 
1262 		TP_fast_assign(
1263 			const struct inode *inode = data->inode;
1264 			const struct nfs_inode *nfsi = NFS_I(inode);
1265 			const struct nfs_fh *fh = data->args.fh ?
1266 						  data->args.fh : &nfsi->fh;
1267 			const struct nfs_writeverf *verf = data->res.verf;
1268 
1269 			__entry->status = task->tk_status;
1270 			__entry->offset = data->args.offset;
1271 			__entry->stable = verf->committed;
1272 			memcpy(__entry->verifier,
1273 				&verf->verifier,
1274 				NFS4_VERIFIER_SIZE);
1275 			__entry->dev = inode->i_sb->s_dev;
1276 			__entry->fileid = nfsi->fileid;
1277 			__entry->fhandle = nfs_fhandle_hash(fh);
1278 		),
1279 
1280 		TP_printk(
1281 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1282 			"offset=%lld status=%d stable=%s verifier=%s",
1283 			MAJOR(__entry->dev), MINOR(__entry->dev),
1284 			(unsigned long long)__entry->fileid,
1285 			__entry->fhandle,
1286 			(long long)__entry->offset, __entry->status,
1287 			nfs_show_stable(__entry->stable),
1288 			__print_hex_str(__entry->verifier, NFS4_VERIFIER_SIZE)
1289 		)
1290 );
1291 
1292 TRACE_EVENT(nfs_fh_to_dentry,
1293 		TP_PROTO(
1294 			const struct super_block *sb,
1295 			const struct nfs_fh *fh,
1296 			u64 fileid,
1297 			int error
1298 		),
1299 
1300 		TP_ARGS(sb, fh, fileid, error),
1301 
1302 		TP_STRUCT__entry(
1303 			__field(int, error)
1304 			__field(dev_t, dev)
1305 			__field(u32, fhandle)
1306 			__field(u64, fileid)
1307 		),
1308 
1309 		TP_fast_assign(
1310 			__entry->error = error;
1311 			__entry->dev = sb->s_dev;
1312 			__entry->fileid = fileid;
1313 			__entry->fhandle = nfs_fhandle_hash(fh);
1314 		),
1315 
1316 		TP_printk(
1317 			"error=%d fileid=%02x:%02x:%llu fhandle=0x%08x ",
1318 			__entry->error,
1319 			MAJOR(__entry->dev), MINOR(__entry->dev),
1320 			(unsigned long long)__entry->fileid,
1321 			__entry->fhandle
1322 		)
1323 );
1324 
1325 TRACE_DEFINE_ENUM(NFS_OK);
1326 TRACE_DEFINE_ENUM(NFSERR_PERM);
1327 TRACE_DEFINE_ENUM(NFSERR_NOENT);
1328 TRACE_DEFINE_ENUM(NFSERR_IO);
1329 TRACE_DEFINE_ENUM(NFSERR_NXIO);
1330 TRACE_DEFINE_ENUM(ECHILD);
1331 TRACE_DEFINE_ENUM(NFSERR_EAGAIN);
1332 TRACE_DEFINE_ENUM(NFSERR_ACCES);
1333 TRACE_DEFINE_ENUM(NFSERR_EXIST);
1334 TRACE_DEFINE_ENUM(NFSERR_XDEV);
1335 TRACE_DEFINE_ENUM(NFSERR_NODEV);
1336 TRACE_DEFINE_ENUM(NFSERR_NOTDIR);
1337 TRACE_DEFINE_ENUM(NFSERR_ISDIR);
1338 TRACE_DEFINE_ENUM(NFSERR_INVAL);
1339 TRACE_DEFINE_ENUM(NFSERR_FBIG);
1340 TRACE_DEFINE_ENUM(NFSERR_NOSPC);
1341 TRACE_DEFINE_ENUM(NFSERR_ROFS);
1342 TRACE_DEFINE_ENUM(NFSERR_MLINK);
1343 TRACE_DEFINE_ENUM(NFSERR_OPNOTSUPP);
1344 TRACE_DEFINE_ENUM(NFSERR_NAMETOOLONG);
1345 TRACE_DEFINE_ENUM(NFSERR_NOTEMPTY);
1346 TRACE_DEFINE_ENUM(NFSERR_DQUOT);
1347 TRACE_DEFINE_ENUM(NFSERR_STALE);
1348 TRACE_DEFINE_ENUM(NFSERR_REMOTE);
1349 TRACE_DEFINE_ENUM(NFSERR_WFLUSH);
1350 TRACE_DEFINE_ENUM(NFSERR_BADHANDLE);
1351 TRACE_DEFINE_ENUM(NFSERR_NOT_SYNC);
1352 TRACE_DEFINE_ENUM(NFSERR_BAD_COOKIE);
1353 TRACE_DEFINE_ENUM(NFSERR_NOTSUPP);
1354 TRACE_DEFINE_ENUM(NFSERR_TOOSMALL);
1355 TRACE_DEFINE_ENUM(NFSERR_SERVERFAULT);
1356 TRACE_DEFINE_ENUM(NFSERR_BADTYPE);
1357 TRACE_DEFINE_ENUM(NFSERR_JUKEBOX);
1358 
1359 #define nfs_show_status(x) \
1360 	__print_symbolic(x, \
1361 			{ NFS_OK, "OK" }, \
1362 			{ NFSERR_PERM, "PERM" }, \
1363 			{ NFSERR_NOENT, "NOENT" }, \
1364 			{ NFSERR_IO, "IO" }, \
1365 			{ NFSERR_NXIO, "NXIO" }, \
1366 			{ ECHILD, "CHILD" }, \
1367 			{ NFSERR_EAGAIN, "AGAIN" }, \
1368 			{ NFSERR_ACCES, "ACCES" }, \
1369 			{ NFSERR_EXIST, "EXIST" }, \
1370 			{ NFSERR_XDEV, "XDEV" }, \
1371 			{ NFSERR_NODEV, "NODEV" }, \
1372 			{ NFSERR_NOTDIR, "NOTDIR" }, \
1373 			{ NFSERR_ISDIR, "ISDIR" }, \
1374 			{ NFSERR_INVAL, "INVAL" }, \
1375 			{ NFSERR_FBIG, "FBIG" }, \
1376 			{ NFSERR_NOSPC, "NOSPC" }, \
1377 			{ NFSERR_ROFS, "ROFS" }, \
1378 			{ NFSERR_MLINK, "MLINK" }, \
1379 			{ NFSERR_OPNOTSUPP, "OPNOTSUPP" }, \
1380 			{ NFSERR_NAMETOOLONG, "NAMETOOLONG" }, \
1381 			{ NFSERR_NOTEMPTY, "NOTEMPTY" }, \
1382 			{ NFSERR_DQUOT, "DQUOT" }, \
1383 			{ NFSERR_STALE, "STALE" }, \
1384 			{ NFSERR_REMOTE, "REMOTE" }, \
1385 			{ NFSERR_WFLUSH, "WFLUSH" }, \
1386 			{ NFSERR_BADHANDLE, "BADHANDLE" }, \
1387 			{ NFSERR_NOT_SYNC, "NOTSYNC" }, \
1388 			{ NFSERR_BAD_COOKIE, "BADCOOKIE" }, \
1389 			{ NFSERR_NOTSUPP, "NOTSUPP" }, \
1390 			{ NFSERR_TOOSMALL, "TOOSMALL" }, \
1391 			{ NFSERR_SERVERFAULT, "REMOTEIO" }, \
1392 			{ NFSERR_BADTYPE, "BADTYPE" }, \
1393 			{ NFSERR_JUKEBOX, "JUKEBOX" })
1394 
1395 TRACE_EVENT(nfs_xdr_status,
1396 		TP_PROTO(
1397 			const struct xdr_stream *xdr,
1398 			int error
1399 		),
1400 
1401 		TP_ARGS(xdr, error),
1402 
1403 		TP_STRUCT__entry(
1404 			__field(unsigned int, task_id)
1405 			__field(unsigned int, client_id)
1406 			__field(u32, xid)
1407 			__field(int, version)
1408 			__field(unsigned long, error)
1409 			__string(program,
1410 				 xdr->rqst->rq_task->tk_client->cl_program->name)
1411 			__string(procedure,
1412 				 xdr->rqst->rq_task->tk_msg.rpc_proc->p_name)
1413 		),
1414 
1415 		TP_fast_assign(
1416 			const struct rpc_rqst *rqstp = xdr->rqst;
1417 			const struct rpc_task *task = rqstp->rq_task;
1418 
1419 			__entry->task_id = task->tk_pid;
1420 			__entry->client_id = task->tk_client->cl_clid;
1421 			__entry->xid = be32_to_cpu(rqstp->rq_xid);
1422 			__entry->version = task->tk_client->cl_vers;
1423 			__entry->error = error;
1424 			__assign_str(program,
1425 				     task->tk_client->cl_program->name)
1426 			__assign_str(procedure, task->tk_msg.rpc_proc->p_name)
1427 		),
1428 
1429 		TP_printk(
1430 			"task:%u@%d xid=0x%08x %sv%d %s error=%ld (%s)",
1431 			__entry->task_id, __entry->client_id, __entry->xid,
1432 			__get_str(program), __entry->version,
1433 			__get_str(procedure), -__entry->error,
1434 			nfs_show_status(__entry->error)
1435 		)
1436 );
1437 
1438 #endif /* _TRACE_NFS_H */
1439 
1440 #undef TRACE_INCLUDE_PATH
1441 #define TRACE_INCLUDE_PATH .
1442 #define TRACE_INCLUDE_FILE nfstrace
1443 /* This part must be outside protection */
1444 #include <trace/define_trace.h>
1445