blob: c84df23b494d358af8fe41b6fad51e02c8372927 [file] [log] [blame]
Dave Chinner0b61f8a2018-06-05 19:42:14 -07001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Nathan Scott7b718762005-11-02 14:58:39 +11003 * Copyright (c) 2001-2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006#include "xfs.h"
Dave Chinner73efe4a2011-01-12 00:35:42 +00007#include "xfs_error.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
Linus Torvalds1da177e2005-04-16 15:20:36 -07009static struct ctl_table_header *xfs_table_header;
10
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#ifdef CONFIG_PROC_FS
12STATIC int
13xfs_stats_clear_proc_handler(
Joel Granados78eb4ea2024-07-24 20:59:29 +020014 const struct ctl_table *ctl,
Joe Perchesb2410e92013-06-13 19:37:50 -070015 int write,
Christoph Hellwig32927392020-04-24 08:43:38 +020016 void *buffer,
Joe Perchesb2410e92013-06-13 19:37:50 -070017 size_t *lenp,
18 loff_t *ppos)
Linus Torvalds1da177e2005-04-16 15:20:36 -070019{
Bill O'Donnellbb230c12015-10-12 05:15:45 +110020 int ret, *valp = ctl->data;
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
Alexey Dobriyan8d65af72009-09-23 15:57:19 -070022 ret = proc_dointvec_minmax(ctl, write, buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
24 if (!ret && write && *valp) {
Bill O'Donnell80529c42015-10-12 05:19:45 +110025 xfs_stats_clearall(xfsstats.xs_stats);
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 xfs_stats_clear = 0;
27 }
28
29 return ret;
30}
Dave Chinner73efe4a2011-01-12 00:35:42 +000031
32STATIC int
33xfs_panic_mask_proc_handler(
Joel Granados78eb4ea2024-07-24 20:59:29 +020034 const struct ctl_table *ctl,
Joe Perchesb2410e92013-06-13 19:37:50 -070035 int write,
Christoph Hellwig32927392020-04-24 08:43:38 +020036 void *buffer,
Joe Perchesb2410e92013-06-13 19:37:50 -070037 size_t *lenp,
38 loff_t *ppos)
Dave Chinner73efe4a2011-01-12 00:35:42 +000039{
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}
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#endif /* CONFIG_PROC_FS */
52
Pavel Reichl3442de92020-09-25 11:11:37 -070053STATIC int
Darrick J. Wong89e0eb82021-02-12 09:14:47 -080054xfs_deprecated_dointvec_minmax(
Joel Granados78eb4ea2024-07-24 20:59:29 +020055 const struct ctl_table *ctl,
Pavel Reichl3442de92020-09-25 11:11:37 -070056 int write,
57 void *buffer,
58 size_t *lenp,
59 loff_t *ppos)
60{
61 if (write) {
Darrick J. Wong89e0eb82021-02-12 09:14:47 -080062 printk_ratelimited(KERN_WARNING
63 "XFS: %s sysctl option is deprecated.\n",
Pavel Reichl3442de92020-09-25 11:11:37 -070064 ctl->procname);
65 }
66 return proc_dointvec_minmax(ctl, write, buffer, lenp, ppos);
67}
68
Joe Perchesb2410e92013-06-13 19:37:50 -070069static struct ctl_table xfs_table[] = {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +110070 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +110071 .procname = "irix_sgid_inherit",
72 .data = &xfs_params.sgid_inherit.val,
73 .maxlen = sizeof(int),
74 .mode = 0644,
Darrick J. Wong89e0eb82021-02-12 09:14:47 -080075 .proc_handler = xfs_deprecated_dointvec_minmax,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +110076 .extra1 = &xfs_params.sgid_inherit.min,
77 .extra2 = &xfs_params.sgid_inherit.max
78 },
79 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +110080 .procname = "irix_symlink_mode",
81 .data = &xfs_params.symlink_mode.val,
82 .maxlen = sizeof(int),
83 .mode = 0644,
Darrick J. Wong89e0eb82021-02-12 09:14:47 -080084 .proc_handler = xfs_deprecated_dointvec_minmax,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +110085 .extra1 = &xfs_params.symlink_mode.min,
86 .extra2 = &xfs_params.symlink_mode.max
87 },
88 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +110089 .procname = "panic_mask",
90 .data = &xfs_params.panic_mask.val,
91 .maxlen = sizeof(int),
92 .mode = 0644,
Dave Chinner73efe4a2011-01-12 00:35:42 +000093 .proc_handler = xfs_panic_mask_proc_handler,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +110094 .extra1 = &xfs_params.panic_mask.min,
95 .extra2 = &xfs_params.panic_mask.max
96 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070097
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +110098 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +110099 .procname = "error_level",
100 .data = &xfs_params.error_level.val,
101 .maxlen = sizeof(int),
102 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800103 .proc_handler = proc_dointvec_minmax,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100104 .extra1 = &xfs_params.error_level.min,
105 .extra2 = &xfs_params.error_level.max
106 },
107 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100108 .procname = "xfssyncd_centisecs",
109 .data = &xfs_params.syncd_timer.val,
110 .maxlen = sizeof(int),
111 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800112 .proc_handler = proc_dointvec_minmax,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100113 .extra1 = &xfs_params.syncd_timer.min,
114 .extra2 = &xfs_params.syncd_timer.max
115 },
116 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100117 .procname = "inherit_sync",
118 .data = &xfs_params.inherit_sync.val,
119 .maxlen = sizeof(int),
120 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800121 .proc_handler = proc_dointvec_minmax,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100122 .extra1 = &xfs_params.inherit_sync.min,
123 .extra2 = &xfs_params.inherit_sync.max
124 },
125 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100126 .procname = "inherit_nodump",
127 .data = &xfs_params.inherit_nodump.val,
128 .maxlen = sizeof(int),
129 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800130 .proc_handler = proc_dointvec_minmax,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100131 .extra1 = &xfs_params.inherit_nodump.min,
132 .extra2 = &xfs_params.inherit_nodump.max
133 },
134 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100135 .procname = "inherit_noatime",
136 .data = &xfs_params.inherit_noatim.val,
137 .maxlen = sizeof(int),
138 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800139 .proc_handler = proc_dointvec_minmax,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100140 .extra1 = &xfs_params.inherit_noatim.min,
141 .extra2 = &xfs_params.inherit_noatim.max
142 },
143 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100144 .procname = "inherit_nosymlinks",
145 .data = &xfs_params.inherit_nosym.val,
146 .maxlen = sizeof(int),
147 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800148 .proc_handler = proc_dointvec_minmax,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100149 .extra1 = &xfs_params.inherit_nosym.min,
150 .extra2 = &xfs_params.inherit_nosym.max
151 },
152 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100153 .procname = "rotorstep",
154 .data = &xfs_params.rotorstep.val,
155 .maxlen = sizeof(int),
156 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800157 .proc_handler = proc_dointvec_minmax,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100158 .extra1 = &xfs_params.rotorstep.min,
159 .extra2 = &xfs_params.rotorstep.max
160 },
161 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100162 .procname = "inherit_nodefrag",
163 .data = &xfs_params.inherit_nodfrg.val,
164 .maxlen = sizeof(int),
165 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800166 .proc_handler = proc_dointvec_minmax,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100167 .extra1 = &xfs_params.inherit_nodfrg.min,
168 .extra2 = &xfs_params.inherit_nodfrg.max
169 },
David Chinner2a82b8b2007-07-11 11:09:12 +1000170 {
David Chinner2a82b8b2007-07-11 11:09:12 +1000171 .procname = "filestream_centisecs",
172 .data = &xfs_params.fstrm_timer.val,
173 .maxlen = sizeof(int),
174 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800175 .proc_handler = proc_dointvec_minmax,
David Chinner2a82b8b2007-07-11 11:09:12 +1000176 .extra1 = &xfs_params.fstrm_timer.min,
177 .extra2 = &xfs_params.fstrm_timer.max,
178 },
Brian Foster579b62f2012-11-06 09:50:47 -0500179 {
180 .procname = "speculative_prealloc_lifetime",
Darrick J. Wong9669f512021-01-22 16:48:43 -0800181 .data = &xfs_params.blockgc_timer.val,
Brian Foster579b62f2012-11-06 09:50:47 -0500182 .maxlen = sizeof(int),
183 .mode = 0644,
184 .proc_handler = proc_dointvec_minmax,
Darrick J. Wong9669f512021-01-22 16:48:43 -0800185 .extra1 = &xfs_params.blockgc_timer.min,
186 .extra2 = &xfs_params.blockgc_timer.max,
Darrick J. Wong83104d42016-10-03 09:11:46 -0700187 },
Darrick J. Wong89e0eb82021-02-12 09:14:47 -0800188 {
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 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 /* please keep this the last entry */
198#ifdef CONFIG_PROC_FS
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100199 {
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100200 .procname = "stats_clear",
201 .data = &xfs_params.stats_clear.val,
202 .maxlen = sizeof(int),
203 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800204 .proc_handler = xfs_stats_clear_proc_handler,
Eric W. Biederman3a68cbf2007-02-10 18:36:59 +1100205 .extra1 = &xfs_params.stats_clear.min,
206 .extra2 = &xfs_params.stats_clear.max
207 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208#endif /* CONFIG_PROC_FS */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209};
210
Christoph Hellwig9f8868f2008-07-18 17:11:46 +1000211int
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212xfs_sysctl_register(void)
213{
Luis Chamberlainf5d2b922023-03-10 00:42:26 -0800214 xfs_table_header = register_sysctl("fs/xfs", xfs_table);
Christoph Hellwig9f8868f2008-07-18 17:11:46 +1000215 if (!xfs_table_header)
216 return -ENOMEM;
217 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218}
219
220void
221xfs_sysctl_unregister(void)
222{
Christoph Hellwig9f8868f2008-07-18 17:11:46 +1000223 unregister_sysctl_table(xfs_table_header);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224}