| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
| Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 2 | * Copyright (c) 2001-2005 Silicon Graphics, Inc. | 
|  | 3 | * All Rights Reserved. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * | 
| Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * published by the Free Software Foundation. | 
|  | 8 | * | 
| Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * | 
| Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include "xfs.h" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <linux/sysctl.h> | 
|  | 20 | #include <linux/proc_fs.h> | 
|  | 21 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | static struct ctl_table_header *xfs_table_header; | 
|  | 23 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #ifdef CONFIG_PROC_FS | 
|  | 25 | STATIC int | 
|  | 26 | xfs_stats_clear_proc_handler( | 
|  | 27 | ctl_table	*ctl, | 
|  | 28 | int		write, | 
|  | 29 | struct file	*filp, | 
|  | 30 | void		__user *buffer, | 
|  | 31 | size_t		*lenp, | 
|  | 32 | loff_t		*ppos) | 
|  | 33 | { | 
|  | 34 | int		c, ret, *valp = ctl->data; | 
|  | 35 | __uint32_t	vn_active; | 
|  | 36 |  | 
|  | 37 | ret = proc_dointvec_minmax(ctl, write, filp, buffer, lenp, ppos); | 
|  | 38 |  | 
|  | 39 | if (!ret && write && *valp) { | 
|  | 40 | printk("XFS Clearing xfsstats\n"); | 
| KAMEZAWA Hiroyuki | 6f0419e | 2006-06-23 02:03:00 -0700 | [diff] [blame] | 41 | for_each_possible_cpu(c) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | preempt_disable(); | 
|  | 43 | /* save vn_active, it's a universal truth! */ | 
|  | 44 | vn_active = per_cpu(xfsstats, c).vn_active; | 
|  | 45 | memset(&per_cpu(xfsstats, c), 0, | 
|  | 46 | sizeof(struct xfsstats)); | 
|  | 47 | per_cpu(xfsstats, c).vn_active = vn_active; | 
|  | 48 | preempt_enable(); | 
|  | 49 | } | 
|  | 50 | xfs_stats_clear = 0; | 
|  | 51 | } | 
|  | 52 |  | 
|  | 53 | return ret; | 
|  | 54 | } | 
|  | 55 | #endif /* CONFIG_PROC_FS */ | 
|  | 56 |  | 
|  | 57 | STATIC ctl_table xfs_table[] = { | 
|  | 58 | {XFS_RESTRICT_CHOWN, "restrict_chown", &xfs_params.restrict_chown.val, | 
|  | 59 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 60 | &sysctl_intvec, NULL, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | &xfs_params.restrict_chown.min, &xfs_params.restrict_chown.max}, | 
|  | 62 |  | 
|  | 63 | {XFS_SGID_INHERIT, "irix_sgid_inherit", &xfs_params.sgid_inherit.val, | 
|  | 64 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, | 
|  | 65 | &sysctl_intvec, NULL, | 
|  | 66 | &xfs_params.sgid_inherit.min, &xfs_params.sgid_inherit.max}, | 
|  | 67 |  | 
|  | 68 | {XFS_SYMLINK_MODE, "irix_symlink_mode", &xfs_params.symlink_mode.val, | 
|  | 69 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 70 | &sysctl_intvec, NULL, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | &xfs_params.symlink_mode.min, &xfs_params.symlink_mode.max}, | 
|  | 72 |  | 
|  | 73 | {XFS_PANIC_MASK, "panic_mask", &xfs_params.panic_mask.val, | 
|  | 74 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 75 | &sysctl_intvec, NULL, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | &xfs_params.panic_mask.min, &xfs_params.panic_mask.max}, | 
|  | 77 |  | 
|  | 78 | {XFS_ERRLEVEL, "error_level", &xfs_params.error_level.val, | 
|  | 79 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 80 | &sysctl_intvec, NULL, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | &xfs_params.error_level.min, &xfs_params.error_level.max}, | 
|  | 82 |  | 
|  | 83 | {XFS_SYNCD_TIMER, "xfssyncd_centisecs", &xfs_params.syncd_timer.val, | 
|  | 84 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 85 | &sysctl_intvec, NULL, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | &xfs_params.syncd_timer.min, &xfs_params.syncd_timer.max}, | 
|  | 87 |  | 
|  | 88 | {XFS_INHERIT_SYNC, "inherit_sync", &xfs_params.inherit_sync.val, | 
|  | 89 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, | 
|  | 90 | &sysctl_intvec, NULL, | 
|  | 91 | &xfs_params.inherit_sync.min, &xfs_params.inherit_sync.max}, | 
|  | 92 |  | 
|  | 93 | {XFS_INHERIT_NODUMP, "inherit_nodump", &xfs_params.inherit_nodump.val, | 
|  | 94 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, | 
|  | 95 | &sysctl_intvec, NULL, | 
|  | 96 | &xfs_params.inherit_nodump.min, &xfs_params.inherit_nodump.max}, | 
|  | 97 |  | 
|  | 98 | {XFS_INHERIT_NOATIME, "inherit_noatime", &xfs_params.inherit_noatim.val, | 
|  | 99 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, | 
|  | 100 | &sysctl_intvec, NULL, | 
|  | 101 | &xfs_params.inherit_noatim.min, &xfs_params.inherit_noatim.max}, | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 102 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | {XFS_BUF_TIMER, "xfsbufd_centisecs", &xfs_params.xfs_buf_timer.val, | 
|  | 104 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, | 
|  | 105 | &sysctl_intvec, NULL, | 
|  | 106 | &xfs_params.xfs_buf_timer.min, &xfs_params.xfs_buf_timer.max}, | 
|  | 107 |  | 
|  | 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 |  | 
|  | 113 | {XFS_INHERIT_NOSYM, "inherit_nosymlinks", &xfs_params.inherit_nosym.val, | 
|  | 114 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, | 
|  | 115 | &sysctl_intvec, NULL, | 
|  | 116 | &xfs_params.inherit_nosym.min, &xfs_params.inherit_nosym.max}, | 
|  | 117 |  | 
|  | 118 | {XFS_ROTORSTEP, "rotorstep", &xfs_params.rotorstep.val, | 
|  | 119 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 120 | &sysctl_intvec, NULL, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | &xfs_params.rotorstep.min, &xfs_params.rotorstep.max}, | 
|  | 122 |  | 
| Barry Naujok | d3446ea | 2006-06-09 14:54:19 +1000 | [diff] [blame] | 123 | {XFS_INHERIT_NODFRG, "inherit_nodefrag", &xfs_params.inherit_nodfrg.val, | 
|  | 124 | sizeof(int), 0644, NULL, &proc_dointvec_minmax, | 
|  | 125 | &sysctl_intvec, NULL, | 
|  | 126 | &xfs_params.inherit_nodfrg.min, &xfs_params.inherit_nodfrg.max}, | 
|  | 127 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | /* please keep this the last entry */ | 
|  | 129 | #ifdef CONFIG_PROC_FS | 
|  | 130 | {XFS_STATS_CLEAR, "stats_clear", &xfs_params.stats_clear.val, | 
|  | 131 | sizeof(int), 0644, NULL, &xfs_stats_clear_proc_handler, | 
| Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 132 | &sysctl_intvec, NULL, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | &xfs_params.stats_clear.min, &xfs_params.stats_clear.max}, | 
|  | 134 | #endif /* CONFIG_PROC_FS */ | 
|  | 135 |  | 
|  | 136 | {0} | 
|  | 137 | }; | 
|  | 138 |  | 
|  | 139 | STATIC ctl_table xfs_dir_table[] = { | 
|  | 140 | {FS_XFS, "xfs", NULL, 0, 0555, xfs_table}, | 
|  | 141 | {0} | 
|  | 142 | }; | 
|  | 143 |  | 
|  | 144 | STATIC ctl_table xfs_root_table[] = { | 
|  | 145 | {CTL_FS, "fs",  NULL, 0, 0555, xfs_dir_table}, | 
|  | 146 | {0} | 
|  | 147 | }; | 
|  | 148 |  | 
|  | 149 | void | 
|  | 150 | xfs_sysctl_register(void) | 
|  | 151 | { | 
|  | 152 | xfs_table_header = register_sysctl_table(xfs_root_table, 1); | 
|  | 153 | } | 
|  | 154 |  | 
|  | 155 | void | 
|  | 156 | xfs_sysctl_unregister(void) | 
|  | 157 | { | 
|  | 158 | if (xfs_table_header) | 
|  | 159 | unregister_sysctl_table(xfs_table_header); | 
|  | 160 | } |