2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
34 #include <linux/proc_fs.h>
36 DEFINE_PER_CPU(struct xfsstats, xfsstats);
47 int c, i, j, len, val;
48 __uint64_t xs_xstrat_bytes = 0;
49 __uint64_t xs_write_bytes = 0;
50 __uint64_t xs_read_bytes = 0;
52 static struct xstats_entry {
56 { "extent_alloc", XFSSTAT_END_EXTENT_ALLOC },
57 { "abt", XFSSTAT_END_ALLOC_BTREE },
58 { "blk_map", XFSSTAT_END_BLOCK_MAPPING },
59 { "bmbt", XFSSTAT_END_BLOCK_MAP_BTREE },
60 { "dir", XFSSTAT_END_DIRECTORY_OPS },
61 { "trans", XFSSTAT_END_TRANSACTIONS },
62 { "ig", XFSSTAT_END_INODE_OPS },
63 { "log", XFSSTAT_END_LOG_OPS },
64 { "push_ail", XFSSTAT_END_TAIL_PUSHING },
65 { "xstrat", XFSSTAT_END_WRITE_CONVERT },
66 { "rw", XFSSTAT_END_READ_WRITE_OPS },
67 { "attr", XFSSTAT_END_ATTRIBUTE_OPS },
68 { "icluster", XFSSTAT_END_INODE_CLUSTER },
69 { "vnodes", XFSSTAT_END_VNODE_OPS },
70 { "buf", XFSSTAT_END_BUF },
73 /* Loop over all stats groups */
74 for (i=j=len = 0; i < sizeof(xstats)/sizeof(struct xstats_entry); i++) {
75 len += sprintf(buffer + len, xstats[i].desc);
76 /* inner loop does each group */
77 while (j < xstats[i].endpoint) {
79 /* sum over all cpus */
80 for (c = 0; c < NR_CPUS; c++) {
81 if (!cpu_possible(c)) continue;
82 val += *(((__u32*)&per_cpu(xfsstats, c) + j));
84 len += sprintf(buffer + len, " %u", val);
89 /* extra precision counters */
90 for (i = 0; i < NR_CPUS; i++) {
91 if (!cpu_possible(i)) continue;
92 xs_xstrat_bytes += per_cpu(xfsstats, i).xs_xstrat_bytes;
93 xs_write_bytes += per_cpu(xfsstats, i).xs_write_bytes;
94 xs_read_bytes += per_cpu(xfsstats, i).xs_read_bytes;
97 len += sprintf(buffer + len, "xpc %Lu %Lu %Lu\n",
98 xs_xstrat_bytes, xs_write_bytes, xs_read_bytes);
99 len += sprintf(buffer + len, "debug %u\n",
111 *start = buffer + offset;
112 if ((len -= offset) > count)
120 xfs_init_procfs(void)
122 if (!proc_mkdir("fs/xfs", NULL))
124 create_proc_read_entry("fs/xfs/stat", 0, NULL, xfs_read_xfsstats, NULL);
128 xfs_cleanup_procfs(void)
130 remove_proc_entry("fs/xfs/stat", NULL);
131 remove_proc_entry("fs/xfs", NULL);