xfs_sysctl.c 5.9 KB

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