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