blob: 0570f77335505b3ab52a2e46ea74b0ef17eaf049 [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_dir.h"
27#include "xfs_dir2.h"
28#include "xfs_alloc.h"
29#include "xfs_dmapi.h"
30#include "xfs_quota.h"
31#include "xfs_mount.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include "xfs_bmap_btree.h"
Nathan Scotta844f452005-11-02 14:38:42 +110033#include "xfs_alloc_btree.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#include "xfs_ialloc_btree.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include "xfs_dir_sf.h"
36#include "xfs_dir2_sf.h"
Nathan Scotta844f452005-11-02 14:38:42 +110037#include "xfs_attr_sf.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#include "xfs_dinode.h"
39#include "xfs_inode.h"
Nathan Scotta844f452005-11-02 14:38:42 +110040#include "xfs_ialloc.h"
41#include "xfs_itable.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#include "xfs_bmap.h"
Nathan Scotta844f452005-11-02 14:38:42 +110043#include "xfs_btree.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include "xfs_rtalloc.h"
45#include "xfs_error.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#include "xfs_rw.h"
47#include "xfs_acl.h"
48#include "xfs_cap.h"
49#include "xfs_mac.h"
50#include "xfs_attr.h"
51#include "xfs_buf_item.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#include "xfs_qm.h"
53
54struct xqmstats xqmstats;
55
56STATIC int
57xfs_qm_read_xfsquota(
58 char *buffer,
59 char **start,
60 off_t offset,
61 int count,
62 int *eof,
63 void *data)
64{
65 int len;
66
67 /* maximum; incore; ratio free to inuse; freelist */
68 len = sprintf(buffer, "%d\t%d\t%d\t%u\n",
69 ndquot,
70 xfs_Gqm? atomic_read(&xfs_Gqm->qm_totaldquots) : 0,
71 xfs_Gqm? xfs_Gqm->qm_dqfree_ratio : 0,
72 xfs_Gqm? xfs_Gqm->qm_dqfreelist.qh_nelems : 0);
73
74 if (offset >= len) {
75 *start = buffer;
76 *eof = 1;
77 return 0;
78 }
79 *start = buffer + offset;
80 if ((len -= offset) > count)
81 return count;
82 *eof = 1;
83
84 return len;
85}
86
87STATIC int
88xfs_qm_read_stats(
89 char *buffer,
90 char **start,
91 off_t offset,
92 int count,
93 int *eof,
94 void *data)
95{
96 int len;
97
98 /* quota performance statistics */
99 len = sprintf(buffer, "qm %u %u %u %u %u %u %u %u\n",
100 xqmstats.xs_qm_dqreclaims,
101 xqmstats.xs_qm_dqreclaim_misses,
102 xqmstats.xs_qm_dquot_dups,
103 xqmstats.xs_qm_dqcachemisses,
104 xqmstats.xs_qm_dqcachehits,
105 xqmstats.xs_qm_dqwants,
106 xqmstats.xs_qm_dqshake_reclaims,
107 xqmstats.xs_qm_dqinact_reclaims);
108
109 if (offset >= len) {
110 *start = buffer;
111 *eof = 1;
112 return 0;
113 }
114 *start = buffer + offset;
115 if ((len -= offset) > count)
116 return count;
117 *eof = 1;
118
119 return len;
120}
121
122void
123xfs_qm_init_procfs(void)
124{
125 create_proc_read_entry("fs/xfs/xqmstat", 0, NULL, xfs_qm_read_stats, NULL);
126 create_proc_read_entry("fs/xfs/xqm", 0, NULL, xfs_qm_read_xfsquota, NULL);
127}
128
129void
130xfs_qm_cleanup_procfs(void)
131{
132 remove_proc_entry("fs/xfs/xqm", NULL);
133 remove_proc_entry("fs/xfs/xqmstat", NULL);
134}