blob: 6f858fb81a369edfdb99deee3f14e7d782806364 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scott4ce31212005-11-02 14:59:41 +11002 * Copyright (c) 2000-2003 Silicon Graphics, Inc.
3 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Nathan Scott4ce31212005-11-02 14:59:41 +11005 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * published by the Free Software Foundation.
8 *
Nathan Scott4ce31212005-11-02 14:59:41 +11009 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 *
Nathan Scott4ce31212005-11-02 14:59:41 +110014 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include "xfs.h"
19#include "xfs_fs.h"
Nathan Scotta844f452005-11-02 14:38:42 +110020#include "xfs_bit.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include "xfs_log.h"
Nathan Scotta844f452005-11-02 14:38:42 +110022#include "xfs_inum.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include "xfs_trans.h"
24#include "xfs_sb.h"
Nathan Scotta844f452005-11-02 14:38:42 +110025#include "xfs_ag.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include "xfs_dir2.h"
27#include "xfs_alloc.h"
28#include "xfs_dmapi.h"
29#include "xfs_quota.h"
30#include "xfs_mount.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include "xfs_bmap_btree.h"
Nathan Scotta844f452005-11-02 14:38:42 +110032#include "xfs_alloc_btree.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include "xfs_ialloc_btree.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#include "xfs_dir2_sf.h"
Nathan Scotta844f452005-11-02 14:38:42 +110035#include "xfs_attr_sf.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include "xfs_dinode.h"
37#include "xfs_inode.h"
Nathan Scotta844f452005-11-02 14:38:42 +110038#include "xfs_ialloc.h"
39#include "xfs_itable.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include "xfs_bmap.h"
Nathan Scotta844f452005-11-02 14:38:42 +110041#include "xfs_btree.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#include "xfs_rtalloc.h"
43#include "xfs_error.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include "xfs_rw.h"
45#include "xfs_acl.h"
46#include "xfs_cap.h"
47#include "xfs_mac.h"
48#include "xfs_attr.h"
49#include "xfs_buf_item.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070050#include "xfs_qm.h"
51
52struct xqmstats xqmstats;
53
54STATIC int
55xfs_qm_read_xfsquota(
56 char *buffer,
57 char **start,
58 off_t offset,
59 int count,
60 int *eof,
61 void *data)
62{
63 int len;
64
65 /* maximum; incore; ratio free to inuse; freelist */
66 len = sprintf(buffer, "%d\t%d\t%d\t%u\n",
67 ndquot,
68 xfs_Gqm? atomic_read(&xfs_Gqm->qm_totaldquots) : 0,
69 xfs_Gqm? xfs_Gqm->qm_dqfree_ratio : 0,
70 xfs_Gqm? xfs_Gqm->qm_dqfreelist.qh_nelems : 0);
71
72 if (offset >= len) {
73 *start = buffer;
74 *eof = 1;
75 return 0;
76 }
77 *start = buffer + offset;
78 if ((len -= offset) > count)
79 return count;
80 *eof = 1;
81
82 return len;
83}
84
85STATIC int
86xfs_qm_read_stats(
87 char *buffer,
88 char **start,
89 off_t offset,
90 int count,
91 int *eof,
92 void *data)
93{
94 int len;
95
96 /* quota performance statistics */
97 len = sprintf(buffer, "qm %u %u %u %u %u %u %u %u\n",
98 xqmstats.xs_qm_dqreclaims,
99 xqmstats.xs_qm_dqreclaim_misses,
100 xqmstats.xs_qm_dquot_dups,
101 xqmstats.xs_qm_dqcachemisses,
102 xqmstats.xs_qm_dqcachehits,
103 xqmstats.xs_qm_dqwants,
104 xqmstats.xs_qm_dqshake_reclaims,
105 xqmstats.xs_qm_dqinact_reclaims);
106
107 if (offset >= len) {
108 *start = buffer;
109 *eof = 1;
110 return 0;
111 }
112 *start = buffer + offset;
113 if ((len -= offset) > count)
114 return count;
115 *eof = 1;
116
117 return len;
118}
119
120void
121xfs_qm_init_procfs(void)
122{
123 create_proc_read_entry("fs/xfs/xqmstat", 0, NULL, xfs_qm_read_stats, NULL);
124 create_proc_read_entry("fs/xfs/xqm", 0, NULL, xfs_qm_read_xfsquota, NULL);
125}
126
127void
128xfs_qm_cleanup_procfs(void)
129{
130 remove_proc_entry("fs/xfs/xqm", NULL);
131 remove_proc_entry("fs/xfs/xqmstat", NULL);
132}