]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/gnu/fs/xfs/FreeBSD/xfs_stats.c
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / sys / gnu / fs / xfs / FreeBSD / xfs_stats.c
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
35 struct xfsstats xfsstats;
36
37 STATIC int
38 xfs_read_xfsstats(
39         char            *buffer,
40         char            **start,
41         off_t           offset,
42         int             count,
43         int             *eof,
44         void            *data)
45 {
46         int             i, j, len;
47         static struct xstats_entry {
48                 char    *desc;
49                 int     endpoint;
50         } xstats[] = {
51                 { "extent_alloc",       XFSSTAT_END_EXTENT_ALLOC        },
52                 { "abt",                XFSSTAT_END_ALLOC_BTREE         },
53                 { "blk_map",            XFSSTAT_END_BLOCK_MAPPING       },
54                 { "bmbt",               XFSSTAT_END_BLOCK_MAP_BTREE     },
55                 { "dir",                XFSSTAT_END_DIRECTORY_OPS       },
56                 { "trans",              XFSSTAT_END_TRANSACTIONS        },
57                 { "ig",                 XFSSTAT_END_INODE_OPS           },
58                 { "log",                XFSSTAT_END_LOG_OPS             },
59                 { "push_ail",           XFSSTAT_END_TAIL_PUSHING        },
60                 { "xstrat",             XFSSTAT_END_WRITE_CONVERT       },
61                 { "rw",                 XFSSTAT_END_READ_WRITE_OPS      },
62                 { "attr",               XFSSTAT_END_ATTRIBUTE_OPS       },
63                 { "icluster",           XFSSTAT_END_INODE_CLUSTER       },
64                 { "vnodes",             XFSSTAT_END_VNODE_OPS           },
65         };
66
67         for (i=j=len = 0; i < sizeof(xstats)/sizeof(struct xstats_entry); i++) {
68                 len += sprintf(buffer + len, "%s", xstats[i].desc);
69                 /* inner loop does each group */
70                 while (j < xstats[i].endpoint) {
71                         len += sprintf(buffer + len, " %u",
72                                         *(((__u32*)&xfsstats) + j));
73                         j++;
74                 }
75                 buffer[len++] = '\n';
76         }
77         /* extra precision counters */
78         len += sprintf(buffer + len, "xpc %ju %ju %ju\n",
79                         (uintmax_t)xfsstats.xs_xstrat_bytes,
80                         (uintmax_t)xfsstats.xs_write_bytes,
81                         (uintmax_t)xfsstats.xs_read_bytes);
82
83         if (offset >= len) {
84                 *start = buffer;
85                 *eof = 1;
86                 return 0;
87         }
88         *start = buffer + offset;
89         if ((len -= offset) > count)
90                 return count;
91         *eof = 1;
92
93         return len;
94 }
95
96 void
97 xfs_init_procfs(void)
98 {
99         if (&xfs_read_xfsstats != NULL);
100 }
101
102 void
103 xfs_cleanup_procfs(void)
104 {
105 }