blob: afe1f66aaa6980a682ae6a736351115a5ae87ac1 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scott7b718762005-11-02 14:58:39 +11002 * Copyright (c) 2001-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Nathan Scott7b718762005-11-02 14:58:39 +11005 * 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 Torvalds1da177e2005-04-16 15:20:36 -07007 * published by the Free Software Foundation.
8 *
Nathan Scott7b718762005-11-02 14:58:39 +11009 * 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 Torvalds1da177e2005-04-16 15:20:36 -070013 *
Nathan Scott7b718762005-11-02 14:58:39 +110014 * 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 Torvalds1da177e2005-04-16 15:20:36 -070017 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include "xfs.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <linux/sysctl.h>
20#include <linux/proc_fs.h>
Dave Chinner73efe4a2011-01-12 00:35:42 +000021#include "xfs_error.h"
Bill O'Donnellbb230c12015-10-12 05:15:45 +110022#include "xfs_stats.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
Linus Torvalds1da177e2005-04-16 15:20:36 -070024static struct ctl_table_header *xfs_table_header;
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#ifdef CONFIG_PROC_FS
27STATIC int
28xfs_stats_clear_proc_handler(
Joe Perchesb2410e92013-06-13 19:37:50 -070029 struct ctl_table *ctl,
30 int write,
31 void __user *buffer,
32 size_t *lenp,
33 loff_t *ppos)
Linus Torvalds1da177e2005-04-16 15:20:36 -070034{
Bill O'Donnellbb230c12015-10-12 05:15:45 +110035 int ret, *valp = ctl->data;
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Alexey Dobriyan8d65af72009-09-23 15:57:19 -070037 ret = proc_dointvec_minmax(ctl, write, buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39 if (!ret && write && *valp) {
Bill O'Donnell80529c42015-10-12 05:19:45 +110040 xfs_stats_clearall(xfsstats.xs_stats);
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 xfs_stats_clear = 0;
42 }
43
44 return ret;
45}
Dave Chinner73efe4a2011-01-12 00:35:42 +000046
47STATIC int
48xfs_panic_mask_proc_handler(
Joe Perchesb2410e92013-06-13 19:37:50 -070049 struct ctl_table *ctl,
50 int write,
51 void __user *buffer,
52 size_t *lenp,
53 loff_t *ppos)
Dave Chinner73efe4a2011-01-12 00:35:42 +000054{
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}
Linus Torvalds1da177e2005-04-16 15:20:36 -070066#endif /* CONFIG_PROC_FS */
67
Joe Perchesb2410e92013-06-13 19:37:50 -070068static struct ctl_table xfs_table[] = {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +110069 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +110070 .procname = "irix_sgid_inherit",
71 .data = &xfs_params.sgid_inherit.val,
72 .maxlen = sizeof(int),
73 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -080074 .proc_handler = proc_dointvec_minmax,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +110075 .extra1 = &xfs_params.sgid_inherit.min,
76 .extra2 = &xfs_params.sgid_inherit.max
77 },
78 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +110079 .procname = "irix_symlink_mode",
80 .data = &xfs_params.symlink_mode.val,
81 .maxlen = sizeof(int),
82 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -080083 .proc_handler = proc_dointvec_minmax,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +110084 .extra1 = &xfs_params.symlink_mode.min,
85 .extra2 = &xfs_params.symlink_mode.max
86 },
87 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +110088 .procname = "panic_mask",
89 .data = &xfs_params.panic_mask.val,
90 .maxlen = sizeof(int),
91 .mode = 0644,
Dave Chinner73efe4a2011-01-12 00:35:42 +000092 .proc_handler = xfs_panic_mask_proc_handler,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +110093 .extra1 = &xfs_params.panic_mask.min,
94 .extra2 = &xfs_params.panic_mask.max
95 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +110097 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +110098 .procname = "error_level",
99 .data = &xfs_params.error_level.val,
100 .maxlen = sizeof(int),
101 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800102 .proc_handler = proc_dointvec_minmax,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100103 .extra1 = &xfs_params.error_level.min,
104 .extra2 = &xfs_params.error_level.max
105 },
106 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100107 .procname = "xfssyncd_centisecs",
108 .data = &xfs_params.syncd_timer.val,
109 .maxlen = sizeof(int),
110 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800111 .proc_handler = proc_dointvec_minmax,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100112 .extra1 = &xfs_params.syncd_timer.min,
113 .extra2 = &xfs_params.syncd_timer.max
114 },
115 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100116 .procname = "inherit_sync",
117 .data = &xfs_params.inherit_sync.val,
118 .maxlen = sizeof(int),
119 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800120 .proc_handler = proc_dointvec_minmax,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100121 .extra1 = &xfs_params.inherit_sync.min,
122 .extra2 = &xfs_params.inherit_sync.max
123 },
124 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100125 .procname = "inherit_nodump",
126 .data = &xfs_params.inherit_nodump.val,
127 .maxlen = sizeof(int),
128 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800129 .proc_handler = proc_dointvec_minmax,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100130 .extra1 = &xfs_params.inherit_nodump.min,
131 .extra2 = &xfs_params.inherit_nodump.max
132 },
133 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100134 .procname = "inherit_noatime",
135 .data = &xfs_params.inherit_noatim.val,
136 .maxlen = sizeof(int),
137 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800138 .proc_handler = proc_dointvec_minmax,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100139 .extra1 = &xfs_params.inherit_noatim.min,
140 .extra2 = &xfs_params.inherit_noatim.max
141 },
142 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100143 .procname = "inherit_nosymlinks",
144 .data = &xfs_params.inherit_nosym.val,
145 .maxlen = sizeof(int),
146 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800147 .proc_handler = proc_dointvec_minmax,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100148 .extra1 = &xfs_params.inherit_nosym.min,
149 .extra2 = &xfs_params.inherit_nosym.max
150 },
151 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100152 .procname = "rotorstep",
153 .data = &xfs_params.rotorstep.val,
154 .maxlen = sizeof(int),
155 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800156 .proc_handler = proc_dointvec_minmax,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100157 .extra1 = &xfs_params.rotorstep.min,
158 .extra2 = &xfs_params.rotorstep.max
159 },
160 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100161 .procname = "inherit_nodefrag",
162 .data = &xfs_params.inherit_nodfrg.val,
163 .maxlen = sizeof(int),
164 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800165 .proc_handler = proc_dointvec_minmax,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100166 .extra1 = &xfs_params.inherit_nodfrg.min,
167 .extra2 = &xfs_params.inherit_nodfrg.max
168 },
David Chinner2a82b8b2007-07-11 11:09:12 +1000169 {
David Chinner2a82b8b2007-07-11 11:09:12 +1000170 .procname = "filestream_centisecs",
171 .data = &xfs_params.fstrm_timer.val,
172 .maxlen = sizeof(int),
173 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800174 .proc_handler = proc_dointvec_minmax,
David Chinner2a82b8b2007-07-11 11:09:12 +1000175 .extra1 = &xfs_params.fstrm_timer.min,
176 .extra2 = &xfs_params.fstrm_timer.max,
177 },
Brian Foster579b62f2012-11-06 09:50:47 -0500178 {
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 },
Darrick J. Wong83104d42016-10-03 09:11:46 -0700187 {
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 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 /* please keep this the last entry */
197#ifdef CONFIG_PROC_FS
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100198 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100199 .procname = "stats_clear",
200 .data = &xfs_params.stats_clear.val,
201 .maxlen = sizeof(int),
202 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800203 .proc_handler = xfs_stats_clear_proc_handler,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100204 .extra1 = &xfs_params.stats_clear.min,
205 .extra2 = &xfs_params.stats_clear.max
206 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207#endif /* CONFIG_PROC_FS */
208
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100209 {}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210};
211
Joe Perchesb2410e92013-06-13 19:37:50 -0700212static struct ctl_table xfs_dir_table[] = {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100213 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100214 .procname = "xfs",
215 .mode = 0555,
216 .child = xfs_table
217 },
218 {}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219};
220
Joe Perchesb2410e92013-06-13 19:37:50 -0700221static struct ctl_table xfs_root_table[] = {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100222 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100223 .procname = "fs",
224 .mode = 0555,
225 .child = xfs_dir_table
226 },
227 {}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228};
229
Christoph Hellwig9f8868f2008-07-18 17:11:46 +1000230int
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231xfs_sysctl_register(void)
232{
Eric W. Biederman0b4d4142007-02-14 00:34:09 -0800233 xfs_table_header = register_sysctl_table(xfs_root_table);
Christoph Hellwig9f8868f2008-07-18 17:11:46 +1000234 if (!xfs_table_header)
235 return -ENOMEM;
236 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237}
238
239void
240xfs_sysctl_unregister(void)
241{
Christoph Hellwig9f8868f2008-07-18 17:11:46 +1000242 unregister_sysctl_table(xfs_table_header);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243}