xfs_btree_trace.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. /*
  2. * Copyright (c) 2008 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it would be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write the Free Software Foundation,
  16. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "xfs.h"
  19. #include "xfs_types.h"
  20. #include "xfs_inum.h"
  21. #include "xfs_bmap_btree.h"
  22. #include "xfs_alloc_btree.h"
  23. #include "xfs_ialloc_btree.h"
  24. #include "xfs_inode.h"
  25. #include "xfs_btree.h"
  26. #include "xfs_btree_trace.h"
  27. STATIC void
  28. xfs_btree_trace_ptr(
  29. struct xfs_btree_cur *cur,
  30. union xfs_btree_ptr ptr,
  31. __psunsigned_t *high,
  32. __psunsigned_t *low)
  33. {
  34. if (cur->bc_flags & XFS_BTREE_LONG_PTRS) {
  35. __u64 val = be64_to_cpu(ptr.l);
  36. *high = val >> 32;
  37. *low = (int)val;
  38. } else {
  39. *high = 0;
  40. *low = be32_to_cpu(ptr.s);
  41. }
  42. }
  43. /*
  44. * Add a trace buffer entry for arguments, for a buffer & 1 integer arg.
  45. */
  46. void
  47. xfs_btree_trace_argbi(
  48. const char *func,
  49. struct xfs_btree_cur *cur,
  50. struct xfs_buf *b,
  51. int i,
  52. int line)
  53. {
  54. cur->bc_ops->trace_enter(cur, func, XBT_ARGS, XFS_BTREE_KTRACE_ARGBI,
  55. line, (__psunsigned_t)b, i, 0, 0, 0, 0, 0,
  56. 0, 0, 0, 0);
  57. }
  58. /*
  59. * Add a trace buffer entry for arguments, for a buffer & 2 integer args.
  60. */
  61. void
  62. xfs_btree_trace_argbii(
  63. const char *func,
  64. struct xfs_btree_cur *cur,
  65. struct xfs_buf *b,
  66. int i0,
  67. int i1,
  68. int line)
  69. {
  70. cur->bc_ops->trace_enter(cur, func, XBT_ARGS, XFS_BTREE_KTRACE_ARGBII,
  71. line, (__psunsigned_t)b, i0, i1, 0, 0, 0, 0,
  72. 0, 0, 0, 0);
  73. }
  74. /*
  75. * Add a trace buffer entry for arguments, for 3 block-length args
  76. * and an integer arg.
  77. */
  78. void
  79. xfs_btree_trace_argfffi(
  80. const char *func,
  81. struct xfs_btree_cur *cur,
  82. xfs_dfiloff_t o,
  83. xfs_dfsbno_t b,
  84. xfs_dfilblks_t i,
  85. int j,
  86. int line)
  87. {
  88. cur->bc_ops->trace_enter(cur, func, XBT_ARGS, XFS_BTREE_KTRACE_ARGFFFI,
  89. line,
  90. o >> 32, (int)o,
  91. b >> 32, (int)b,
  92. i >> 32, (int)i,
  93. (int)j, 0, 0, 0, 0);
  94. }
  95. /*
  96. * Add a trace buffer entry for arguments, for one integer arg.
  97. */
  98. void
  99. xfs_btree_trace_argi(
  100. const char *func,
  101. struct xfs_btree_cur *cur,
  102. int i,
  103. int line)
  104. {
  105. cur->bc_ops->trace_enter(cur, func, XBT_ARGS, XFS_BTREE_KTRACE_ARGI,
  106. line, i, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  107. }
  108. /*
  109. * Add a trace buffer entry for arguments, for int, fsblock, key.
  110. */
  111. void
  112. xfs_btree_trace_argipk(
  113. const char *func,
  114. struct xfs_btree_cur *cur,
  115. int i,
  116. union xfs_btree_ptr ptr,
  117. union xfs_btree_key *key,
  118. int line)
  119. {
  120. __psunsigned_t high, low;
  121. __uint64_t l0, l1;
  122. xfs_btree_trace_ptr(cur, ptr, &high, &low);
  123. cur->bc_ops->trace_key(cur, key, &l0, &l1);
  124. cur->bc_ops->trace_enter(cur, func, XBT_ARGS, XFS_BTREE_KTRACE_ARGIPK,
  125. line, i, high, low,
  126. l0 >> 32, (int)l0,
  127. l1 >> 32, (int)l1,
  128. 0, 0, 0, 0);
  129. }
  130. /*
  131. * Add a trace buffer entry for arguments, for int, fsblock, rec.
  132. */
  133. void
  134. xfs_btree_trace_argipr(
  135. const char *func,
  136. struct xfs_btree_cur *cur,
  137. int i,
  138. union xfs_btree_ptr ptr,
  139. union xfs_btree_rec *rec,
  140. int line)
  141. {
  142. __psunsigned_t high, low;
  143. __uint64_t l0, l1, l2;
  144. xfs_btree_trace_ptr(cur, ptr, &high, &low);
  145. cur->bc_ops->trace_record(cur, rec, &l0, &l1, &l2);
  146. cur->bc_ops->trace_enter(cur, func, XBT_ARGS, XFS_BTREE_KTRACE_ARGIPR,
  147. line, i,
  148. high, low,
  149. l0 >> 32, (int)l0,
  150. l1 >> 32, (int)l1,
  151. l2 >> 32, (int)l2,
  152. 0, 0);
  153. }
  154. /*
  155. * Add a trace buffer entry for arguments, for int, key.
  156. */
  157. void
  158. xfs_btree_trace_argik(
  159. const char *func,
  160. struct xfs_btree_cur *cur,
  161. int i,
  162. union xfs_btree_key *key,
  163. int line)
  164. {
  165. __uint64_t l0, l1;
  166. cur->bc_ops->trace_key(cur, key, &l0, &l1);
  167. cur->bc_ops->trace_enter(cur, func, XBT_ARGS, XFS_BTREE_KTRACE_ARGIK,
  168. line, i,
  169. l0 >> 32, (int)l0,
  170. l1 >> 32, (int)l1,
  171. 0, 0, 0, 0, 0, 0);
  172. }
  173. /*
  174. * Add a trace buffer entry for arguments, for record.
  175. */
  176. void
  177. xfs_btree_trace_argr(
  178. const char *func,
  179. struct xfs_btree_cur *cur,
  180. union xfs_btree_rec *rec,
  181. int line)
  182. {
  183. __uint64_t l0, l1, l2;
  184. cur->bc_ops->trace_record(cur, rec, &l0, &l1, &l2);
  185. cur->bc_ops->trace_enter(cur, func, XBT_ARGS, XFS_BTREE_KTRACE_ARGR,
  186. line,
  187. l0 >> 32, (int)l0,
  188. l1 >> 32, (int)l1,
  189. l2 >> 32, (int)l2,
  190. 0, 0, 0, 0, 0);
  191. }
  192. /*
  193. * Add a trace buffer entry for the cursor/operation.
  194. */
  195. void
  196. xfs_btree_trace_cursor(
  197. const char *func,
  198. struct xfs_btree_cur *cur,
  199. int type,
  200. int line)
  201. {
  202. __uint32_t s0;
  203. __uint64_t l0, l1;
  204. char *s;
  205. switch (type) {
  206. case XBT_ARGS:
  207. s = "args";
  208. break;
  209. case XBT_ENTRY:
  210. s = "entry";
  211. break;
  212. case XBT_ERROR:
  213. s = "error";
  214. break;
  215. case XBT_EXIT:
  216. s = "exit";
  217. break;
  218. default:
  219. s = "unknown";
  220. break;
  221. }
  222. cur->bc_ops->trace_cursor(cur, &s0, &l0, &l1);
  223. cur->bc_ops->trace_enter(cur, func, s, XFS_BTREE_KTRACE_CUR, line,
  224. s0,
  225. l0 >> 32, (int)l0,
  226. l1 >> 32, (int)l1,
  227. (__psunsigned_t)cur->bc_bufs[0],
  228. (__psunsigned_t)cur->bc_bufs[1],
  229. (__psunsigned_t)cur->bc_bufs[2],
  230. (__psunsigned_t)cur->bc_bufs[3],
  231. (cur->bc_ptrs[0] << 16) | cur->bc_ptrs[1],
  232. (cur->bc_ptrs[2] << 16) | cur->bc_ptrs[3]);
  233. }