xfs_sysctl.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * Copyright (c) 2001-2004 Silicon Graphics, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of version 2 of the GNU General Public License as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it would be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. *
  12. * Further, this software is distributed without any warranty that it is
  13. * free of the rightful claim of any third person regarding infringement
  14. * or the like. Any license provided herein, whether implied or
  15. * otherwise, applies only to this software file. Patent licenses, if
  16. * any, provided herein do not apply to combinations of this program with
  17. * other software, or any other product whatsoever.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write the Free Software Foundation, Inc., 59
  21. * Temple Place - Suite 330, Boston MA 02111-1307, USA.
  22. *
  23. * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
  24. * Mountain View, CA 94043, or:
  25. *
  26. * http://www.sgi.com
  27. *
  28. * For further information regarding this notice, see:
  29. *
  30. * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
  31. */
  32. #include "xfs.h"
  33. #include "xfs_rw.h"
  34. #include <linux/sysctl.h>
  35. #include <linux/proc_fs.h>
  36. static struct ctl_table_header *xfs_table_header;
  37. #ifdef CONFIG_PROC_FS
  38. STATIC int
  39. xfs_stats_clear_proc_handler(
  40. ctl_table *ctl,
  41. int write,
  42. struct file *filp,
  43. void __user *buffer,
  44. size_t *lenp,
  45. loff_t *ppos)
  46. {
  47. int c, ret, *valp = ctl->data;
  48. __uint32_t vn_active;
  49. ret = proc_dointvec_minmax(ctl, write, filp, buffer, lenp, ppos);
  50. if (!ret && write && *valp) {
  51. printk("XFS Clearing xfsstats\n");
  52. for (c = 0; c < NR_CPUS; c++) {
  53. if (!cpu_possible(c)) continue;
  54. preempt_disable();
  55. /* save vn_active, it's a universal truth! */
  56. vn_active = per_cpu(xfsstats, c).vn_active;
  57. memset(&per_cpu(xfsstats, c), 0,
  58. sizeof(struct xfsstats));
  59. per_cpu(xfsstats, c).vn_active = vn_active;
  60. preempt_enable();
  61. }
  62. xfs_stats_clear = 0;
  63. }
  64. return ret;
  65. }
  66. #endif /* CONFIG_PROC_FS */
  67. STATIC ctl_table xfs_table[] = {
  68. {XFS_RESTRICT_CHOWN, "restrict_chown", &xfs_params.restrict_chown.val,
  69. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  70. &sysctl_intvec, NULL,
  71. &xfs_params.restrict_chown.min, &xfs_params.restrict_chown.max},
  72. {XFS_SGID_INHERIT, "irix_sgid_inherit", &xfs_params.sgid_inherit.val,
  73. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  74. &sysctl_intvec, NULL,
  75. &xfs_params.sgid_inherit.min, &xfs_params.sgid_inherit.max},
  76. {XFS_SYMLINK_MODE, "irix_symlink_mode", &xfs_params.symlink_mode.val,
  77. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  78. &sysctl_intvec, NULL,
  79. &xfs_params.symlink_mode.min, &xfs_params.symlink_mode.max},
  80. {XFS_PANIC_MASK, "panic_mask", &xfs_params.panic_mask.val,
  81. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  82. &sysctl_intvec, NULL,
  83. &xfs_params.panic_mask.min, &xfs_params.panic_mask.max},
  84. {XFS_ERRLEVEL, "error_level", &xfs_params.error_level.val,
  85. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  86. &sysctl_intvec, NULL,
  87. &xfs_params.error_level.min, &xfs_params.error_level.max},
  88. {XFS_SYNCD_TIMER, "xfssyncd_centisecs", &xfs_params.syncd_timer.val,
  89. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  90. &sysctl_intvec, NULL,
  91. &xfs_params.syncd_timer.min, &xfs_params.syncd_timer.max},
  92. {XFS_INHERIT_SYNC, "inherit_sync", &xfs_params.inherit_sync.val,
  93. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  94. &sysctl_intvec, NULL,
  95. &xfs_params.inherit_sync.min, &xfs_params.inherit_sync.max},
  96. {XFS_INHERIT_NODUMP, "inherit_nodump", &xfs_params.inherit_nodump.val,
  97. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  98. &sysctl_intvec, NULL,
  99. &xfs_params.inherit_nodump.min, &xfs_params.inherit_nodump.max},
  100. {XFS_INHERIT_NOATIME, "inherit_noatime", &xfs_params.inherit_noatim.val,
  101. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  102. &sysctl_intvec, NULL,
  103. &xfs_params.inherit_noatim.min, &xfs_params.inherit_noatim.max},
  104. {XFS_BUF_TIMER, "xfsbufd_centisecs", &xfs_params.xfs_buf_timer.val,
  105. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  106. &sysctl_intvec, NULL,
  107. &xfs_params.xfs_buf_timer.min, &xfs_params.xfs_buf_timer.max},
  108. {XFS_BUF_AGE, "age_buffer_centisecs", &xfs_params.xfs_buf_age.val,
  109. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  110. &sysctl_intvec, NULL,
  111. &xfs_params.xfs_buf_age.min, &xfs_params.xfs_buf_age.max},
  112. {XFS_INHERIT_NOSYM, "inherit_nosymlinks", &xfs_params.inherit_nosym.val,
  113. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  114. &sysctl_intvec, NULL,
  115. &xfs_params.inherit_nosym.min, &xfs_params.inherit_nosym.max},
  116. {XFS_ROTORSTEP, "rotorstep", &xfs_params.rotorstep.val,
  117. sizeof(int), 0644, NULL, &proc_dointvec_minmax,
  118. &sysctl_intvec, NULL,
  119. &xfs_params.rotorstep.min, &xfs_params.rotorstep.max},
  120. /* please keep this the last entry */
  121. #ifdef CONFIG_PROC_FS
  122. {XFS_STATS_CLEAR, "stats_clear", &xfs_params.stats_clear.val,
  123. sizeof(int), 0644, NULL, &xfs_stats_clear_proc_handler,
  124. &sysctl_intvec, NULL,
  125. &xfs_params.stats_clear.min, &xfs_params.stats_clear.max},
  126. #endif /* CONFIG_PROC_FS */
  127. {0}
  128. };
  129. STATIC ctl_table xfs_dir_table[] = {
  130. {FS_XFS, "xfs", NULL, 0, 0555, xfs_table},
  131. {0}
  132. };
  133. STATIC ctl_table xfs_root_table[] = {
  134. {CTL_FS, "fs", NULL, 0, 0555, xfs_dir_table},
  135. {0}
  136. };
  137. void
  138. xfs_sysctl_register(void)
  139. {
  140. xfs_table_header = register_sysctl_table(xfs_root_table, 1);
  141. }
  142. void
  143. xfs_sysctl_unregister(void)
  144. {
  145. if (xfs_table_header)
  146. unregister_sysctl_table(xfs_table_header);
  147. }