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