xfs_qm_stats.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (c) 2000-2003 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  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
  7. * published by the Free Software Foundation.
  8. *
  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.
  13. *
  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
  17. */
  18. #include "xfs.h"
  19. #include "xfs_fs.h"
  20. #include "xfs_bit.h"
  21. #include "xfs_log.h"
  22. #include "xfs_inum.h"
  23. #include "xfs_trans.h"
  24. #include "xfs_sb.h"
  25. #include "xfs_ag.h"
  26. #include "xfs_alloc.h"
  27. #include "xfs_quota.h"
  28. #include "xfs_mount.h"
  29. #include "xfs_bmap_btree.h"
  30. #include "xfs_inode.h"
  31. #include "xfs_itable.h"
  32. #include "xfs_bmap.h"
  33. #include "xfs_rtalloc.h"
  34. #include "xfs_error.h"
  35. #include "xfs_attr.h"
  36. #include "xfs_buf_item.h"
  37. #include "xfs_qm.h"
  38. struct xqmstats xqmstats;
  39. static int xqm_proc_show(struct seq_file *m, void *v)
  40. {
  41. /* maximum; incore; ratio free to inuse; freelist */
  42. seq_printf(m, "%d\t%d\t%d\t%u\n",
  43. ndquot,
  44. xfs_Gqm? atomic_read(&xfs_Gqm->qm_totaldquots) : 0,
  45. xfs_Gqm? xfs_Gqm->qm_dqfree_ratio : 0,
  46. xfs_Gqm? xfs_Gqm->qm_dqfrlist_cnt : 0);
  47. return 0;
  48. }
  49. static int xqm_proc_open(struct inode *inode, struct file *file)
  50. {
  51. return single_open(file, xqm_proc_show, NULL);
  52. }
  53. static const struct file_operations xqm_proc_fops = {
  54. .owner = THIS_MODULE,
  55. .open = xqm_proc_open,
  56. .read = seq_read,
  57. .llseek = seq_lseek,
  58. .release = single_release,
  59. };
  60. static int xqmstat_proc_show(struct seq_file *m, void *v)
  61. {
  62. /* quota performance statistics */
  63. seq_printf(m, "qm %u %u %u %u %u %u %u %u\n",
  64. xqmstats.xs_qm_dqreclaims,
  65. xqmstats.xs_qm_dqreclaim_misses,
  66. xqmstats.xs_qm_dquot_dups,
  67. xqmstats.xs_qm_dqcachemisses,
  68. xqmstats.xs_qm_dqcachehits,
  69. xqmstats.xs_qm_dqwants,
  70. xqmstats.xs_qm_dqshake_reclaims,
  71. xqmstats.xs_qm_dqinact_reclaims);
  72. return 0;
  73. }
  74. static int xqmstat_proc_open(struct inode *inode, struct file *file)
  75. {
  76. return single_open(file, xqmstat_proc_show, NULL);
  77. }
  78. static const struct file_operations xqmstat_proc_fops = {
  79. .owner = THIS_MODULE,
  80. .open = xqmstat_proc_open,
  81. .read = seq_read,
  82. .llseek = seq_lseek,
  83. .release = single_release,
  84. };
  85. void
  86. xfs_qm_init_procfs(void)
  87. {
  88. proc_create("fs/xfs/xqmstat", 0, NULL, &xqmstat_proc_fops);
  89. proc_create("fs/xfs/xqm", 0, NULL, &xqm_proc_fops);
  90. }
  91. void
  92. xfs_qm_cleanup_procfs(void)
  93. {
  94. remove_proc_entry("fs/xfs/xqm", NULL);
  95. remove_proc_entry("fs/xfs/xqmstat", NULL);
  96. }