blob: 54f2260299d1a9adb5220da36420e52474de64ce [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scott7b718762005-11-02 14:58:39 +11002 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Nathan Scott7b718762005-11-02 14:58:39 +11005 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * published by the Free Software Foundation.
8 *
Nathan Scott7b718762005-11-02 14:58:39 +11009 * 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.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 *
Nathan Scott7b718762005-11-02 14:58:39 +110014 * 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 */
18#ifndef __XFS_STATS_H__
19#define __XFS_STATS_H__
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#if defined(CONFIG_PROC_FS) && !defined(XFS_STATS_OFF)
22
23#include <linux/percpu.h>
24
25/*
26 * XFS global statistics
27 */
28struct xfsstats {
29# define XFSSTAT_END_EXTENT_ALLOC 4
30 __uint32_t xs_allocx;
31 __uint32_t xs_allocb;
32 __uint32_t xs_freex;
33 __uint32_t xs_freeb;
34# define XFSSTAT_END_ALLOC_BTREE (XFSSTAT_END_EXTENT_ALLOC+4)
35 __uint32_t xs_abt_lookup;
36 __uint32_t xs_abt_compare;
37 __uint32_t xs_abt_insrec;
38 __uint32_t xs_abt_delrec;
39# define XFSSTAT_END_BLOCK_MAPPING (XFSSTAT_END_ALLOC_BTREE+7)
40 __uint32_t xs_blk_mapr;
41 __uint32_t xs_blk_mapw;
42 __uint32_t xs_blk_unmap;
43 __uint32_t xs_add_exlist;
44 __uint32_t xs_del_exlist;
45 __uint32_t xs_look_exlist;
46 __uint32_t xs_cmp_exlist;
47# define XFSSTAT_END_BLOCK_MAP_BTREE (XFSSTAT_END_BLOCK_MAPPING+4)
48 __uint32_t xs_bmbt_lookup;
49 __uint32_t xs_bmbt_compare;
50 __uint32_t xs_bmbt_insrec;
51 __uint32_t xs_bmbt_delrec;
52# define XFSSTAT_END_DIRECTORY_OPS (XFSSTAT_END_BLOCK_MAP_BTREE+4)
53 __uint32_t xs_dir_lookup;
54 __uint32_t xs_dir_create;
55 __uint32_t xs_dir_remove;
56 __uint32_t xs_dir_getdents;
57# define XFSSTAT_END_TRANSACTIONS (XFSSTAT_END_DIRECTORY_OPS+3)
58 __uint32_t xs_trans_sync;
59 __uint32_t xs_trans_async;
60 __uint32_t xs_trans_empty;
61# define XFSSTAT_END_INODE_OPS (XFSSTAT_END_TRANSACTIONS+7)
62 __uint32_t xs_ig_attempts;
63 __uint32_t xs_ig_found;
64 __uint32_t xs_ig_frecycle;
65 __uint32_t xs_ig_missed;
66 __uint32_t xs_ig_dup;
67 __uint32_t xs_ig_reclaims;
68 __uint32_t xs_ig_attrchg;
69# define XFSSTAT_END_LOG_OPS (XFSSTAT_END_INODE_OPS+5)
70 __uint32_t xs_log_writes;
71 __uint32_t xs_log_blocks;
72 __uint32_t xs_log_noiclogs;
73 __uint32_t xs_log_force;
74 __uint32_t xs_log_force_sleep;
75# define XFSSTAT_END_TAIL_PUSHING (XFSSTAT_END_LOG_OPS+10)
76 __uint32_t xs_try_logspace;
77 __uint32_t xs_sleep_logspace;
78 __uint32_t xs_push_ail;
79 __uint32_t xs_push_ail_success;
80 __uint32_t xs_push_ail_pushbuf;
81 __uint32_t xs_push_ail_pinned;
82 __uint32_t xs_push_ail_locked;
83 __uint32_t xs_push_ail_flushing;
84 __uint32_t xs_push_ail_restarts;
85 __uint32_t xs_push_ail_flush;
86# define XFSSTAT_END_WRITE_CONVERT (XFSSTAT_END_TAIL_PUSHING+2)
87 __uint32_t xs_xstrat_quick;
88 __uint32_t xs_xstrat_split;
89# define XFSSTAT_END_READ_WRITE_OPS (XFSSTAT_END_WRITE_CONVERT+2)
90 __uint32_t xs_write_calls;
91 __uint32_t xs_read_calls;
92# define XFSSTAT_END_ATTRIBUTE_OPS (XFSSTAT_END_READ_WRITE_OPS+4)
93 __uint32_t xs_attr_get;
94 __uint32_t xs_attr_set;
95 __uint32_t xs_attr_remove;
96 __uint32_t xs_attr_list;
97# define XFSSTAT_END_INODE_CLUSTER (XFSSTAT_END_ATTRIBUTE_OPS+3)
98 __uint32_t xs_iflush_count;
99 __uint32_t xs_icluster_flushcnt;
100 __uint32_t xs_icluster_flushinode;
101# define XFSSTAT_END_VNODE_OPS (XFSSTAT_END_INODE_CLUSTER+8)
102 __uint32_t vn_active; /* # vnodes not on free lists */
103 __uint32_t vn_alloc; /* # times vn_alloc called */
104 __uint32_t vn_get; /* # times vn_get called */
105 __uint32_t vn_hold; /* # times vn_hold called */
106 __uint32_t vn_rele; /* # times vn_rele called */
107 __uint32_t vn_reclaim; /* # times vn_reclaim called */
108 __uint32_t vn_remove; /* # times vn_remove called */
109 __uint32_t vn_free; /* # times vn_free called */
110#define XFSSTAT_END_BUF (XFSSTAT_END_VNODE_OPS+9)
Nathan Scottce8e9222006-01-11 15:39:08 +1100111 __uint32_t xb_get;
112 __uint32_t xb_create;
113 __uint32_t xb_get_locked;
114 __uint32_t xb_get_locked_waited;
115 __uint32_t xb_busy_locked;
116 __uint32_t xb_miss_locked;
117 __uint32_t xb_page_retries;
118 __uint32_t xb_page_found;
119 __uint32_t xb_get_read;
David Chinner854929f2008-10-30 16:55:03 +1100120/* Version 2 btree counters */
121#define XFSSTAT_END_ABTB_V2 (XFSSTAT_END_BUF+15)
122 __uint32_t xs_abtb_2_lookup;
123 __uint32_t xs_abtb_2_compare;
124 __uint32_t xs_abtb_2_insrec;
125 __uint32_t xs_abtb_2_delrec;
126 __uint32_t xs_abtb_2_newroot;
127 __uint32_t xs_abtb_2_killroot;
128 __uint32_t xs_abtb_2_increment;
129 __uint32_t xs_abtb_2_decrement;
130 __uint32_t xs_abtb_2_lshift;
131 __uint32_t xs_abtb_2_rshift;
132 __uint32_t xs_abtb_2_split;
133 __uint32_t xs_abtb_2_join;
134 __uint32_t xs_abtb_2_alloc;
135 __uint32_t xs_abtb_2_free;
136 __uint32_t xs_abtb_2_moves;
137#define XFSSTAT_END_ABTC_V2 (XFSSTAT_END_ABTB_V2+15)
138 __uint32_t xs_abtc_2_lookup;
139 __uint32_t xs_abtc_2_compare;
140 __uint32_t xs_abtc_2_insrec;
141 __uint32_t xs_abtc_2_delrec;
142 __uint32_t xs_abtc_2_newroot;
143 __uint32_t xs_abtc_2_killroot;
144 __uint32_t xs_abtc_2_increment;
145 __uint32_t xs_abtc_2_decrement;
146 __uint32_t xs_abtc_2_lshift;
147 __uint32_t xs_abtc_2_rshift;
148 __uint32_t xs_abtc_2_split;
149 __uint32_t xs_abtc_2_join;
150 __uint32_t xs_abtc_2_alloc;
151 __uint32_t xs_abtc_2_free;
152 __uint32_t xs_abtc_2_moves;
153#define XFSSTAT_END_BMBT_V2 (XFSSTAT_END_ABTC_V2+15)
154 __uint32_t xs_bmbt_2_lookup;
155 __uint32_t xs_bmbt_2_compare;
156 __uint32_t xs_bmbt_2_insrec;
157 __uint32_t xs_bmbt_2_delrec;
158 __uint32_t xs_bmbt_2_newroot;
159 __uint32_t xs_bmbt_2_killroot;
160 __uint32_t xs_bmbt_2_increment;
161 __uint32_t xs_bmbt_2_decrement;
162 __uint32_t xs_bmbt_2_lshift;
163 __uint32_t xs_bmbt_2_rshift;
164 __uint32_t xs_bmbt_2_split;
165 __uint32_t xs_bmbt_2_join;
166 __uint32_t xs_bmbt_2_alloc;
167 __uint32_t xs_bmbt_2_free;
168 __uint32_t xs_bmbt_2_moves;
169#define XFSSTAT_END_IBT_V2 (XFSSTAT_END_BMBT_V2+15)
170 __uint32_t xs_ibt_2_lookup;
171 __uint32_t xs_ibt_2_compare;
172 __uint32_t xs_ibt_2_insrec;
173 __uint32_t xs_ibt_2_delrec;
174 __uint32_t xs_ibt_2_newroot;
175 __uint32_t xs_ibt_2_killroot;
176 __uint32_t xs_ibt_2_increment;
177 __uint32_t xs_ibt_2_decrement;
178 __uint32_t xs_ibt_2_lshift;
179 __uint32_t xs_ibt_2_rshift;
180 __uint32_t xs_ibt_2_split;
181 __uint32_t xs_ibt_2_join;
182 __uint32_t xs_ibt_2_alloc;
183 __uint32_t xs_ibt_2_free;
184 __uint32_t xs_ibt_2_moves;
Brian Fosteraafc3c22014-04-24 16:00:52 +1000185#define XFSSTAT_END_FIBT_V2 (XFSSTAT_END_IBT_V2+15)
186 __uint32_t xs_fibt_2_lookup;
187 __uint32_t xs_fibt_2_compare;
188 __uint32_t xs_fibt_2_insrec;
189 __uint32_t xs_fibt_2_delrec;
190 __uint32_t xs_fibt_2_newroot;
191 __uint32_t xs_fibt_2_killroot;
192 __uint32_t xs_fibt_2_increment;
193 __uint32_t xs_fibt_2_decrement;
194 __uint32_t xs_fibt_2_lshift;
195 __uint32_t xs_fibt_2_rshift;
196 __uint32_t xs_fibt_2_split;
197 __uint32_t xs_fibt_2_join;
198 __uint32_t xs_fibt_2_alloc;
199 __uint32_t xs_fibt_2_free;
200 __uint32_t xs_fibt_2_moves;
201#define XFSSTAT_END_XQMSTAT (XFSSTAT_END_FIBT_V2+6)
Christoph Hellwig48776fd2012-03-13 08:52:33 +0000202 __uint32_t xs_qm_dqreclaims;
203 __uint32_t xs_qm_dqreclaim_misses;
204 __uint32_t xs_qm_dquot_dups;
205 __uint32_t xs_qm_dqcachemisses;
206 __uint32_t xs_qm_dqcachehits;
207 __uint32_t xs_qm_dqwants;
208#define XFSSTAT_END_QM (XFSSTAT_END_XQMSTAT+2)
209 __uint32_t xs_qm_dquot;
210 __uint32_t xs_qm_dquot_unused;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211/* Extra precision counters */
212 __uint64_t xs_xstrat_bytes;
213 __uint64_t xs_write_bytes;
214 __uint64_t xs_read_bytes;
215};
216
Bill O'Donnell80529c42015-10-12 05:19:45 +1100217int xfs_stats_format(struct xfsstats __percpu *stats, char *buf);
218void xfs_stats_clearall(struct xfsstats __percpu *stats);
219extern struct xstats xfsstats;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220
Bill O'Donnell80529c42015-10-12 05:19:45 +1100221#define XFS_STATS_INC(v) \
222 (per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v++)
223
224#define XFS_STATS_DEC(v) \
225 (per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v--)
226
227#define XFS_STATS_ADD(v, inc) \
228 (per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v += (inc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229
Christoph Hellwig9f8868f2008-07-18 17:11:46 +1000230extern int xfs_init_procfs(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231extern void xfs_cleanup_procfs(void);
232
233
234#else /* !CONFIG_PROC_FS */
235
236# define XFS_STATS_INC(count)
237# define XFS_STATS_DEC(count)
238# define XFS_STATS_ADD(count, inc)
239
Christoph Hellwig9f8868f2008-07-18 17:11:46 +1000240static inline int xfs_init_procfs(void)
241{
Christoph Hellwig766b0922008-07-18 17:12:50 +1000242 return 0;
243}
244
Christoph Hellwig9f8868f2008-07-18 17:11:46 +1000245static inline void xfs_cleanup_procfs(void)
246{
Christoph Hellwig766b0922008-07-18 17:12:50 +1000247}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248
249#endif /* !CONFIG_PROC_FS */
250
251#endif /* __XFS_STATS_H__ */