xfs_sysctl.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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. #include "xfs_error.h"
  22. static struct ctl_table_header *xfs_table_header;
  23. #ifdef CONFIG_PROC_FS
  24. STATIC int
  25. xfs_stats_clear_proc_handler(
  26. ctl_table *ctl,
  27. int write,
  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, buffer, lenp, ppos);
  35. if (!ret && write && *valp) {
  36. xfs_notice(NULL, "Clearing xfsstats");
  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. STATIC int
  51. xfs_panic_mask_proc_handler(
  52. ctl_table *ctl,
  53. int write,
  54. void __user *buffer,
  55. size_t *lenp,
  56. loff_t *ppos)
  57. {
  58. int ret, *valp = ctl->data;
  59. ret = proc_dointvec_minmax(ctl, write, buffer, lenp, ppos);
  60. if (!ret && write) {
  61. xfs_panic_mask = *valp;
  62. #ifdef DEBUG
  63. xfs_panic_mask |= (XFS_PTAG_SHUTDOWN_CORRUPT | XFS_PTAG_LOGRES);
  64. #endif
  65. }
  66. return ret;
  67. }
  68. #endif /* CONFIG_PROC_FS */
  69. static ctl_table xfs_table[] = {
  70. {
  71. .procname = "irix_sgid_inherit",
  72. .data = &xfs_params.sgid_inherit.val,
  73. .maxlen = sizeof(int),
  74. .mode = 0644,
  75. .proc_handler = proc_dointvec_minmax,
  76. .extra1 = &xfs_params.sgid_inherit.min,
  77. .extra2 = &xfs_params.sgid_inherit.max
  78. },
  79. {
  80. .procname = "irix_symlink_mode",
  81. .data = &xfs_params.symlink_mode.val,
  82. .maxlen = sizeof(int),
  83. .mode = 0644,
  84. .proc_handler = proc_dointvec_minmax,
  85. .extra1 = &xfs_params.symlink_mode.min,
  86. .extra2 = &xfs_params.symlink_mode.max
  87. },
  88. {
  89. .procname = "panic_mask",
  90. .data = &xfs_params.panic_mask.val,
  91. .maxlen = sizeof(int),
  92. .mode = 0644,
  93. .proc_handler = xfs_panic_mask_proc_handler,
  94. .extra1 = &xfs_params.panic_mask.min,
  95. .extra2 = &xfs_params.panic_mask.max
  96. },
  97. {
  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. .extra1 = &xfs_params.error_level.min,
  104. .extra2 = &xfs_params.error_level.max
  105. },
  106. {
  107. .procname = "xfssyncd_centisecs",
  108. .data = &xfs_params.syncd_timer.val,
  109. .maxlen = sizeof(int),
  110. .mode = 0644,
  111. .proc_handler = proc_dointvec_minmax,
  112. .extra1 = &xfs_params.syncd_timer.min,
  113. .extra2 = &xfs_params.syncd_timer.max
  114. },
  115. {
  116. .procname = "inherit_sync",
  117. .data = &xfs_params.inherit_sync.val,
  118. .maxlen = sizeof(int),
  119. .mode = 0644,
  120. .proc_handler = proc_dointvec_minmax,
  121. .extra1 = &xfs_params.inherit_sync.min,
  122. .extra2 = &xfs_params.inherit_sync.max
  123. },
  124. {
  125. .procname = "inherit_nodump",
  126. .data = &xfs_params.inherit_nodump.val,
  127. .maxlen = sizeof(int),
  128. .mode = 0644,
  129. .proc_handler = proc_dointvec_minmax,
  130. .extra1 = &xfs_params.inherit_nodump.min,
  131. .extra2 = &xfs_params.inherit_nodump.max
  132. },
  133. {
  134. .procname = "inherit_noatime",
  135. .data = &xfs_params.inherit_noatim.val,
  136. .maxlen = sizeof(int),
  137. .mode = 0644,
  138. .proc_handler = proc_dointvec_minmax,
  139. .extra1 = &xfs_params.inherit_noatim.min,
  140. .extra2 = &xfs_params.inherit_noatim.max
  141. },
  142. {
  143. .procname = "xfsbufd_centisecs",
  144. .data = &xfs_params.xfs_buf_timer.val,
  145. .maxlen = sizeof(int),
  146. .mode = 0644,
  147. .proc_handler = proc_dointvec_minmax,
  148. .extra1 = &xfs_params.xfs_buf_timer.min,
  149. .extra2 = &xfs_params.xfs_buf_timer.max
  150. },
  151. {
  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. .extra1 = &xfs_params.xfs_buf_age.min,
  158. .extra2 = &xfs_params.xfs_buf_age.max
  159. },
  160. {
  161. .procname = "inherit_nosymlinks",
  162. .data = &xfs_params.inherit_nosym.val,
  163. .maxlen = sizeof(int),
  164. .mode = 0644,
  165. .proc_handler = proc_dointvec_minmax,
  166. .extra1 = &xfs_params.inherit_nosym.min,
  167. .extra2 = &xfs_params.inherit_nosym.max
  168. },
  169. {
  170. .procname = "rotorstep",
  171. .data = &xfs_params.rotorstep.val,
  172. .maxlen = sizeof(int),
  173. .mode = 0644,
  174. .proc_handler = proc_dointvec_minmax,
  175. .extra1 = &xfs_params.rotorstep.min,
  176. .extra2 = &xfs_params.rotorstep.max
  177. },
  178. {
  179. .procname = "inherit_nodefrag",
  180. .data = &xfs_params.inherit_nodfrg.val,
  181. .maxlen = sizeof(int),
  182. .mode = 0644,
  183. .proc_handler = proc_dointvec_minmax,
  184. .extra1 = &xfs_params.inherit_nodfrg.min,
  185. .extra2 = &xfs_params.inherit_nodfrg.max
  186. },
  187. {
  188. .procname = "filestream_centisecs",
  189. .data = &xfs_params.fstrm_timer.val,
  190. .maxlen = sizeof(int),
  191. .mode = 0644,
  192. .proc_handler = proc_dointvec_minmax,
  193. .extra1 = &xfs_params.fstrm_timer.min,
  194. .extra2 = &xfs_params.fstrm_timer.max,
  195. },
  196. /* please keep this the last entry */
  197. #ifdef CONFIG_PROC_FS
  198. {
  199. .procname = "stats_clear",
  200. .data = &xfs_params.stats_clear.val,
  201. .maxlen = sizeof(int),
  202. .mode = 0644,
  203. .proc_handler = xfs_stats_clear_proc_handler,
  204. .extra1 = &xfs_params.stats_clear.min,
  205. .extra2 = &xfs_params.stats_clear.max
  206. },
  207. #endif /* CONFIG_PROC_FS */
  208. {}
  209. };
  210. static ctl_table xfs_dir_table[] = {
  211. {
  212. .procname = "xfs",
  213. .mode = 0555,
  214. .child = xfs_table
  215. },
  216. {}
  217. };
  218. static ctl_table xfs_root_table[] = {
  219. {
  220. .procname = "fs",
  221. .mode = 0555,
  222. .child = xfs_dir_table
  223. },
  224. {}
  225. };
  226. int
  227. xfs_sysctl_register(void)
  228. {
  229. xfs_table_header = register_sysctl_table(xfs_root_table);
  230. if (!xfs_table_header)
  231. return -ENOMEM;
  232. return 0;
  233. }
  234. void
  235. xfs_sysctl_unregister(void)
  236. {
  237. unregister_sysctl_table(xfs_table_header);
  238. }