Whamcloud - gitweb
b=3031
[fs/lustre-release.git] / lustre / obdclass / sysctl.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2001, 2002 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  */
22
23 #include <linux/module.h>
24 #include <linux/autoconf.h>
25 #include <linux/sysctl.h>
26 #include <linux/sched.h>
27 #include <linux/mm.h>
28 #include <linux/sysctl.h>
29 #include <linux/version.h>
30 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
31 #include <linux/swapctl.h>
32 #endif
33 #include <linux/proc_fs.h>
34 #include <linux/slab.h>
35 #include <linux/stat.h>
36 #include <linux/ctype.h>
37 #include <asm/bitops.h>
38 #include <asm/segment.h>
39 #include <asm/uaccess.h>
40 #include <linux/utsname.h>
41
42 #define DEBUG_SUBSYSTEM S_CLASS
43
44 #include <linux/obd_support.h>
45
46 struct ctl_table_header *obd_table_header = NULL;
47
48 #define OBD_SYSCTL 300
49
50 enum {
51         OBD_FAIL_LOC = 1,       /* control test failures instrumentation */
52         OBD_TIMEOUT,            /* RPC timeout before recovery/intr */
53         OBD_DUMP_ON_TIMEOUT,    /* dump kernel debug log upon eviction */
54         OBD_UPCALL,             /* path to recovery upcall */
55         OBD_MEMUSED,            /* bytes currently OBD_ALLOCated */
56         OBD_SYNCFILTER,         /* XXX temporary, as we play with sync osts.. */
57         OBD_LDLM_TIMEOUT,       /* LDLM timeout for ASTs before client eviction */
58 };
59
60 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9))
61 int proc_fail_loc(ctl_table *table, int write, struct file *filp,
62                   void *buffer, size_t *lenp);
63 #else
64 int proc_fail_loc(ctl_table *table, int write, struct file *filp,
65                   void *buffer, size_t *lenp, loff_t *ppos);
66 #endif
67 static ctl_table obd_table[] = {
68         {OBD_FAIL_LOC, "fail_loc", &obd_fail_loc, sizeof(int), 0644, NULL,
69                 &proc_dointvec},
70         {OBD_TIMEOUT, "timeout", &obd_timeout, sizeof(int), 0644, NULL,
71                 &proc_fail_loc},
72         {OBD_DUMP_ON_TIMEOUT, "dump_on_timeout", &obd_dump_on_timeout,
73                 sizeof(int), 0644, NULL, &proc_dointvec},
74         /* XXX need to lock so we avoid update races with recovery upcall! */
75         {OBD_UPCALL, "upcall", obd_lustre_upcall, 128, 0644, NULL,
76                 &proc_dostring, &sysctl_string },
77         {OBD_MEMUSED, "memused", (int *)&obd_memory.counter,
78                 sizeof(int), 0644, NULL, &proc_dointvec},
79         {OBD_SYNCFILTER, "filter_sync_on_commit", &obd_sync_filter, sizeof(int),
80                 0644, NULL, &proc_dointvec},
81         {OBD_LDLM_TIMEOUT, "ldlm_timeout", &ldlm_timeout, sizeof(int), 0644,
82                 NULL, &proc_dointvec},
83         { 0 }
84 };
85
86 static ctl_table parent_table[] = {
87        {OBD_SYSCTL, "lustre", NULL, 0, 0555, obd_table},
88        {0}
89 };
90
91 void obd_sysctl_init (void)
92 {
93 #ifdef CONFIG_SYSCTL
94         if ( !obd_table_header )
95                 obd_table_header = register_sysctl_table(parent_table, 0);
96 #endif
97 }
98
99 void obd_sysctl_clean (void)
100 {
101 #ifdef CONFIG_SYSCTL
102         if ( obd_table_header )
103                 unregister_sysctl_table(obd_table_header);
104         obd_table_header = NULL;
105 #endif
106 }
107 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9))
108 int proc_fail_loc(ctl_table *table, int write, struct file *filp,
109                   void *buffer, size_t *lenp)
110 #else
111 int proc_fail_loc(ctl_table *table, int write, struct file *filp,
112                   void *buffer, size_t *lenp, loff_t *ppos)
113 #endif
114 {
115         int rc;
116         int old_fail_loc = obd_fail_loc;
117
118 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9))
119         rc = proc_dointvec(table,write,filp,buffer,lenp);
120 #else
121         rc = proc_dointvec(table,write,filp,buffer,lenp, ppos);
122 #endif
123         if (old_fail_loc != obd_fail_loc)
124                 wake_up(&obd_race_waitq);
125         return rc;
126 }