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/config.h>
15 #include <linux/time.h>
17 #include <linux/sysctl.h>
18 #include <linux/proc_fs.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 FS_CODA 1 /* Coda file system */
38 #define CODA_TIMEOUT 3 /* timeout on upcalls to become intrble */
39 #define CODA_HARD 5 /* mount type "hard" or "soft" */
40 #define CODA_VFS 6 /* vfs statistics */
41 #define CODA_CACHE_INV 9 /* cache invalidation statistics */
42 #define CODA_FAKE_STATFS 10 /* don't query venus for actual cache usage */
44 struct coda_vfs_stats coda_vfs_stat;
45 static struct coda_cache_inv_stats coda_cache_inv_stat;
47 static void reset_coda_vfs_stats( void )
49 memset( &coda_vfs_stat, 0, sizeof( coda_vfs_stat ) );
52 static void reset_coda_cache_inv_stats( void )
54 memset( &coda_cache_inv_stat, 0, sizeof( coda_cache_inv_stat ) );
57 static int do_reset_coda_vfs_stats( ctl_table * table, int write,
58 struct file * filp, void __user * buffer,
59 size_t * lenp, loff_t * ppos )
62 reset_coda_vfs_stats();
72 static int do_reset_coda_cache_inv_stats( ctl_table * table, int write,
75 size_t * lenp, loff_t * ppos )
78 reset_coda_cache_inv_stats();
88 static int coda_vfs_stats_get_info( char * buffer, char ** start,
89 off_t offset, int length)
93 struct coda_vfs_stats * ps = & coda_vfs_stat;
95 /* this works as long as we are below 1024 characters! */
96 len += sprintf( buffer,
97 "Coda VFS statistics\n"
98 "===================\n\n"
105 "\treaddir\t\t%9d\n\n"
115 "\tpermission\t%9d\n",
117 /* file operations */
126 /* inode operations */
138 *start = buffer + begin;
149 static int coda_cache_inv_stats_get_info( char * buffer, char ** start,
150 off_t offset, int length)
154 struct coda_cache_inv_stats * ps = & coda_cache_inv_stat;
156 /* this works as long as we are below 1024 characters! */
157 len += sprintf( buffer,
158 "Coda cache invalidation statistics\n"
159 "==================================\n\n"
176 *start = buffer + begin;
187 static ctl_table coda_table[] = {
188 {CODA_TIMEOUT, "timeout", &coda_timeout, sizeof(int), 0644, NULL, &proc_dointvec},
189 {CODA_HARD, "hard", &coda_hard, sizeof(int), 0644, NULL, &proc_dointvec},
190 {CODA_VFS, "vfs_stats", NULL, 0, 0644, NULL, &do_reset_coda_vfs_stats},
191 {CODA_CACHE_INV, "cache_inv_stats", NULL, 0, 0644, NULL, &do_reset_coda_cache_inv_stats},
192 {CODA_FAKE_STATFS, "fake_statfs", &coda_fake_statfs, sizeof(int), 0600, NULL, &proc_dointvec},
196 static ctl_table fs_table[] = {
197 {FS_CODA, "coda", NULL, 0, 0555, coda_table},
202 #ifdef CONFIG_PROC_FS
205 target directory structure:
206 /proc/fs (see linux/fs/proc/root.c)
208 /proc/fs/coda/{vfs_stats,
212 static struct proc_dir_entry* proc_fs_coda;
216 #define coda_proc_create(name,get_info) \
217 create_proc_info_entry(name, 0, proc_fs_coda, get_info)
219 void coda_sysctl_init(void)
221 reset_coda_vfs_stats();
222 reset_coda_cache_inv_stats();
224 #ifdef CONFIG_PROC_FS
225 proc_fs_coda = proc_mkdir("coda", proc_root_fs);
227 proc_fs_coda->owner = THIS_MODULE;
228 coda_proc_create("vfs_stats", coda_vfs_stats_get_info);
229 coda_proc_create("cache_inv_stats", coda_cache_inv_stats_get_info);
234 if ( !fs_table_header )
235 fs_table_header = register_sysctl_table(fs_table, 0);
239 void coda_sysctl_clean(void)
243 if ( fs_table_header ) {
244 unregister_sysctl_table(fs_table_header);
245 fs_table_header = NULL;
249 #ifdef CONFIG_PROC_FS
250 remove_proc_entry("cache_inv_stats", proc_fs_coda);
251 remove_proc_entry("vfs_stats", proc_fs_coda);
252 remove_proc_entry("coda", proc_root_fs);