xfs_sysctl.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /*
  2. * Copyright (c) 2001-2005 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 <linux/sysctl.h>
  20. #include <linux/proc_fs.h>
  21. static struct ctl_table_header *xfs_table_header;
  22. #ifdef CONFIG_PROC_FS
  23. STATIC int
  24. xfs_stats_clear_proc_handler(
  25. ctl_table *ctl,
  26. int write,
  27. void __user *buffer,
  28. size_t *lenp,
  29. loff_t *ppos)
  30. {
  31. int c, ret, *valp = ctl->data;
  32. __uint32_t vn_active;
  33. ret = proc_dointvec_minmax(ctl, write, buffer, lenp, ppos);
  34. if (!ret && write && *valp) {
  35. printk("XFS Clearing xfsstats\n");
  36. for_each_possible_cpu(c) {
  37. preempt_disable();
  38. /* save vn_active, it's a universal truth! */
  39. vn_active = per_cpu(xfsstats, c).vn_active;
  40. memset(&per_cpu(xfsstats, c), 0,
  41. sizeof(struct xfsstats));
  42. per_cpu(xfsstats, c).vn_active = vn_active;
  43. preempt_enable();
  44. }
  45. xfs_stats_clear = 0;
  46. }
  47. return ret;
  48. }
  49. #endif /* CONFIG_PROC_FS */
  50. static ctl_table xfs_table[] = {
  51. {
  52. .procname = "irix_sgid_inherit",
  53. .data = &xfs_params.sgid_inherit.val,
  54. .maxlen = sizeof(int),
  55. .mode = 0644,
  56. .proc_handler = proc_dointvec_minmax,
  57. .extra1 = &xfs_params.sgid_inherit.min,
  58. .extra2 = &xfs_params.sgid_inherit.max
  59. },
  60. {
  61. .procname = "irix_symlink_mode",
  62. .data = &xfs_params.symlink_mode.val,
  63. .maxlen = sizeof(int),
  64. .mode = 0644,
  65. .proc_handler = proc_dointvec_minmax,
  66. .extra1 = &xfs_params.symlink_mode.min,
  67. .extra2 = &xfs_params.symlink_mode.max
  68. },
  69. {
  70. .procname = "panic_mask",
  71. .data = &xfs_params.panic_mask.val,
  72. .maxlen = sizeof(int),
  73. .mode = 0644,
  74. .proc_handler = proc_dointvec_minmax,
  75. .extra1 = &xfs_params.panic_mask.min,
  76. .extra2 = &xfs_params.panic_mask.max
  77. },
  78. {
  79. .procname = "error_level",
  80. .data = &xfs_params.error_level.val,
  81. .maxlen = sizeof(int),
  82. .mode = 0644,
  83. .proc_handler = proc_dointvec_minmax,
  84. .extra1 = &xfs_params.error_level.min,
  85. .extra2 = &xfs_params.error_level.max
  86. },
  87. {
  88. .procname = "xfssyncd_centisecs",
  89. .data = &xfs_params.syncd_timer.val,
  90. .maxlen = sizeof(int),
  91. .mode = 0644,
  92. .proc_handler = proc_dointvec_minmax,
  93. .extra1 = &xfs_params.syncd_timer.min,
  94. .extra2 = &xfs_params.syncd_timer.max
  95. },
  96. {
  97. .procname = "inherit_sync",
  98. .data = &xfs_params.inherit_sync.val,
  99. .maxlen = sizeof(int),
  100. .mode = 0644,
  101. .proc_handler = proc_dointvec_minmax,
  102. .extra1 = &xfs_params.inherit_sync.min,
  103. .extra2 = &xfs_params.inherit_sync.max
  104. },
  105. {
  106. .procname = "inherit_nodump",
  107. .data = &xfs_params.inherit_nodump.val,
  108. .maxlen = sizeof(int),
  109. .mode = 0644,
  110. .proc_handler = proc_dointvec_minmax,
  111. .extra1 = &xfs_params.inherit_nodump.min,
  112. .extra2 = &xfs_params.inherit_nodump.max
  113. },
  114. {
  115. .procname = "inherit_noatime",
  116. .data = &xfs_params.inherit_noatim.val,
  117. .maxlen = sizeof(int),
  118. .mode = 0644,
  119. .proc_handler = proc_dointvec_minmax,
  120. .extra1 = &xfs_params.inherit_noatim.min,
  121. .extra2 = &xfs_params.inherit_noatim.max
  122. },
  123. {
  124. .procname = "xfsbufd_centisecs",
  125. .data = &xfs_params.xfs_buf_timer.val,
  126. .maxlen = sizeof(int),
  127. .mode = 0644,
  128. .proc_handler = proc_dointvec_minmax,
  129. .extra1 = &xfs_params.xfs_buf_timer.min,
  130. .extra2 = &xfs_params.xfs_buf_timer.max
  131. },
  132. {
  133. .procname = "age_buffer_centisecs",
  134. .data = &xfs_params.xfs_buf_age.val,
  135. .maxlen = sizeof(int),
  136. .mode = 0644,
  137. .proc_handler = proc_dointvec_minmax,
  138. .extra1 = &xfs_params.xfs_buf_age.min,
  139. .extra2 = &xfs_params.xfs_buf_age.max
  140. },
  141. {
  142. .procname = "inherit_nosymlinks",
  143. .data = &xfs_params.inherit_nosym.val,
  144. .maxlen = sizeof(int),
  145. .mode = 0644,
  146. .proc_handler = proc_dointvec_minmax,
  147. .extra1 = &xfs_params.inherit_nosym.min,
  148. .extra2 = &xfs_params.inherit_nosym.max
  149. },
  150. {
  151. .procname = "rotorstep",
  152. .data = &xfs_params.rotorstep.val,
  153. .maxlen = sizeof(int),
  154. .mode = 0644,
  155. .proc_handler = proc_dointvec_minmax,
  156. .extra1 = &xfs_params.rotorstep.min,
  157. .extra2 = &xfs_params.rotorstep.max
  158. },
  159. {
  160. .procname = "inherit_nodefrag",
  161. .data = &xfs_params.inherit_nodfrg.val,
  162. .maxlen = sizeof(int),
  163. .mode = 0644,
  164. .proc_handler = proc_dointvec_minmax,
  165. .extra1 = &xfs_params.inherit_nodfrg.min,
  166. .extra2 = &xfs_params.inherit_nodfrg.max
  167. },
  168. {
  169. .procname = "filestream_centisecs",
  170. .data = &xfs_params.fstrm_timer.val,
  171. .maxlen = sizeof(int),
  172. .mode = 0644,
  173. .proc_handler = proc_dointvec_minmax,
  174. .extra1 = &xfs_params.fstrm_timer.min,
  175. .extra2 = &xfs_params.fstrm_timer.max,
  176. },
  177. /* please keep this the last entry */
  178. #ifdef CONFIG_PROC_FS
  179. {
  180. .procname = "stats_clear",
  181. .data = &xfs_params.stats_clear.val,
  182. .maxlen = sizeof(int),
  183. .mode = 0644,
  184. .proc_handler = xfs_stats_clear_proc_handler,
  185. .extra1 = &xfs_params.stats_clear.min,
  186. .extra2 = &xfs_params.stats_clear.max
  187. },
  188. #endif /* CONFIG_PROC_FS */
  189. {}
  190. };
  191. static ctl_table xfs_dir_table[] = {
  192. {
  193. .procname = "xfs",
  194. .mode = 0555,
  195. .child = xfs_table
  196. },
  197. {}
  198. };
  199. static ctl_table xfs_root_table[] = {
  200. {
  201. .procname = "fs",
  202. .mode = 0555,
  203. .child = xfs_dir_table
  204. },
  205. {}
  206. };
  207. int
  208. xfs_sysctl_register(void)
  209. {
  210. xfs_table_header = register_sysctl_table(xfs_root_table);
  211. if (!xfs_table_header)
  212. return -ENOMEM;
  213. return 0;
  214. }
  215. void
  216. xfs_sysctl_unregister(void)
  217. {
  218. unregister_sysctl_table(xfs_table_header);
  219. }