blob: a02564972420b7720c21a3996afcb5d078e2c070 [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>
21
Linus Torvalds1da177e2005-04-16 15:20:36 -070022static struct ctl_table_header *xfs_table_header;
23
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#ifdef CONFIG_PROC_FS
25STATIC int
26xfs_stats_clear_proc_handler(
27 ctl_table *ctl,
28 int write,
29 struct file *filp,
30 void __user *buffer,
31 size_t *lenp,
32 loff_t *ppos)
33{
34 int c, ret, *valp = ctl->data;
35 __uint32_t vn_active;
36
37 ret = proc_dointvec_minmax(ctl, write, filp, buffer, lenp, ppos);
38
39 if (!ret && write && *valp) {
40 printk("XFS Clearing xfsstats\n");
41 for (c = 0; c < NR_CPUS; c++) {
42 if (!cpu_possible(c)) continue;
43 preempt_disable();
44 /* save vn_active, it's a universal truth! */
45 vn_active = per_cpu(xfsstats, c).vn_active;
46 memset(&per_cpu(xfsstats, c), 0,
47 sizeof(struct xfsstats));
48 per_cpu(xfsstats, c).vn_active = vn_active;
49 preempt_enable();
50 }
51 xfs_stats_clear = 0;
52 }
53
54 return ret;
55}
56#endif /* CONFIG_PROC_FS */
57
58STATIC ctl_table xfs_table[] = {
59 {XFS_RESTRICT_CHOWN, "restrict_chown", &xfs_params.restrict_chown.val,
60 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
Nathan Scotta844f452005-11-02 14:38:42 +110061 &sysctl_intvec, NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 &xfs_params.restrict_chown.min, &xfs_params.restrict_chown.max},
63
64 {XFS_SGID_INHERIT, "irix_sgid_inherit", &xfs_params.sgid_inherit.val,
65 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
66 &sysctl_intvec, NULL,
67 &xfs_params.sgid_inherit.min, &xfs_params.sgid_inherit.max},
68
69 {XFS_SYMLINK_MODE, "irix_symlink_mode", &xfs_params.symlink_mode.val,
70 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
Nathan Scotta844f452005-11-02 14:38:42 +110071 &sysctl_intvec, NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 &xfs_params.symlink_mode.min, &xfs_params.symlink_mode.max},
73
74 {XFS_PANIC_MASK, "panic_mask", &xfs_params.panic_mask.val,
75 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
Nathan Scotta844f452005-11-02 14:38:42 +110076 &sysctl_intvec, NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 &xfs_params.panic_mask.min, &xfs_params.panic_mask.max},
78
79 {XFS_ERRLEVEL, "error_level", &xfs_params.error_level.val,
80 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
Nathan Scotta844f452005-11-02 14:38:42 +110081 &sysctl_intvec, NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 &xfs_params.error_level.min, &xfs_params.error_level.max},
83
84 {XFS_SYNCD_TIMER, "xfssyncd_centisecs", &xfs_params.syncd_timer.val,
85 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
Nathan Scotta844f452005-11-02 14:38:42 +110086 &sysctl_intvec, NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 &xfs_params.syncd_timer.min, &xfs_params.syncd_timer.max},
88
89 {XFS_INHERIT_SYNC, "inherit_sync", &xfs_params.inherit_sync.val,
90 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
91 &sysctl_intvec, NULL,
92 &xfs_params.inherit_sync.min, &xfs_params.inherit_sync.max},
93
94 {XFS_INHERIT_NODUMP, "inherit_nodump", &xfs_params.inherit_nodump.val,
95 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
96 &sysctl_intvec, NULL,
97 &xfs_params.inherit_nodump.min, &xfs_params.inherit_nodump.max},
98
99 {XFS_INHERIT_NOATIME, "inherit_noatime", &xfs_params.inherit_noatim.val,
100 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
101 &sysctl_intvec, NULL,
102 &xfs_params.inherit_noatim.min, &xfs_params.inherit_noatim.max},
Nathan Scotta844f452005-11-02 14:38:42 +1100103
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 {XFS_BUF_TIMER, "xfsbufd_centisecs", &xfs_params.xfs_buf_timer.val,
105 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
106 &sysctl_intvec, NULL,
107 &xfs_params.xfs_buf_timer.min, &xfs_params.xfs_buf_timer.max},
108
109 {XFS_BUF_AGE, "age_buffer_centisecs", &xfs_params.xfs_buf_age.val,
110 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
111 &sysctl_intvec, NULL,
112 &xfs_params.xfs_buf_age.min, &xfs_params.xfs_buf_age.max},
113
114 {XFS_INHERIT_NOSYM, "inherit_nosymlinks", &xfs_params.inherit_nosym.val,
115 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
116 &sysctl_intvec, NULL,
117 &xfs_params.inherit_nosym.min, &xfs_params.inherit_nosym.max},
118
119 {XFS_ROTORSTEP, "rotorstep", &xfs_params.rotorstep.val,
120 sizeof(int), 0644, NULL, &proc_dointvec_minmax,
Nathan Scotta844f452005-11-02 14:38:42 +1100121 &sysctl_intvec, NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 &xfs_params.rotorstep.min, &xfs_params.rotorstep.max},
123
124 /* please keep this the last entry */
125#ifdef CONFIG_PROC_FS
126 {XFS_STATS_CLEAR, "stats_clear", &xfs_params.stats_clear.val,
127 sizeof(int), 0644, NULL, &xfs_stats_clear_proc_handler,
Nathan Scotta844f452005-11-02 14:38:42 +1100128 &sysctl_intvec, NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 &xfs_params.stats_clear.min, &xfs_params.stats_clear.max},
130#endif /* CONFIG_PROC_FS */
131
132 {0}
133};
134
135STATIC ctl_table xfs_dir_table[] = {
136 {FS_XFS, "xfs", NULL, 0, 0555, xfs_table},
137 {0}
138};
139
140STATIC ctl_table xfs_root_table[] = {
141 {CTL_FS, "fs", NULL, 0, 0555, xfs_dir_table},
142 {0}
143};
144
145void
146xfs_sysctl_register(void)
147{
148 xfs_table_header = register_sysctl_table(xfs_root_table, 1);
149}
150
151void
152xfs_sysctl_unregister(void)
153{
154 if (xfs_table_header)
155 unregister_sysctl_table(xfs_table_header);
156}