xfs_qm_stats.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of version 2 of the GNU General Public License as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it would be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. *
  12. * Further, this software is distributed without any warranty that it is
  13. * free of the rightful claim of any third person regarding infringement
  14. * or the like. Any license provided herein, whether implied or
  15. * otherwise, applies only to this software file. Patent licenses, if
  16. * any, provided herein do not apply to combinations of this program with
  17. * other software, or any other product whatsoever.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write the Free Software Foundation, Inc., 59
  21. * Temple Place - Suite 330, Boston MA 02111-1307, USA.
  22. *
  23. * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
  24. * Mountain View, CA 94043, or:
  25. *
  26. * http://www.sgi.com
  27. *
  28. * For further information regarding this notice, see:
  29. *
  30. * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
  31. */
  32. #include "xfs.h"
  33. #include "xfs_fs.h"
  34. #include "xfs_inum.h"
  35. #include "xfs_log.h"
  36. #include "xfs_trans.h"
  37. #include "xfs_sb.h"
  38. #include "xfs_dir.h"
  39. #include "xfs_dir2.h"
  40. #include "xfs_alloc.h"
  41. #include "xfs_dmapi.h"
  42. #include "xfs_quota.h"
  43. #include "xfs_mount.h"
  44. #include "xfs_alloc_btree.h"
  45. #include "xfs_bmap_btree.h"
  46. #include "xfs_ialloc_btree.h"
  47. #include "xfs_btree.h"
  48. #include "xfs_ialloc.h"
  49. #include "xfs_attr_sf.h"
  50. #include "xfs_dir_sf.h"
  51. #include "xfs_dir2_sf.h"
  52. #include "xfs_dinode.h"
  53. #include "xfs_inode.h"
  54. #include "xfs_bmap.h"
  55. #include "xfs_bit.h"
  56. #include "xfs_rtalloc.h"
  57. #include "xfs_error.h"
  58. #include "xfs_itable.h"
  59. #include "xfs_rw.h"
  60. #include "xfs_acl.h"
  61. #include "xfs_cap.h"
  62. #include "xfs_mac.h"
  63. #include "xfs_attr.h"
  64. #include "xfs_buf_item.h"
  65. #include "xfs_qm.h"
  66. struct xqmstats xqmstats;
  67. STATIC int
  68. xfs_qm_read_xfsquota(
  69. char *buffer,
  70. char **start,
  71. off_t offset,
  72. int count,
  73. int *eof,
  74. void *data)
  75. {
  76. int len;
  77. /* maximum; incore; ratio free to inuse; freelist */
  78. len = sprintf(buffer, "%d\t%d\t%d\t%u\n",
  79. ndquot,
  80. xfs_Gqm? atomic_read(&xfs_Gqm->qm_totaldquots) : 0,
  81. xfs_Gqm? xfs_Gqm->qm_dqfree_ratio : 0,
  82. xfs_Gqm? xfs_Gqm->qm_dqfreelist.qh_nelems : 0);
  83. if (offset >= len) {
  84. *start = buffer;
  85. *eof = 1;
  86. return 0;
  87. }
  88. *start = buffer + offset;
  89. if ((len -= offset) > count)
  90. return count;
  91. *eof = 1;
  92. return len;
  93. }
  94. STATIC int
  95. xfs_qm_read_stats(
  96. char *buffer,
  97. char **start,
  98. off_t offset,
  99. int count,
  100. int *eof,
  101. void *data)
  102. {
  103. int len;
  104. /* quota performance statistics */
  105. len = sprintf(buffer, "qm %u %u %u %u %u %u %u %u\n",
  106. xqmstats.xs_qm_dqreclaims,
  107. xqmstats.xs_qm_dqreclaim_misses,
  108. xqmstats.xs_qm_dquot_dups,
  109. xqmstats.xs_qm_dqcachemisses,
  110. xqmstats.xs_qm_dqcachehits,
  111. xqmstats.xs_qm_dqwants,
  112. xqmstats.xs_qm_dqshake_reclaims,
  113. xqmstats.xs_qm_dqinact_reclaims);
  114. if (offset >= len) {
  115. *start = buffer;
  116. *eof = 1;
  117. return 0;
  118. }
  119. *start = buffer + offset;
  120. if ((len -= offset) > count)
  121. return count;
  122. *eof = 1;
  123. return len;
  124. }
  125. void
  126. xfs_qm_init_procfs(void)
  127. {
  128. create_proc_read_entry("fs/xfs/xqmstat", 0, NULL, xfs_qm_read_stats, NULL);
  129. create_proc_read_entry("fs/xfs/xqm", 0, NULL, xfs_qm_read_xfsquota, NULL);
  130. }
  131. void
  132. xfs_qm_cleanup_procfs(void)
  133. {
  134. remove_proc_entry("fs/xfs/xqm", NULL);
  135. remove_proc_entry("fs/xfs/xqmstat", NULL);
  136. }