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 | |
David Chinner | 7989cb8 | 2007-02-10 18:34:56 +1100 | [diff] [blame] | 57 | static ctl_table xfs_table[] = { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 58 | { |
| 59 | .ctl_name = XFS_RESTRICT_CHOWN, |
| 60 | .procname = "restrict_chown", |
| 61 | .data = &xfs_params.restrict_chown.val, |
| 62 | .maxlen = sizeof(int), |
| 63 | .mode = 0644, |
| 64 | .proc_handler = &proc_dointvec_minmax, |
| 65 | .strategy = &sysctl_intvec, |
| 66 | .extra1 = &xfs_params.restrict_chown.min, |
| 67 | .extra2 = &xfs_params.restrict_chown.max |
| 68 | }, |
| 69 | { |
| 70 | .ctl_name = XFS_SGID_INHERIT, |
| 71 | .procname = "irix_sgid_inherit", |
| 72 | .data = &xfs_params.sgid_inherit.val, |
| 73 | .maxlen = sizeof(int), |
| 74 | .mode = 0644, |
| 75 | .proc_handler = &proc_dointvec_minmax, |
| 76 | .strategy = &sysctl_intvec, |
| 77 | .extra1 = &xfs_params.sgid_inherit.min, |
| 78 | .extra2 = &xfs_params.sgid_inherit.max |
| 79 | }, |
| 80 | { |
| 81 | .ctl_name = XFS_SYMLINK_MODE, |
| 82 | .procname = "irix_symlink_mode", |
| 83 | .data = &xfs_params.symlink_mode.val, |
| 84 | .maxlen = sizeof(int), |
| 85 | .mode = 0644, |
| 86 | .proc_handler = &proc_dointvec_minmax, |
| 87 | .strategy = &sysctl_intvec, |
| 88 | .extra1 = &xfs_params.symlink_mode.min, |
| 89 | .extra2 = &xfs_params.symlink_mode.max |
| 90 | }, |
| 91 | { |
| 92 | .ctl_name = XFS_PANIC_MASK, |
| 93 | .procname = "panic_mask", |
| 94 | .data = &xfs_params.panic_mask.val, |
| 95 | .maxlen = sizeof(int), |
| 96 | .mode = 0644, |
| 97 | .proc_handler = &proc_dointvec_minmax, |
| 98 | .strategy = &sysctl_intvec, |
| 99 | .extra1 = &xfs_params.panic_mask.min, |
| 100 | .extra2 = &xfs_params.panic_mask.max |
| 101 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 103 | { |
| 104 | .ctl_name = XFS_ERRLEVEL, |
| 105 | .procname = "error_level", |
| 106 | .data = &xfs_params.error_level.val, |
| 107 | .maxlen = sizeof(int), |
| 108 | .mode = 0644, |
| 109 | .proc_handler = &proc_dointvec_minmax, |
| 110 | .strategy = &sysctl_intvec, |
| 111 | .extra1 = &xfs_params.error_level.min, |
| 112 | .extra2 = &xfs_params.error_level.max |
| 113 | }, |
| 114 | { |
| 115 | .ctl_name = XFS_SYNCD_TIMER, |
| 116 | .procname = "xfssyncd_centisecs", |
| 117 | .data = &xfs_params.syncd_timer.val, |
| 118 | .maxlen = sizeof(int), |
| 119 | .mode = 0644, |
| 120 | .proc_handler = &proc_dointvec_minmax, |
| 121 | .strategy = &sysctl_intvec, |
| 122 | .extra1 = &xfs_params.syncd_timer.min, |
| 123 | .extra2 = &xfs_params.syncd_timer.max |
| 124 | }, |
| 125 | { |
| 126 | .ctl_name = XFS_INHERIT_SYNC, |
| 127 | .procname = "inherit_sync", |
| 128 | .data = &xfs_params.inherit_sync.val, |
| 129 | .maxlen = sizeof(int), |
| 130 | .mode = 0644, |
| 131 | .proc_handler = &proc_dointvec_minmax, |
| 132 | .strategy = &sysctl_intvec, |
| 133 | .extra1 = &xfs_params.inherit_sync.min, |
| 134 | .extra2 = &xfs_params.inherit_sync.max |
| 135 | }, |
| 136 | { |
| 137 | .ctl_name = XFS_INHERIT_NODUMP, |
| 138 | .procname = "inherit_nodump", |
| 139 | .data = &xfs_params.inherit_nodump.val, |
| 140 | .maxlen = sizeof(int), |
| 141 | .mode = 0644, |
| 142 | .proc_handler = &proc_dointvec_minmax, |
| 143 | .strategy = &sysctl_intvec, |
| 144 | .extra1 = &xfs_params.inherit_nodump.min, |
| 145 | .extra2 = &xfs_params.inherit_nodump.max |
| 146 | }, |
| 147 | { |
| 148 | .ctl_name = XFS_INHERIT_NOATIME, |
| 149 | .procname = "inherit_noatime", |
| 150 | .data = &xfs_params.inherit_noatim.val, |
| 151 | .maxlen = sizeof(int), |
| 152 | .mode = 0644, |
| 153 | .proc_handler = &proc_dointvec_minmax, |
| 154 | .strategy = &sysctl_intvec, |
| 155 | .extra1 = &xfs_params.inherit_noatim.min, |
| 156 | .extra2 = &xfs_params.inherit_noatim.max |
| 157 | }, |
| 158 | { |
| 159 | .ctl_name = XFS_BUF_TIMER, |
| 160 | .procname = "xfsbufd_centisecs", |
| 161 | .data = &xfs_params.xfs_buf_timer.val, |
| 162 | .maxlen = sizeof(int), |
| 163 | .mode = 0644, |
| 164 | .proc_handler = &proc_dointvec_minmax, |
| 165 | .strategy = &sysctl_intvec, |
| 166 | .extra1 = &xfs_params.xfs_buf_timer.min, |
| 167 | .extra2 = &xfs_params.xfs_buf_timer.max |
| 168 | }, |
| 169 | { |
| 170 | .ctl_name = XFS_BUF_AGE, |
| 171 | .procname = "age_buffer_centisecs", |
| 172 | .data = &xfs_params.xfs_buf_age.val, |
| 173 | .maxlen = sizeof(int), |
| 174 | .mode = 0644, |
| 175 | .proc_handler = &proc_dointvec_minmax, |
| 176 | .strategy = &sysctl_intvec, |
| 177 | .extra1 = &xfs_params.xfs_buf_age.min, |
| 178 | .extra2 = &xfs_params.xfs_buf_age.max |
| 179 | }, |
| 180 | { |
| 181 | .ctl_name = XFS_INHERIT_NOSYM, |
| 182 | .procname = "inherit_nosymlinks", |
| 183 | .data = &xfs_params.inherit_nosym.val, |
| 184 | .maxlen = sizeof(int), |
| 185 | .mode = 0644, |
| 186 | .proc_handler = &proc_dointvec_minmax, |
| 187 | .strategy = &sysctl_intvec, |
| 188 | .extra1 = &xfs_params.inherit_nosym.min, |
| 189 | .extra2 = &xfs_params.inherit_nosym.max |
| 190 | }, |
| 191 | { |
| 192 | .ctl_name = XFS_ROTORSTEP, |
| 193 | .procname = "rotorstep", |
| 194 | .data = &xfs_params.rotorstep.val, |
| 195 | .maxlen = sizeof(int), |
| 196 | .mode = 0644, |
| 197 | .proc_handler = &proc_dointvec_minmax, |
| 198 | .strategy = &sysctl_intvec, |
| 199 | .extra1 = &xfs_params.rotorstep.min, |
| 200 | .extra2 = &xfs_params.rotorstep.max |
| 201 | }, |
| 202 | { |
| 203 | .ctl_name = XFS_INHERIT_NODFRG, |
| 204 | .procname = "inherit_nodefrag", |
| 205 | .data = &xfs_params.inherit_nodfrg.val, |
| 206 | .maxlen = sizeof(int), |
| 207 | .mode = 0644, |
| 208 | .proc_handler = &proc_dointvec_minmax, |
| 209 | .strategy = &sysctl_intvec, |
| 210 | .extra1 = &xfs_params.inherit_nodfrg.min, |
| 211 | .extra2 = &xfs_params.inherit_nodfrg.max |
| 212 | }, |
David Chinner | 2a82b8b | 2007-07-11 11:09:12 +1000 | [diff] [blame^] | 213 | { |
| 214 | .ctl_name = XFS_FILESTREAM_TIMER, |
| 215 | .procname = "filestream_centisecs", |
| 216 | .data = &xfs_params.fstrm_timer.val, |
| 217 | .maxlen = sizeof(int), |
| 218 | .mode = 0644, |
| 219 | .proc_handler = &proc_dointvec_minmax, |
| 220 | .strategy = &sysctl_intvec, |
| 221 | .extra1 = &xfs_params.fstrm_timer.min, |
| 222 | .extra2 = &xfs_params.fstrm_timer.max, |
| 223 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | /* please keep this the last entry */ |
| 225 | #ifdef CONFIG_PROC_FS |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 226 | { |
| 227 | .ctl_name = XFS_STATS_CLEAR, |
| 228 | .procname = "stats_clear", |
| 229 | .data = &xfs_params.stats_clear.val, |
| 230 | .maxlen = sizeof(int), |
| 231 | .mode = 0644, |
| 232 | .proc_handler = &xfs_stats_clear_proc_handler, |
| 233 | .strategy = &sysctl_intvec, |
| 234 | .extra1 = &xfs_params.stats_clear.min, |
| 235 | .extra2 = &xfs_params.stats_clear.max |
| 236 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | #endif /* CONFIG_PROC_FS */ |
| 238 | |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 239 | {} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | }; |
| 241 | |
David Chinner | 7989cb8 | 2007-02-10 18:34:56 +1100 | [diff] [blame] | 242 | static ctl_table xfs_dir_table[] = { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 243 | { |
| 244 | .ctl_name = FS_XFS, |
| 245 | .procname = "xfs", |
| 246 | .mode = 0555, |
| 247 | .child = xfs_table |
| 248 | }, |
| 249 | {} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | }; |
| 251 | |
David Chinner | 7989cb8 | 2007-02-10 18:34:56 +1100 | [diff] [blame] | 252 | static ctl_table xfs_root_table[] = { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 253 | { |
| 254 | .ctl_name = CTL_FS, |
| 255 | .procname = "fs", |
| 256 | .mode = 0555, |
| 257 | .child = xfs_dir_table |
| 258 | }, |
| 259 | {} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | }; |
| 261 | |
| 262 | void |
| 263 | xfs_sysctl_register(void) |
| 264 | { |
Eric W. Biederman | 0b4d414 | 2007-02-14 00:34:09 -0800 | [diff] [blame] | 265 | xfs_table_header = register_sysctl_table(xfs_root_table); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | void |
| 269 | xfs_sysctl_unregister(void) |
| 270 | { |
| 271 | if (xfs_table_header) |
| 272 | unregister_sysctl_table(xfs_table_header); |
| 273 | } |