xfs_sysctl.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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. struct file *filp,
  28. void __user *buffer,
  29. size_t *lenp,
  30. loff_t *ppos)
  31. {
  32. int c, ret, *valp = ctl->data;
  33. __uint32_t vn_active;
  34. ret = proc_dointvec_minmax(ctl, write, filp, buffer, lenp, ppos);
  35. if (!ret && write && *valp) {
  36. printk("XFS Clearing xfsstats\n");
  37. for_each_possible_cpu(c) {
  38. preempt_disable();
  39. /* save vn_active, it's a universal truth! */
  40. vn_active = per_cpu(xfsstats, c).vn_active;
  41. memset(&per_cpu(xfsstats, c), 0,
  42. sizeof(struct xfsstats));
  43. per_cpu(xfsstats, c).vn_active = vn_active;
  44. preempt_enable();
  45. }
  46. xfs_stats_clear = 0;
  47. }
  48. return ret;
  49. }
  50. #endif /* CONFIG_PROC_FS */
  51. static ctl_table xfs_table[] = {
  52. {
  53. .ctl_name = XFS_RESTRICT_CHOWN,
  54. .procname = "restrict_chown",
  55. .data = &xfs_params.restrict_chown.val,
  56. .maxlen = sizeof(int),
  57. .mode = 0644,
  58. .proc_handler = &proc_dointvec_minmax,
  59. .strategy = &sysctl_intvec,
  60. .extra1 = &xfs_params.restrict_chown.min,
  61. .extra2 = &xfs_params.restrict_chown.max
  62. },
  63. {
  64. .ctl_name = XFS_SGID_INHERIT,
  65. .procname = "irix_sgid_inherit",
  66. .data = &xfs_params.sgid_inherit.val,
  67. .maxlen = sizeof(int),
  68. .mode = 0644,
  69. .proc_handler = &proc_dointvec_minmax,
  70. .strategy = &sysctl_intvec,
  71. .extra1 = &xfs_params.sgid_inherit.min,
  72. .extra2 = &xfs_params.sgid_inherit.max
  73. },
  74. {
  75. .ctl_name = XFS_SYMLINK_MODE,
  76. .procname = "irix_symlink_mode",
  77. .data = &xfs_params.symlink_mode.val,
  78. .maxlen = sizeof(int),
  79. .mode = 0644,
  80. .proc_handler = &proc_dointvec_minmax,
  81. .strategy = &sysctl_intvec,
  82. .extra1 = &xfs_params.symlink_mode.min,
  83. .extra2 = &xfs_params.symlink_mode.max
  84. },
  85. {
  86. .ctl_name = XFS_PANIC_MASK,
  87. .procname = "panic_mask",
  88. .data = &xfs_params.panic_mask.val,
  89. .maxlen = sizeof(int),
  90. .mode = 0644,
  91. .proc_handler = &proc_dointvec_minmax,
  92. .strategy = &sysctl_intvec,
  93. .extra1 = &xfs_params.panic_mask.min,
  94. .extra2 = &xfs_params.panic_mask.max
  95. },
  96. {
  97. .ctl_name = XFS_ERRLEVEL,
  98. .procname = "error_level",
  99. .data = &xfs_params.error_level.val,
  100. .maxlen = sizeof(int),
  101. .mode = 0644,
  102. .proc_handler = &proc_dointvec_minmax,
  103. .strategy = &sysctl_intvec,
  104. .extra1 = &xfs_params.error_level.min,
  105. .extra2 = &xfs_params.error_level.max
  106. },
  107. {
  108. .ctl_name = XFS_SYNCD_TIMER,
  109. .procname = "xfssyncd_centisecs",
  110. .data = &xfs_params.syncd_timer.val,
  111. .maxlen = sizeof(int),
  112. .mode = 0644,
  113. .proc_handler = &proc_dointvec_minmax,
  114. .strategy = &sysctl_intvec,
  115. .extra1 = &xfs_params.syncd_timer.min,
  116. .extra2 = &xfs_params.syncd_timer.max
  117. },
  118. {
  119. .ctl_name = XFS_INHERIT_SYNC,
  120. .procname = "inherit_sync",
  121. .data = &xfs_params.inherit_sync.val,
  122. .maxlen = sizeof(int),
  123. .mode = 0644,
  124. .proc_handler = &proc_dointvec_minmax,
  125. .strategy = &sysctl_intvec,
  126. .extra1 = &xfs_params.inherit_sync.min,
  127. .extra2 = &xfs_params.inherit_sync.max
  128. },
  129. {
  130. .ctl_name = XFS_INHERIT_NODUMP,
  131. .procname = "inherit_nodump",
  132. .data = &xfs_params.inherit_nodump.val,
  133. .maxlen = sizeof(int),
  134. .mode = 0644,
  135. .proc_handler = &proc_dointvec_minmax,
  136. .strategy = &sysctl_intvec,
  137. .extra1 = &xfs_params.inherit_nodump.min,
  138. .extra2 = &xfs_params.inherit_nodump.max
  139. },
  140. {
  141. .ctl_name = XFS_INHERIT_NOATIME,
  142. .procname = "inherit_noatime",
  143. .data = &xfs_params.inherit_noatim.val,
  144. .maxlen = sizeof(int),
  145. .mode = 0644,
  146. .proc_handler = &proc_dointvec_minmax,
  147. .strategy = &sysctl_intvec,
  148. .extra1 = &xfs_params.inherit_noatim.min,
  149. .extra2 = &xfs_params.inherit_noatim.max
  150. },
  151. {
  152. .ctl_name = XFS_BUF_TIMER,
  153. .procname = "xfsbufd_centisecs",
  154. .data = &xfs_params.xfs_buf_timer.val,
  155. .maxlen = sizeof(int),
  156. .mode = 0644,
  157. .proc_handler = &proc_dointvec_minmax,
  158. .strategy = &sysctl_intvec,
  159. .extra1 = &xfs_params.xfs_buf_timer.min,
  160. .extra2 = &xfs_params.xfs_buf_timer.max
  161. },
  162. {
  163. .ctl_name = XFS_BUF_AGE,
  164. .procname = "age_buffer_centisecs",
  165. .data = &xfs_params.xfs_buf_age.val,
  166. .maxlen = sizeof(int),
  167. .mode = 0644,
  168. .proc_handler = &proc_dointvec_minmax,
  169. .strategy = &sysctl_intvec,
  170. .extra1 = &xfs_params.xfs_buf_age.min,
  171. .extra2 = &xfs_params.xfs_buf_age.max
  172. },
  173. {
  174. .ctl_name = XFS_INHERIT_NOSYM,
  175. .procname = "inherit_nosymlinks",
  176. .data = &xfs_params.inherit_nosym.val,
  177. .maxlen = sizeof(int),
  178. .mode = 0644,
  179. .proc_handler = &proc_dointvec_minmax,
  180. .strategy = &sysctl_intvec,
  181. .extra1 = &xfs_params.inherit_nosym.min,
  182. .extra2 = &xfs_params.inherit_nosym.max
  183. },
  184. {
  185. .ctl_name = XFS_ROTORSTEP,
  186. .procname = "rotorstep",
  187. .data = &xfs_params.rotorstep.val,
  188. .maxlen = sizeof(int),
  189. .mode = 0644,
  190. .proc_handler = &proc_dointvec_minmax,
  191. .strategy = &sysctl_intvec,
  192. .extra1 = &xfs_params.rotorstep.min,
  193. .extra2 = &xfs_params.rotorstep.max
  194. },
  195. {
  196. .ctl_name = XFS_INHERIT_NODFRG,
  197. .procname = "inherit_nodefrag",
  198. .data = &xfs_params.inherit_nodfrg.val,
  199. .maxlen = sizeof(int),
  200. .mode = 0644,
  201. .proc_handler = &proc_dointvec_minmax,
  202. .strategy = &sysctl_intvec,
  203. .extra1 = &xfs_params.inherit_nodfrg.min,
  204. .extra2 = &xfs_params.inherit_nodfrg.max
  205. },
  206. /* please keep this the last entry */
  207. #ifdef CONFIG_PROC_FS
  208. {
  209. .ctl_name = XFS_STATS_CLEAR,
  210. .procname = "stats_clear",
  211. .data = &xfs_params.stats_clear.val,
  212. .maxlen = sizeof(int),
  213. .mode = 0644,
  214. .proc_handler = &xfs_stats_clear_proc_handler,
  215. .strategy = &sysctl_intvec,
  216. .extra1 = &xfs_params.stats_clear.min,
  217. .extra2 = &xfs_params.stats_clear.max
  218. },
  219. #endif /* CONFIG_PROC_FS */
  220. {}
  221. };
  222. static ctl_table xfs_dir_table[] = {
  223. {
  224. .ctl_name = FS_XFS,
  225. .procname = "xfs",
  226. .mode = 0555,
  227. .child = xfs_table
  228. },
  229. {}
  230. };
  231. static ctl_table xfs_root_table[] = {
  232. {
  233. .ctl_name = CTL_FS,
  234. .procname = "fs",
  235. .mode = 0555,
  236. .child = xfs_dir_table
  237. },
  238. {}
  239. };
  240. void
  241. xfs_sysctl_register(void)
  242. {
  243. xfs_table_header = register_sysctl_table(xfs_root_table);
  244. }
  245. void
  246. xfs_sysctl_unregister(void)
  247. {
  248. if (xfs_table_header)
  249. unregister_sysctl_table(xfs_table_header);
  250. }