blob: 8671a0b32644010a04e98f64518c63050add8048 [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_alloc.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include "xfs_quota.h"
28#include "xfs_mount.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include "xfs_bmap_btree.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include "xfs_inode.h"
Nathan Scotta844f452005-11-02 14:38:42 +110031#include "xfs_itable.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include "xfs_bmap.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include "xfs_rtalloc.h"
34#include "xfs_error.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include "xfs_attr.h"
36#include "xfs_buf_item.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#include "xfs_qm.h"
38
39struct xqmstats xqmstats;
40
Alexey Dobriyan361735f2009-08-28 23:55:00 +040041static int xqm_proc_show(struct seq_file *m, void *v)
Linus Torvalds1da177e2005-04-16 15:20:36 -070042{
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 /* maximum; incore; ratio free to inuse; freelist */
Alexey Dobriyan361735f2009-08-28 23:55:00 +040044 seq_printf(m, "%d\t%d\t%d\t%u\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 ndquot,
46 xfs_Gqm? atomic_read(&xfs_Gqm->qm_totaldquots) : 0,
47 xfs_Gqm? xfs_Gqm->qm_dqfree_ratio : 0,
Dave Chinner3a8406f2010-04-13 15:06:52 +100048 xfs_Gqm? xfs_Gqm->qm_dqfrlist_cnt : 0);
Alexey Dobriyan361735f2009-08-28 23:55:00 +040049 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070050}
51
Alexey Dobriyan361735f2009-08-28 23:55:00 +040052static int xqm_proc_open(struct inode *inode, struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -070053{
Alexey Dobriyan361735f2009-08-28 23:55:00 +040054 return single_open(file, xqm_proc_show, NULL);
55}
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Alexey Dobriyan361735f2009-08-28 23:55:00 +040057static const struct file_operations xqm_proc_fops = {
58 .owner = THIS_MODULE,
59 .open = xqm_proc_open,
60 .read = seq_read,
61 .llseek = seq_lseek,
62 .release = single_release,
63};
64
65static int xqmstat_proc_show(struct seq_file *m, void *v)
66{
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 /* quota performance statistics */
Alexey Dobriyan361735f2009-08-28 23:55:00 +040068 seq_printf(m, "qm %u %u %u %u %u %u %u %u\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 xqmstats.xs_qm_dqreclaims,
70 xqmstats.xs_qm_dqreclaim_misses,
71 xqmstats.xs_qm_dquot_dups,
72 xqmstats.xs_qm_dqcachemisses,
73 xqmstats.xs_qm_dqcachehits,
74 xqmstats.xs_qm_dqwants,
75 xqmstats.xs_qm_dqshake_reclaims,
76 xqmstats.xs_qm_dqinact_reclaims);
Alexey Dobriyan361735f2009-08-28 23:55:00 +040077 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070078}
79
Alexey Dobriyan361735f2009-08-28 23:55:00 +040080static int xqmstat_proc_open(struct inode *inode, struct file *file)
81{
82 return single_open(file, xqmstat_proc_show, NULL);
83}
84
85static const struct file_operations xqmstat_proc_fops = {
86 .owner = THIS_MODULE,
87 .open = xqmstat_proc_open,
88 .read = seq_read,
89 .llseek = seq_lseek,
90 .release = single_release,
91};
92
Linus Torvalds1da177e2005-04-16 15:20:36 -070093void
94xfs_qm_init_procfs(void)
95{
Alexey Dobriyan361735f2009-08-28 23:55:00 +040096 proc_create("fs/xfs/xqmstat", 0, NULL, &xqmstat_proc_fops);
97 proc_create("fs/xfs/xqm", 0, NULL, &xqm_proc_fops);
Linus Torvalds1da177e2005-04-16 15:20:36 -070098}
99
100void
101xfs_qm_cleanup_procfs(void)
102{
103 remove_proc_entry("fs/xfs/xqm", NULL);
104 remove_proc_entry("fs/xfs/xqmstat", NULL);
105}