blob: 483b0eff198836ca1516cf56bdffc5f283af8dad [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
22#include <linux/percpu.h>
23
24/*
25 * XFS global statistics
26 */
27struct xfsstats {
28# define XFSSTAT_END_EXTENT_ALLOC 4
29 __uint32_t xs_allocx;
30 __uint32_t xs_allocb;
31 __uint32_t xs_freex;
32 __uint32_t xs_freeb;
33# define XFSSTAT_END_ALLOC_BTREE (XFSSTAT_END_EXTENT_ALLOC+4)
34 __uint32_t xs_abt_lookup;
35 __uint32_t xs_abt_compare;
36 __uint32_t xs_abt_insrec;
37 __uint32_t xs_abt_delrec;
38# define XFSSTAT_END_BLOCK_MAPPING (XFSSTAT_END_ALLOC_BTREE+7)
39 __uint32_t xs_blk_mapr;
40 __uint32_t xs_blk_mapw;
41 __uint32_t xs_blk_unmap;
42 __uint32_t xs_add_exlist;
43 __uint32_t xs_del_exlist;
44 __uint32_t xs_look_exlist;
45 __uint32_t xs_cmp_exlist;
46# define XFSSTAT_END_BLOCK_MAP_BTREE (XFSSTAT_END_BLOCK_MAPPING+4)
47 __uint32_t xs_bmbt_lookup;
48 __uint32_t xs_bmbt_compare;
49 __uint32_t xs_bmbt_insrec;
50 __uint32_t xs_bmbt_delrec;
51# define XFSSTAT_END_DIRECTORY_OPS (XFSSTAT_END_BLOCK_MAP_BTREE+4)
52 __uint32_t xs_dir_lookup;
53 __uint32_t xs_dir_create;
54 __uint32_t xs_dir_remove;
55 __uint32_t xs_dir_getdents;
56# define XFSSTAT_END_TRANSACTIONS (XFSSTAT_END_DIRECTORY_OPS+3)
57 __uint32_t xs_trans_sync;
58 __uint32_t xs_trans_async;
59 __uint32_t xs_trans_empty;
60# define XFSSTAT_END_INODE_OPS (XFSSTAT_END_TRANSACTIONS+7)
61 __uint32_t xs_ig_attempts;
62 __uint32_t xs_ig_found;
63 __uint32_t xs_ig_frecycle;
64 __uint32_t xs_ig_missed;
65 __uint32_t xs_ig_dup;
66 __uint32_t xs_ig_reclaims;
67 __uint32_t xs_ig_attrchg;
68# define XFSSTAT_END_LOG_OPS (XFSSTAT_END_INODE_OPS+5)
69 __uint32_t xs_log_writes;
70 __uint32_t xs_log_blocks;
71 __uint32_t xs_log_noiclogs;
72 __uint32_t xs_log_force;
73 __uint32_t xs_log_force_sleep;
74# define XFSSTAT_END_TAIL_PUSHING (XFSSTAT_END_LOG_OPS+10)
75 __uint32_t xs_try_logspace;
76 __uint32_t xs_sleep_logspace;
77 __uint32_t xs_push_ail;
78 __uint32_t xs_push_ail_success;
79 __uint32_t xs_push_ail_pushbuf;
80 __uint32_t xs_push_ail_pinned;
81 __uint32_t xs_push_ail_locked;
82 __uint32_t xs_push_ail_flushing;
83 __uint32_t xs_push_ail_restarts;
84 __uint32_t xs_push_ail_flush;
85# define XFSSTAT_END_WRITE_CONVERT (XFSSTAT_END_TAIL_PUSHING+2)
86 __uint32_t xs_xstrat_quick;
87 __uint32_t xs_xstrat_split;
88# define XFSSTAT_END_READ_WRITE_OPS (XFSSTAT_END_WRITE_CONVERT+2)
89 __uint32_t xs_write_calls;
90 __uint32_t xs_read_calls;
91# define XFSSTAT_END_ATTRIBUTE_OPS (XFSSTAT_END_READ_WRITE_OPS+4)
92 __uint32_t xs_attr_get;
93 __uint32_t xs_attr_set;
94 __uint32_t xs_attr_remove;
95 __uint32_t xs_attr_list;
96# define XFSSTAT_END_INODE_CLUSTER (XFSSTAT_END_ATTRIBUTE_OPS+3)
97 __uint32_t xs_iflush_count;
98 __uint32_t xs_icluster_flushcnt;
99 __uint32_t xs_icluster_flushinode;
100# define XFSSTAT_END_VNODE_OPS (XFSSTAT_END_INODE_CLUSTER+8)
101 __uint32_t vn_active; /* # vnodes not on free lists */
102 __uint32_t vn_alloc; /* # times vn_alloc called */
103 __uint32_t vn_get; /* # times vn_get called */
104 __uint32_t vn_hold; /* # times vn_hold called */
105 __uint32_t vn_rele; /* # times vn_rele called */
106 __uint32_t vn_reclaim; /* # times vn_reclaim called */
107 __uint32_t vn_remove; /* # times vn_remove called */
108 __uint32_t vn_free; /* # times vn_free called */
109#define XFSSTAT_END_BUF (XFSSTAT_END_VNODE_OPS+9)
Nathan Scottce8e9222006-01-11 15:39:08 +1100110 __uint32_t xb_get;
111 __uint32_t xb_create;
112 __uint32_t xb_get_locked;
113 __uint32_t xb_get_locked_waited;
114 __uint32_t xb_busy_locked;
115 __uint32_t xb_miss_locked;
116 __uint32_t xb_page_retries;
117 __uint32_t xb_page_found;
118 __uint32_t xb_get_read;
David Chinner854929f2008-10-30 16:55:03 +1100119/* Version 2 btree counters */
120#define XFSSTAT_END_ABTB_V2 (XFSSTAT_END_BUF+15)
121 __uint32_t xs_abtb_2_lookup;
122 __uint32_t xs_abtb_2_compare;
123 __uint32_t xs_abtb_2_insrec;
124 __uint32_t xs_abtb_2_delrec;
125 __uint32_t xs_abtb_2_newroot;
126 __uint32_t xs_abtb_2_killroot;
127 __uint32_t xs_abtb_2_increment;
128 __uint32_t xs_abtb_2_decrement;
129 __uint32_t xs_abtb_2_lshift;
130 __uint32_t xs_abtb_2_rshift;
131 __uint32_t xs_abtb_2_split;
132 __uint32_t xs_abtb_2_join;
133 __uint32_t xs_abtb_2_alloc;
134 __uint32_t xs_abtb_2_free;
135 __uint32_t xs_abtb_2_moves;
136#define XFSSTAT_END_ABTC_V2 (XFSSTAT_END_ABTB_V2+15)
137 __uint32_t xs_abtc_2_lookup;
138 __uint32_t xs_abtc_2_compare;
139 __uint32_t xs_abtc_2_insrec;
140 __uint32_t xs_abtc_2_delrec;
141 __uint32_t xs_abtc_2_newroot;
142 __uint32_t xs_abtc_2_killroot;
143 __uint32_t xs_abtc_2_increment;
144 __uint32_t xs_abtc_2_decrement;
145 __uint32_t xs_abtc_2_lshift;
146 __uint32_t xs_abtc_2_rshift;
147 __uint32_t xs_abtc_2_split;
148 __uint32_t xs_abtc_2_join;
149 __uint32_t xs_abtc_2_alloc;
150 __uint32_t xs_abtc_2_free;
151 __uint32_t xs_abtc_2_moves;
152#define XFSSTAT_END_BMBT_V2 (XFSSTAT_END_ABTC_V2+15)
153 __uint32_t xs_bmbt_2_lookup;
154 __uint32_t xs_bmbt_2_compare;
155 __uint32_t xs_bmbt_2_insrec;
156 __uint32_t xs_bmbt_2_delrec;
157 __uint32_t xs_bmbt_2_newroot;
158 __uint32_t xs_bmbt_2_killroot;
159 __uint32_t xs_bmbt_2_increment;
160 __uint32_t xs_bmbt_2_decrement;
161 __uint32_t xs_bmbt_2_lshift;
162 __uint32_t xs_bmbt_2_rshift;
163 __uint32_t xs_bmbt_2_split;
164 __uint32_t xs_bmbt_2_join;
165 __uint32_t xs_bmbt_2_alloc;
166 __uint32_t xs_bmbt_2_free;
167 __uint32_t xs_bmbt_2_moves;
168#define XFSSTAT_END_IBT_V2 (XFSSTAT_END_BMBT_V2+15)
169 __uint32_t xs_ibt_2_lookup;
170 __uint32_t xs_ibt_2_compare;
171 __uint32_t xs_ibt_2_insrec;
172 __uint32_t xs_ibt_2_delrec;
173 __uint32_t xs_ibt_2_newroot;
174 __uint32_t xs_ibt_2_killroot;
175 __uint32_t xs_ibt_2_increment;
176 __uint32_t xs_ibt_2_decrement;
177 __uint32_t xs_ibt_2_lshift;
178 __uint32_t xs_ibt_2_rshift;
179 __uint32_t xs_ibt_2_split;
180 __uint32_t xs_ibt_2_join;
181 __uint32_t xs_ibt_2_alloc;
182 __uint32_t xs_ibt_2_free;
183 __uint32_t xs_ibt_2_moves;
Brian Fosteraafc3c22014-04-24 16:00:52 +1000184#define XFSSTAT_END_FIBT_V2 (XFSSTAT_END_IBT_V2+15)
185 __uint32_t xs_fibt_2_lookup;
186 __uint32_t xs_fibt_2_compare;
187 __uint32_t xs_fibt_2_insrec;
188 __uint32_t xs_fibt_2_delrec;
189 __uint32_t xs_fibt_2_newroot;
190 __uint32_t xs_fibt_2_killroot;
191 __uint32_t xs_fibt_2_increment;
192 __uint32_t xs_fibt_2_decrement;
193 __uint32_t xs_fibt_2_lshift;
194 __uint32_t xs_fibt_2_rshift;
195 __uint32_t xs_fibt_2_split;
196 __uint32_t xs_fibt_2_join;
197 __uint32_t xs_fibt_2_alloc;
198 __uint32_t xs_fibt_2_free;
199 __uint32_t xs_fibt_2_moves;
200#define XFSSTAT_END_XQMSTAT (XFSSTAT_END_FIBT_V2+6)
Christoph Hellwig48776fd2012-03-13 08:52:33 +0000201 __uint32_t xs_qm_dqreclaims;
202 __uint32_t xs_qm_dqreclaim_misses;
203 __uint32_t xs_qm_dquot_dups;
204 __uint32_t xs_qm_dqcachemisses;
205 __uint32_t xs_qm_dqcachehits;
206 __uint32_t xs_qm_dqwants;
207#define XFSSTAT_END_QM (XFSSTAT_END_XQMSTAT+2)
208 __uint32_t xs_qm_dquot;
209 __uint32_t xs_qm_dquot_unused;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210/* Extra precision counters */
211 __uint64_t xs_xstrat_bytes;
212 __uint64_t xs_write_bytes;
213 __uint64_t xs_read_bytes;
214};
215
Bill O'Donnell80529c42015-10-12 05:19:45 +1100216int xfs_stats_format(struct xfsstats __percpu *stats, char *buf);
217void xfs_stats_clearall(struct xfsstats __percpu *stats);
218extern struct xstats xfsstats;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219
Bill O'Donnellff6d6af2015-10-12 18:21:22 +1100220#define XFS_STATS_INC(mp, v) \
221do { \
222 per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v++; \
223 per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->v++; \
224} while (0)
Bill O'Donnell80529c42015-10-12 05:19:45 +1100225
Bill O'Donnellff6d6af2015-10-12 18:21:22 +1100226#define XFS_STATS_DEC(mp, v) \
227do { \
228 per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v--; \
229 per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->v--; \
230} while (0)
Bill O'Donnell80529c42015-10-12 05:19:45 +1100231
Bill O'Donnellff6d6af2015-10-12 18:21:22 +1100232#define XFS_STATS_ADD(mp, v, inc) \
233do { \
234 per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v += (inc); \
235 per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->v += (inc); \
236} while (0)
237
238#if defined(CONFIG_PROC_FS)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239
Christoph Hellwig9f8868f2008-07-18 17:11:46 +1000240extern int xfs_init_procfs(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241extern void xfs_cleanup_procfs(void);
242
243
244#else /* !CONFIG_PROC_FS */
245
Christoph Hellwig9f8868f2008-07-18 17:11:46 +1000246static inline int xfs_init_procfs(void)
247{
Christoph Hellwig766b0922008-07-18 17:12:50 +1000248 return 0;
249}
250
Christoph Hellwig9f8868f2008-07-18 17:11:46 +1000251static inline void xfs_cleanup_procfs(void)
252{
Christoph Hellwig766b0922008-07-18 17:12:50 +1000253}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254
255#endif /* !CONFIG_PROC_FS */
256
257#endif /* __XFS_STATS_H__ */