filelock.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  2. * Events for filesystem locks
  3. *
  4. * Copyright 2013 Jeff Layton <[email protected]>
  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. TRACE_EVENT(locks_get_lock_context,
  33. TP_PROTO(struct inode *inode, int type, struct file_lock_context *ctx),
  34. TP_ARGS(inode, type, ctx),
  35. TP_STRUCT__entry(
  36. __field(unsigned long, i_ino)
  37. __field(dev_t, s_dev)
  38. __field(unsigned char, type)
  39. __field(struct file_lock_context *, ctx)
  40. ),
  41. TP_fast_assign(
  42. __entry->s_dev = inode->i_sb->s_dev;
  43. __entry->i_ino = inode->i_ino;
  44. __entry->type = type;
  45. __entry->ctx = ctx;
  46. ),
  47. TP_printk("dev=0x%x:0x%x ino=0x%lx type=%s ctx=%p",
  48. MAJOR(__entry->s_dev), MINOR(__entry->s_dev),
  49. __entry->i_ino, show_fl_type(__entry->type), __entry->ctx)
  50. );
  51. DECLARE_EVENT_CLASS(filelock_lock,
  52. TP_PROTO(struct inode *inode, struct file_lock *fl, int ret),
  53. TP_ARGS(inode, fl, ret),
  54. TP_STRUCT__entry(
  55. __field(struct file_lock *, fl)
  56. __field(unsigned long, i_ino)
  57. __field(dev_t, s_dev)
  58. __field(struct file_lock *, fl_next)
  59. __field(fl_owner_t, fl_owner)
  60. __field(unsigned int, fl_pid)
  61. __field(unsigned int, fl_flags)
  62. __field(unsigned char, fl_type)
  63. __field(loff_t, fl_start)
  64. __field(loff_t, fl_end)
  65. __field(int, ret)
  66. ),
  67. TP_fast_assign(
  68. __entry->fl = fl ? fl : NULL;
  69. __entry->s_dev = inode->i_sb->s_dev;
  70. __entry->i_ino = inode->i_ino;
  71. __entry->fl_next = fl ? fl->fl_next : NULL;
  72. __entry->fl_owner = fl ? fl->fl_owner : NULL;
  73. __entry->fl_pid = fl ? fl->fl_pid : 0;
  74. __entry->fl_flags = fl ? fl->fl_flags : 0;
  75. __entry->fl_type = fl ? fl->fl_type : 0;
  76. __entry->fl_start = fl ? fl->fl_start : 0;
  77. __entry->fl_end = fl ? fl->fl_end : 0;
  78. __entry->ret = ret;
  79. ),
  80. TP_printk("fl=0x%p dev=0x%x:0x%x ino=0x%lx fl_next=0x%p fl_owner=0x%p fl_pid=%u fl_flags=%s fl_type=%s fl_start=%lld fl_end=%lld ret=%d",
  81. __entry->fl, MAJOR(__entry->s_dev), MINOR(__entry->s_dev),
  82. __entry->i_ino, __entry->fl_next, __entry->fl_owner,
  83. __entry->fl_pid, show_fl_flags(__entry->fl_flags),
  84. show_fl_type(__entry->fl_type),
  85. __entry->fl_start, __entry->fl_end, __entry->ret)
  86. );
  87. DEFINE_EVENT(filelock_lock, posix_lock_inode,
  88. TP_PROTO(struct inode *inode, struct file_lock *fl, int ret),
  89. TP_ARGS(inode, fl, ret));
  90. DEFINE_EVENT(filelock_lock, fcntl_setlk,
  91. TP_PROTO(struct inode *inode, struct file_lock *fl, int ret),
  92. TP_ARGS(inode, fl, ret));
  93. DEFINE_EVENT(filelock_lock, locks_remove_posix,
  94. TP_PROTO(struct inode *inode, struct file_lock *fl, int ret),
  95. TP_ARGS(inode, fl, ret));
  96. DECLARE_EVENT_CLASS(filelock_lease,
  97. TP_PROTO(struct inode *inode, struct file_lock *fl),
  98. TP_ARGS(inode, fl),
  99. TP_STRUCT__entry(
  100. __field(struct file_lock *, fl)
  101. __field(unsigned long, i_ino)
  102. __field(dev_t, s_dev)
  103. __field(struct file_lock *, fl_next)
  104. __field(fl_owner_t, fl_owner)
  105. __field(unsigned int, fl_flags)
  106. __field(unsigned char, fl_type)
  107. __field(unsigned long, fl_break_time)
  108. __field(unsigned long, fl_downgrade_time)
  109. ),
  110. TP_fast_assign(
  111. __entry->fl = fl ? fl : NULL;
  112. __entry->s_dev = inode->i_sb->s_dev;
  113. __entry->i_ino = inode->i_ino;
  114. __entry->fl_next = fl ? fl->fl_next : NULL;
  115. __entry->fl_owner = fl ? fl->fl_owner : NULL;
  116. __entry->fl_flags = fl ? fl->fl_flags : 0;
  117. __entry->fl_type = fl ? fl->fl_type : 0;
  118. __entry->fl_break_time = fl ? fl->fl_break_time : 0;
  119. __entry->fl_downgrade_time = fl ? fl->fl_downgrade_time : 0;
  120. ),
  121. 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",
  122. __entry->fl, MAJOR(__entry->s_dev), MINOR(__entry->s_dev),
  123. __entry->i_ino, __entry->fl_next, __entry->fl_owner,
  124. show_fl_flags(__entry->fl_flags),
  125. show_fl_type(__entry->fl_type),
  126. __entry->fl_break_time, __entry->fl_downgrade_time)
  127. );
  128. DEFINE_EVENT(filelock_lease, break_lease_noblock, TP_PROTO(struct inode *inode, struct file_lock *fl),
  129. TP_ARGS(inode, fl));
  130. DEFINE_EVENT(filelock_lease, break_lease_block, TP_PROTO(struct inode *inode, struct file_lock *fl),
  131. TP_ARGS(inode, fl));
  132. DEFINE_EVENT(filelock_lease, break_lease_unblock, TP_PROTO(struct inode *inode, struct file_lock *fl),
  133. TP_ARGS(inode, fl));
  134. DEFINE_EVENT(filelock_lease, generic_delete_lease, TP_PROTO(struct inode *inode, struct file_lock *fl),
  135. TP_ARGS(inode, fl));
  136. DEFINE_EVENT(filelock_lease, time_out_leases, TP_PROTO(struct inode *inode, struct file_lock *fl),
  137. TP_ARGS(inode, fl));
  138. TRACE_EVENT(generic_add_lease,
  139. TP_PROTO(struct inode *inode, struct file_lock *fl),
  140. TP_ARGS(inode, fl),
  141. TP_STRUCT__entry(
  142. __field(unsigned long, i_ino)
  143. __field(int, wcount)
  144. __field(int, dcount)
  145. __field(int, icount)
  146. __field(dev_t, s_dev)
  147. __field(fl_owner_t, fl_owner)
  148. __field(unsigned int, fl_flags)
  149. __field(unsigned char, fl_type)
  150. ),
  151. TP_fast_assign(
  152. __entry->s_dev = inode->i_sb->s_dev;
  153. __entry->i_ino = inode->i_ino;
  154. __entry->wcount = atomic_read(&inode->i_writecount);
  155. __entry->dcount = d_count(fl->fl_file->f_path.dentry);
  156. __entry->icount = atomic_read(&inode->i_count);
  157. __entry->fl_owner = fl ? fl->fl_owner : NULL;
  158. __entry->fl_flags = fl ? fl->fl_flags : 0;
  159. __entry->fl_type = fl ? fl->fl_type : 0;
  160. ),
  161. 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",
  162. MAJOR(__entry->s_dev), MINOR(__entry->s_dev),
  163. __entry->i_ino, __entry->wcount, __entry->dcount,
  164. __entry->icount, __entry->fl_owner,
  165. show_fl_flags(__entry->fl_flags),
  166. show_fl_type(__entry->fl_type))
  167. );
  168. #endif /* _TRACE_FILELOCK_H */
  169. /* This part must be outside protection */
  170. #include <trace/define_trace.h>