Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / obdclass / linux / linux-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 the Lustre file system, http://www.lustre.org
7  *   Lustre is a trademark of Cluster File Systems, Inc.
8  *
9  *   You may have signed or agreed to another license before downloading
10  *   this software.  If so, you are bound by the terms and conditions
11  *   of that agreement, and the following does not apply to you.  See the
12  *   LICENSE file included with this distribution for more information.
13  *
14  *   If you did not agree to a different license, then this copy of Lustre
15  *   is open source software; you can redistribute it and/or modify it
16  *   under the terms of version 2 of the GNU General Public License as
17  *   published by the Free Software Foundation.
18  *
19  *   In either case, Lustre is distributed in the hope that it will be
20  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
21  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  *   license text for more details.
23  *
24  */
25
26 #include <linux/module.h>
27 #include <linux/autoconf.h>
28 #include <linux/sysctl.h>
29 #include <linux/sched.h>
30 #include <linux/mm.h>
31 #include <linux/sysctl.h>
32 #include <linux/version.h>
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 <obd_support.h>
45
46 cfs_sysctl_table_header_t *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_MEMUSED,            /* bytes currently OBD_ALLOCated */
55         OBD_SYNCFILTER,         /* XXX temporary, as we play with sync osts.. */
56         OBD_LDLM_TIMEOUT,       /* LDLM timeout for ASTs before client eviction */
57         OBD_DUMP_ON_EVICTION,   /* dump kernel debug log upon eviction */
58         OBD_DEBUG_PEER_ON_TIMEOUT, /* dump peer debug when RPC times out */
59 };
60
61 int LL_PROC_PROTO(proc_fail_loc)
62 {
63         int rc;
64         int old_fail_loc = obd_fail_loc;
65
66         rc = ll_proc_dointvec(table, write, filp, buffer, lenp, ppos);
67         if (old_fail_loc != obd_fail_loc)
68                 wake_up(&obd_race_waitq);
69         return rc;
70 }
71
72 int LL_PROC_PROTO(proc_set_timeout)
73 {
74         int rc;
75
76         rc = ll_proc_dointvec(table, write, filp, buffer, lenp, ppos);
77         if (ldlm_timeout >= obd_timeout)
78                 ldlm_timeout = max(obd_timeout / 3, 1U);
79         return rc;
80 }
81
82 static cfs_sysctl_table_t obd_table[] = {
83         {
84                 .ctl_name = OBD_FAIL_LOC,
85                 .procname = "fail_loc",
86                 .data     = &obd_fail_loc,
87                 .maxlen   = sizeof(int),
88                 .mode     = 0644,
89                 .proc_handler = &proc_fail_loc
90         },
91         {
92                 .ctl_name = OBD_TIMEOUT,
93                 .procname = "timeout",
94                 .data     = &obd_timeout,
95                 .maxlen   = sizeof(int),
96                 .mode     = 0644,
97                 .proc_handler = &proc_set_timeout
98         },
99         {
100                 .ctl_name = OBD_DEBUG_PEER_ON_TIMEOUT,
101                 .procname = "debug_peer_on_timeout",
102                 .data     = &obd_debug_peer_on_timeout,
103                 .maxlen   = sizeof(int),
104                 .mode     = 0644,
105                 .proc_handler = &proc_dointvec
106         },
107         {
108                 .ctl_name = OBD_DUMP_ON_TIMEOUT,
109                 .procname = "dump_on_timeout",
110                 .data     = &obd_dump_on_timeout,
111                 .maxlen   = sizeof(int),
112                 .mode     = 0644,
113                 .proc_handler = &proc_dointvec
114         },
115         {
116                 .ctl_name = OBD_DUMP_ON_EVICTION,
117                 .procname = "dump_on_eviction",
118                 .data     = &obd_dump_on_eviction,
119                 .maxlen   = sizeof(int),
120                 .mode     = 0644,
121                 .proc_handler = &proc_dointvec
122         },
123         {
124                 .ctl_name = OBD_MEMUSED,
125                 .procname = "memused",
126                 .data     = (int *)&obd_memory.counter,
127                 .maxlen   = sizeof(int),
128                 .mode     = 0644,
129                 .proc_handler = &proc_dointvec
130         },
131         {
132                 .ctl_name = OBD_LDLM_TIMEOUT,
133                 .procname = "ldlm_timeout",
134                 .data     = &ldlm_timeout,
135                 .maxlen   = sizeof(int),
136                 .mode     = 0644,
137                 .proc_handler = &proc_set_timeout
138         },
139         { 0 }
140 };
141
142 static cfs_sysctl_table_t parent_table[] = {
143         {
144                 .ctl_name = OBD_SYSCTL,
145                 .procname = "lustre",
146                 .data     = NULL,
147                 .maxlen   = 0,
148                 .mode     = 0555,
149                 .child    = obd_table
150         },
151         {0}
152 };
153
154 void obd_sysctl_init (void)
155 {
156 #ifdef CONFIG_SYSCTL
157         if ( !obd_table_header )
158                 obd_table_header = cfs_register_sysctl_table(parent_table, 0);
159 #endif
160 }
161
162 void obd_sysctl_clean (void)
163 {
164 #ifdef CONFIG_SYSCTL
165         if ( obd_table_header )
166                 cfs_unregister_sysctl_table(obd_table_header);
167         obd_table_header = NULL;
168 #endif
169 }