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_FSCACHE, "FSCACHE" }, \
41 { 1 << NFS_INO_LAYOUTCOMMIT, "NEED_LAYOUTCOMMIT" }, \
42 { 1 << NFS_INO_LAYOUTCOMMITTING, "LAYOUTCOMMIT" })
44 DECLARE_EVENT_CLASS(nfs_inode_event,
46 const struct inode *inode
59 const struct nfs_inode *nfsi = NFS_I(inode);
60 __entry->dev = inode->i_sb->s_dev;
61 __entry->fileid = nfsi->fileid;
62 __entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
63 __entry->version = inode->i_version;
67 "fileid=%02x:%02x:%llu fhandle=0x%08x version=%llu ",
68 MAJOR(__entry->dev), MINOR(__entry->dev),
69 (unsigned long long)__entry->fileid,
71 (unsigned long long)__entry->version
75 DECLARE_EVENT_CLASS(nfs_inode_event_done,
77 const struct inode *inode,
81 TP_ARGS(inode, error),
87 __field(unsigned char, type)
91 __field(unsigned long, nfsi_flags)
92 __field(unsigned long, cache_validity)
96 const struct nfs_inode *nfsi = NFS_I(inode);
97 __entry->error = error;
98 __entry->dev = inode->i_sb->s_dev;
99 __entry->fileid = nfsi->fileid;
100 __entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
101 __entry->type = nfs_umode_to_dtype(inode->i_mode);
102 __entry->version = inode->i_version;
103 __entry->size = i_size_read(inode);
104 __entry->nfsi_flags = nfsi->flags;
105 __entry->cache_validity = nfsi->cache_validity;
109 "error=%d fileid=%02x:%02x:%llu fhandle=0x%08x "
110 "type=%u (%s) version=%llu size=%lld "
111 "cache_validity=%lu (%s) nfs_flags=%ld (%s)",
113 MAJOR(__entry->dev), MINOR(__entry->dev),
114 (unsigned long long)__entry->fileid,
117 nfs_show_file_type(__entry->type),
118 (unsigned long long)__entry->version,
119 (long long)__entry->size,
120 __entry->cache_validity,
121 nfs_show_cache_validity(__entry->cache_validity),
123 nfs_show_nfsi_flags(__entry->nfsi_flags)
127 #define DEFINE_NFS_INODE_EVENT(name) \
128 DEFINE_EVENT(nfs_inode_event, name, \
130 const struct inode *inode \
133 #define DEFINE_NFS_INODE_EVENT_DONE(name) \
134 DEFINE_EVENT(nfs_inode_event_done, name, \
136 const struct inode *inode, \
139 TP_ARGS(inode, error))
140 DEFINE_NFS_INODE_EVENT(nfs_refresh_inode_enter);
141 DEFINE_NFS_INODE_EVENT_DONE(nfs_refresh_inode_exit);
142 DEFINE_NFS_INODE_EVENT(nfs_revalidate_inode_enter);
143 DEFINE_NFS_INODE_EVENT_DONE(nfs_revalidate_inode_exit);
144 DEFINE_NFS_INODE_EVENT(nfs_invalidate_mapping_enter);
145 DEFINE_NFS_INODE_EVENT_DONE(nfs_invalidate_mapping_exit);
146 DEFINE_NFS_INODE_EVENT(nfs_getattr_enter);
147 DEFINE_NFS_INODE_EVENT_DONE(nfs_getattr_exit);
148 DEFINE_NFS_INODE_EVENT(nfs_setattr_enter);
149 DEFINE_NFS_INODE_EVENT_DONE(nfs_setattr_exit);
150 DEFINE_NFS_INODE_EVENT(nfs_writeback_page_enter);
151 DEFINE_NFS_INODE_EVENT_DONE(nfs_writeback_page_exit);
152 DEFINE_NFS_INODE_EVENT(nfs_writeback_inode_enter);
153 DEFINE_NFS_INODE_EVENT_DONE(nfs_writeback_inode_exit);
154 DEFINE_NFS_INODE_EVENT(nfs_fsync_enter);
155 DEFINE_NFS_INODE_EVENT_DONE(nfs_fsync_exit);
156 DEFINE_NFS_INODE_EVENT(nfs_access_enter);
157 DEFINE_NFS_INODE_EVENT_DONE(nfs_access_exit);
159 #define show_lookup_flags(flags) \
160 __print_flags((unsigned long)flags, "|", \
161 { LOOKUP_AUTOMOUNT, "AUTOMOUNT" }, \
162 { LOOKUP_DIRECTORY, "DIRECTORY" }, \
163 { LOOKUP_OPEN, "OPEN" }, \
164 { LOOKUP_CREATE, "CREATE" }, \
165 { LOOKUP_EXCL, "EXCL" })
167 DECLARE_EVENT_CLASS(nfs_lookup_event,
169 const struct inode *dir,
170 const struct dentry *dentry,
174 TP_ARGS(dir, dentry, flags),
177 __field(unsigned int, flags)
180 __string(name, dentry->d_name.name)
184 __entry->dev = dir->i_sb->s_dev;
185 __entry->dir = NFS_FILEID(dir);
186 __entry->flags = flags;
187 __assign_str(name, dentry->d_name.name);
191 "flags=%u (%s) name=%02x:%02x:%llu/%s",
193 show_lookup_flags(__entry->flags),
194 MAJOR(__entry->dev), MINOR(__entry->dev),
195 (unsigned long long)__entry->dir,
200 #define DEFINE_NFS_LOOKUP_EVENT(name) \
201 DEFINE_EVENT(nfs_lookup_event, name, \
203 const struct inode *dir, \
204 const struct dentry *dentry, \
207 TP_ARGS(dir, dentry, flags))
209 DECLARE_EVENT_CLASS(nfs_lookup_event_done,
211 const struct inode *dir,
212 const struct dentry *dentry,
217 TP_ARGS(dir, dentry, flags, error),
221 __field(unsigned int, flags)
224 __string(name, dentry->d_name.name)
228 __entry->dev = dir->i_sb->s_dev;
229 __entry->dir = NFS_FILEID(dir);
230 __entry->error = error;
231 __entry->flags = flags;
232 __assign_str(name, dentry->d_name.name);
236 "error=%d flags=%u (%s) name=%02x:%02x:%llu/%s",
239 show_lookup_flags(__entry->flags),
240 MAJOR(__entry->dev), MINOR(__entry->dev),
241 (unsigned long long)__entry->dir,
246 #define DEFINE_NFS_LOOKUP_EVENT_DONE(name) \
247 DEFINE_EVENT(nfs_lookup_event_done, name, \
249 const struct inode *dir, \
250 const struct dentry *dentry, \
251 unsigned int flags, \
254 TP_ARGS(dir, dentry, flags, error))
256 DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_enter);
257 DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_lookup_exit);
258 DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_revalidate_enter);
259 DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_lookup_revalidate_exit);
261 #define show_open_flags(flags) \
262 __print_flags((unsigned long)flags, "|", \
263 { O_CREAT, "O_CREAT" }, \
264 { O_EXCL, "O_EXCL" }, \
265 { O_TRUNC, "O_TRUNC" }, \
266 { O_APPEND, "O_APPEND" }, \
267 { O_DSYNC, "O_DSYNC" }, \
268 { O_DIRECT, "O_DIRECT" }, \
269 { O_DIRECTORY, "O_DIRECTORY" })
271 #define show_fmode_flags(mode) \
272 __print_flags(mode, "|", \
273 { ((__force unsigned long)FMODE_READ), "READ" }, \
274 { ((__force unsigned long)FMODE_WRITE), "WRITE" }, \
275 { ((__force unsigned long)FMODE_EXEC), "EXEC" })
277 TRACE_EVENT(nfs_atomic_open_enter,
279 const struct inode *dir,
280 const struct nfs_open_context *ctx,
284 TP_ARGS(dir, ctx, flags),
287 __field(unsigned int, flags)
288 __field(unsigned int, fmode)
291 __string(name, ctx->dentry->d_name.name)
295 __entry->dev = dir->i_sb->s_dev;
296 __entry->dir = NFS_FILEID(dir);
297 __entry->flags = flags;
298 __entry->fmode = (__force unsigned int)ctx->mode;
299 __assign_str(name, ctx->dentry->d_name.name);
303 "flags=%u (%s) fmode=%s name=%02x:%02x:%llu/%s",
305 show_open_flags(__entry->flags),
306 show_fmode_flags(__entry->fmode),
307 MAJOR(__entry->dev), MINOR(__entry->dev),
308 (unsigned long long)__entry->dir,
313 TRACE_EVENT(nfs_atomic_open_exit,
315 const struct inode *dir,
316 const struct nfs_open_context *ctx,
321 TP_ARGS(dir, ctx, flags, error),
325 __field(unsigned int, flags)
326 __field(unsigned int, fmode)
329 __string(name, ctx->dentry->d_name.name)
333 __entry->error = error;
334 __entry->dev = dir->i_sb->s_dev;
335 __entry->dir = NFS_FILEID(dir);
336 __entry->flags = flags;
337 __entry->fmode = (__force unsigned int)ctx->mode;
338 __assign_str(name, ctx->dentry->d_name.name);
342 "error=%d flags=%u (%s) fmode=%s "
343 "name=%02x:%02x:%llu/%s",
346 show_open_flags(__entry->flags),
347 show_fmode_flags(__entry->fmode),
348 MAJOR(__entry->dev), MINOR(__entry->dev),
349 (unsigned long long)__entry->dir,
354 TRACE_EVENT(nfs_create_enter,
356 const struct inode *dir,
357 const struct dentry *dentry,
361 TP_ARGS(dir, dentry, flags),
364 __field(unsigned int, flags)
367 __string(name, dentry->d_name.name)
371 __entry->dev = dir->i_sb->s_dev;
372 __entry->dir = NFS_FILEID(dir);
373 __entry->flags = flags;
374 __assign_str(name, dentry->d_name.name);
378 "flags=%u (%s) name=%02x:%02x:%llu/%s",
380 show_open_flags(__entry->flags),
381 MAJOR(__entry->dev), MINOR(__entry->dev),
382 (unsigned long long)__entry->dir,
387 TRACE_EVENT(nfs_create_exit,
389 const struct inode *dir,
390 const struct dentry *dentry,
395 TP_ARGS(dir, dentry, flags, error),
399 __field(unsigned int, flags)
402 __string(name, dentry->d_name.name)
406 __entry->error = error;
407 __entry->dev = dir->i_sb->s_dev;
408 __entry->dir = NFS_FILEID(dir);
409 __entry->flags = flags;
410 __assign_str(name, dentry->d_name.name);
414 "error=%d flags=%u (%s) name=%02x:%02x:%llu/%s",
417 show_open_flags(__entry->flags),
418 MAJOR(__entry->dev), MINOR(__entry->dev),
419 (unsigned long long)__entry->dir,
424 DECLARE_EVENT_CLASS(nfs_directory_event,
426 const struct inode *dir,
427 const struct dentry *dentry
430 TP_ARGS(dir, dentry),
435 __string(name, dentry->d_name.name)
439 __entry->dev = dir->i_sb->s_dev;
440 __entry->dir = NFS_FILEID(dir);
441 __assign_str(name, dentry->d_name.name);
445 "name=%02x:%02x:%llu/%s",
446 MAJOR(__entry->dev), MINOR(__entry->dev),
447 (unsigned long long)__entry->dir,
452 #define DEFINE_NFS_DIRECTORY_EVENT(name) \
453 DEFINE_EVENT(nfs_directory_event, name, \
455 const struct inode *dir, \
456 const struct dentry *dentry \
458 TP_ARGS(dir, dentry))
460 DECLARE_EVENT_CLASS(nfs_directory_event_done,
462 const struct inode *dir,
463 const struct dentry *dentry,
467 TP_ARGS(dir, dentry, error),
473 __string(name, dentry->d_name.name)
477 __entry->dev = dir->i_sb->s_dev;
478 __entry->dir = NFS_FILEID(dir);
479 __entry->error = error;
480 __assign_str(name, dentry->d_name.name);
484 "error=%d name=%02x:%02x:%llu/%s",
486 MAJOR(__entry->dev), MINOR(__entry->dev),
487 (unsigned long long)__entry->dir,
492 #define DEFINE_NFS_DIRECTORY_EVENT_DONE(name) \
493 DEFINE_EVENT(nfs_directory_event_done, name, \
495 const struct inode *dir, \
496 const struct dentry *dentry, \
499 TP_ARGS(dir, dentry, error))
501 DEFINE_NFS_DIRECTORY_EVENT(nfs_mknod_enter);
502 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_mknod_exit);
503 DEFINE_NFS_DIRECTORY_EVENT(nfs_mkdir_enter);
504 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_mkdir_exit);
505 DEFINE_NFS_DIRECTORY_EVENT(nfs_rmdir_enter);
506 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_rmdir_exit);
507 DEFINE_NFS_DIRECTORY_EVENT(nfs_remove_enter);
508 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_remove_exit);
509 DEFINE_NFS_DIRECTORY_EVENT(nfs_unlink_enter);
510 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_unlink_exit);
511 DEFINE_NFS_DIRECTORY_EVENT(nfs_symlink_enter);
512 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_symlink_exit);
514 TRACE_EVENT(nfs_link_enter,
516 const struct inode *inode,
517 const struct inode *dir,
518 const struct dentry *dentry
521 TP_ARGS(inode, dir, dentry),
527 __string(name, dentry->d_name.name)
531 __entry->dev = inode->i_sb->s_dev;
532 __entry->fileid = NFS_FILEID(inode);
533 __entry->dir = NFS_FILEID(dir);
534 __assign_str(name, dentry->d_name.name);
538 "fileid=%02x:%02x:%llu name=%02x:%02x:%llu/%s",
539 MAJOR(__entry->dev), MINOR(__entry->dev),
541 MAJOR(__entry->dev), MINOR(__entry->dev),
542 (unsigned long long)__entry->dir,
547 TRACE_EVENT(nfs_link_exit,
549 const struct inode *inode,
550 const struct inode *dir,
551 const struct dentry *dentry,
555 TP_ARGS(inode, dir, dentry, error),
562 __string(name, dentry->d_name.name)
566 __entry->dev = inode->i_sb->s_dev;
567 __entry->fileid = NFS_FILEID(inode);
568 __entry->dir = NFS_FILEID(dir);
569 __entry->error = error;
570 __assign_str(name, dentry->d_name.name);
574 "error=%d fileid=%02x:%02x:%llu name=%02x:%02x:%llu/%s",
576 MAJOR(__entry->dev), MINOR(__entry->dev),
578 MAJOR(__entry->dev), MINOR(__entry->dev),
579 (unsigned long long)__entry->dir,
584 DECLARE_EVENT_CLASS(nfs_rename_event,
586 const struct inode *old_dir,
587 const struct dentry *old_dentry,
588 const struct inode *new_dir,
589 const struct dentry *new_dentry
592 TP_ARGS(old_dir, old_dentry, new_dir, new_dentry),
596 __field(u64, old_dir)
597 __field(u64, new_dir)
598 __string(old_name, old_dentry->d_name.name)
599 __string(new_name, new_dentry->d_name.name)
603 __entry->dev = old_dir->i_sb->s_dev;
604 __entry->old_dir = NFS_FILEID(old_dir);
605 __entry->new_dir = NFS_FILEID(new_dir);
606 __assign_str(old_name, old_dentry->d_name.name);
607 __assign_str(new_name, new_dentry->d_name.name);
611 "old_name=%02x:%02x:%llu/%s new_name=%02x:%02x:%llu/%s",
612 MAJOR(__entry->dev), MINOR(__entry->dev),
613 (unsigned long long)__entry->old_dir,
615 MAJOR(__entry->dev), MINOR(__entry->dev),
616 (unsigned long long)__entry->new_dir,
620 #define DEFINE_NFS_RENAME_EVENT(name) \
621 DEFINE_EVENT(nfs_rename_event, name, \
623 const struct inode *old_dir, \
624 const struct dentry *old_dentry, \
625 const struct inode *new_dir, \
626 const struct dentry *new_dentry \
628 TP_ARGS(old_dir, old_dentry, new_dir, new_dentry))
630 DECLARE_EVENT_CLASS(nfs_rename_event_done,
632 const struct inode *old_dir,
633 const struct dentry *old_dentry,
634 const struct inode *new_dir,
635 const struct dentry *new_dentry,
639 TP_ARGS(old_dir, old_dentry, new_dir, new_dentry, error),
644 __field(u64, old_dir)
645 __string(old_name, old_dentry->d_name.name)
646 __field(u64, new_dir)
647 __string(new_name, new_dentry->d_name.name)
651 __entry->dev = old_dir->i_sb->s_dev;
652 __entry->old_dir = NFS_FILEID(old_dir);
653 __entry->new_dir = NFS_FILEID(new_dir);
654 __entry->error = error;
655 __assign_str(old_name, old_dentry->d_name.name);
656 __assign_str(new_name, new_dentry->d_name.name);
660 "error=%d old_name=%02x:%02x:%llu/%s "
661 "new_name=%02x:%02x:%llu/%s",
663 MAJOR(__entry->dev), MINOR(__entry->dev),
664 (unsigned long long)__entry->old_dir,
666 MAJOR(__entry->dev), MINOR(__entry->dev),
667 (unsigned long long)__entry->new_dir,
671 #define DEFINE_NFS_RENAME_EVENT_DONE(name) \
672 DEFINE_EVENT(nfs_rename_event_done, name, \
674 const struct inode *old_dir, \
675 const struct dentry *old_dentry, \
676 const struct inode *new_dir, \
677 const struct dentry *new_dentry, \
680 TP_ARGS(old_dir, old_dentry, new_dir, \
683 DEFINE_NFS_RENAME_EVENT(nfs_rename_enter);
684 DEFINE_NFS_RENAME_EVENT_DONE(nfs_rename_exit);
686 DEFINE_NFS_RENAME_EVENT_DONE(nfs_sillyrename_rename);
688 TRACE_EVENT(nfs_sillyrename_unlink,
690 const struct nfs_unlinkdata *data,
694 TP_ARGS(data, error),
700 __dynamic_array(char, name, data->args.name.len + 1)
704 struct inode *dir = d_inode(data->dentry->d_parent);
705 size_t len = data->args.name.len;
706 __entry->dev = dir->i_sb->s_dev;
707 __entry->dir = NFS_FILEID(dir);
708 __entry->error = error;
709 memcpy(__get_str(name),
710 data->args.name.name, len);
711 __get_str(name)[len] = 0;
715 "error=%d name=%02x:%02x:%llu/%s",
717 MAJOR(__entry->dev), MINOR(__entry->dev),
718 (unsigned long long)__entry->dir,
722 #endif /* _TRACE_NFS_H */
724 #undef TRACE_INCLUDE_PATH
725 #define TRACE_INCLUDE_PATH .
726 #define TRACE_INCLUDE_FILE nfstrace
727 /* This part must be outside protection */
728 #include <trace/define_trace.h>