Loading...
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#include "xfs_error.h"
22
23static struct ctl_table_header *xfs_table_header;
24
25#ifdef CONFIG_PROC_FS
26STATIC int
27xfs_stats_clear_proc_handler(
28 struct ctl_table *ctl,
29 int write,
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, buffer, lenp, ppos);
38
39 if (!ret && write && *valp) {
40 xfs_notice(NULL, "Clearing xfsstats");
41 for_each_possible_cpu(c) {
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
56STATIC int
57xfs_panic_mask_proc_handler(
58 struct ctl_table *ctl,
59 int write,
60 void __user *buffer,
61 size_t *lenp,
62 loff_t *ppos)
63{
64 int ret, *valp = ctl->data;
65
66 ret = proc_dointvec_minmax(ctl, write, buffer, lenp, ppos);
67 if (!ret && write) {
68 xfs_panic_mask = *valp;
69#ifdef DEBUG
70 xfs_panic_mask |= (XFS_PTAG_SHUTDOWN_CORRUPT | XFS_PTAG_LOGRES);
71#endif
72 }
73 return ret;
74}
75#endif /* CONFIG_PROC_FS */
76
77static struct ctl_table xfs_table[] = {
78 {
79 .procname = "irix_sgid_inherit",
80 .data = &xfs_params.sgid_inherit.val,
81 .maxlen = sizeof(int),
82 .mode = 0644,
83 .proc_handler = proc_dointvec_minmax,
84 .extra1 = &xfs_params.sgid_inherit.min,
85 .extra2 = &xfs_params.sgid_inherit.max
86 },
87 {
88 .procname = "irix_symlink_mode",
89 .data = &xfs_params.symlink_mode.val,
90 .maxlen = sizeof(int),
91 .mode = 0644,
92 .proc_handler = proc_dointvec_minmax,
93 .extra1 = &xfs_params.symlink_mode.min,
94 .extra2 = &xfs_params.symlink_mode.max
95 },
96 {
97 .procname = "panic_mask",
98 .data = &xfs_params.panic_mask.val,
99 .maxlen = sizeof(int),
100 .mode = 0644,
101 .proc_handler = xfs_panic_mask_proc_handler,
102 .extra1 = &xfs_params.panic_mask.min,
103 .extra2 = &xfs_params.panic_mask.max
104 },
105
106 {
107 .procname = "error_level",
108 .data = &xfs_params.error_level.val,
109 .maxlen = sizeof(int),
110 .mode = 0644,
111 .proc_handler = proc_dointvec_minmax,
112 .extra1 = &xfs_params.error_level.min,
113 .extra2 = &xfs_params.error_level.max
114 },
115 {
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 .extra1 = &xfs_params.syncd_timer.min,
122 .extra2 = &xfs_params.syncd_timer.max
123 },
124 {
125 .procname = "inherit_sync",
126 .data = &xfs_params.inherit_sync.val,
127 .maxlen = sizeof(int),
128 .mode = 0644,
129 .proc_handler = proc_dointvec_minmax,
130 .extra1 = &xfs_params.inherit_sync.min,
131 .extra2 = &xfs_params.inherit_sync.max
132 },
133 {
134 .procname = "inherit_nodump",
135 .data = &xfs_params.inherit_nodump.val,
136 .maxlen = sizeof(int),
137 .mode = 0644,
138 .proc_handler = proc_dointvec_minmax,
139 .extra1 = &xfs_params.inherit_nodump.min,
140 .extra2 = &xfs_params.inherit_nodump.max
141 },
142 {
143 .procname = "inherit_noatime",
144 .data = &xfs_params.inherit_noatim.val,
145 .maxlen = sizeof(int),
146 .mode = 0644,
147 .proc_handler = proc_dointvec_minmax,
148 .extra1 = &xfs_params.inherit_noatim.min,
149 .extra2 = &xfs_params.inherit_noatim.max
150 },
151 {
152 .procname = "xfsbufd_centisecs",
153 .data = &xfs_params.xfs_buf_timer.val,
154 .maxlen = sizeof(int),
155 .mode = 0644,
156 .proc_handler = proc_dointvec_minmax,
157 .extra1 = &xfs_params.xfs_buf_timer.min,
158 .extra2 = &xfs_params.xfs_buf_timer.max
159 },
160 {
161 .procname = "age_buffer_centisecs",
162 .data = &xfs_params.xfs_buf_age.val,
163 .maxlen = sizeof(int),
164 .mode = 0644,
165 .proc_handler = proc_dointvec_minmax,
166 .extra1 = &xfs_params.xfs_buf_age.min,
167 .extra2 = &xfs_params.xfs_buf_age.max
168 },
169 {
170 .procname = "inherit_nosymlinks",
171 .data = &xfs_params.inherit_nosym.val,
172 .maxlen = sizeof(int),
173 .mode = 0644,
174 .proc_handler = proc_dointvec_minmax,
175 .extra1 = &xfs_params.inherit_nosym.min,
176 .extra2 = &xfs_params.inherit_nosym.max
177 },
178 {
179 .procname = "rotorstep",
180 .data = &xfs_params.rotorstep.val,
181 .maxlen = sizeof(int),
182 .mode = 0644,
183 .proc_handler = proc_dointvec_minmax,
184 .extra1 = &xfs_params.rotorstep.min,
185 .extra2 = &xfs_params.rotorstep.max
186 },
187 {
188 .procname = "inherit_nodefrag",
189 .data = &xfs_params.inherit_nodfrg.val,
190 .maxlen = sizeof(int),
191 .mode = 0644,
192 .proc_handler = proc_dointvec_minmax,
193 .extra1 = &xfs_params.inherit_nodfrg.min,
194 .extra2 = &xfs_params.inherit_nodfrg.max
195 },
196 {
197 .procname = "filestream_centisecs",
198 .data = &xfs_params.fstrm_timer.val,
199 .maxlen = sizeof(int),
200 .mode = 0644,
201 .proc_handler = proc_dointvec_minmax,
202 .extra1 = &xfs_params.fstrm_timer.min,
203 .extra2 = &xfs_params.fstrm_timer.max,
204 },
205 {
206 .procname = "speculative_prealloc_lifetime",
207 .data = &xfs_params.eofb_timer.val,
208 .maxlen = sizeof(int),
209 .mode = 0644,
210 .proc_handler = proc_dointvec_minmax,
211 .extra1 = &xfs_params.eofb_timer.min,
212 .extra2 = &xfs_params.eofb_timer.max,
213 },
214 /* please keep this the last entry */
215#ifdef CONFIG_PROC_FS
216 {
217 .procname = "stats_clear",
218 .data = &xfs_params.stats_clear.val,
219 .maxlen = sizeof(int),
220 .mode = 0644,
221 .proc_handler = xfs_stats_clear_proc_handler,
222 .extra1 = &xfs_params.stats_clear.min,
223 .extra2 = &xfs_params.stats_clear.max
224 },
225#endif /* CONFIG_PROC_FS */
226
227 {}
228};
229
230static struct ctl_table xfs_dir_table[] = {
231 {
232 .procname = "xfs",
233 .mode = 0555,
234 .child = xfs_table
235 },
236 {}
237};
238
239static struct ctl_table xfs_root_table[] = {
240 {
241 .procname = "fs",
242 .mode = 0555,
243 .child = xfs_dir_table
244 },
245 {}
246};
247
248int
249xfs_sysctl_register(void)
250{
251 xfs_table_header = register_sysctl_table(xfs_root_table);
252 if (!xfs_table_header)
253 return -ENOMEM;
254 return 0;
255}
256
257void
258xfs_sysctl_unregister(void)
259{
260 unregister_sysctl_table(xfs_table_header);
261}
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2001-2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
5 */
6#include "xfs.h"
7#include "xfs_error.h"
8
9static struct ctl_table_header *xfs_table_header;
10
11#ifdef CONFIG_PROC_FS
12STATIC int
13xfs_stats_clear_proc_handler(
14 struct ctl_table *ctl,
15 int write,
16 void __user *buffer,
17 size_t *lenp,
18 loff_t *ppos)
19{
20 int ret, *valp = ctl->data;
21
22 ret = proc_dointvec_minmax(ctl, write, buffer, lenp, ppos);
23
24 if (!ret && write && *valp) {
25 xfs_stats_clearall(xfsstats.xs_stats);
26 xfs_stats_clear = 0;
27 }
28
29 return ret;
30}
31
32STATIC int
33xfs_panic_mask_proc_handler(
34 struct ctl_table *ctl,
35 int write,
36 void __user *buffer,
37 size_t *lenp,
38 loff_t *ppos)
39{
40 int ret, *valp = ctl->data;
41
42 ret = proc_dointvec_minmax(ctl, write, buffer, lenp, ppos);
43 if (!ret && write) {
44 xfs_panic_mask = *valp;
45#ifdef DEBUG
46 xfs_panic_mask |= (XFS_PTAG_SHUTDOWN_CORRUPT | XFS_PTAG_LOGRES);
47#endif
48 }
49 return ret;
50}
51#endif /* CONFIG_PROC_FS */
52
53static struct ctl_table xfs_table[] = {
54 {
55 .procname = "irix_sgid_inherit",
56 .data = &xfs_params.sgid_inherit.val,
57 .maxlen = sizeof(int),
58 .mode = 0644,
59 .proc_handler = proc_dointvec_minmax,
60 .extra1 = &xfs_params.sgid_inherit.min,
61 .extra2 = &xfs_params.sgid_inherit.max
62 },
63 {
64 .procname = "irix_symlink_mode",
65 .data = &xfs_params.symlink_mode.val,
66 .maxlen = sizeof(int),
67 .mode = 0644,
68 .proc_handler = proc_dointvec_minmax,
69 .extra1 = &xfs_params.symlink_mode.min,
70 .extra2 = &xfs_params.symlink_mode.max
71 },
72 {
73 .procname = "panic_mask",
74 .data = &xfs_params.panic_mask.val,
75 .maxlen = sizeof(int),
76 .mode = 0644,
77 .proc_handler = xfs_panic_mask_proc_handler,
78 .extra1 = &xfs_params.panic_mask.min,
79 .extra2 = &xfs_params.panic_mask.max
80 },
81
82 {
83 .procname = "error_level",
84 .data = &xfs_params.error_level.val,
85 .maxlen = sizeof(int),
86 .mode = 0644,
87 .proc_handler = proc_dointvec_minmax,
88 .extra1 = &xfs_params.error_level.min,
89 .extra2 = &xfs_params.error_level.max
90 },
91 {
92 .procname = "xfssyncd_centisecs",
93 .data = &xfs_params.syncd_timer.val,
94 .maxlen = sizeof(int),
95 .mode = 0644,
96 .proc_handler = proc_dointvec_minmax,
97 .extra1 = &xfs_params.syncd_timer.min,
98 .extra2 = &xfs_params.syncd_timer.max
99 },
100 {
101 .procname = "inherit_sync",
102 .data = &xfs_params.inherit_sync.val,
103 .maxlen = sizeof(int),
104 .mode = 0644,
105 .proc_handler = proc_dointvec_minmax,
106 .extra1 = &xfs_params.inherit_sync.min,
107 .extra2 = &xfs_params.inherit_sync.max
108 },
109 {
110 .procname = "inherit_nodump",
111 .data = &xfs_params.inherit_nodump.val,
112 .maxlen = sizeof(int),
113 .mode = 0644,
114 .proc_handler = proc_dointvec_minmax,
115 .extra1 = &xfs_params.inherit_nodump.min,
116 .extra2 = &xfs_params.inherit_nodump.max
117 },
118 {
119 .procname = "inherit_noatime",
120 .data = &xfs_params.inherit_noatim.val,
121 .maxlen = sizeof(int),
122 .mode = 0644,
123 .proc_handler = proc_dointvec_minmax,
124 .extra1 = &xfs_params.inherit_noatim.min,
125 .extra2 = &xfs_params.inherit_noatim.max
126 },
127 {
128 .procname = "inherit_nosymlinks",
129 .data = &xfs_params.inherit_nosym.val,
130 .maxlen = sizeof(int),
131 .mode = 0644,
132 .proc_handler = proc_dointvec_minmax,
133 .extra1 = &xfs_params.inherit_nosym.min,
134 .extra2 = &xfs_params.inherit_nosym.max
135 },
136 {
137 .procname = "rotorstep",
138 .data = &xfs_params.rotorstep.val,
139 .maxlen = sizeof(int),
140 .mode = 0644,
141 .proc_handler = proc_dointvec_minmax,
142 .extra1 = &xfs_params.rotorstep.min,
143 .extra2 = &xfs_params.rotorstep.max
144 },
145 {
146 .procname = "inherit_nodefrag",
147 .data = &xfs_params.inherit_nodfrg.val,
148 .maxlen = sizeof(int),
149 .mode = 0644,
150 .proc_handler = proc_dointvec_minmax,
151 .extra1 = &xfs_params.inherit_nodfrg.min,
152 .extra2 = &xfs_params.inherit_nodfrg.max
153 },
154 {
155 .procname = "filestream_centisecs",
156 .data = &xfs_params.fstrm_timer.val,
157 .maxlen = sizeof(int),
158 .mode = 0644,
159 .proc_handler = proc_dointvec_minmax,
160 .extra1 = &xfs_params.fstrm_timer.min,
161 .extra2 = &xfs_params.fstrm_timer.max,
162 },
163 {
164 .procname = "speculative_prealloc_lifetime",
165 .data = &xfs_params.eofb_timer.val,
166 .maxlen = sizeof(int),
167 .mode = 0644,
168 .proc_handler = proc_dointvec_minmax,
169 .extra1 = &xfs_params.eofb_timer.min,
170 .extra2 = &xfs_params.eofb_timer.max,
171 },
172 {
173 .procname = "speculative_cow_prealloc_lifetime",
174 .data = &xfs_params.cowb_timer.val,
175 .maxlen = sizeof(int),
176 .mode = 0644,
177 .proc_handler = proc_dointvec_minmax,
178 .extra1 = &xfs_params.cowb_timer.min,
179 .extra2 = &xfs_params.cowb_timer.max,
180 },
181 /* please keep this the last entry */
182#ifdef CONFIG_PROC_FS
183 {
184 .procname = "stats_clear",
185 .data = &xfs_params.stats_clear.val,
186 .maxlen = sizeof(int),
187 .mode = 0644,
188 .proc_handler = xfs_stats_clear_proc_handler,
189 .extra1 = &xfs_params.stats_clear.min,
190 .extra2 = &xfs_params.stats_clear.max
191 },
192#endif /* CONFIG_PROC_FS */
193
194 {}
195};
196
197static struct ctl_table xfs_dir_table[] = {
198 {
199 .procname = "xfs",
200 .mode = 0555,
201 .child = xfs_table
202 },
203 {}
204};
205
206static struct ctl_table xfs_root_table[] = {
207 {
208 .procname = "fs",
209 .mode = 0555,
210 .child = xfs_dir_table
211 },
212 {}
213};
214
215int
216xfs_sysctl_register(void)
217{
218 xfs_table_header = register_sysctl_table(xfs_root_table);
219 if (!xfs_table_header)
220 return -ENOMEM;
221 return 0;
222}
223
224void
225xfs_sysctl_unregister(void)
226{
227 unregister_sysctl_table(xfs_table_header);
228}