xfs_qm_stats.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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_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"
  32. #include "xfs_bmap_btree.h"
  33. #include "xfs_alloc_btree.h"
  34. #include "xfs_ialloc_btree.h"
  35. #include "xfs_dir_sf.h"
  36. #include "xfs_dir2_sf.h"
  37. #include "xfs_attr_sf.h"
  38. #include "xfs_dinode.h"
  39. #include "xfs_inode.h"
  40. #include "xfs_ialloc.h"
  41. #include "xfs_itable.h"
  42. #include "xfs_bmap.h"
  43. #include "xfs_btree.h"
  44. #include "xfs_rtalloc.h"
  45. #include "xfs_error.h"
  46. #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"
  52. #include "xfs_qm.h"
  53. struct xqmstats xqmstats;
  54. STATIC int
  55. xfs_qm_read_xfsquota(
  56. char *buffer,
  57. char **start,
  58. off_t offset,
  59. int count,
  60. int *eof,
  61. void *data)
  62. {
  63. int len;
  64. /* maximum; incore; ratio free to inuse; freelist */
  65. len = sprintf(buffer, "%d\t%d\t%d\t%u\n",
  66. ndquot,
  67. xfs_Gqm? atomic_read(&xfs_Gqm->qm_totaldquots) : 0,
  68. xfs_Gqm? xfs_Gqm->qm_dqfree_ratio : 0,
  69. xfs_Gqm? xfs_Gqm->qm_dqfreelist.qh_nelems : 0);
  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. return len;
  80. }
  81. STATIC int
  82. xfs_qm_read_stats(
  83. char *buffer,
  84. char **start,
  85. off_t offset,
  86. int count,
  87. int *eof,
  88. void *data)
  89. {
  90. int len;
  91. /* quota performance statistics */
  92. len = sprintf(buffer, "qm %u %u %u %u %u %u %u %u\n",
  93. xqmstats.xs_qm_dqreclaims,
  94. xqmstats.xs_qm_dqreclaim_misses,
  95. xqmstats.xs_qm_dquot_dups,
  96. xqmstats.xs_qm_dqcachemisses,
  97. xqmstats.xs_qm_dqcachehits,
  98. xqmstats.xs_qm_dqwants,
  99. xqmstats.xs_qm_dqshake_reclaims,
  100. xqmstats.xs_qm_dqinact_reclaims);
  101. if (offset >= len) {
  102. *start = buffer;
  103. *eof = 1;
  104. return 0;
  105. }
  106. *start = buffer + offset;
  107. if ((len -= offset) > count)
  108. return count;
  109. *eof = 1;
  110. return len;
  111. }
  112. void
  113. xfs_qm_init_procfs(void)
  114. {
  115. create_proc_read_entry("fs/xfs/xqmstat", 0, NULL, xfs_qm_read_stats, NULL);
  116. create_proc_read_entry("fs/xfs/xqm", 0, NULL, xfs_qm_read_xfsquota, NULL);
  117. }
  118. void
  119. xfs_qm_cleanup_procfs(void)
  120. {
  121. remove_proc_entry("fs/xfs/xqm", NULL);
  122. remove_proc_entry("fs/xfs/xqmstat", NULL);
  123. }