xref: /linux/fs/nfs/nfstrace.h (revision e9f0878c4b2004ac19581274c1ae4c61ae3ca70e)
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 #define nfs_show_file_type(ftype) \
15 	__print_symbolic(ftype, \
16 			{ DT_UNKNOWN, "UNKNOWN" }, \
17 			{ DT_FIFO, "FIFO" }, \
18 			{ DT_CHR, "CHR" }, \
19 			{ DT_DIR, "DIR" }, \
20 			{ DT_BLK, "BLK" }, \
21 			{ DT_REG, "REG" }, \
22 			{ DT_LNK, "LNK" }, \
23 			{ DT_SOCK, "SOCK" }, \
24 			{ DT_WHT, "WHT" })
25 
26 #define nfs_show_cache_validity(v) \
27 	__print_flags(v, "|", \
28 			{ NFS_INO_INVALID_ATTR, "INVALID_ATTR" }, \
29 			{ NFS_INO_INVALID_DATA, "INVALID_DATA" }, \
30 			{ NFS_INO_INVALID_ATIME, "INVALID_ATIME" }, \
31 			{ NFS_INO_INVALID_ACCESS, "INVALID_ACCESS" }, \
32 			{ NFS_INO_INVALID_ACL, "INVALID_ACL" }, \
33 			{ NFS_INO_REVAL_PAGECACHE, "REVAL_PAGECACHE" }, \
34 			{ NFS_INO_REVAL_FORCED, "REVAL_FORCED" }, \
35 			{ NFS_INO_INVALID_LABEL, "INVALID_LABEL" })
36 
37 #define nfs_show_nfsi_flags(v) \
38 	__print_flags(v, "|", \
39 			{ 1 << NFS_INO_ADVISE_RDPLUS, "ADVISE_RDPLUS" }, \
40 			{ 1 << NFS_INO_STALE, "STALE" }, \
41 			{ 1 << NFS_INO_INVALIDATING, "INVALIDATING" }, \
42 			{ 1 << NFS_INO_FSCACHE, "FSCACHE" }, \
43 			{ 1 << NFS_INO_LAYOUTCOMMIT, "NEED_LAYOUTCOMMIT" }, \
44 			{ 1 << NFS_INO_LAYOUTCOMMITTING, "LAYOUTCOMMIT" })
45 
46 DECLARE_EVENT_CLASS(nfs_inode_event,
47 		TP_PROTO(
48 			const struct inode *inode
49 		),
50 
51 		TP_ARGS(inode),
52 
53 		TP_STRUCT__entry(
54 			__field(dev_t, dev)
55 			__field(u32, fhandle)
56 			__field(u64, fileid)
57 			__field(u64, version)
58 		),
59 
60 		TP_fast_assign(
61 			const struct nfs_inode *nfsi = NFS_I(inode);
62 			__entry->dev = inode->i_sb->s_dev;
63 			__entry->fileid = nfsi->fileid;
64 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
65 			__entry->version = inode_peek_iversion_raw(inode);
66 		),
67 
68 		TP_printk(
69 			"fileid=%02x:%02x:%llu fhandle=0x%08x version=%llu ",
70 			MAJOR(__entry->dev), MINOR(__entry->dev),
71 			(unsigned long long)__entry->fileid,
72 			__entry->fhandle,
73 			(unsigned long long)__entry->version
74 		)
75 );
76 
77 DECLARE_EVENT_CLASS(nfs_inode_event_done,
78 		TP_PROTO(
79 			const struct inode *inode,
80 			int error
81 		),
82 
83 		TP_ARGS(inode, error),
84 
85 		TP_STRUCT__entry(
86 			__field(int, error)
87 			__field(dev_t, dev)
88 			__field(u32, fhandle)
89 			__field(unsigned char, type)
90 			__field(u64, fileid)
91 			__field(u64, version)
92 			__field(loff_t, size)
93 			__field(unsigned long, nfsi_flags)
94 			__field(unsigned long, cache_validity)
95 		),
96 
97 		TP_fast_assign(
98 			const struct nfs_inode *nfsi = NFS_I(inode);
99 			__entry->error = error;
100 			__entry->dev = inode->i_sb->s_dev;
101 			__entry->fileid = nfsi->fileid;
102 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
103 			__entry->type = nfs_umode_to_dtype(inode->i_mode);
104 			__entry->version = inode_peek_iversion_raw(inode);
105 			__entry->size = i_size_read(inode);
106 			__entry->nfsi_flags = nfsi->flags;
107 			__entry->cache_validity = nfsi->cache_validity;
108 		),
109 
110 		TP_printk(
111 			"error=%d fileid=%02x:%02x:%llu fhandle=0x%08x "
112 			"type=%u (%s) version=%llu size=%lld "
113 			"cache_validity=%lu (%s) nfs_flags=%ld (%s)",
114 			__entry->error,
115 			MAJOR(__entry->dev), MINOR(__entry->dev),
116 			(unsigned long long)__entry->fileid,
117 			__entry->fhandle,
118 			__entry->type,
119 			nfs_show_file_type(__entry->type),
120 			(unsigned long long)__entry->version,
121 			(long long)__entry->size,
122 			__entry->cache_validity,
123 			nfs_show_cache_validity(__entry->cache_validity),
124 			__entry->nfsi_flags,
125 			nfs_show_nfsi_flags(__entry->nfsi_flags)
126 		)
127 );
128 
129 #define DEFINE_NFS_INODE_EVENT(name) \
130 	DEFINE_EVENT(nfs_inode_event, name, \
131 			TP_PROTO( \
132 				const struct inode *inode \
133 			), \
134 			TP_ARGS(inode))
135 #define DEFINE_NFS_INODE_EVENT_DONE(name) \
136 	DEFINE_EVENT(nfs_inode_event_done, name, \
137 			TP_PROTO( \
138 				const struct inode *inode, \
139 				int error \
140 			), \
141 			TP_ARGS(inode, error))
142 DEFINE_NFS_INODE_EVENT(nfs_refresh_inode_enter);
143 DEFINE_NFS_INODE_EVENT_DONE(nfs_refresh_inode_exit);
144 DEFINE_NFS_INODE_EVENT(nfs_revalidate_inode_enter);
145 DEFINE_NFS_INODE_EVENT_DONE(nfs_revalidate_inode_exit);
146 DEFINE_NFS_INODE_EVENT(nfs_invalidate_mapping_enter);
147 DEFINE_NFS_INODE_EVENT_DONE(nfs_invalidate_mapping_exit);
148 DEFINE_NFS_INODE_EVENT(nfs_getattr_enter);
149 DEFINE_NFS_INODE_EVENT_DONE(nfs_getattr_exit);
150 DEFINE_NFS_INODE_EVENT(nfs_setattr_enter);
151 DEFINE_NFS_INODE_EVENT_DONE(nfs_setattr_exit);
152 DEFINE_NFS_INODE_EVENT(nfs_writeback_page_enter);
153 DEFINE_NFS_INODE_EVENT_DONE(nfs_writeback_page_exit);
154 DEFINE_NFS_INODE_EVENT(nfs_writeback_inode_enter);
155 DEFINE_NFS_INODE_EVENT_DONE(nfs_writeback_inode_exit);
156 DEFINE_NFS_INODE_EVENT(nfs_fsync_enter);
157 DEFINE_NFS_INODE_EVENT_DONE(nfs_fsync_exit);
158 DEFINE_NFS_INODE_EVENT(nfs_access_enter);
159 DEFINE_NFS_INODE_EVENT_DONE(nfs_access_exit);
160 
161 #define show_lookup_flags(flags) \
162 	__print_flags((unsigned long)flags, "|", \
163 			{ LOOKUP_AUTOMOUNT, "AUTOMOUNT" }, \
164 			{ LOOKUP_DIRECTORY, "DIRECTORY" }, \
165 			{ LOOKUP_OPEN, "OPEN" }, \
166 			{ LOOKUP_CREATE, "CREATE" }, \
167 			{ LOOKUP_EXCL, "EXCL" })
168 
169 DECLARE_EVENT_CLASS(nfs_lookup_event,
170 		TP_PROTO(
171 			const struct inode *dir,
172 			const struct dentry *dentry,
173 			unsigned int flags
174 		),
175 
176 		TP_ARGS(dir, dentry, flags),
177 
178 		TP_STRUCT__entry(
179 			__field(unsigned int, flags)
180 			__field(dev_t, dev)
181 			__field(u64, dir)
182 			__string(name, dentry->d_name.name)
183 		),
184 
185 		TP_fast_assign(
186 			__entry->dev = dir->i_sb->s_dev;
187 			__entry->dir = NFS_FILEID(dir);
188 			__entry->flags = flags;
189 			__assign_str(name, dentry->d_name.name);
190 		),
191 
192 		TP_printk(
193 			"flags=%u (%s) name=%02x:%02x:%llu/%s",
194 			__entry->flags,
195 			show_lookup_flags(__entry->flags),
196 			MAJOR(__entry->dev), MINOR(__entry->dev),
197 			(unsigned long long)__entry->dir,
198 			__get_str(name)
199 		)
200 );
201 
202 #define DEFINE_NFS_LOOKUP_EVENT(name) \
203 	DEFINE_EVENT(nfs_lookup_event, name, \
204 			TP_PROTO( \
205 				const struct inode *dir, \
206 				const struct dentry *dentry, \
207 				unsigned int flags \
208 			), \
209 			TP_ARGS(dir, dentry, flags))
210 
211 DECLARE_EVENT_CLASS(nfs_lookup_event_done,
212 		TP_PROTO(
213 			const struct inode *dir,
214 			const struct dentry *dentry,
215 			unsigned int flags,
216 			int error
217 		),
218 
219 		TP_ARGS(dir, dentry, flags, error),
220 
221 		TP_STRUCT__entry(
222 			__field(int, error)
223 			__field(unsigned int, flags)
224 			__field(dev_t, dev)
225 			__field(u64, dir)
226 			__string(name, dentry->d_name.name)
227 		),
228 
229 		TP_fast_assign(
230 			__entry->dev = dir->i_sb->s_dev;
231 			__entry->dir = NFS_FILEID(dir);
232 			__entry->error = error;
233 			__entry->flags = flags;
234 			__assign_str(name, dentry->d_name.name);
235 		),
236 
237 		TP_printk(
238 			"error=%d flags=%u (%s) name=%02x:%02x:%llu/%s",
239 			__entry->error,
240 			__entry->flags,
241 			show_lookup_flags(__entry->flags),
242 			MAJOR(__entry->dev), MINOR(__entry->dev),
243 			(unsigned long long)__entry->dir,
244 			__get_str(name)
245 		)
246 );
247 
248 #define DEFINE_NFS_LOOKUP_EVENT_DONE(name) \
249 	DEFINE_EVENT(nfs_lookup_event_done, name, \
250 			TP_PROTO( \
251 				const struct inode *dir, \
252 				const struct dentry *dentry, \
253 				unsigned int flags, \
254 				int error \
255 			), \
256 			TP_ARGS(dir, dentry, flags, error))
257 
258 DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_enter);
259 DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_lookup_exit);
260 DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_revalidate_enter);
261 DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_lookup_revalidate_exit);
262 
263 #define show_open_flags(flags) \
264 	__print_flags((unsigned long)flags, "|", \
265 		{ O_CREAT, "O_CREAT" }, \
266 		{ O_EXCL, "O_EXCL" }, \
267 		{ O_TRUNC, "O_TRUNC" }, \
268 		{ O_APPEND, "O_APPEND" }, \
269 		{ O_DSYNC, "O_DSYNC" }, \
270 		{ O_DIRECT, "O_DIRECT" }, \
271 		{ O_DIRECTORY, "O_DIRECTORY" })
272 
273 #define show_fmode_flags(mode) \
274 	__print_flags(mode, "|", \
275 		{ ((__force unsigned long)FMODE_READ), "READ" }, \
276 		{ ((__force unsigned long)FMODE_WRITE), "WRITE" }, \
277 		{ ((__force unsigned long)FMODE_EXEC), "EXEC" })
278 
279 TRACE_EVENT(nfs_atomic_open_enter,
280 		TP_PROTO(
281 			const struct inode *dir,
282 			const struct nfs_open_context *ctx,
283 			unsigned int flags
284 		),
285 
286 		TP_ARGS(dir, ctx, flags),
287 
288 		TP_STRUCT__entry(
289 			__field(unsigned int, flags)
290 			__field(unsigned int, fmode)
291 			__field(dev_t, dev)
292 			__field(u64, dir)
293 			__string(name, ctx->dentry->d_name.name)
294 		),
295 
296 		TP_fast_assign(
297 			__entry->dev = dir->i_sb->s_dev;
298 			__entry->dir = NFS_FILEID(dir);
299 			__entry->flags = flags;
300 			__entry->fmode = (__force unsigned int)ctx->mode;
301 			__assign_str(name, ctx->dentry->d_name.name);
302 		),
303 
304 		TP_printk(
305 			"flags=%u (%s) fmode=%s name=%02x:%02x:%llu/%s",
306 			__entry->flags,
307 			show_open_flags(__entry->flags),
308 			show_fmode_flags(__entry->fmode),
309 			MAJOR(__entry->dev), MINOR(__entry->dev),
310 			(unsigned long long)__entry->dir,
311 			__get_str(name)
312 		)
313 );
314 
315 TRACE_EVENT(nfs_atomic_open_exit,
316 		TP_PROTO(
317 			const struct inode *dir,
318 			const struct nfs_open_context *ctx,
319 			unsigned int flags,
320 			int error
321 		),
322 
323 		TP_ARGS(dir, ctx, flags, error),
324 
325 		TP_STRUCT__entry(
326 			__field(int, error)
327 			__field(unsigned int, flags)
328 			__field(unsigned int, fmode)
329 			__field(dev_t, dev)
330 			__field(u64, dir)
331 			__string(name, ctx->dentry->d_name.name)
332 		),
333 
334 		TP_fast_assign(
335 			__entry->error = error;
336 			__entry->dev = dir->i_sb->s_dev;
337 			__entry->dir = NFS_FILEID(dir);
338 			__entry->flags = flags;
339 			__entry->fmode = (__force unsigned int)ctx->mode;
340 			__assign_str(name, ctx->dentry->d_name.name);
341 		),
342 
343 		TP_printk(
344 			"error=%d flags=%u (%s) fmode=%s "
345 			"name=%02x:%02x:%llu/%s",
346 			__entry->error,
347 			__entry->flags,
348 			show_open_flags(__entry->flags),
349 			show_fmode_flags(__entry->fmode),
350 			MAJOR(__entry->dev), MINOR(__entry->dev),
351 			(unsigned long long)__entry->dir,
352 			__get_str(name)
353 		)
354 );
355 
356 TRACE_EVENT(nfs_create_enter,
357 		TP_PROTO(
358 			const struct inode *dir,
359 			const struct dentry *dentry,
360 			unsigned int flags
361 		),
362 
363 		TP_ARGS(dir, dentry, flags),
364 
365 		TP_STRUCT__entry(
366 			__field(unsigned int, flags)
367 			__field(dev_t, dev)
368 			__field(u64, dir)
369 			__string(name, dentry->d_name.name)
370 		),
371 
372 		TP_fast_assign(
373 			__entry->dev = dir->i_sb->s_dev;
374 			__entry->dir = NFS_FILEID(dir);
375 			__entry->flags = flags;
376 			__assign_str(name, dentry->d_name.name);
377 		),
378 
379 		TP_printk(
380 			"flags=%u (%s) name=%02x:%02x:%llu/%s",
381 			__entry->flags,
382 			show_open_flags(__entry->flags),
383 			MAJOR(__entry->dev), MINOR(__entry->dev),
384 			(unsigned long long)__entry->dir,
385 			__get_str(name)
386 		)
387 );
388 
389 TRACE_EVENT(nfs_create_exit,
390 		TP_PROTO(
391 			const struct inode *dir,
392 			const struct dentry *dentry,
393 			unsigned int flags,
394 			int error
395 		),
396 
397 		TP_ARGS(dir, dentry, flags, error),
398 
399 		TP_STRUCT__entry(
400 			__field(int, error)
401 			__field(unsigned int, flags)
402 			__field(dev_t, dev)
403 			__field(u64, dir)
404 			__string(name, dentry->d_name.name)
405 		),
406 
407 		TP_fast_assign(
408 			__entry->error = error;
409 			__entry->dev = dir->i_sb->s_dev;
410 			__entry->dir = NFS_FILEID(dir);
411 			__entry->flags = flags;
412 			__assign_str(name, dentry->d_name.name);
413 		),
414 
415 		TP_printk(
416 			"error=%d flags=%u (%s) name=%02x:%02x:%llu/%s",
417 			__entry->error,
418 			__entry->flags,
419 			show_open_flags(__entry->flags),
420 			MAJOR(__entry->dev), MINOR(__entry->dev),
421 			(unsigned long long)__entry->dir,
422 			__get_str(name)
423 		)
424 );
425 
426 DECLARE_EVENT_CLASS(nfs_directory_event,
427 		TP_PROTO(
428 			const struct inode *dir,
429 			const struct dentry *dentry
430 		),
431 
432 		TP_ARGS(dir, dentry),
433 
434 		TP_STRUCT__entry(
435 			__field(dev_t, dev)
436 			__field(u64, dir)
437 			__string(name, dentry->d_name.name)
438 		),
439 
440 		TP_fast_assign(
441 			__entry->dev = dir->i_sb->s_dev;
442 			__entry->dir = NFS_FILEID(dir);
443 			__assign_str(name, dentry->d_name.name);
444 		),
445 
446 		TP_printk(
447 			"name=%02x:%02x:%llu/%s",
448 			MAJOR(__entry->dev), MINOR(__entry->dev),
449 			(unsigned long long)__entry->dir,
450 			__get_str(name)
451 		)
452 );
453 
454 #define DEFINE_NFS_DIRECTORY_EVENT(name) \
455 	DEFINE_EVENT(nfs_directory_event, name, \
456 			TP_PROTO( \
457 				const struct inode *dir, \
458 				const struct dentry *dentry \
459 			), \
460 			TP_ARGS(dir, dentry))
461 
462 DECLARE_EVENT_CLASS(nfs_directory_event_done,
463 		TP_PROTO(
464 			const struct inode *dir,
465 			const struct dentry *dentry,
466 			int error
467 		),
468 
469 		TP_ARGS(dir, dentry, error),
470 
471 		TP_STRUCT__entry(
472 			__field(int, error)
473 			__field(dev_t, dev)
474 			__field(u64, dir)
475 			__string(name, dentry->d_name.name)
476 		),
477 
478 		TP_fast_assign(
479 			__entry->dev = dir->i_sb->s_dev;
480 			__entry->dir = NFS_FILEID(dir);
481 			__entry->error = error;
482 			__assign_str(name, dentry->d_name.name);
483 		),
484 
485 		TP_printk(
486 			"error=%d name=%02x:%02x:%llu/%s",
487 			__entry->error,
488 			MAJOR(__entry->dev), MINOR(__entry->dev),
489 			(unsigned long long)__entry->dir,
490 			__get_str(name)
491 		)
492 );
493 
494 #define DEFINE_NFS_DIRECTORY_EVENT_DONE(name) \
495 	DEFINE_EVENT(nfs_directory_event_done, name, \
496 			TP_PROTO( \
497 				const struct inode *dir, \
498 				const struct dentry *dentry, \
499 				int error \
500 			), \
501 			TP_ARGS(dir, dentry, error))
502 
503 DEFINE_NFS_DIRECTORY_EVENT(nfs_mknod_enter);
504 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_mknod_exit);
505 DEFINE_NFS_DIRECTORY_EVENT(nfs_mkdir_enter);
506 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_mkdir_exit);
507 DEFINE_NFS_DIRECTORY_EVENT(nfs_rmdir_enter);
508 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_rmdir_exit);
509 DEFINE_NFS_DIRECTORY_EVENT(nfs_remove_enter);
510 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_remove_exit);
511 DEFINE_NFS_DIRECTORY_EVENT(nfs_unlink_enter);
512 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_unlink_exit);
513 DEFINE_NFS_DIRECTORY_EVENT(nfs_symlink_enter);
514 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_symlink_exit);
515 
516 TRACE_EVENT(nfs_link_enter,
517 		TP_PROTO(
518 			const struct inode *inode,
519 			const struct inode *dir,
520 			const struct dentry *dentry
521 		),
522 
523 		TP_ARGS(inode, dir, dentry),
524 
525 		TP_STRUCT__entry(
526 			__field(dev_t, dev)
527 			__field(u64, fileid)
528 			__field(u64, dir)
529 			__string(name, dentry->d_name.name)
530 		),
531 
532 		TP_fast_assign(
533 			__entry->dev = inode->i_sb->s_dev;
534 			__entry->fileid = NFS_FILEID(inode);
535 			__entry->dir = NFS_FILEID(dir);
536 			__assign_str(name, dentry->d_name.name);
537 		),
538 
539 		TP_printk(
540 			"fileid=%02x:%02x:%llu name=%02x:%02x:%llu/%s",
541 			MAJOR(__entry->dev), MINOR(__entry->dev),
542 			__entry->fileid,
543 			MAJOR(__entry->dev), MINOR(__entry->dev),
544 			(unsigned long long)__entry->dir,
545 			__get_str(name)
546 		)
547 );
548 
549 TRACE_EVENT(nfs_link_exit,
550 		TP_PROTO(
551 			const struct inode *inode,
552 			const struct inode *dir,
553 			const struct dentry *dentry,
554 			int error
555 		),
556 
557 		TP_ARGS(inode, dir, dentry, error),
558 
559 		TP_STRUCT__entry(
560 			__field(int, error)
561 			__field(dev_t, dev)
562 			__field(u64, fileid)
563 			__field(u64, dir)
564 			__string(name, dentry->d_name.name)
565 		),
566 
567 		TP_fast_assign(
568 			__entry->dev = inode->i_sb->s_dev;
569 			__entry->fileid = NFS_FILEID(inode);
570 			__entry->dir = NFS_FILEID(dir);
571 			__entry->error = error;
572 			__assign_str(name, dentry->d_name.name);
573 		),
574 
575 		TP_printk(
576 			"error=%d fileid=%02x:%02x:%llu name=%02x:%02x:%llu/%s",
577 			__entry->error,
578 			MAJOR(__entry->dev), MINOR(__entry->dev),
579 			__entry->fileid,
580 			MAJOR(__entry->dev), MINOR(__entry->dev),
581 			(unsigned long long)__entry->dir,
582 			__get_str(name)
583 		)
584 );
585 
586 DECLARE_EVENT_CLASS(nfs_rename_event,
587 		TP_PROTO(
588 			const struct inode *old_dir,
589 			const struct dentry *old_dentry,
590 			const struct inode *new_dir,
591 			const struct dentry *new_dentry
592 		),
593 
594 		TP_ARGS(old_dir, old_dentry, new_dir, new_dentry),
595 
596 		TP_STRUCT__entry(
597 			__field(dev_t, dev)
598 			__field(u64, old_dir)
599 			__field(u64, new_dir)
600 			__string(old_name, old_dentry->d_name.name)
601 			__string(new_name, new_dentry->d_name.name)
602 		),
603 
604 		TP_fast_assign(
605 			__entry->dev = old_dir->i_sb->s_dev;
606 			__entry->old_dir = NFS_FILEID(old_dir);
607 			__entry->new_dir = NFS_FILEID(new_dir);
608 			__assign_str(old_name, old_dentry->d_name.name);
609 			__assign_str(new_name, new_dentry->d_name.name);
610 		),
611 
612 		TP_printk(
613 			"old_name=%02x:%02x:%llu/%s new_name=%02x:%02x:%llu/%s",
614 			MAJOR(__entry->dev), MINOR(__entry->dev),
615 			(unsigned long long)__entry->old_dir,
616 			__get_str(old_name),
617 			MAJOR(__entry->dev), MINOR(__entry->dev),
618 			(unsigned long long)__entry->new_dir,
619 			__get_str(new_name)
620 		)
621 );
622 #define DEFINE_NFS_RENAME_EVENT(name) \
623 	DEFINE_EVENT(nfs_rename_event, name, \
624 			TP_PROTO( \
625 				const struct inode *old_dir, \
626 				const struct dentry *old_dentry, \
627 				const struct inode *new_dir, \
628 				const struct dentry *new_dentry \
629 			), \
630 			TP_ARGS(old_dir, old_dentry, new_dir, new_dentry))
631 
632 DECLARE_EVENT_CLASS(nfs_rename_event_done,
633 		TP_PROTO(
634 			const struct inode *old_dir,
635 			const struct dentry *old_dentry,
636 			const struct inode *new_dir,
637 			const struct dentry *new_dentry,
638 			int error
639 		),
640 
641 		TP_ARGS(old_dir, old_dentry, new_dir, new_dentry, error),
642 
643 		TP_STRUCT__entry(
644 			__field(dev_t, dev)
645 			__field(int, error)
646 			__field(u64, old_dir)
647 			__string(old_name, old_dentry->d_name.name)
648 			__field(u64, new_dir)
649 			__string(new_name, new_dentry->d_name.name)
650 		),
651 
652 		TP_fast_assign(
653 			__entry->dev = old_dir->i_sb->s_dev;
654 			__entry->old_dir = NFS_FILEID(old_dir);
655 			__entry->new_dir = NFS_FILEID(new_dir);
656 			__entry->error = error;
657 			__assign_str(old_name, old_dentry->d_name.name);
658 			__assign_str(new_name, new_dentry->d_name.name);
659 		),
660 
661 		TP_printk(
662 			"error=%d old_name=%02x:%02x:%llu/%s "
663 			"new_name=%02x:%02x:%llu/%s",
664 			__entry->error,
665 			MAJOR(__entry->dev), MINOR(__entry->dev),
666 			(unsigned long long)__entry->old_dir,
667 			__get_str(old_name),
668 			MAJOR(__entry->dev), MINOR(__entry->dev),
669 			(unsigned long long)__entry->new_dir,
670 			__get_str(new_name)
671 		)
672 );
673 #define DEFINE_NFS_RENAME_EVENT_DONE(name) \
674 	DEFINE_EVENT(nfs_rename_event_done, name, \
675 			TP_PROTO( \
676 				const struct inode *old_dir, \
677 				const struct dentry *old_dentry, \
678 				const struct inode *new_dir, \
679 				const struct dentry *new_dentry, \
680 				int error \
681 			), \
682 			TP_ARGS(old_dir, old_dentry, new_dir, \
683 				new_dentry, error))
684 
685 DEFINE_NFS_RENAME_EVENT(nfs_rename_enter);
686 DEFINE_NFS_RENAME_EVENT_DONE(nfs_rename_exit);
687 
688 DEFINE_NFS_RENAME_EVENT_DONE(nfs_sillyrename_rename);
689 
690 TRACE_EVENT(nfs_sillyrename_unlink,
691 		TP_PROTO(
692 			const struct nfs_unlinkdata *data,
693 			int error
694 		),
695 
696 		TP_ARGS(data, error),
697 
698 		TP_STRUCT__entry(
699 			__field(dev_t, dev)
700 			__field(int, error)
701 			__field(u64, dir)
702 			__dynamic_array(char, name, data->args.name.len + 1)
703 		),
704 
705 		TP_fast_assign(
706 			struct inode *dir = d_inode(data->dentry->d_parent);
707 			size_t len = data->args.name.len;
708 			__entry->dev = dir->i_sb->s_dev;
709 			__entry->dir = NFS_FILEID(dir);
710 			__entry->error = error;
711 			memcpy(__get_str(name),
712 				data->args.name.name, len);
713 			__get_str(name)[len] = 0;
714 		),
715 
716 		TP_printk(
717 			"error=%d name=%02x:%02x:%llu/%s",
718 			__entry->error,
719 			MAJOR(__entry->dev), MINOR(__entry->dev),
720 			(unsigned long long)__entry->dir,
721 			__get_str(name)
722 		)
723 );
724 
725 TRACE_EVENT(nfs_initiate_read,
726 		TP_PROTO(
727 			const struct inode *inode,
728 			loff_t offset, unsigned long count
729 		),
730 
731 		TP_ARGS(inode, offset, count),
732 
733 		TP_STRUCT__entry(
734 			__field(loff_t, offset)
735 			__field(unsigned long, count)
736 			__field(dev_t, dev)
737 			__field(u32, fhandle)
738 			__field(u64, fileid)
739 		),
740 
741 		TP_fast_assign(
742 			const struct nfs_inode *nfsi = NFS_I(inode);
743 
744 			__entry->offset = offset;
745 			__entry->count = count;
746 			__entry->dev = inode->i_sb->s_dev;
747 			__entry->fileid = nfsi->fileid;
748 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
749 		),
750 
751 		TP_printk(
752 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
753 			"offset=%lld count=%lu",
754 			MAJOR(__entry->dev), MINOR(__entry->dev),
755 			(unsigned long long)__entry->fileid,
756 			__entry->fhandle,
757 			__entry->offset, __entry->count
758 		)
759 );
760 
761 TRACE_EVENT(nfs_readpage_done,
762 		TP_PROTO(
763 			const struct inode *inode,
764 			int status, loff_t offset, bool eof
765 		),
766 
767 		TP_ARGS(inode, status, offset, eof),
768 
769 		TP_STRUCT__entry(
770 			__field(int, status)
771 			__field(loff_t, offset)
772 			__field(bool, eof)
773 			__field(dev_t, dev)
774 			__field(u32, fhandle)
775 			__field(u64, fileid)
776 		),
777 
778 		TP_fast_assign(
779 			const struct nfs_inode *nfsi = NFS_I(inode);
780 
781 			__entry->status = status;
782 			__entry->offset = offset;
783 			__entry->eof = eof;
784 			__entry->dev = inode->i_sb->s_dev;
785 			__entry->fileid = nfsi->fileid;
786 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
787 		),
788 
789 		TP_printk(
790 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
791 			"offset=%lld status=%d%s",
792 			MAJOR(__entry->dev), MINOR(__entry->dev),
793 			(unsigned long long)__entry->fileid,
794 			__entry->fhandle,
795 			__entry->offset, __entry->status,
796 			__entry->eof ? " eof" : ""
797 		)
798 );
799 
800 TRACE_DEFINE_ENUM(NFS_UNSTABLE);
801 TRACE_DEFINE_ENUM(NFS_DATA_SYNC);
802 TRACE_DEFINE_ENUM(NFS_FILE_SYNC);
803 
804 #define nfs_show_stable(stable) \
805 	__print_symbolic(stable, \
806 			{ NFS_UNSTABLE, "UNSTABLE" }, \
807 			{ NFS_DATA_SYNC, "DATA_SYNC" }, \
808 			{ NFS_FILE_SYNC, "FILE_SYNC" })
809 
810 TRACE_EVENT(nfs_initiate_write,
811 		TP_PROTO(
812 			const struct inode *inode,
813 			loff_t offset, unsigned long count,
814 			enum nfs3_stable_how stable
815 		),
816 
817 		TP_ARGS(inode, offset, count, stable),
818 
819 		TP_STRUCT__entry(
820 			__field(loff_t, offset)
821 			__field(unsigned long, count)
822 			__field(enum nfs3_stable_how, stable)
823 			__field(dev_t, dev)
824 			__field(u32, fhandle)
825 			__field(u64, fileid)
826 		),
827 
828 		TP_fast_assign(
829 			const struct nfs_inode *nfsi = NFS_I(inode);
830 
831 			__entry->offset = offset;
832 			__entry->count = count;
833 			__entry->stable = stable;
834 			__entry->dev = inode->i_sb->s_dev;
835 			__entry->fileid = nfsi->fileid;
836 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
837 		),
838 
839 		TP_printk(
840 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
841 			"offset=%lld count=%lu stable=%s",
842 			MAJOR(__entry->dev), MINOR(__entry->dev),
843 			(unsigned long long)__entry->fileid,
844 			__entry->fhandle,
845 			__entry->offset, __entry->count,
846 			nfs_show_stable(__entry->stable)
847 		)
848 );
849 
850 TRACE_EVENT(nfs_writeback_done,
851 		TP_PROTO(
852 			const struct inode *inode,
853 			int status,
854 			loff_t offset,
855 			struct nfs_writeverf *writeverf
856 		),
857 
858 		TP_ARGS(inode, status, offset, writeverf),
859 
860 		TP_STRUCT__entry(
861 			__field(int, status)
862 			__field(loff_t, offset)
863 			__field(enum nfs3_stable_how, stable)
864 			__field(unsigned long long, verifier)
865 			__field(dev_t, dev)
866 			__field(u32, fhandle)
867 			__field(u64, fileid)
868 		),
869 
870 		TP_fast_assign(
871 			const struct nfs_inode *nfsi = NFS_I(inode);
872 
873 			__entry->status = status;
874 			__entry->offset = offset;
875 			__entry->stable = writeverf->committed;
876 			memcpy(&__entry->verifier, &writeverf->verifier,
877 			       sizeof(__entry->verifier));
878 			__entry->dev = inode->i_sb->s_dev;
879 			__entry->fileid = nfsi->fileid;
880 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
881 		),
882 
883 		TP_printk(
884 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
885 			"offset=%lld status=%d stable=%s "
886 			"verifier 0x%016llx",
887 			MAJOR(__entry->dev), MINOR(__entry->dev),
888 			(unsigned long long)__entry->fileid,
889 			__entry->fhandle,
890 			__entry->offset, __entry->status,
891 			nfs_show_stable(__entry->stable),
892 			__entry->verifier
893 		)
894 );
895 
896 TRACE_EVENT(nfs_initiate_commit,
897 		TP_PROTO(
898 			const struct nfs_commit_data *data
899 		),
900 
901 		TP_ARGS(data),
902 
903 		TP_STRUCT__entry(
904 			__field(loff_t, offset)
905 			__field(unsigned long, count)
906 			__field(dev_t, dev)
907 			__field(u32, fhandle)
908 			__field(u64, fileid)
909 		),
910 
911 		TP_fast_assign(
912 			const struct inode *inode = data->inode;
913 			const struct nfs_inode *nfsi = NFS_I(inode);
914 
915 			__entry->offset = data->args.offset;
916 			__entry->count = data->args.count;
917 			__entry->dev = inode->i_sb->s_dev;
918 			__entry->fileid = nfsi->fileid;
919 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
920 		),
921 
922 		TP_printk(
923 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
924 			"offset=%lld count=%lu",
925 			MAJOR(__entry->dev), MINOR(__entry->dev),
926 			(unsigned long long)__entry->fileid,
927 			__entry->fhandle,
928 			__entry->offset, __entry->count
929 		)
930 );
931 
932 TRACE_EVENT(nfs_commit_done,
933 		TP_PROTO(
934 			const struct nfs_commit_data *data
935 		),
936 
937 		TP_ARGS(data),
938 
939 		TP_STRUCT__entry(
940 			__field(int, status)
941 			__field(loff_t, offset)
942 			__field(unsigned long long, verifier)
943 			__field(dev_t, dev)
944 			__field(u32, fhandle)
945 			__field(u64, fileid)
946 		),
947 
948 		TP_fast_assign(
949 			const struct inode *inode = data->inode;
950 			const struct nfs_inode *nfsi = NFS_I(inode);
951 
952 			__entry->status = data->res.op_status;
953 			__entry->offset = data->args.offset;
954 			memcpy(&__entry->verifier, &data->verf.verifier,
955 			       sizeof(__entry->verifier));
956 			__entry->dev = inode->i_sb->s_dev;
957 			__entry->fileid = nfsi->fileid;
958 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
959 		),
960 
961 		TP_printk(
962 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
963 			"offset=%lld status=%d verifier 0x%016llx",
964 			MAJOR(__entry->dev), MINOR(__entry->dev),
965 			(unsigned long long)__entry->fileid,
966 			__entry->fhandle,
967 			__entry->offset, __entry->status,
968 			__entry->verifier
969 		)
970 );
971 
972 #endif /* _TRACE_NFS_H */
973 
974 #undef TRACE_INCLUDE_PATH
975 #define TRACE_INCLUDE_PATH .
976 #define TRACE_INCLUDE_FILE nfstrace
977 /* This part must be outside protection */
978 #include <trace/define_trace.h>
979