blob: b8befe1c90ec8e4dce44a005889604b416c41d32 [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"
Nathan Scotta844f452005-11-02 14:38:42 +110035#include "xfs_bit.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include "xfs_log.h"
Nathan Scotta844f452005-11-02 14:38:42 +110037#include "xfs_inum.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#include "xfs_trans.h"
39#include "xfs_sb.h"
Nathan Scotta844f452005-11-02 14:38:42 +110040#include "xfs_ag.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#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"
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#include "xfs_bmap_btree.h"
Nathan Scotta844f452005-11-02 14:38:42 +110048#include "xfs_alloc_btree.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#include "xfs_ialloc_btree.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070050#include "xfs_dir_sf.h"
51#include "xfs_dir2_sf.h"
Nathan Scotta844f452005-11-02 14:38:42 +110052#include "xfs_attr_sf.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070053#include "xfs_dinode.h"
54#include "xfs_inode.h"
Nathan Scotta844f452005-11-02 14:38:42 +110055#include "xfs_ialloc.h"
56#include "xfs_itable.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070057#include "xfs_bmap.h"
Nathan Scotta844f452005-11-02 14:38:42 +110058#include "xfs_btree.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070059#include "xfs_rtalloc.h"
60#include "xfs_error.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070061#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
70struct xqmstats xqmstats;
71
72STATIC int
73xfs_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
103STATIC int
104xfs_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
138void
139xfs_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
145void
146xfs_qm_cleanup_procfs(void)
147{
148 remove_proc_entry("fs/xfs/xqm", NULL);
149 remove_proc_entry("fs/xfs/xqmstat", NULL);
150}