xfs_sysctl.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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_deprecated_dointvec_minmax(
  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_ratelimited(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 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 = xfs_deprecated_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 = xfs_deprecated_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.blockgc_timer.val,
  172. .maxlen = sizeof(int),
  173. .mode = 0644,
  174. .proc_handler = proc_dointvec_minmax,
  175. .extra1 = &xfs_params.blockgc_timer.min,
  176. .extra2 = &xfs_params.blockgc_timer.max,
  177. },
  178. {
  179. .procname = "speculative_cow_prealloc_lifetime",
  180. .data = &xfs_params.blockgc_timer.val,
  181. .maxlen = sizeof(int),
  182. .mode = 0644,
  183. .proc_handler = xfs_deprecated_dointvec_minmax,
  184. .extra1 = &xfs_params.blockgc_timer.min,
  185. .extra2 = &xfs_params.blockgc_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. }