2 * Copyright (c) 2013 Trond Myklebust <Trond.Myklebust@netapp.com>
5 #define TRACE_SYSTEM nfs
7 #if !defined(_TRACE_NFS_H) || defined(TRACE_HEADER_MULTI_READ)
10 #include <linux/tracepoint.h>
12 #define nfs_show_file_type(ftype) \
13 __print_symbolic(ftype, \
14 { DT_UNKNOWN, "UNKNOWN" }, \
15 { DT_FIFO, "FIFO" }, \
21 { DT_SOCK, "SOCK" }, \
24 #define nfs_show_cache_validity(v) \
25 __print_flags(v, "|", \
26 { NFS_INO_INVALID_ATTR, "INVALID_ATTR" }, \
27 { NFS_INO_INVALID_DATA, "INVALID_DATA" }, \
28 { NFS_INO_INVALID_ATIME, "INVALID_ATIME" }, \
29 { NFS_INO_INVALID_ACCESS, "INVALID_ACCESS" }, \
30 { NFS_INO_INVALID_ACL, "INVALID_ACL" }, \
31 { NFS_INO_REVAL_PAGECACHE, "REVAL_PAGECACHE" }, \
32 { NFS_INO_REVAL_FORCED, "REVAL_FORCED" }, \
33 { NFS_INO_INVALID_LABEL, "INVALID_LABEL" })
35 #define nfs_show_nfsi_flags(v) \
36 __print_flags(v, "|", \
37 { 1 << NFS_INO_ADVISE_RDPLUS, "ADVISE_RDPLUS" }, \
38 { 1 << NFS_INO_STALE, "STALE" }, \
39 { 1 << NFS_INO_INVALIDATING, "INVALIDATING" }, \
40 { 1 << NFS_INO_FLUSHING, "FLUSHING" }, \
41 { 1 << NFS_INO_FSCACHE, "FSCACHE" }, \
42 { 1 << NFS_INO_LAYOUTCOMMIT, "NEED_LAYOUTCOMMIT" }, \
43 { 1 << NFS_INO_LAYOUTCOMMITTING, "LAYOUTCOMMIT" })
45 DECLARE_EVENT_CLASS(nfs_inode_event
,
47 const struct inode
*inode
60 const struct nfs_inode
*nfsi
= NFS_I(inode
);
61 __entry
->dev
= inode
->i_sb
->s_dev
;
62 __entry
->fileid
= nfsi
->fileid
;
63 __entry
->fhandle
= nfs_fhandle_hash(&nfsi
->fh
);
64 __entry
->version
= inode
->i_version
;
68 "fileid=%02x:%02x:%llu fhandle=0x%08x version=%llu ",
69 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
70 (unsigned long long)__entry
->fileid
,
72 (unsigned long long)__entry
->version
76 DECLARE_EVENT_CLASS(nfs_inode_event_done
,
78 const struct inode
*inode
,
82 TP_ARGS(inode
, error
),
88 __field(unsigned char, type
)
92 __field(unsigned long, nfsi_flags
)
93 __field(unsigned long, cache_validity
)
97 const struct nfs_inode
*nfsi
= NFS_I(inode
);
98 __entry
->error
= error
;
99 __entry
->dev
= inode
->i_sb
->s_dev
;
100 __entry
->fileid
= nfsi
->fileid
;
101 __entry
->fhandle
= nfs_fhandle_hash(&nfsi
->fh
);
102 __entry
->type
= nfs_umode_to_dtype(inode
->i_mode
);
103 __entry
->version
= inode
->i_version
;
104 __entry
->size
= i_size_read(inode
);
105 __entry
->nfsi_flags
= nfsi
->flags
;
106 __entry
->cache_validity
= nfsi
->cache_validity
;
110 "error=%d fileid=%02x:%02x:%llu fhandle=0x%08x "
111 "type=%u (%s) version=%llu size=%lld "
112 "cache_validity=%lu (%s) nfs_flags=%ld (%s)",
114 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
115 (unsigned long long)__entry
->fileid
,
118 nfs_show_file_type(__entry
->type
),
119 (unsigned long long)__entry
->version
,
120 (long long)__entry
->size
,
121 __entry
->cache_validity
,
122 nfs_show_cache_validity(__entry
->cache_validity
),
124 nfs_show_nfsi_flags(__entry
->nfsi_flags
)
128 #define DEFINE_NFS_INODE_EVENT(name) \
129 DEFINE_EVENT(nfs_inode_event, name, \
131 const struct inode *inode \
134 #define DEFINE_NFS_INODE_EVENT_DONE(name) \
135 DEFINE_EVENT(nfs_inode_event_done, name, \
137 const struct inode *inode, \
140 TP_ARGS(inode, error))
141 DEFINE_NFS_INODE_EVENT(nfs_refresh_inode_enter
);
142 DEFINE_NFS_INODE_EVENT_DONE(nfs_refresh_inode_exit
);
143 DEFINE_NFS_INODE_EVENT(nfs_revalidate_inode_enter
);
144 DEFINE_NFS_INODE_EVENT_DONE(nfs_revalidate_inode_exit
);
145 DEFINE_NFS_INODE_EVENT(nfs_invalidate_mapping_enter
);
146 DEFINE_NFS_INODE_EVENT_DONE(nfs_invalidate_mapping_exit
);
147 DEFINE_NFS_INODE_EVENT(nfs_getattr_enter
);
148 DEFINE_NFS_INODE_EVENT_DONE(nfs_getattr_exit
);
149 DEFINE_NFS_INODE_EVENT(nfs_setattr_enter
);
150 DEFINE_NFS_INODE_EVENT_DONE(nfs_setattr_exit
);
151 DEFINE_NFS_INODE_EVENT(nfs_writeback_page_enter
);
152 DEFINE_NFS_INODE_EVENT_DONE(nfs_writeback_page_exit
);
153 DEFINE_NFS_INODE_EVENT(nfs_writeback_inode_enter
);
154 DEFINE_NFS_INODE_EVENT_DONE(nfs_writeback_inode_exit
);
155 DEFINE_NFS_INODE_EVENT(nfs_fsync_enter
);
156 DEFINE_NFS_INODE_EVENT_DONE(nfs_fsync_exit
);
157 DEFINE_NFS_INODE_EVENT(nfs_access_enter
);
158 DEFINE_NFS_INODE_EVENT_DONE(nfs_access_exit
);
160 #define show_lookup_flags(flags) \
161 __print_flags((unsigned long)flags, "|", \
162 { LOOKUP_AUTOMOUNT, "AUTOMOUNT" }, \
163 { LOOKUP_DIRECTORY, "DIRECTORY" }, \
164 { LOOKUP_OPEN, "OPEN" }, \
165 { LOOKUP_CREATE, "CREATE" }, \
166 { LOOKUP_EXCL, "EXCL" })
168 DECLARE_EVENT_CLASS(nfs_lookup_event
,
170 const struct inode
*dir
,
171 const struct dentry
*dentry
,
175 TP_ARGS(dir
, dentry
, flags
),
178 __field(unsigned int, flags
)
181 __string(name
, dentry
->d_name
.name
)
185 __entry
->dev
= dir
->i_sb
->s_dev
;
186 __entry
->dir
= NFS_FILEID(dir
);
187 __entry
->flags
= flags
;
188 __assign_str(name
, dentry
->d_name
.name
);
192 "flags=%u (%s) name=%02x:%02x:%llu/%s",
194 show_lookup_flags(__entry
->flags
),
195 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
196 (unsigned long long)__entry
->dir
,
201 #define DEFINE_NFS_LOOKUP_EVENT(name) \
202 DEFINE_EVENT(nfs_lookup_event, name, \
204 const struct inode *dir, \
205 const struct dentry *dentry, \
208 TP_ARGS(dir, dentry, flags))
210 DECLARE_EVENT_CLASS(nfs_lookup_event_done
,
212 const struct inode
*dir
,
213 const struct dentry
*dentry
,
218 TP_ARGS(dir
, dentry
, flags
, error
),
222 __field(unsigned int, flags
)
225 __string(name
, dentry
->d_name
.name
)
229 __entry
->dev
= dir
->i_sb
->s_dev
;
230 __entry
->dir
= NFS_FILEID(dir
);
231 __entry
->error
= error
;
232 __entry
->flags
= flags
;
233 __assign_str(name
, dentry
->d_name
.name
);
237 "error=%d flags=%u (%s) name=%02x:%02x:%llu/%s",
240 show_lookup_flags(__entry
->flags
),
241 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
242 (unsigned long long)__entry
->dir
,
247 #define DEFINE_NFS_LOOKUP_EVENT_DONE(name) \
248 DEFINE_EVENT(nfs_lookup_event_done, name, \
250 const struct inode *dir, \
251 const struct dentry *dentry, \
252 unsigned int flags, \
255 TP_ARGS(dir, dentry, flags, error))
257 DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_enter
);
258 DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_lookup_exit
);
259 DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_revalidate_enter
);
260 DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_lookup_revalidate_exit
);
262 #define show_open_flags(flags) \
263 __print_flags((unsigned long)flags, "|", \
264 { O_CREAT, "O_CREAT" }, \
265 { O_EXCL, "O_EXCL" }, \
266 { O_TRUNC, "O_TRUNC" }, \
267 { O_APPEND, "O_APPEND" }, \
268 { O_DSYNC, "O_DSYNC" }, \
269 { O_DIRECT, "O_DIRECT" }, \
270 { O_DIRECTORY, "O_DIRECTORY" })
272 #define show_fmode_flags(mode) \
273 __print_flags(mode, "|", \
274 { ((__force unsigned long)FMODE_READ), "READ" }, \
275 { ((__force unsigned long)FMODE_WRITE), "WRITE" }, \
276 { ((__force unsigned long)FMODE_EXEC), "EXEC" })
278 TRACE_EVENT(nfs_atomic_open_enter
,
280 const struct inode
*dir
,
281 const struct nfs_open_context
*ctx
,
285 TP_ARGS(dir
, ctx
, flags
),
288 __field(unsigned int, flags
)
289 __field(unsigned int, fmode
)
292 __string(name
, ctx
->dentry
->d_name
.name
)
296 __entry
->dev
= dir
->i_sb
->s_dev
;
297 __entry
->dir
= NFS_FILEID(dir
);
298 __entry
->flags
= flags
;
299 __entry
->fmode
= (__force
unsigned int)ctx
->mode
;
300 __assign_str(name
, ctx
->dentry
->d_name
.name
);
304 "flags=%u (%s) fmode=%s name=%02x:%02x:%llu/%s",
306 show_open_flags(__entry
->flags
),
307 show_fmode_flags(__entry
->fmode
),
308 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
309 (unsigned long long)__entry
->dir
,
314 TRACE_EVENT(nfs_atomic_open_exit
,
316 const struct inode
*dir
,
317 const struct nfs_open_context
*ctx
,
322 TP_ARGS(dir
, ctx
, flags
, error
),
326 __field(unsigned int, flags
)
327 __field(unsigned int, fmode
)
330 __string(name
, ctx
->dentry
->d_name
.name
)
334 __entry
->error
= error
;
335 __entry
->dev
= dir
->i_sb
->s_dev
;
336 __entry
->dir
= NFS_FILEID(dir
);
337 __entry
->flags
= flags
;
338 __entry
->fmode
= (__force
unsigned int)ctx
->mode
;
339 __assign_str(name
, ctx
->dentry
->d_name
.name
);
343 "error=%d flags=%u (%s) fmode=%s "
344 "name=%02x:%02x:%llu/%s",
347 show_open_flags(__entry
->flags
),
348 show_fmode_flags(__entry
->fmode
),
349 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
350 (unsigned long long)__entry
->dir
,
355 TRACE_EVENT(nfs_create_enter
,
357 const struct inode
*dir
,
358 const struct dentry
*dentry
,
362 TP_ARGS(dir
, dentry
, flags
),
365 __field(unsigned int, flags
)
368 __string(name
, dentry
->d_name
.name
)
372 __entry
->dev
= dir
->i_sb
->s_dev
;
373 __entry
->dir
= NFS_FILEID(dir
);
374 __entry
->flags
= flags
;
375 __assign_str(name
, dentry
->d_name
.name
);
379 "flags=%u (%s) name=%02x:%02x:%llu/%s",
381 show_open_flags(__entry
->flags
),
382 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
383 (unsigned long long)__entry
->dir
,
388 TRACE_EVENT(nfs_create_exit
,
390 const struct inode
*dir
,
391 const struct dentry
*dentry
,
396 TP_ARGS(dir
, dentry
, flags
, error
),
400 __field(unsigned int, flags
)
403 __string(name
, dentry
->d_name
.name
)
407 __entry
->error
= error
;
408 __entry
->dev
= dir
->i_sb
->s_dev
;
409 __entry
->dir
= NFS_FILEID(dir
);
410 __entry
->flags
= flags
;
411 __assign_str(name
, dentry
->d_name
.name
);
415 "error=%d flags=%u (%s) name=%02x:%02x:%llu/%s",
418 show_open_flags(__entry
->flags
),
419 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
420 (unsigned long long)__entry
->dir
,
425 DECLARE_EVENT_CLASS(nfs_directory_event
,
427 const struct inode
*dir
,
428 const struct dentry
*dentry
431 TP_ARGS(dir
, dentry
),
436 __string(name
, dentry
->d_name
.name
)
440 __entry
->dev
= dir
->i_sb
->s_dev
;
441 __entry
->dir
= NFS_FILEID(dir
);
442 __assign_str(name
, dentry
->d_name
.name
);
446 "name=%02x:%02x:%llu/%s",
447 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
448 (unsigned long long)__entry
->dir
,
453 #define DEFINE_NFS_DIRECTORY_EVENT(name) \
454 DEFINE_EVENT(nfs_directory_event, name, \
456 const struct inode *dir, \
457 const struct dentry *dentry \
459 TP_ARGS(dir, dentry))
461 DECLARE_EVENT_CLASS(nfs_directory_event_done
,
463 const struct inode
*dir
,
464 const struct dentry
*dentry
,
468 TP_ARGS(dir
, dentry
, error
),
474 __string(name
, dentry
->d_name
.name
)
478 __entry
->dev
= dir
->i_sb
->s_dev
;
479 __entry
->dir
= NFS_FILEID(dir
);
480 __entry
->error
= error
;
481 __assign_str(name
, dentry
->d_name
.name
);
485 "error=%d name=%02x:%02x:%llu/%s",
487 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
488 (unsigned long long)__entry
->dir
,
493 #define DEFINE_NFS_DIRECTORY_EVENT_DONE(name) \
494 DEFINE_EVENT(nfs_directory_event_done, name, \
496 const struct inode *dir, \
497 const struct dentry *dentry, \
500 TP_ARGS(dir, dentry, error))
502 DEFINE_NFS_DIRECTORY_EVENT(nfs_mknod_enter
);
503 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_mknod_exit
);
504 DEFINE_NFS_DIRECTORY_EVENT(nfs_mkdir_enter
);
505 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_mkdir_exit
);
506 DEFINE_NFS_DIRECTORY_EVENT(nfs_rmdir_enter
);
507 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_rmdir_exit
);
508 DEFINE_NFS_DIRECTORY_EVENT(nfs_remove_enter
);
509 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_remove_exit
);
510 DEFINE_NFS_DIRECTORY_EVENT(nfs_unlink_enter
);
511 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_unlink_exit
);
512 DEFINE_NFS_DIRECTORY_EVENT(nfs_symlink_enter
);
513 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_symlink_exit
);
515 TRACE_EVENT(nfs_link_enter
,
517 const struct inode
*inode
,
518 const struct inode
*dir
,
519 const struct dentry
*dentry
522 TP_ARGS(inode
, dir
, dentry
),
528 __string(name
, dentry
->d_name
.name
)
532 __entry
->dev
= inode
->i_sb
->s_dev
;
533 __entry
->fileid
= NFS_FILEID(inode
);
534 __entry
->dir
= NFS_FILEID(dir
);
535 __assign_str(name
, dentry
->d_name
.name
);
539 "fileid=%02x:%02x:%llu name=%02x:%02x:%llu/%s",
540 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
542 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
543 (unsigned long long)__entry
->dir
,
548 TRACE_EVENT(nfs_link_exit
,
550 const struct inode
*inode
,
551 const struct inode
*dir
,
552 const struct dentry
*dentry
,
556 TP_ARGS(inode
, dir
, dentry
, error
),
563 __string(name
, dentry
->d_name
.name
)
567 __entry
->dev
= inode
->i_sb
->s_dev
;
568 __entry
->fileid
= NFS_FILEID(inode
);
569 __entry
->dir
= NFS_FILEID(dir
);
570 __entry
->error
= error
;
571 __assign_str(name
, dentry
->d_name
.name
);
575 "error=%d fileid=%02x:%02x:%llu name=%02x:%02x:%llu/%s",
577 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
579 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
580 (unsigned long long)__entry
->dir
,
585 DECLARE_EVENT_CLASS(nfs_rename_event
,
587 const struct inode
*old_dir
,
588 const struct dentry
*old_dentry
,
589 const struct inode
*new_dir
,
590 const struct dentry
*new_dentry
593 TP_ARGS(old_dir
, old_dentry
, new_dir
, new_dentry
),
597 __field(u64
, old_dir
)
598 __field(u64
, new_dir
)
599 __string(old_name
, old_dentry
->d_name
.name
)
600 __string(new_name
, new_dentry
->d_name
.name
)
604 __entry
->dev
= old_dir
->i_sb
->s_dev
;
605 __entry
->old_dir
= NFS_FILEID(old_dir
);
606 __entry
->new_dir
= NFS_FILEID(new_dir
);
607 __assign_str(old_name
, old_dentry
->d_name
.name
);
608 __assign_str(new_name
, new_dentry
->d_name
.name
);
612 "old_name=%02x:%02x:%llu/%s new_name=%02x:%02x:%llu/%s",
613 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
614 (unsigned long long)__entry
->old_dir
,
616 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
617 (unsigned long long)__entry
->new_dir
,
621 #define DEFINE_NFS_RENAME_EVENT(name) \
622 DEFINE_EVENT(nfs_rename_event, name, \
624 const struct inode *old_dir, \
625 const struct dentry *old_dentry, \
626 const struct inode *new_dir, \
627 const struct dentry *new_dentry \
629 TP_ARGS(old_dir, old_dentry, new_dir, new_dentry))
631 DECLARE_EVENT_CLASS(nfs_rename_event_done
,
633 const struct inode
*old_dir
,
634 const struct dentry
*old_dentry
,
635 const struct inode
*new_dir
,
636 const struct dentry
*new_dentry
,
640 TP_ARGS(old_dir
, old_dentry
, new_dir
, new_dentry
, error
),
645 __field(u64
, old_dir
)
646 __string(old_name
, old_dentry
->d_name
.name
)
647 __field(u64
, new_dir
)
648 __string(new_name
, new_dentry
->d_name
.name
)
652 __entry
->dev
= old_dir
->i_sb
->s_dev
;
653 __entry
->old_dir
= NFS_FILEID(old_dir
);
654 __entry
->new_dir
= NFS_FILEID(new_dir
);
655 __entry
->error
= error
;
656 __assign_str(old_name
, old_dentry
->d_name
.name
);
657 __assign_str(new_name
, new_dentry
->d_name
.name
);
661 "error=%d old_name=%02x:%02x:%llu/%s "
662 "new_name=%02x:%02x:%llu/%s",
664 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
665 (unsigned long long)__entry
->old_dir
,
667 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
668 (unsigned long long)__entry
->new_dir
,
672 #define DEFINE_NFS_RENAME_EVENT_DONE(name) \
673 DEFINE_EVENT(nfs_rename_event_done, name, \
675 const struct inode *old_dir, \
676 const struct dentry *old_dentry, \
677 const struct inode *new_dir, \
678 const struct dentry *new_dentry, \
681 TP_ARGS(old_dir, old_dentry, new_dir, \
684 DEFINE_NFS_RENAME_EVENT(nfs_rename_enter
);
685 DEFINE_NFS_RENAME_EVENT_DONE(nfs_rename_exit
);
687 DEFINE_NFS_RENAME_EVENT_DONE(nfs_sillyrename_rename
);
689 TRACE_EVENT(nfs_sillyrename_unlink
,
691 const struct nfs_unlinkdata
*data
,
695 TP_ARGS(data
, error
),
701 __dynamic_array(char, name
, data
->args
.name
.len
+ 1)
705 struct inode
*dir
= data
->dir
;
706 size_t len
= data
->args
.name
.len
;
707 __entry
->dev
= dir
->i_sb
->s_dev
;
708 __entry
->dir
= NFS_FILEID(dir
);
709 __entry
->error
= error
;
710 memcpy(__get_dynamic_array(name
),
711 data
->args
.name
.name
, len
);
712 ((char *)__get_dynamic_array(name
))[len
] = 0;
716 "error=%d name=%02x:%02x:%llu/%s",
718 MAJOR(__entry
->dev
), MINOR(__entry
->dev
),
719 (unsigned long long)__entry
->dir
,
723 #endif /* _TRACE_NFS_H */
725 #undef TRACE_INCLUDE_PATH
726 #define TRACE_INCLUDE_PATH .
727 #define TRACE_INCLUDE_FILE nfstrace
728 /* This part must be outside protection */
729 #include <trace/define_trace.h>