xfs_sysctl.c 6.7 KB

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