This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / fs / xfs / linux / xfs_sysctl.c
1 /*
2  * Copyright (c) 2001-2002 Silicon Graphics, Inc.  All Rights Reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of version 2 of the GNU General Public License as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it would be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  *
12  * Further, this software is distributed without any warranty that it is
13  * free of the rightful claim of any third person regarding infringement
14  * or the like.  Any license provided herein, whether implied or
15  * otherwise, applies only to this software file.  Patent licenses, if
16  * any, provided herein do not apply to combinations of this program with
17  * other software, or any other product whatsoever.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write the Free Software Foundation, Inc., 59
21  * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22  *
23  * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24  * Mountain View, CA  94043, or:
25  *
26  * http://www.sgi.com
27  *
28  * For further information regarding this notice, see:
29  *
30  * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31  */
32
33 #include "xfs.h"
34 #include "xfs_rw.h"
35 #include <linux/sysctl.h>
36 #include <linux/proc_fs.h>
37
38
39 static struct ctl_table_header *xfs_table_header;
40
41
42 #ifdef CONFIG_PROC_FS
43 STATIC int
44 xfs_stats_clear_proc_handler(
45         ctl_table       *ctl,
46         int             write,
47         struct file     *filp,
48         void            *buffer,
49         size_t          *lenp)
50 {
51         int             c, ret, *valp = ctl->data;
52         __uint32_t      vn_active;
53
54         ret = proc_dointvec_minmax(ctl, write, filp, buffer, lenp);
55
56         if (!ret && write && *valp) {
57                 printk("XFS Clearing xfsstats\n");
58                 for (c = 0; c < NR_CPUS; c++) {
59                         if (!cpu_possible(c)) continue;
60                         preempt_disable();
61                         /* save vn_active, it's a universal truth! */
62                         vn_active = per_cpu(xfsstats, c).vn_active;
63                         memset(&per_cpu(xfsstats, c), 0,
64                                sizeof(struct xfsstats));
65                         per_cpu(xfsstats, c).vn_active = vn_active;
66                         preempt_enable();
67                 }
68                 xfs_stats_clear = 0;
69         }
70
71         return ret;
72 }
73 #endif /* CONFIG_PROC_FS */
74
75 STATIC ctl_table xfs_table[] = {
76         {XFS_RESTRICT_CHOWN, "restrict_chown", &xfs_params.restrict_chown.val,
77         sizeof(int), 0644, NULL, &proc_dointvec_minmax,
78         &sysctl_intvec, NULL, 
79         &xfs_params.restrict_chown.min, &xfs_params.restrict_chown.max},
80
81         {XFS_SGID_INHERIT, "irix_sgid_inherit", &xfs_params.sgid_inherit.val,
82         sizeof(int), 0644, NULL, &proc_dointvec_minmax,
83         &sysctl_intvec, NULL,
84         &xfs_params.sgid_inherit.min, &xfs_params.sgid_inherit.max},
85
86         {XFS_SYMLINK_MODE, "irix_symlink_mode", &xfs_params.symlink_mode.val,
87         sizeof(int), 0644, NULL, &proc_dointvec_minmax,
88         &sysctl_intvec, NULL, 
89         &xfs_params.symlink_mode.min, &xfs_params.symlink_mode.max},
90
91         {XFS_PANIC_MASK, "panic_mask", &xfs_params.panic_mask.val,
92         sizeof(int), 0644, NULL, &proc_dointvec_minmax,
93         &sysctl_intvec, NULL, 
94         &xfs_params.panic_mask.min, &xfs_params.panic_mask.max},
95
96         {XFS_ERRLEVEL, "error_level", &xfs_params.error_level.val,
97         sizeof(int), 0644, NULL, &proc_dointvec_minmax,
98         &sysctl_intvec, NULL, 
99         &xfs_params.error_level.min, &xfs_params.error_level.max},
100
101         {XFS_SYNC_INTERVAL, "sync_interval", &xfs_params.sync_interval.val,
102         sizeof(int), 0644, NULL, &proc_dointvec_minmax,
103         &sysctl_intvec, NULL, 
104         &xfs_params.sync_interval.min, &xfs_params.sync_interval.max},
105
106         {XFS_INHERIT_SYNC, "inherit_sync", &xfs_params.inherit_sync.val,
107         sizeof(int), 0644, NULL, &proc_dointvec_minmax,
108         &sysctl_intvec, NULL,
109         &xfs_params.inherit_sync.min, &xfs_params.inherit_sync.max},
110
111         {XFS_INHERIT_NODUMP, "inherit_nodump", &xfs_params.inherit_nodump.val,
112         sizeof(int), 0644, NULL, &proc_dointvec_minmax,
113         &sysctl_intvec, NULL,
114         &xfs_params.inherit_nodump.min, &xfs_params.inherit_nodump.max},
115
116         {XFS_INHERIT_NOATIME, "inherit_noatime", &xfs_params.inherit_noatim.val,
117         sizeof(int), 0644, NULL, &proc_dointvec_minmax,
118         &sysctl_intvec, NULL,
119         &xfs_params.inherit_noatim.min, &xfs_params.inherit_noatim.max},
120         
121         {XFS_FLUSH_INTERVAL, "flush_interval", &xfs_params.flush_interval.val,
122         sizeof(int), 0644, NULL, &proc_dointvec_minmax,
123         &sysctl_intvec, NULL,
124         &xfs_params.flush_interval.min, &xfs_params.flush_interval.max},
125
126         {XFS_AGE_BUFFER, "age_buffer", &xfs_params.age_buffer.val,
127         sizeof(int), 0644, NULL, &proc_dointvec_minmax,
128         &sysctl_intvec, NULL,
129         &xfs_params.age_buffer.min, &xfs_params.age_buffer.max},
130
131         /* please keep this the last entry */
132 #ifdef CONFIG_PROC_FS
133         {XFS_STATS_CLEAR, "stats_clear", &xfs_params.stats_clear.val,
134         sizeof(int), 0644, NULL, &xfs_stats_clear_proc_handler,
135         &sysctl_intvec, NULL, 
136         &xfs_params.stats_clear.min, &xfs_params.stats_clear.max},
137 #endif /* CONFIG_PROC_FS */
138
139         {0}
140 };
141
142 STATIC ctl_table xfs_dir_table[] = {
143         {FS_XFS, "xfs", NULL, 0, 0555, xfs_table},
144         {0}
145 };
146
147 STATIC ctl_table xfs_root_table[] = {
148         {CTL_FS, "fs",  NULL, 0, 0555, xfs_dir_table},
149         {0}
150 };
151
152 void
153 xfs_sysctl_register(void)
154 {
155         xfs_table_header = register_sysctl_table(xfs_root_table, 1);
156 }
157
158 void
159 xfs_sysctl_unregister(void)
160 {
161         if (xfs_table_header)
162                 unregister_sysctl_table(xfs_table_header);
163 }