xfs_sysctl.c 5.9 KB

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