xfs_sysctl.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. /* please keep this the last entry */
  179. #ifdef CONFIG_PROC_FS
  180. {
  181. .procname = "stats_clear",
  182. .data = &xfs_params.stats_clear.val,
  183. .maxlen = sizeof(int),
  184. .mode = 0644,
  185. .proc_handler = xfs_stats_clear_proc_handler,
  186. .extra1 = &xfs_params.stats_clear.min,
  187. .extra2 = &xfs_params.stats_clear.max
  188. },
  189. #endif /* CONFIG_PROC_FS */
  190. {}
  191. };
  192. static struct ctl_table xfs_dir_table[] = {
  193. {
  194. .procname = "xfs",
  195. .mode = 0555,
  196. .child = xfs_table
  197. },
  198. {}
  199. };
  200. static struct ctl_table xfs_root_table[] = {
  201. {
  202. .procname = "fs",
  203. .mode = 0555,
  204. .child = xfs_dir_table
  205. },
  206. {}
  207. };
  208. int
  209. xfs_sysctl_register(void)
  210. {
  211. xfs_table_header = register_sysctl_table(xfs_root_table);
  212. if (!xfs_table_header)
  213. return -ENOMEM;
  214. return 0;
  215. }
  216. void
  217. xfs_sysctl_unregister(void)
  218. {
  219. unregister_sysctl_table(xfs_table_header);
  220. }