2 * Sysctl operations for Coda filesystem
3 * Original version: (C) 1996 P. Braam and M. Callahan
4 * Rewritten for Linux 2.1. (C) 1997 Carnegie Mellon University
6 * Carnegie Mellon encourages users to contribute improvements to
7 * the Coda project. Contact Peter Braam (coda@cs.cmu.edu).
9 * CODA operation statistics
10 * (c) March, 1998 Zhanyong Wan <zhanyong.wan@yale.edu>
14 #include <linux/time.h>
16 #include <linux/sysctl.h>
17 #include <linux/proc_fs.h>
18 #include <linux/seq_file.h>
19 #include <linux/slab.h>
20 #include <linux/stat.h>
21 #include <linux/ctype.h>
22 #include <linux/bitops.h>
23 #include <asm/uaccess.h>
24 #include <linux/utsname.h>
25 #include <linux/module.h>
27 #include <linux/coda.h>
28 #include <linux/coda_linux.h>
29 #include <linux/coda_fs_i.h>
30 #include <linux/coda_psdev.h>
31 #include <linux/coda_cache.h>
32 #include <linux/coda_proc.h>
34 static struct ctl_table_header
*fs_table_header
;
36 #define CODA_TIMEOUT 3 /* timeout on upcalls to become intrble */
37 #define CODA_HARD 5 /* mount type "hard" or "soft" */
38 #define CODA_VFS 6 /* vfs statistics */
39 #define CODA_CACHE_INV 9 /* cache invalidation statistics */
40 #define CODA_FAKE_STATFS 10 /* don't query venus for actual cache usage */
42 struct coda_vfs_stats coda_vfs_stat
;
43 static struct coda_cache_inv_stats coda_cache_inv_stat
;
45 static void reset_coda_vfs_stats( void )
47 memset( &coda_vfs_stat
, 0, sizeof( coda_vfs_stat
) );
50 static void reset_coda_cache_inv_stats( void )
52 memset( &coda_cache_inv_stat
, 0, sizeof( coda_cache_inv_stat
) );
55 static int do_reset_coda_vfs_stats( ctl_table
* table
, int write
,
56 struct file
* filp
, void __user
* buffer
,
57 size_t * lenp
, loff_t
* ppos
)
60 reset_coda_vfs_stats();
70 static int do_reset_coda_cache_inv_stats( ctl_table
* table
, int write
,
73 size_t * lenp
, loff_t
* ppos
)
76 reset_coda_cache_inv_stats();
86 static int proc_vfs_stats_show(struct seq_file
*m
, void *v
)
88 struct coda_vfs_stats
* ps
= & coda_vfs_stat
;
91 "Coda VFS statistics\n"
92 "===================\n\n"
99 "\treaddir\t\t%9d\n\n"
109 "\tpermission\t%9d\n",
111 /* file operations */
120 /* inode operations */
133 static int proc_cache_inv_stats_show(struct seq_file
*m
, void *v
)
135 struct coda_cache_inv_stats
* ps
= & coda_cache_inv_stat
;
138 "Coda cache invalidation statistics\n"
139 "==================================\n\n"
157 static int proc_vfs_stats_open(struct inode
*inode
, struct file
*file
)
159 return single_open(file
, proc_vfs_stats_show
, NULL
);
162 static int proc_cache_inv_stats_open(struct inode
*inode
, struct file
*file
)
164 return single_open(file
, proc_cache_inv_stats_show
, NULL
);
167 static const struct file_operations proc_vfs_stats_fops
= {
168 .owner
= THIS_MODULE
,
169 .open
= proc_vfs_stats_open
,
172 .release
= single_release
,
175 static const struct file_operations proc_cache_inv_stats_fops
= {
176 .owner
= THIS_MODULE
,
177 .open
= proc_cache_inv_stats_open
,
180 .release
= single_release
,
183 static ctl_table coda_table
[] = {
185 .ctl_name
= CTL_UNNUMBERED
,
186 .procname
= "timeout",
187 .data
= &coda_timeout
,
188 .maxlen
= sizeof(int),
190 .proc_handler
= &proc_dointvec
193 .ctl_name
= CTL_UNNUMBERED
,
196 .maxlen
= sizeof(int),
198 .proc_handler
= &proc_dointvec
201 .ctl_name
= CTL_UNNUMBERED
,
202 .procname
= "vfs_stats",
206 .proc_handler
= &do_reset_coda_vfs_stats
209 .ctl_name
= CTL_UNNUMBERED
,
210 .procname
= "cache_inv_stats",
214 .proc_handler
= &do_reset_coda_cache_inv_stats
217 .ctl_name
= CTL_UNNUMBERED
,
218 .procname
= "fake_statfs",
219 .data
= &coda_fake_statfs
,
220 .maxlen
= sizeof(int),
222 .proc_handler
= &proc_dointvec
227 static ctl_table fs_table
[] = {
229 .ctl_name
= CTL_UNNUMBERED
,
238 #ifdef CONFIG_PROC_FS
241 target directory structure:
242 /proc/fs (see linux/fs/proc/root.c)
244 /proc/fs/coda/{vfs_stats,
248 static struct proc_dir_entry
* proc_fs_coda
;
252 void coda_sysctl_init(void)
254 reset_coda_vfs_stats();
255 reset_coda_cache_inv_stats();
257 #ifdef CONFIG_PROC_FS
258 proc_fs_coda
= proc_mkdir("coda", proc_root_fs
);
260 struct proc_dir_entry
*pde
;
262 proc_fs_coda
->owner
= THIS_MODULE
;
263 pde
= create_proc_entry("vfs_stats", 0, proc_fs_coda
);
265 pde
->proc_fops
= &proc_vfs_stats_fops
;
266 pde
= create_proc_entry("cache_inv_stats", 0, proc_fs_coda
);
268 pde
->proc_fops
= &proc_cache_inv_stats_fops
;
273 if ( !fs_table_header
)
274 fs_table_header
= register_sysctl_table(fs_table
);
278 void coda_sysctl_clean(void)
282 if ( fs_table_header
) {
283 unregister_sysctl_table(fs_table_header
);
284 fs_table_header
= NULL
;
288 #ifdef CONFIG_PROC_FS
289 remove_proc_entry("cache_inv_stats", proc_fs_coda
);
290 remove_proc_entry("vfs_stats", proc_fs_coda
);
291 remove_proc_entry("coda", proc_root_fs
);