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_COMMIT, "COMMIT" }, \
43 { 1 << NFS_INO_LAYOUTCOMMIT, "NEED_LAYOUTCOMMIT" }, \
44 { 1 << NFS_INO_LAYOUTCOMMITTING, "LAYOUTCOMMIT" })
46 DECLARE_EVENT_CLASS(nfs_inode_event,
48 const struct inode *inode
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->i_version;
69 "fileid=%02x:%02x:%llu fhandle=0x%08x version=%llu ",
70 MAJOR(__entry->dev), MINOR(__entry->dev),
71 (unsigned long long)__entry->fileid,
73 (unsigned long long)__entry->version
77 DECLARE_EVENT_CLASS(nfs_inode_event_done,
79 const struct inode *inode,
83 TP_ARGS(inode, error),
89 __field(unsigned char, type)
93 __field(unsigned long, nfsi_flags)
94 __field(unsigned long, cache_validity)
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->i_version;
105 __entry->size = i_size_read(inode);
106 __entry->nfsi_flags = nfsi->flags;
107 __entry->cache_validity = nfsi->cache_validity;
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)",
115 MAJOR(__entry->dev), MINOR(__entry->dev),
116 (unsigned long long)__entry->fileid,
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),
125 nfs_show_nfsi_flags(__entry->nfsi_flags)
129 #define DEFINE_NFS_INODE_EVENT(name) \
130 DEFINE_EVENT(nfs_inode_event, name, \
132 const struct inode *inode \
135 #define DEFINE_NFS_INODE_EVENT_DONE(name) \
136 DEFINE_EVENT(nfs_inode_event_done, name, \
138 const struct inode *inode, \
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);
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" })
169 DECLARE_EVENT_CLASS(nfs_lookup_event,
171 const struct inode *dir,
172 const struct dentry *dentry,
176 TP_ARGS(dir, dentry, flags),
179 __field(unsigned int, flags)
182 __string(name, dentry->d_name.name)
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);
193 "flags=%u (%s) name=%02x:%02x:%llu/%s",
195 show_lookup_flags(__entry->flags),
196 MAJOR(__entry->dev), MINOR(__entry->dev),
197 (unsigned long long)__entry->dir,
202 #define DEFINE_NFS_LOOKUP_EVENT(name) \
203 DEFINE_EVENT(nfs_lookup_event, name, \
205 const struct inode *dir, \
206 const struct dentry *dentry, \
209 TP_ARGS(dir, dentry, flags))
211 DECLARE_EVENT_CLASS(nfs_lookup_event_done,
213 const struct inode *dir,
214 const struct dentry *dentry,
219 TP_ARGS(dir, dentry, flags, error),
223 __field(unsigned int, flags)
226 __string(name, dentry->d_name.name)
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);
238 "error=%d flags=%u (%s) name=%02x:%02x:%llu/%s",
241 show_lookup_flags(__entry->flags),
242 MAJOR(__entry->dev), MINOR(__entry->dev),
243 (unsigned long long)__entry->dir,
248 #define DEFINE_NFS_LOOKUP_EVENT_DONE(name) \
249 DEFINE_EVENT(nfs_lookup_event_done, name, \
251 const struct inode *dir, \
252 const struct dentry *dentry, \
253 unsigned int flags, \
256 TP_ARGS(dir, dentry, flags, error))
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);
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" })
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" })
279 TRACE_EVENT(nfs_atomic_open_enter,
281 const struct inode *dir,
282 const struct nfs_open_context *ctx,
286 TP_ARGS(dir, ctx, flags),
289 __field(unsigned int, flags)
290 __field(unsigned int, fmode)
293 __string(name, ctx->dentry->d_name.name)
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);
305 "flags=%u (%s) fmode=%s name=%02x:%02x:%llu/%s",
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,
315 TRACE_EVENT(nfs_atomic_open_exit,
317 const struct inode *dir,
318 const struct nfs_open_context *ctx,
323 TP_ARGS(dir, ctx, flags, error),
327 __field(unsigned int, flags)
328 __field(unsigned int, fmode)
331 __string(name, ctx->dentry->d_name.name)
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);
344 "error=%d flags=%u (%s) fmode=%s "
345 "name=%02x:%02x:%llu/%s",
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,
356 TRACE_EVENT(nfs_create_enter,
358 const struct inode *dir,
359 const struct dentry *dentry,
363 TP_ARGS(dir, dentry, flags),
366 __field(unsigned int, flags)
369 __string(name, dentry->d_name.name)
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);
380 "flags=%u (%s) name=%02x:%02x:%llu/%s",
382 show_open_flags(__entry->flags),
383 MAJOR(__entry->dev), MINOR(__entry->dev),
384 (unsigned long long)__entry->dir,
389 TRACE_EVENT(nfs_create_exit,
391 const struct inode *dir,
392 const struct dentry *dentry,
397 TP_ARGS(dir, dentry, flags, error),
401 __field(unsigned int, flags)
404 __string(name, dentry->d_name.name)
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);
416 "error=%d flags=%u (%s) name=%02x:%02x:%llu/%s",
419 show_open_flags(__entry->flags),
420 MAJOR(__entry->dev), MINOR(__entry->dev),
421 (unsigned long long)__entry->dir,
426 DECLARE_EVENT_CLASS(nfs_directory_event,
428 const struct inode *dir,
429 const struct dentry *dentry
432 TP_ARGS(dir, dentry),
437 __string(name, dentry->d_name.name)
441 __entry->dev = dir->i_sb->s_dev;
442 __entry->dir = NFS_FILEID(dir);
443 __assign_str(name, dentry->d_name.name);
447 "name=%02x:%02x:%llu/%s",
448 MAJOR(__entry->dev), MINOR(__entry->dev),
449 (unsigned long long)__entry->dir,
454 #define DEFINE_NFS_DIRECTORY_EVENT(name) \
455 DEFINE_EVENT(nfs_directory_event, name, \
457 const struct inode *dir, \
458 const struct dentry *dentry \
460 TP_ARGS(dir, dentry))
462 DECLARE_EVENT_CLASS(nfs_directory_event_done,
464 const struct inode *dir,
465 const struct dentry *dentry,
469 TP_ARGS(dir, dentry, error),
475 __string(name, dentry->d_name.name)
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);
486 "error=%d name=%02x:%02x:%llu/%s",
488 MAJOR(__entry->dev), MINOR(__entry->dev),
489 (unsigned long long)__entry->dir,
494 #define DEFINE_NFS_DIRECTORY_EVENT_DONE(name) \
495 DEFINE_EVENT(nfs_directory_event_done, name, \
497 const struct inode *dir, \
498 const struct dentry *dentry, \
501 TP_ARGS(dir, dentry, error))
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);
516 TRACE_EVENT(nfs_link_enter,
518 const struct inode *inode,
519 const struct inode *dir,
520 const struct dentry *dentry
523 TP_ARGS(inode, dir, dentry),
529 __string(name, dentry->d_name.name)
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);
540 "fileid=%02x:%02x:%llu name=%02x:%02x:%llu/%s",
541 MAJOR(__entry->dev), MINOR(__entry->dev),
543 MAJOR(__entry->dev), MINOR(__entry->dev),
544 (unsigned long long)__entry->dir,
549 TRACE_EVENT(nfs_link_exit,
551 const struct inode *inode,
552 const struct inode *dir,
553 const struct dentry *dentry,
557 TP_ARGS(inode, dir, dentry, error),
564 __string(name, dentry->d_name.name)
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);
576 "error=%d fileid=%02x:%02x:%llu name=%02x:%02x:%llu/%s",
578 MAJOR(__entry->dev), MINOR(__entry->dev),
580 MAJOR(__entry->dev), MINOR(__entry->dev),
581 (unsigned long long)__entry->dir,
586 DECLARE_EVENT_CLASS(nfs_rename_event,
588 const struct inode *old_dir,
589 const struct dentry *old_dentry,
590 const struct inode *new_dir,
591 const struct dentry *new_dentry
594 TP_ARGS(old_dir, old_dentry, new_dir, new_dentry),
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)
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);
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,
617 MAJOR(__entry->dev), MINOR(__entry->dev),
618 (unsigned long long)__entry->new_dir,
622 #define DEFINE_NFS_RENAME_EVENT(name) \
623 DEFINE_EVENT(nfs_rename_event, name, \
625 const struct inode *old_dir, \
626 const struct dentry *old_dentry, \
627 const struct inode *new_dir, \
628 const struct dentry *new_dentry \
630 TP_ARGS(old_dir, old_dentry, new_dir, new_dentry))
632 DECLARE_EVENT_CLASS(nfs_rename_event_done,
634 const struct inode *old_dir,
635 const struct dentry *old_dentry,
636 const struct inode *new_dir,
637 const struct dentry *new_dentry,
641 TP_ARGS(old_dir, old_dentry, new_dir, new_dentry, 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)
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);
662 "error=%d old_name=%02x:%02x:%llu/%s "
663 "new_name=%02x:%02x:%llu/%s",
665 MAJOR(__entry->dev), MINOR(__entry->dev),
666 (unsigned long long)__entry->old_dir,
668 MAJOR(__entry->dev), MINOR(__entry->dev),
669 (unsigned long long)__entry->new_dir,
673 #define DEFINE_NFS_RENAME_EVENT_DONE(name) \
674 DEFINE_EVENT(nfs_rename_event_done, name, \
676 const struct inode *old_dir, \
677 const struct dentry *old_dentry, \
678 const struct inode *new_dir, \
679 const struct dentry *new_dentry, \
682 TP_ARGS(old_dir, old_dentry, new_dir, \
685 DEFINE_NFS_RENAME_EVENT(nfs_rename_enter);
686 DEFINE_NFS_RENAME_EVENT_DONE(nfs_rename_exit);
688 DEFINE_NFS_RENAME_EVENT_DONE(nfs_sillyrename_rename);
690 TRACE_EVENT(nfs_sillyrename_unlink,
692 const struct nfs_unlinkdata *data,
696 TP_ARGS(data, error),
702 __dynamic_array(char, name, data->args.name.len + 1)
706 struct inode *dir = data->dir;
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_dynamic_array(name),
712 data->args.name.name, len);
713 ((char *)__get_dynamic_array(name))[len] = 0;
717 "error=%d name=%02x:%02x:%llu/%s",
719 MAJOR(__entry->dev), MINOR(__entry->dev),
720 (unsigned long long)__entry->dir,
724 #endif /* _TRACE_NFS_H */
726 #undef TRACE_INCLUDE_PATH
727 #define TRACE_INCLUDE_PATH .
728 #define TRACE_INCLUDE_FILE nfstrace
729 /* This part must be outside protection */
730 #include <trace/define_trace.h>