xfs_sysctl.c 5.3 KB

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