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