xfs_sysctl.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. static struct ctl_table_header *xfs_table_header;
  22. #ifdef CONFIG_PROC_FS
  23. STATIC int
  24. xfs_stats_clear_proc_handler(
  25. ctl_table *ctl,
  26. int write,
  27. struct file *filp,
  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, filp, buffer, lenp, ppos);
  35. if (!ret && write && *valp) {
  36. printk("XFS Clearing xfsstats\n");
  37. for (c = 0; c < NR_CPUS; c++) {
  38. if (!cpu_possible(c)) continue;
  39. preempt_disable();
  40. /* save vn_active, it's a universal truth! */
  41. vn_active = per_cpu(xfsstats, c).vn_active;
  42. memset(&per_cpu(xfsstats, c), 0,
  43. sizeof(struct xfsstats));
  44. per_cpu(xfsstats, c).vn_active = vn_active;
  45. preempt_enable();
  46. }
  47. xfs_stats_clear = 0;
  48. }
  49. return ret;
  50. }
  51. #endif /* CONFIG_PROC_FS */
  52. STATIC ctl_table xfs_table[] = {
  53. {XFS_RESTRICT_CHOWN, "restrict_chown", &xfs_params.restrict_chown.val,
  54. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  55. &sysctl_intvec, NULL,
  56. &xfs_params.restrict_chown.min, &xfs_params.restrict_chown.max},
  57. {XFS_SGID_INHERIT, "irix_sgid_inherit", &xfs_params.sgid_inherit.val,
  58. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  59. &sysctl_intvec, NULL,
  60. &xfs_params.sgid_inherit.min, &xfs_params.sgid_inherit.max},
  61. {XFS_SYMLINK_MODE, "irix_symlink_mode", &xfs_params.symlink_mode.val,
  62. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  63. &sysctl_intvec, NULL,
  64. &xfs_params.symlink_mode.min, &xfs_params.symlink_mode.max},
  65. {XFS_PANIC_MASK, "panic_mask", &xfs_params.panic_mask.val,
  66. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  67. &sysctl_intvec, NULL,
  68. &xfs_params.panic_mask.min, &xfs_params.panic_mask.max},
  69. {XFS_ERRLEVEL, "error_level", &xfs_params.error_level.val,
  70. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  71. &sysctl_intvec, NULL,
  72. &xfs_params.error_level.min, &xfs_params.error_level.max},
  73. {XFS_SYNCD_TIMER, "xfssyncd_centisecs", &xfs_params.syncd_timer.val,
  74. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  75. &sysctl_intvec, NULL,
  76. &xfs_params.syncd_timer.min, &xfs_params.syncd_timer.max},
  77. {XFS_INHERIT_SYNC, "inherit_sync", &xfs_params.inherit_sync.val,
  78. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  79. &sysctl_intvec, NULL,
  80. &xfs_params.inherit_sync.min, &xfs_params.inherit_sync.max},
  81. {XFS_INHERIT_NODUMP, "inherit_nodump", &xfs_params.inherit_nodump.val,
  82. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  83. &sysctl_intvec, NULL,
  84. &xfs_params.inherit_nodump.min, &xfs_params.inherit_nodump.max},
  85. {XFS_INHERIT_NOATIME, "inherit_noatime", &xfs_params.inherit_noatim.val,
  86. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  87. &sysctl_intvec, NULL,
  88. &xfs_params.inherit_noatim.min, &xfs_params.inherit_noatim.max},
  89. {XFS_BUF_TIMER, "xfsbufd_centisecs", &xfs_params.xfs_buf_timer.val,
  90. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  91. &sysctl_intvec, NULL,
  92. &xfs_params.xfs_buf_timer.min, &xfs_params.xfs_buf_timer.max},
  93. {XFS_BUF_AGE, "age_buffer_centisecs", &xfs_params.xfs_buf_age.val,
  94. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  95. &sysctl_intvec, NULL,
  96. &xfs_params.xfs_buf_age.min, &xfs_params.xfs_buf_age.max},
  97. {XFS_INHERIT_NOSYM, "inherit_nosymlinks", &xfs_params.inherit_nosym.val,
  98. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  99. &sysctl_intvec, NULL,
  100. &xfs_params.inherit_nosym.min, &xfs_params.inherit_nosym.max},
  101. {XFS_ROTORSTEP, "rotorstep", &xfs_params.rotorstep.val,
  102. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  103. &sysctl_intvec, NULL,
  104. &xfs_params.rotorstep.min, &xfs_params.rotorstep.max},
  105. /* please keep this the last entry */
  106. #ifdef CONFIG_PROC_FS
  107. {XFS_STATS_CLEAR, "stats_clear", &xfs_params.stats_clear.val,
  108. sizeof(int), 0644, NULL, &xfs_stats_clear_proc_handler,
  109. &sysctl_intvec, NULL,
  110. &xfs_params.stats_clear.min, &xfs_params.stats_clear.max},
  111. #endif /* CONFIG_PROC_FS */
  112. {0}
  113. };
  114. STATIC ctl_table xfs_dir_table[] = {
  115. {FS_XFS, "xfs", NULL, 0, 0555, xfs_table},
  116. {0}
  117. };
  118. STATIC ctl_table xfs_root_table[] = {
  119. {CTL_FS, "fs", NULL, 0, 0555, xfs_dir_table},
  120. {0}
  121. };
  122. void
  123. xfs_sysctl_register(void)
  124. {
  125. xfs_table_header = register_sysctl_table(xfs_root_table, 1);
  126. }
  127. void
  128. xfs_sysctl_unregister(void)
  129. {
  130. if (xfs_table_header)
  131. unregister_sysctl_table(xfs_table_header);
  132. }