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. static struct ctl_table_header *xfs_table_header;
  23. #ifdef CONFIG_PROC_FS
  24. STATIC int
  25. xfs_stats_clear_proc_handler(
  26. struct 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. struct 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 struct 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 = "inherit_nosymlinks",
  144. .data = &xfs_params.inherit_nosym.val,
  145. .maxlen = sizeof(int),
  146. .mode = 0644,
  147. .proc_handler = proc_dointvec_minmax,
  148. .extra1 = &xfs_params.inherit_nosym.min,
  149. .extra2 = &xfs_params.inherit_nosym.max
  150. },
  151. {
  152. .procname = "rotorstep",
  153. .data = &xfs_params.rotorstep.val,
  154. .maxlen = sizeof(int),
  155. .mode = 0644,
  156. .proc_handler = proc_dointvec_minmax,
  157. .extra1 = &xfs_params.rotorstep.min,
  158. .extra2 = &xfs_params.rotorstep.max
  159. },
  160. {
  161. .procname = "inherit_nodefrag",
  162. .data = &xfs_params.inherit_nodfrg.val,
  163. .maxlen = sizeof(int),
  164. .mode = 0644,
  165. .proc_handler = proc_dointvec_minmax,
  166. .extra1 = &xfs_params.inherit_nodfrg.min,
  167. .extra2 = &xfs_params.inherit_nodfrg.max
  168. },
  169. {
  170. .procname = "filestream_centisecs",
  171. .data = &xfs_params.fstrm_timer.val,
  172. .maxlen = sizeof(int),
  173. .mode = 0644,
  174. .proc_handler = proc_dointvec_minmax,
  175. .extra1 = &xfs_params.fstrm_timer.min,
  176. .extra2 = &xfs_params.fstrm_timer.max,
  177. },
  178. {
  179. .procname = "speculative_prealloc_lifetime",
  180. .data = &xfs_params.eofb_timer.val,
  181. .maxlen = sizeof(int),
  182. .mode = 0644,
  183. .proc_handler = proc_dointvec_minmax,
  184. .extra1 = &xfs_params.eofb_timer.min,
  185. .extra2 = &xfs_params.eofb_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. }