Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Nathan Scott | 4ce3121 | 2005-11-02 14:59:41 +1100 | [diff] [blame] | 2 | * Copyright (c) 2000-2003 Silicon Graphics, Inc. |
| 3 | * All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Nathan Scott | 4ce3121 | 2005-11-02 14:59:41 +1100 | [diff] [blame] | 5 | * 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * published by the Free Software Foundation. |
| 8 | * |
Nathan Scott | 4ce3121 | 2005-11-02 14:59:41 +1100 | [diff] [blame] | 9 | * 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * |
Nathan Scott | 4ce3121 | 2005-11-02 14:59:41 +1100 | [diff] [blame] | 14 | * 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include "xfs.h" |
| 19 | #include "xfs_fs.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 20 | #include "xfs_bit.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include "xfs_log.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 22 | #include "xfs_inum.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include "xfs_trans.h" |
| 24 | #include "xfs_sb.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 25 | #include "xfs_ag.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #include "xfs_bmap_btree.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 32 | #include "xfs_alloc_btree.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include "xfs_ialloc_btree.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include "xfs_dir2_sf.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 35 | #include "xfs_attr_sf.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include "xfs_dinode.h" |
| 37 | #include "xfs_inode.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 38 | #include "xfs_ialloc.h" |
| 39 | #include "xfs_itable.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #include "xfs_bmap.h" |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 41 | #include "xfs_btree.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #include "xfs_rtalloc.h" |
| 43 | #include "xfs_error.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include "xfs_rw.h" |
| 45 | #include "xfs_acl.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | #include "xfs_attr.h" |
| 47 | #include "xfs_buf_item.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #include "xfs_qm.h" |
| 49 | |
| 50 | struct xqmstats xqmstats; |
| 51 | |
| 52 | STATIC int |
| 53 | xfs_qm_read_xfsquota( |
| 54 | char *buffer, |
| 55 | char **start, |
| 56 | off_t offset, |
| 57 | int count, |
| 58 | int *eof, |
| 59 | void *data) |
| 60 | { |
| 61 | int len; |
| 62 | |
| 63 | /* maximum; incore; ratio free to inuse; freelist */ |
| 64 | len = sprintf(buffer, "%d\t%d\t%d\t%u\n", |
| 65 | ndquot, |
| 66 | xfs_Gqm? atomic_read(&xfs_Gqm->qm_totaldquots) : 0, |
| 67 | xfs_Gqm? xfs_Gqm->qm_dqfree_ratio : 0, |
| 68 | xfs_Gqm? xfs_Gqm->qm_dqfreelist.qh_nelems : 0); |
| 69 | |
| 70 | if (offset >= len) { |
| 71 | *start = buffer; |
| 72 | *eof = 1; |
| 73 | return 0; |
| 74 | } |
| 75 | *start = buffer + offset; |
| 76 | if ((len -= offset) > count) |
| 77 | return count; |
| 78 | *eof = 1; |
| 79 | |
| 80 | return len; |
| 81 | } |
| 82 | |
| 83 | STATIC int |
| 84 | xfs_qm_read_stats( |
| 85 | char *buffer, |
| 86 | char **start, |
| 87 | off_t offset, |
| 88 | int count, |
| 89 | int *eof, |
| 90 | void *data) |
| 91 | { |
| 92 | int len; |
| 93 | |
| 94 | /* quota performance statistics */ |
| 95 | len = sprintf(buffer, "qm %u %u %u %u %u %u %u %u\n", |
| 96 | xqmstats.xs_qm_dqreclaims, |
| 97 | xqmstats.xs_qm_dqreclaim_misses, |
| 98 | xqmstats.xs_qm_dquot_dups, |
| 99 | xqmstats.xs_qm_dqcachemisses, |
| 100 | xqmstats.xs_qm_dqcachehits, |
| 101 | xqmstats.xs_qm_dqwants, |
| 102 | xqmstats.xs_qm_dqshake_reclaims, |
| 103 | xqmstats.xs_qm_dqinact_reclaims); |
| 104 | |
| 105 | if (offset >= len) { |
| 106 | *start = buffer; |
| 107 | *eof = 1; |
| 108 | return 0; |
| 109 | } |
| 110 | *start = buffer + offset; |
| 111 | if ((len -= offset) > count) |
| 112 | return count; |
| 113 | *eof = 1; |
| 114 | |
| 115 | return len; |
| 116 | } |
| 117 | |
| 118 | void |
| 119 | xfs_qm_init_procfs(void) |
| 120 | { |
| 121 | create_proc_read_entry("fs/xfs/xqmstat", 0, NULL, xfs_qm_read_stats, NULL); |
| 122 | create_proc_read_entry("fs/xfs/xqm", 0, NULL, xfs_qm_read_xfsquota, NULL); |
| 123 | } |
| 124 | |
| 125 | void |
| 126 | xfs_qm_cleanup_procfs(void) |
| 127 | { |
| 128 | remove_proc_entry("fs/xfs/xqm", NULL); |
| 129 | remove_proc_entry("fs/xfs/xqmstat", NULL); |
| 130 | } |