xfs_stats.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /*
  2. * Copyright (c) 2000,2005 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. #ifndef __XFS_STATS_H__
  19. #define __XFS_STATS_H__
  20. #include <linux/percpu.h>
  21. /*
  22. * The btree stats arrays have fixed offsets for the different stats. We
  23. * store the base index in the btree cursor via XFS_STATS_CALC_INDEX() and
  24. * that allows us to use fixed offsets into the stats array for each btree
  25. * stat. These index offsets are defined in the order they will be emitted
  26. * in the stats files, so it is possible to add new btree stat types by
  27. * appending to the enum list below.
  28. */
  29. enum {
  30. __XBTS_lookup = 0,
  31. __XBTS_compare = 1,
  32. __XBTS_insrec = 2,
  33. __XBTS_delrec = 3,
  34. __XBTS_newroot = 4,
  35. __XBTS_killroot = 5,
  36. __XBTS_increment = 6,
  37. __XBTS_decrement = 7,
  38. __XBTS_lshift = 8,
  39. __XBTS_rshift = 9,
  40. __XBTS_split = 10,
  41. __XBTS_join = 11,
  42. __XBTS_alloc = 12,
  43. __XBTS_free = 13,
  44. __XBTS_moves = 14,
  45. __XBTS_MAX = 15,
  46. };
  47. /*
  48. * XFS global statistics
  49. */
  50. struct __xfsstats {
  51. # define XFSSTAT_END_EXTENT_ALLOC 4
  52. __uint32_t xs_allocx;
  53. __uint32_t xs_allocb;
  54. __uint32_t xs_freex;
  55. __uint32_t xs_freeb;
  56. # define XFSSTAT_END_ALLOC_BTREE (XFSSTAT_END_EXTENT_ALLOC+4)
  57. __uint32_t xs_abt_lookup;
  58. __uint32_t xs_abt_compare;
  59. __uint32_t xs_abt_insrec;
  60. __uint32_t xs_abt_delrec;
  61. # define XFSSTAT_END_BLOCK_MAPPING (XFSSTAT_END_ALLOC_BTREE+7)
  62. __uint32_t xs_blk_mapr;
  63. __uint32_t xs_blk_mapw;
  64. __uint32_t xs_blk_unmap;
  65. __uint32_t xs_add_exlist;
  66. __uint32_t xs_del_exlist;
  67. __uint32_t xs_look_exlist;
  68. __uint32_t xs_cmp_exlist;
  69. # define XFSSTAT_END_BLOCK_MAP_BTREE (XFSSTAT_END_BLOCK_MAPPING+4)
  70. __uint32_t xs_bmbt_lookup;
  71. __uint32_t xs_bmbt_compare;
  72. __uint32_t xs_bmbt_insrec;
  73. __uint32_t xs_bmbt_delrec;
  74. # define XFSSTAT_END_DIRECTORY_OPS (XFSSTAT_END_BLOCK_MAP_BTREE+4)
  75. __uint32_t xs_dir_lookup;
  76. __uint32_t xs_dir_create;
  77. __uint32_t xs_dir_remove;
  78. __uint32_t xs_dir_getdents;
  79. # define XFSSTAT_END_TRANSACTIONS (XFSSTAT_END_DIRECTORY_OPS+3)
  80. __uint32_t xs_trans_sync;
  81. __uint32_t xs_trans_async;
  82. __uint32_t xs_trans_empty;
  83. # define XFSSTAT_END_INODE_OPS (XFSSTAT_END_TRANSACTIONS+7)
  84. __uint32_t xs_ig_attempts;
  85. __uint32_t xs_ig_found;
  86. __uint32_t xs_ig_frecycle;
  87. __uint32_t xs_ig_missed;
  88. __uint32_t xs_ig_dup;
  89. __uint32_t xs_ig_reclaims;
  90. __uint32_t xs_ig_attrchg;
  91. # define XFSSTAT_END_LOG_OPS (XFSSTAT_END_INODE_OPS+5)
  92. __uint32_t xs_log_writes;
  93. __uint32_t xs_log_blocks;
  94. __uint32_t xs_log_noiclogs;
  95. __uint32_t xs_log_force;
  96. __uint32_t xs_log_force_sleep;
  97. # define XFSSTAT_END_TAIL_PUSHING (XFSSTAT_END_LOG_OPS+10)
  98. __uint32_t xs_try_logspace;
  99. __uint32_t xs_sleep_logspace;
  100. __uint32_t xs_push_ail;
  101. __uint32_t xs_push_ail_success;
  102. __uint32_t xs_push_ail_pushbuf;
  103. __uint32_t xs_push_ail_pinned;
  104. __uint32_t xs_push_ail_locked;
  105. __uint32_t xs_push_ail_flushing;
  106. __uint32_t xs_push_ail_restarts;
  107. __uint32_t xs_push_ail_flush;
  108. # define XFSSTAT_END_WRITE_CONVERT (XFSSTAT_END_TAIL_PUSHING+2)
  109. __uint32_t xs_xstrat_quick;
  110. __uint32_t xs_xstrat_split;
  111. # define XFSSTAT_END_READ_WRITE_OPS (XFSSTAT_END_WRITE_CONVERT+2)
  112. __uint32_t xs_write_calls;
  113. __uint32_t xs_read_calls;
  114. # define XFSSTAT_END_ATTRIBUTE_OPS (XFSSTAT_END_READ_WRITE_OPS+4)
  115. __uint32_t xs_attr_get;
  116. __uint32_t xs_attr_set;
  117. __uint32_t xs_attr_remove;
  118. __uint32_t xs_attr_list;
  119. # define XFSSTAT_END_INODE_CLUSTER (XFSSTAT_END_ATTRIBUTE_OPS+3)
  120. __uint32_t xs_iflush_count;
  121. __uint32_t xs_icluster_flushcnt;
  122. __uint32_t xs_icluster_flushinode;
  123. # define XFSSTAT_END_VNODE_OPS (XFSSTAT_END_INODE_CLUSTER+8)
  124. __uint32_t vn_active; /* # vnodes not on free lists */
  125. __uint32_t vn_alloc; /* # times vn_alloc called */
  126. __uint32_t vn_get; /* # times vn_get called */
  127. __uint32_t vn_hold; /* # times vn_hold called */
  128. __uint32_t vn_rele; /* # times vn_rele called */
  129. __uint32_t vn_reclaim; /* # times vn_reclaim called */
  130. __uint32_t vn_remove; /* # times vn_remove called */
  131. __uint32_t vn_free; /* # times vn_free called */
  132. #define XFSSTAT_END_BUF (XFSSTAT_END_VNODE_OPS+9)
  133. __uint32_t xb_get;
  134. __uint32_t xb_create;
  135. __uint32_t xb_get_locked;
  136. __uint32_t xb_get_locked_waited;
  137. __uint32_t xb_busy_locked;
  138. __uint32_t xb_miss_locked;
  139. __uint32_t xb_page_retries;
  140. __uint32_t xb_page_found;
  141. __uint32_t xb_get_read;
  142. /* Version 2 btree counters */
  143. #define XFSSTAT_END_ABTB_V2 (XFSSTAT_END_BUF + __XBTS_MAX)
  144. __uint32_t xs_abtb_2[__XBTS_MAX];
  145. #define XFSSTAT_END_ABTC_V2 (XFSSTAT_END_ABTB_V2 + __XBTS_MAX)
  146. __uint32_t xs_abtc_2[__XBTS_MAX];
  147. #define XFSSTAT_END_BMBT_V2 (XFSSTAT_END_ABTC_V2 + __XBTS_MAX)
  148. __uint32_t xs_bmbt_2[__XBTS_MAX];
  149. #define XFSSTAT_END_IBT_V2 (XFSSTAT_END_BMBT_V2 + __XBTS_MAX)
  150. __uint32_t xs_ibt_2[__XBTS_MAX];
  151. #define XFSSTAT_END_FIBT_V2 (XFSSTAT_END_IBT_V2 + __XBTS_MAX)
  152. __uint32_t xs_fibt_2[__XBTS_MAX];
  153. #define XFSSTAT_END_RMAP_V2 (XFSSTAT_END_FIBT_V2 + __XBTS_MAX)
  154. __uint32_t xs_rmap_2[__XBTS_MAX];
  155. #define XFSSTAT_END_REFCOUNT (XFSSTAT_END_RMAP_V2 + __XBTS_MAX)
  156. __uint32_t xs_refcbt_2[__XBTS_MAX];
  157. #define XFSSTAT_END_XQMSTAT (XFSSTAT_END_REFCOUNT + 6)
  158. __uint32_t xs_qm_dqreclaims;
  159. __uint32_t xs_qm_dqreclaim_misses;
  160. __uint32_t xs_qm_dquot_dups;
  161. __uint32_t xs_qm_dqcachemisses;
  162. __uint32_t xs_qm_dqcachehits;
  163. __uint32_t xs_qm_dqwants;
  164. #define XFSSTAT_END_QM (XFSSTAT_END_XQMSTAT+2)
  165. __uint32_t xs_qm_dquot;
  166. __uint32_t xs_qm_dquot_unused;
  167. /* Extra precision counters */
  168. __uint64_t xs_xstrat_bytes;
  169. __uint64_t xs_write_bytes;
  170. __uint64_t xs_read_bytes;
  171. };
  172. struct xfsstats {
  173. union {
  174. struct __xfsstats s;
  175. uint32_t a[XFSSTAT_END_XQMSTAT];
  176. };
  177. };
  178. /*
  179. * simple wrapper for getting the array index of s struct member offset
  180. */
  181. #define XFS_STATS_CALC_INDEX(member) \
  182. (offsetof(struct __xfsstats, member) / (int)sizeof(__uint32_t))
  183. int xfs_stats_format(struct xfsstats __percpu *stats, char *buf);
  184. void xfs_stats_clearall(struct xfsstats __percpu *stats);
  185. extern struct xstats xfsstats;
  186. #define XFS_STATS_INC(mp, v) \
  187. do { \
  188. per_cpu_ptr(xfsstats.xs_stats, current_cpu())->s.v++; \
  189. per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->s.v++; \
  190. } while (0)
  191. #define XFS_STATS_DEC(mp, v) \
  192. do { \
  193. per_cpu_ptr(xfsstats.xs_stats, current_cpu())->s.v--; \
  194. per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->s.v--; \
  195. } while (0)
  196. #define XFS_STATS_ADD(mp, v, inc) \
  197. do { \
  198. per_cpu_ptr(xfsstats.xs_stats, current_cpu())->s.v += (inc); \
  199. per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->s.v += (inc); \
  200. } while (0)
  201. #define XFS_STATS_INC_OFF(mp, off) \
  202. do { \
  203. per_cpu_ptr(xfsstats.xs_stats, current_cpu())->a[off]++; \
  204. per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->a[off]++; \
  205. } while (0)
  206. #define XFS_STATS_DEC_OFF(mp, off) \
  207. do { \
  208. per_cpu_ptr(xfsstats.xs_stats, current_cpu())->a[off]; \
  209. per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->a[off]; \
  210. } while (0)
  211. #define XFS_STATS_ADD_OFF(mp, off, inc) \
  212. do { \
  213. per_cpu_ptr(xfsstats.xs_stats, current_cpu())->a[off] += (inc); \
  214. per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->a[off] += (inc); \
  215. } while (0)
  216. #if defined(CONFIG_PROC_FS)
  217. extern int xfs_init_procfs(void);
  218. extern void xfs_cleanup_procfs(void);
  219. #else /* !CONFIG_PROC_FS */
  220. static inline int xfs_init_procfs(void)
  221. {
  222. return 0;
  223. }
  224. static inline void xfs_cleanup_procfs(void)
  225. {
  226. }
  227. #endif /* !CONFIG_PROC_FS */
  228. #endif /* __XFS_STATS_H__ */