Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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 const 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 const 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 inline int
54xfs_deprecated_dointvec_minmax(
55 const 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 const struct ctl_table xfs_table[] = {
70 {
71 .procname = "panic_mask",
72 .data = &xfs_params.panic_mask.val,
73 .maxlen = sizeof(int),
74 .mode = 0644,
75 .proc_handler = xfs_panic_mask_proc_handler,
76 .extra1 = &xfs_params.panic_mask.min,
77 .extra2 = &xfs_params.panic_mask.max
78 },
79
80 {
81 .procname = "error_level",
82 .data = &xfs_params.error_level.val,
83 .maxlen = sizeof(int),
84 .mode = 0644,
85 .proc_handler = proc_dointvec_minmax,
86 .extra1 = &xfs_params.error_level.min,
87 .extra2 = &xfs_params.error_level.max
88 },
89 {
90 .procname = "xfssyncd_centisecs",
91 .data = &xfs_params.syncd_timer.val,
92 .maxlen = sizeof(int),
93 .mode = 0644,
94 .proc_handler = proc_dointvec_minmax,
95 .extra1 = &xfs_params.syncd_timer.min,
96 .extra2 = &xfs_params.syncd_timer.max
97 },
98 {
99 .procname = "inherit_sync",
100 .data = &xfs_params.inherit_sync.val,
101 .maxlen = sizeof(int),
102 .mode = 0644,
103 .proc_handler = proc_dointvec_minmax,
104 .extra1 = &xfs_params.inherit_sync.min,
105 .extra2 = &xfs_params.inherit_sync.max
106 },
107 {
108 .procname = "inherit_nodump",
109 .data = &xfs_params.inherit_nodump.val,
110 .maxlen = sizeof(int),
111 .mode = 0644,
112 .proc_handler = proc_dointvec_minmax,
113 .extra1 = &xfs_params.inherit_nodump.min,
114 .extra2 = &xfs_params.inherit_nodump.max
115 },
116 {
117 .procname = "inherit_noatime",
118 .data = &xfs_params.inherit_noatim.val,
119 .maxlen = sizeof(int),
120 .mode = 0644,
121 .proc_handler = proc_dointvec_minmax,
122 .extra1 = &xfs_params.inherit_noatim.min,
123 .extra2 = &xfs_params.inherit_noatim.max
124 },
125 {
126 .procname = "inherit_nosymlinks",
127 .data = &xfs_params.inherit_nosym.val,
128 .maxlen = sizeof(int),
129 .mode = 0644,
130 .proc_handler = proc_dointvec_minmax,
131 .extra1 = &xfs_params.inherit_nosym.min,
132 .extra2 = &xfs_params.inherit_nosym.max
133 },
134 {
135 .procname = "rotorstep",
136 .data = &xfs_params.rotorstep.val,
137 .maxlen = sizeof(int),
138 .mode = 0644,
139 .proc_handler = proc_dointvec_minmax,
140 .extra1 = &xfs_params.rotorstep.min,
141 .extra2 = &xfs_params.rotorstep.max
142 },
143 {
144 .procname = "inherit_nodefrag",
145 .data = &xfs_params.inherit_nodfrg.val,
146 .maxlen = sizeof(int),
147 .mode = 0644,
148 .proc_handler = proc_dointvec_minmax,
149 .extra1 = &xfs_params.inherit_nodfrg.min,
150 .extra2 = &xfs_params.inherit_nodfrg.max
151 },
152 {
153 .procname = "filestream_centisecs",
154 .data = &xfs_params.fstrm_timer.val,
155 .maxlen = sizeof(int),
156 .mode = 0644,
157 .proc_handler = proc_dointvec_minmax,
158 .extra1 = &xfs_params.fstrm_timer.min,
159 .extra2 = &xfs_params.fstrm_timer.max,
160 },
161 {
162 .procname = "speculative_prealloc_lifetime",
163 .data = &xfs_params.blockgc_timer.val,
164 .maxlen = sizeof(int),
165 .mode = 0644,
166 .proc_handler = proc_dointvec_minmax,
167 .extra1 = &xfs_params.blockgc_timer.min,
168 .extra2 = &xfs_params.blockgc_timer.max,
169 },
170 /* please keep this the last entry */
171#ifdef CONFIG_PROC_FS
172 {
173 .procname = "stats_clear",
174 .data = &xfs_params.stats_clear.val,
175 .maxlen = sizeof(int),
176 .mode = 0644,
177 .proc_handler = xfs_stats_clear_proc_handler,
178 .extra1 = &xfs_params.stats_clear.min,
179 .extra2 = &xfs_params.stats_clear.max
180 },
181#endif /* CONFIG_PROC_FS */
182};
183
184int
185xfs_sysctl_register(void)
186{
187 xfs_table_header = register_sysctl("fs/xfs", xfs_table);
188 if (!xfs_table_header)
189 return -ENOMEM;
190 return 0;
191}
192
193void
194xfs_sysctl_unregister(void)
195{
196 unregister_sysctl_table(xfs_table_header);
197}