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