Whamcloud - gitweb
A couple days of changes--much improvement.
[fs/lustre-release.git] / lustre / obdclass / sysctl.c
1 #include <linux/sched.h>
2 #include <linux/mm.h>
3 #include <linux/sysctl.h>
4 #include <linux/swapctl.h>
5 #include <linux/proc_fs.h>
6 #include <linux/malloc.h>
7 #include <linux/stat.h>
8 #include <linux/ctype.h>
9 #include <asm/bitops.h>
10 #include <asm/segment.h>
11 #include <asm/uaccess.h>
12 #include <linux/utsname.h>
13
14 #include <linux/sym_obd.h>
15 #include <linux/presto.h>
16 #include <linux/obd_psdev.h>
17 #include <linux/presto_upcall.h>
18
19 struct ctl_table_header *obd_table_header = NULL;
20
21 static int vars[2];
22 static int index = 0;
23
24 static int obd_sctl_vars( ctl_table * table, int write, struct file *
25                           filp, void * buffer, size_t * lenp );
26 static int obd_sctl_reset( ctl_table * table, int write, struct file
27                            * filp, void * buffer, size_t * lenp );
28
29
30
31 #define OBD_SYSCTL 1
32
33 #define OBD_DEBUG           1       /* control debugging */
34 #define OBD_ENTRY           2       /* control enter/leave pattern */
35 #define OBD_TIMEOUT         3       /* timeout on upcalls to become intrble */
36 #define OBD_HARD            4       /* mount type "hard" or "soft" */
37 #define OBD_VARS            5       
38 #define OBD_INDEX           6
39 #define OBD_RESET           7
40
41 #define OBD_VARS_SLOT       2
42
43 static ctl_table obd_table[] = {
44         {OBD_DEBUG, "debug", &obd_debug_level, sizeof(int), 0644, NULL, &proc_dointvec},
45         {OBD_ENTRY, "trace", &obd_print_entry, sizeof(int), 0644, NULL, &proc_dointvec},
46         {OBD_VARS, "vars", &vars[0], sizeof(int), 0644, NULL, &proc_dointvec},
47         {OBD_INDEX, "index", &index, sizeof(int), 0644, NULL, &obd_sctl_vars},
48         {OBD_RESET, "reset", NULL, 0, 0644, NULL, &obd_sctl_reset},
49         { 0 }
50 };
51
52 static ctl_table jukebox_table[] = {
53        {OBD_SYSCTL, "obd",    NULL, 0, 0555, obd_table},
54        {0}
55 };
56
57
58 void obd_sysctl_init (void)
59 {
60 #ifdef CONFIG_SYSCTL
61         if ( !obd_table_header )
62                 obd_table_header = register_sysctl_table(jukebox_table, 0); 
63 #endif
64 }
65
66 void obd_sysctl_clean (void)
67 {
68 #ifdef CONFIG_SYSCTL
69         if ( obd_table_header )
70                 unregister_sysctl_table(obd_table_header);
71         obd_table_header = NULL;
72 #endif
73 }
74
75 int obd_sctl_reset (ctl_table * table, int write, 
76                     struct file * filp, void * buffer, 
77                     size_t * lenp)
78 {
79         if ( write ) {
80                 /* do something here */
81                 vars[0]=0;
82                 vars[1]=0;
83         }
84
85         *lenp = 0;
86         return 0;
87 }
88
89 int obd_sctl_vars (ctl_table * table, int write, 
90                    struct file * filp, void * buffer, 
91                    size_t * lenp)
92 {
93         int rc;
94
95         rc = proc_dointvec(table, write, filp, buffer, lenp);
96
97         if ( rc ) 
98                 return rc;
99
100         if ( index < 0 || index > 1 ) {
101                 printk("Index illegal!\n");
102                 index = 0;
103         } else {
104                 obd_table[OBD_VARS_SLOT].data = &vars[index];
105         }
106
107         return rc; 
108 }