[XFS] Remove xfs_macros.c, xfs_macros.h, rework headers a whole lot.
[linux-2.6] / fs / xfs / quota / xfs_qm_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 #include "xfs_fs.h"
35 #include "xfs_bit.h"
36 #include "xfs_log.h"
37 #include "xfs_inum.h"
38 #include "xfs_trans.h"
39 #include "xfs_sb.h"
40 #include "xfs_ag.h"
41 #include "xfs_dir.h"
42 #include "xfs_dir2.h"
43 #include "xfs_alloc.h"
44 #include "xfs_dmapi.h"
45 #include "xfs_quota.h"
46 #include "xfs_mount.h"
47 #include "xfs_bmap_btree.h"
48 #include "xfs_alloc_btree.h"
49 #include "xfs_ialloc_btree.h"
50 #include "xfs_dir_sf.h"
51 #include "xfs_dir2_sf.h"
52 #include "xfs_attr_sf.h"
53 #include "xfs_dinode.h"
54 #include "xfs_inode.h"
55 #include "xfs_ialloc.h"
56 #include "xfs_itable.h"
57 #include "xfs_bmap.h"
58 #include "xfs_btree.h"
59 #include "xfs_rtalloc.h"
60 #include "xfs_error.h"
61 #include "xfs_rw.h"
62 #include "xfs_acl.h"
63 #include "xfs_cap.h"
64 #include "xfs_mac.h"
65 #include "xfs_attr.h"
66 #include "xfs_buf_item.h"
67
68 #include "xfs_qm.h"
69
70 struct xqmstats xqmstats;
71
72 STATIC int
73 xfs_qm_read_xfsquota(
74         char            *buffer,
75         char            **start,
76         off_t           offset,
77         int             count,
78         int             *eof,
79         void            *data)
80 {
81         int             len;
82
83         /* maximum; incore; ratio free to inuse; freelist */
84         len = sprintf(buffer, "%d\t%d\t%d\t%u\n",
85                         ndquot,
86                         xfs_Gqm? atomic_read(&xfs_Gqm->qm_totaldquots) : 0,
87                         xfs_Gqm? xfs_Gqm->qm_dqfree_ratio : 0,
88                         xfs_Gqm? xfs_Gqm->qm_dqfreelist.qh_nelems : 0);
89
90         if (offset >= len) {
91                 *start = buffer;
92                 *eof = 1;
93                 return 0;
94         }
95         *start = buffer + offset;
96         if ((len -= offset) > count)
97                 return count;
98         *eof = 1;
99
100         return len;
101 }
102
103 STATIC int
104 xfs_qm_read_stats(
105         char            *buffer,
106         char            **start,
107         off_t           offset,
108         int             count,
109         int             *eof,
110         void            *data)
111 {
112         int             len;
113
114         /* quota performance statistics */
115         len = sprintf(buffer, "qm %u %u %u %u %u %u %u %u\n",
116                         xqmstats.xs_qm_dqreclaims,
117                         xqmstats.xs_qm_dqreclaim_misses,
118                         xqmstats.xs_qm_dquot_dups,
119                         xqmstats.xs_qm_dqcachemisses,
120                         xqmstats.xs_qm_dqcachehits,
121                         xqmstats.xs_qm_dqwants,
122                         xqmstats.xs_qm_dqshake_reclaims,
123                         xqmstats.xs_qm_dqinact_reclaims);
124
125         if (offset >= len) {
126                 *start = buffer;
127                 *eof = 1;
128                 return 0;
129         }
130         *start = buffer + offset;
131         if ((len -= offset) > count)
132                 return count;
133         *eof = 1;
134
135         return len;
136 }
137
138 void
139 xfs_qm_init_procfs(void)
140 {
141         create_proc_read_entry("fs/xfs/xqmstat", 0, NULL, xfs_qm_read_stats, NULL);
142         create_proc_read_entry("fs/xfs/xqm", 0, NULL, xfs_qm_read_xfsquota, NULL);
143 }
144
145 void
146 xfs_qm_cleanup_procfs(void)
147 {
148         remove_proc_entry("fs/xfs/xqm", NULL);
149         remove_proc_entry("fs/xfs/xqmstat", NULL);
150 }