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, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | void __user *buffer, |
| 30 | size_t *lenp, |
| 31 | loff_t *ppos) |
| 32 | { |
| 33 | int c, ret, *valp = ctl->data; |
| 34 | __uint32_t vn_active; |
| 35 | |
Alexey Dobriyan | 8d65af7 | 2009-09-23 15:57:19 -0700 | [diff] [blame] | 36 | ret = proc_dointvec_minmax(ctl, write, buffer, lenp, ppos); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
| 38 | if (!ret && write && *valp) { |
| 39 | printk("XFS Clearing xfsstats\n"); |
KAMEZAWA Hiroyuki | 6f0419e | 2006-06-23 02:03:00 -0700 | [diff] [blame] | 40 | for_each_possible_cpu(c) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | preempt_disable(); |
| 42 | /* save vn_active, it's a universal truth! */ |
| 43 | vn_active = per_cpu(xfsstats, c).vn_active; |
| 44 | memset(&per_cpu(xfsstats, c), 0, |
| 45 | sizeof(struct xfsstats)); |
| 46 | per_cpu(xfsstats, c).vn_active = vn_active; |
| 47 | preempt_enable(); |
| 48 | } |
| 49 | xfs_stats_clear = 0; |
| 50 | } |
| 51 | |
| 52 | return ret; |
| 53 | } |
| 54 | #endif /* CONFIG_PROC_FS */ |
| 55 | |
David Chinner | 7989cb8 | 2007-02-10 18:34:56 +1100 | [diff] [blame] | 56 | static ctl_table xfs_table[] = { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 57 | { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 58 | .procname = "irix_sgid_inherit", |
| 59 | .data = &xfs_params.sgid_inherit.val, |
| 60 | .maxlen = sizeof(int), |
| 61 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 62 | .proc_handler = proc_dointvec_minmax, |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 63 | .extra1 = &xfs_params.sgid_inherit.min, |
| 64 | .extra2 = &xfs_params.sgid_inherit.max |
| 65 | }, |
| 66 | { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 67 | .procname = "irix_symlink_mode", |
| 68 | .data = &xfs_params.symlink_mode.val, |
| 69 | .maxlen = sizeof(int), |
| 70 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 71 | .proc_handler = proc_dointvec_minmax, |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 72 | .extra1 = &xfs_params.symlink_mode.min, |
| 73 | .extra2 = &xfs_params.symlink_mode.max |
| 74 | }, |
| 75 | { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 76 | .procname = "panic_mask", |
| 77 | .data = &xfs_params.panic_mask.val, |
| 78 | .maxlen = sizeof(int), |
| 79 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 80 | .proc_handler = proc_dointvec_minmax, |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 81 | .extra1 = &xfs_params.panic_mask.min, |
| 82 | .extra2 = &xfs_params.panic_mask.max |
| 83 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 85 | { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 86 | .procname = "error_level", |
| 87 | .data = &xfs_params.error_level.val, |
| 88 | .maxlen = sizeof(int), |
| 89 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 90 | .proc_handler = proc_dointvec_minmax, |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 91 | .extra1 = &xfs_params.error_level.min, |
| 92 | .extra2 = &xfs_params.error_level.max |
| 93 | }, |
| 94 | { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 95 | .procname = "xfssyncd_centisecs", |
| 96 | .data = &xfs_params.syncd_timer.val, |
| 97 | .maxlen = sizeof(int), |
| 98 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 99 | .proc_handler = proc_dointvec_minmax, |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 100 | .extra1 = &xfs_params.syncd_timer.min, |
| 101 | .extra2 = &xfs_params.syncd_timer.max |
| 102 | }, |
| 103 | { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 104 | .procname = "inherit_sync", |
| 105 | .data = &xfs_params.inherit_sync.val, |
| 106 | .maxlen = sizeof(int), |
| 107 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 108 | .proc_handler = proc_dointvec_minmax, |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 109 | .extra1 = &xfs_params.inherit_sync.min, |
| 110 | .extra2 = &xfs_params.inherit_sync.max |
| 111 | }, |
| 112 | { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 113 | .procname = "inherit_nodump", |
| 114 | .data = &xfs_params.inherit_nodump.val, |
| 115 | .maxlen = sizeof(int), |
| 116 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 117 | .proc_handler = proc_dointvec_minmax, |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 118 | .extra1 = &xfs_params.inherit_nodump.min, |
| 119 | .extra2 = &xfs_params.inherit_nodump.max |
| 120 | }, |
| 121 | { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 122 | .procname = "inherit_noatime", |
| 123 | .data = &xfs_params.inherit_noatim.val, |
| 124 | .maxlen = sizeof(int), |
| 125 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 126 | .proc_handler = proc_dointvec_minmax, |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 127 | .extra1 = &xfs_params.inherit_noatim.min, |
| 128 | .extra2 = &xfs_params.inherit_noatim.max |
| 129 | }, |
| 130 | { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 131 | .procname = "xfsbufd_centisecs", |
| 132 | .data = &xfs_params.xfs_buf_timer.val, |
| 133 | .maxlen = sizeof(int), |
| 134 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 135 | .proc_handler = proc_dointvec_minmax, |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 136 | .extra1 = &xfs_params.xfs_buf_timer.min, |
| 137 | .extra2 = &xfs_params.xfs_buf_timer.max |
| 138 | }, |
| 139 | { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 140 | .procname = "age_buffer_centisecs", |
| 141 | .data = &xfs_params.xfs_buf_age.val, |
| 142 | .maxlen = sizeof(int), |
| 143 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 144 | .proc_handler = proc_dointvec_minmax, |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 145 | .extra1 = &xfs_params.xfs_buf_age.min, |
| 146 | .extra2 = &xfs_params.xfs_buf_age.max |
| 147 | }, |
| 148 | { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 149 | .procname = "inherit_nosymlinks", |
| 150 | .data = &xfs_params.inherit_nosym.val, |
| 151 | .maxlen = sizeof(int), |
| 152 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 153 | .proc_handler = proc_dointvec_minmax, |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 154 | .extra1 = &xfs_params.inherit_nosym.min, |
| 155 | .extra2 = &xfs_params.inherit_nosym.max |
| 156 | }, |
| 157 | { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 158 | .procname = "rotorstep", |
| 159 | .data = &xfs_params.rotorstep.val, |
| 160 | .maxlen = sizeof(int), |
| 161 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 162 | .proc_handler = proc_dointvec_minmax, |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 163 | .extra1 = &xfs_params.rotorstep.min, |
| 164 | .extra2 = &xfs_params.rotorstep.max |
| 165 | }, |
| 166 | { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 167 | .procname = "inherit_nodefrag", |
| 168 | .data = &xfs_params.inherit_nodfrg.val, |
| 169 | .maxlen = sizeof(int), |
| 170 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 171 | .proc_handler = proc_dointvec_minmax, |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 172 | .extra1 = &xfs_params.inherit_nodfrg.min, |
| 173 | .extra2 = &xfs_params.inherit_nodfrg.max |
| 174 | }, |
David Chinner | 2a82b8b | 2007-07-11 11:09:12 +1000 | [diff] [blame] | 175 | { |
David Chinner | 2a82b8b | 2007-07-11 11:09:12 +1000 | [diff] [blame] | 176 | .procname = "filestream_centisecs", |
| 177 | .data = &xfs_params.fstrm_timer.val, |
| 178 | .maxlen = sizeof(int), |
| 179 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 180 | .proc_handler = proc_dointvec_minmax, |
David Chinner | 2a82b8b | 2007-07-11 11:09:12 +1000 | [diff] [blame] | 181 | .extra1 = &xfs_params.fstrm_timer.min, |
| 182 | .extra2 = &xfs_params.fstrm_timer.max, |
| 183 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | /* please keep this the last entry */ |
| 185 | #ifdef CONFIG_PROC_FS |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 186 | { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 187 | .procname = "stats_clear", |
| 188 | .data = &xfs_params.stats_clear.val, |
| 189 | .maxlen = sizeof(int), |
| 190 | .mode = 0644, |
Eric W. Biederman | 6d45611 | 2009-11-16 03:11:48 -0800 | [diff] [blame] | 191 | .proc_handler = xfs_stats_clear_proc_handler, |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 192 | .extra1 = &xfs_params.stats_clear.min, |
| 193 | .extra2 = &xfs_params.stats_clear.max |
| 194 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | #endif /* CONFIG_PROC_FS */ |
| 196 | |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 197 | {} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | }; |
| 199 | |
David Chinner | 7989cb8 | 2007-02-10 18:34:56 +1100 | [diff] [blame] | 200 | static ctl_table xfs_dir_table[] = { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 201 | { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 202 | .procname = "xfs", |
| 203 | .mode = 0555, |
| 204 | .child = xfs_table |
| 205 | }, |
| 206 | {} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | }; |
| 208 | |
David Chinner | 7989cb8 | 2007-02-10 18:34:56 +1100 | [diff] [blame] | 209 | static ctl_table xfs_root_table[] = { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 210 | { |
Eric W. Biederman | 3a68cbf | 2007-02-10 18:36:59 +1100 | [diff] [blame] | 211 | .procname = "fs", |
| 212 | .mode = 0555, |
| 213 | .child = xfs_dir_table |
| 214 | }, |
| 215 | {} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | }; |
| 217 | |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 218 | int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | xfs_sysctl_register(void) |
| 220 | { |
Eric W. Biederman | 0b4d414 | 2007-02-14 00:34:09 -0800 | [diff] [blame] | 221 | xfs_table_header = register_sysctl_table(xfs_root_table); |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 222 | if (!xfs_table_header) |
| 223 | return -ENOMEM; |
| 224 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | void |
| 228 | xfs_sysctl_unregister(void) |
| 229 | { |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 230 | unregister_sysctl_table(xfs_table_header); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | } |