filelock.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Events for filesystem locks
  3. *
  4. * Copyright 2013 Jeff Layton <jlayton@poochiereds.net>
  5. */
  6. #undef TRACE_SYSTEM
  7. #define TRACE_SYSTEM filelock
  8. #if !defined(_TRACE_FILELOCK_H) || defined(TRACE_HEADER_MULTI_READ)
  9. #define _TRACE_FILELOCK_H
  10. #include <linux/tracepoint.h>
  11. #include <linux/fs.h>
  12. #include <linux/device.h>
  13. #include <linux/kdev_t.h>
  14. #define show_fl_flags(val) \
  15. __print_flags(val, "|", \
  16. { FL_POSIX, "FL_POSIX" }, \
  17. { FL_FLOCK, "FL_FLOCK" }, \
  18. { FL_DELEG, "FL_DELEG" }, \
  19. { FL_ACCESS, "FL_ACCESS" }, \
  20. { FL_EXISTS, "FL_EXISTS" }, \
  21. { FL_LEASE, "FL_LEASE" }, \
  22. { FL_CLOSE, "FL_CLOSE" }, \
  23. { FL_SLEEP, "FL_SLEEP" }, \
  24. { FL_DOWNGRADE_PENDING, "FL_DOWNGRADE_PENDING" }, \
  25. { FL_UNLOCK_PENDING, "FL_UNLOCK_PENDING" }, \
  26. { FL_OFDLCK, "FL_OFDLCK" })
  27. #define show_fl_type(val) \
  28. __print_symbolic(val, \
  29. { F_RDLCK, "F_RDLCK" }, \
  30. { F_WRLCK, "F_WRLCK" }, \
  31. { F_UNLCK, "F_UNLCK" })
  32. DECLARE_EVENT_CLASS(filelock_lease,
  33. TP_PROTO(struct inode *inode, struct file_lock *fl),
  34. TP_ARGS(inode, fl),
  35. TP_STRUCT__entry(
  36. __field(struct file_lock *, fl)
  37. __field(unsigned long, i_ino)
  38. __field(dev_t, s_dev)
  39. __field(struct file_lock *, fl_next)
  40. __field(fl_owner_t, fl_owner)
  41. __field(unsigned int, fl_flags)
  42. __field(unsigned char, fl_type)
  43. __field(unsigned long, fl_break_time)
  44. __field(unsigned long, fl_downgrade_time)
  45. ),
  46. TP_fast_assign(
  47. __entry->fl = fl ? fl : NULL;
  48. __entry->s_dev = inode->i_sb->s_dev;
  49. __entry->i_ino = inode->i_ino;
  50. __entry->fl_next = fl ? fl->fl_next : NULL;
  51. __entry->fl_owner = fl ? fl->fl_owner : NULL;
  52. __entry->fl_flags = fl ? fl->fl_flags : 0;
  53. __entry->fl_type = fl ? fl->fl_type : 0;
  54. __entry->fl_break_time = fl ? fl->fl_break_time : 0;
  55. __entry->fl_downgrade_time = fl ? fl->fl_downgrade_time : 0;
  56. ),
  57. TP_printk("fl=0x%p dev=0x%x:0x%x ino=0x%lx fl_next=0x%p fl_owner=0x%p fl_flags=%s fl_type=%s fl_break_time=%lu fl_downgrade_time=%lu",
  58. __entry->fl, MAJOR(__entry->s_dev), MINOR(__entry->s_dev),
  59. __entry->i_ino, __entry->fl_next, __entry->fl_owner,
  60. show_fl_flags(__entry->fl_flags),
  61. show_fl_type(__entry->fl_type),
  62. __entry->fl_break_time, __entry->fl_downgrade_time)
  63. );
  64. DEFINE_EVENT(filelock_lease, break_lease_noblock, TP_PROTO(struct inode *inode, struct file_lock *fl),
  65. TP_ARGS(inode, fl));
  66. DEFINE_EVENT(filelock_lease, break_lease_block, TP_PROTO(struct inode *inode, struct file_lock *fl),
  67. TP_ARGS(inode, fl));
  68. DEFINE_EVENT(filelock_lease, break_lease_unblock, TP_PROTO(struct inode *inode, struct file_lock *fl),
  69. TP_ARGS(inode, fl));
  70. DEFINE_EVENT(filelock_lease, generic_delete_lease, TP_PROTO(struct inode *inode, struct file_lock *fl),
  71. TP_ARGS(inode, fl));
  72. DEFINE_EVENT(filelock_lease, time_out_leases, TP_PROTO(struct inode *inode, struct file_lock *fl),
  73. TP_ARGS(inode, fl));
  74. TRACE_EVENT(generic_add_lease,
  75. TP_PROTO(struct inode *inode, struct file_lock *fl),
  76. TP_ARGS(inode, fl),
  77. TP_STRUCT__entry(
  78. __field(unsigned long, i_ino)
  79. __field(int, wcount)
  80. __field(int, dcount)
  81. __field(int, icount)
  82. __field(dev_t, s_dev)
  83. __field(fl_owner_t, fl_owner)
  84. __field(unsigned int, fl_flags)
  85. __field(unsigned char, fl_type)
  86. ),
  87. TP_fast_assign(
  88. __entry->s_dev = inode->i_sb->s_dev;
  89. __entry->i_ino = inode->i_ino;
  90. __entry->wcount = atomic_read(&inode->i_writecount);
  91. __entry->dcount = d_count(fl->fl_file->f_path.dentry);
  92. __entry->icount = atomic_read(&inode->i_count);
  93. __entry->fl_owner = fl ? fl->fl_owner : NULL;
  94. __entry->fl_flags = fl ? fl->fl_flags : 0;
  95. __entry->fl_type = fl ? fl->fl_type : 0;
  96. ),
  97. TP_printk("dev=0x%x:0x%x ino=0x%lx wcount=%d dcount=%d icount=%d fl_owner=0x%p fl_flags=%s fl_type=%s",
  98. MAJOR(__entry->s_dev), MINOR(__entry->s_dev),
  99. __entry->i_ino, __entry->wcount, __entry->dcount,
  100. __entry->icount, __entry->fl_owner,
  101. show_fl_flags(__entry->fl_flags),
  102. show_fl_type(__entry->fl_type))
  103. );
  104. #endif /* _TRACE_FILELOCK_H */
  105. /* This part must be outside protection */
  106. #include <trace/define_trace.h>