blob: 83e7ea3e25fadc9a93ea101357a4a893dc243cc0 [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"
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include "xfs_attr.h"
46#include "xfs_buf_item.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#include "xfs_qm.h"
48
49struct xqmstats xqmstats;
50
Alexey Dobriyan361735f2009-08-28 23:55:00 +040051static int xqm_proc_show(struct seq_file *m, void *v)
Linus Torvalds1da177e2005-04-16 15:20:36 -070052{
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 /* maximum; incore; ratio free to inuse; freelist */
Alexey Dobriyan361735f2009-08-28 23:55:00 +040054 seq_printf(m, "%d\t%d\t%d\t%u\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 ndquot,
56 xfs_Gqm? atomic_read(&xfs_Gqm->qm_totaldquots) : 0,
57 xfs_Gqm? xfs_Gqm->qm_dqfree_ratio : 0,
58 xfs_Gqm? xfs_Gqm->qm_dqfreelist.qh_nelems : 0);
Alexey Dobriyan361735f2009-08-28 23:55:00 +040059 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060}
61
Alexey Dobriyan361735f2009-08-28 23:55:00 +040062static int xqm_proc_open(struct inode *inode, struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -070063{
Alexey Dobriyan361735f2009-08-28 23:55:00 +040064 return single_open(file, xqm_proc_show, NULL);
65}
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
Alexey Dobriyan361735f2009-08-28 23:55:00 +040067static const struct file_operations xqm_proc_fops = {
68 .owner = THIS_MODULE,
69 .open = xqm_proc_open,
70 .read = seq_read,
71 .llseek = seq_lseek,
72 .release = single_release,
73};
74
75static int xqmstat_proc_show(struct seq_file *m, void *v)
76{
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 /* quota performance statistics */
Alexey Dobriyan361735f2009-08-28 23:55:00 +040078 seq_printf(m, "qm %u %u %u %u %u %u %u %u\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 xqmstats.xs_qm_dqreclaims,
80 xqmstats.xs_qm_dqreclaim_misses,
81 xqmstats.xs_qm_dquot_dups,
82 xqmstats.xs_qm_dqcachemisses,
83 xqmstats.xs_qm_dqcachehits,
84 xqmstats.xs_qm_dqwants,
85 xqmstats.xs_qm_dqshake_reclaims,
86 xqmstats.xs_qm_dqinact_reclaims);
Alexey Dobriyan361735f2009-08-28 23:55:00 +040087 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070088}
89
Alexey Dobriyan361735f2009-08-28 23:55:00 +040090static int xqmstat_proc_open(struct inode *inode, struct file *file)
91{
92 return single_open(file, xqmstat_proc_show, NULL);
93}
94
95static const struct file_operations xqmstat_proc_fops = {
96 .owner = THIS_MODULE,
97 .open = xqmstat_proc_open,
98 .read = seq_read,
99 .llseek = seq_lseek,
100 .release = single_release,
101};
102
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103void
104xfs_qm_init_procfs(void)
105{
Alexey Dobriyan361735f2009-08-28 23:55:00 +0400106 proc_create("fs/xfs/xqmstat", 0, NULL, &xqmstat_proc_fops);
107 proc_create("fs/xfs/xqm", 0, NULL, &xqm_proc_fops);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108}
109
110void
111xfs_qm_cleanup_procfs(void)
112{
113 remove_proc_entry("fs/xfs/xqm", NULL);
114 remove_proc_entry("fs/xfs/xqmstat", NULL);
115}