aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/linux-2.6/xfs_stats.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_stats.c')
-rw-r--r--fs/xfs/linux-2.6/xfs_stats.c132
1 files changed, 132 insertions, 0 deletions
diff --git a/fs/xfs/linux-2.6/xfs_stats.c b/fs/xfs/linux-2.6/xfs_stats.c
new file mode 100644
index 000000000000..aaf5ddba47f3
--- /dev/null
+++ b/fs/xfs/linux-2.6/xfs_stats.c
@@ -0,0 +1,132 @@
1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
3 *
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.
7 *
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.
11 *
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.
18 *
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.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32
33#include "xfs.h"
34#include <linux/proc_fs.h>
35
36DEFINE_PER_CPU(struct xfsstats, xfsstats);
37
38STATIC int
39xfs_read_xfsstats(
40 char *buffer,
41 char **start,
42 off_t offset,
43 int count,
44 int *eof,
45 void *data)
46{
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;
51
52 static struct xstats_entry {
53 char *desc;
54 int endpoint;
55 } xstats[] = {
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 },
71 };
72
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) {
78 val = 0;
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));
83 }
84 len += sprintf(buffer + len, " %u", val);
85 j++;
86 }
87 buffer[len++] = '\n';
88 }
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;
95 }
96
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",
100#if defined(DEBUG)
101 1);
102#else
103 0);
104#endif
105
106 if (offset >= len) {
107 *start = buffer;
108 *eof = 1;
109 return 0;
110 }
111 *start = buffer + offset;
112 if ((len -= offset) > count)
113 return count;
114 *eof = 1;
115
116 return len;
117}
118
119void
120xfs_init_procfs(void)
121{
122 if (!proc_mkdir("fs/xfs", NULL))
123 return;
124 create_proc_read_entry("fs/xfs/stat", 0, NULL, xfs_read_xfsstats, NULL);
125}
126
127void
128xfs_cleanup_procfs(void)
129{
130 remove_proc_entry("fs/xfs/stat", NULL);
131 remove_proc_entry("fs/xfs", NULL);
132}