2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
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.
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.
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
19 #include <linux/proc_fs.h>
21 DEFINE_PER_CPU(struct xfsstats, xfsstats);
32 int c, i, j, len, val;
33 __uint64_t xs_xstrat_bytes = 0;
34 __uint64_t xs_write_bytes = 0;
35 __uint64_t xs_read_bytes = 0;
37 static const struct xstats_entry {
41 { "extent_alloc", XFSSTAT_END_EXTENT_ALLOC },
42 { "abt", XFSSTAT_END_ALLOC_BTREE },
43 { "blk_map", XFSSTAT_END_BLOCK_MAPPING },
44 { "bmbt", XFSSTAT_END_BLOCK_MAP_BTREE },
45 { "dir", XFSSTAT_END_DIRECTORY_OPS },
46 { "trans", XFSSTAT_END_TRANSACTIONS },
47 { "ig", XFSSTAT_END_INODE_OPS },
48 { "log", XFSSTAT_END_LOG_OPS },
49 { "push_ail", XFSSTAT_END_TAIL_PUSHING },
50 { "xstrat", XFSSTAT_END_WRITE_CONVERT },
51 { "rw", XFSSTAT_END_READ_WRITE_OPS },
52 { "attr", XFSSTAT_END_ATTRIBUTE_OPS },
53 { "icluster", XFSSTAT_END_INODE_CLUSTER },
54 { "vnodes", XFSSTAT_END_VNODE_OPS },
55 { "buf", XFSSTAT_END_BUF },
58 /* Loop over all stats groups */
59 for (i=j=len = 0; i < sizeof(xstats)/sizeof(struct xstats_entry); i++) {
60 len += sprintf(buffer + len, xstats[i].desc);
61 /* inner loop does each group */
62 while (j < xstats[i].endpoint) {
64 /* sum over all cpus */
65 for (c = 0; c < NR_CPUS; c++) {
66 if (!cpu_possible(c)) continue;
67 val += *(((__u32*)&per_cpu(xfsstats, c) + j));
69 len += sprintf(buffer + len, " %u", val);
74 /* extra precision counters */
75 for (i = 0; i < NR_CPUS; i++) {
76 if (!cpu_possible(i)) continue;
77 xs_xstrat_bytes += per_cpu(xfsstats, i).xs_xstrat_bytes;
78 xs_write_bytes += per_cpu(xfsstats, i).xs_write_bytes;
79 xs_read_bytes += per_cpu(xfsstats, i).xs_read_bytes;
82 len += sprintf(buffer + len, "xpc %Lu %Lu %Lu\n",
83 xs_xstrat_bytes, xs_write_bytes, xs_read_bytes);
84 len += sprintf(buffer + len, "debug %u\n",
96 *start = buffer + offset;
97 if ((len -= offset) > count)
105 xfs_init_procfs(void)
107 if (!proc_mkdir("fs/xfs", NULL))
109 create_proc_read_entry("fs/xfs/stat", 0, NULL, xfs_read_xfsstats, NULL);
113 xfs_cleanup_procfs(void)
115 remove_proc_entry("fs/xfs/stat", NULL);
116 remove_proc_entry("fs/xfs", NULL);