1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
6 * This file is part of the Lustre file system, http://www.lustre.org
7 * Lustre is a trademark of Cluster File Systems, Inc.
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.
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.
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.
26 #include <linux/module.h>
27 #include <linux/autoconf.h>
28 #include <linux/sysctl.h>
29 #include <linux/sched.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>
42 #define DEBUG_SUBSYSTEM S_CLASS
44 #include <obd_support.h>
46 cfs_sysctl_table_header_t *obd_table_header = NULL;
48 #define OBD_SYSCTL 300
51 OBD_FAIL_LOC = 1, /* control test failures instrumentation */
52 OBD_FAIL_VAL, /* userdata for fail loc */
53 OBD_TIMEOUT, /* RPC timeout before recovery/intr */
54 OBD_DUMP_ON_TIMEOUT, /* dump kernel debug log upon eviction */
55 OBD_MEMUSED, /* bytes currently OBD_ALLOCated */
56 OBD_PAGESUSED, /* pages currently OBD_PAGE_ALLOCated */
57 OBD_MAXMEMUSED, /* maximum bytes OBD_ALLOCated concurrently */
58 OBD_MAXPAGESUSED, /* maximum pages OBD_PAGE_ALLOCated concurrently */
59 OBD_SYNCFILTER, /* XXX temporary, as we play with sync osts.. */
60 OBD_LDLM_TIMEOUT, /* LDLM timeout for ASTs before client eviction */
61 OBD_DUMP_ON_EVICTION, /* dump kernel debug log upon eviction */
62 OBD_DEBUG_PEER_ON_TIMEOUT, /* dump peer debug when RPC times out */
65 int LL_PROC_PROTO(proc_fail_loc)
68 int old_fail_loc = obd_fail_loc;
70 rc = ll_proc_dointvec(table, write, filp, buffer, lenp, ppos);
71 if (old_fail_loc != obd_fail_loc)
72 wake_up(&obd_race_waitq);
76 int LL_PROC_PROTO(proc_set_timeout)
80 rc = ll_proc_dointvec(table, write, filp, buffer, lenp, ppos);
81 if (ldlm_timeout >= obd_timeout)
82 ldlm_timeout = max(obd_timeout / 3, 1U);
86 int LL_PROC_PROTO(proc_memory_alloc)
90 DECLARE_LL_PROC_PPOS_DECL;
92 if (!*lenp || (*ppos && !write)) {
99 len = snprintf(buf, sizeof(buf), LPU64"\n", obd_memory_sum());
103 if (copy_to_user(buffer, buf, len))
110 int LL_PROC_PROTO(proc_pages_alloc)
114 DECLARE_LL_PROC_PPOS_DECL;
116 if (!*lenp || (*ppos && !write)) {
123 len = snprintf(buf, sizeof(buf), LPU64"\n", obd_pages_sum());
127 if (copy_to_user(buffer, buf, len))
134 int LL_PROC_PROTO(proc_mem_max)
138 DECLARE_LL_PROC_PPOS_DECL;
140 if (!*lenp || (*ppos && !write)) {
147 len = snprintf(buf, sizeof(buf), LPU64"\n", obd_memory_max());
151 if (copy_to_user(buffer, buf, len))
158 int LL_PROC_PROTO(proc_pages_max)
162 DECLARE_LL_PROC_PPOS_DECL;
164 if (!*lenp || (*ppos && !write)) {
171 len = snprintf(buf, sizeof(buf), LPU64"\n", obd_pages_max());
175 if (copy_to_user(buffer, buf, len))
182 static cfs_sysctl_table_t obd_table[] = {
184 .ctl_name = OBD_FAIL_LOC,
185 .procname = "fail_loc",
186 .data = &obd_fail_loc,
187 .maxlen = sizeof(int),
189 .proc_handler = &proc_fail_loc
192 .ctl_name = OBD_FAIL_VAL,
193 .procname = "fail_val",
194 .data = &obd_fail_val,
195 .maxlen = sizeof(int),
197 .proc_handler = &proc_dointvec
200 .ctl_name = OBD_TIMEOUT,
201 .procname = "timeout",
202 .data = &obd_timeout,
203 .maxlen = sizeof(int),
205 .proc_handler = &proc_set_timeout
208 .ctl_name = OBD_DEBUG_PEER_ON_TIMEOUT,
209 .procname = "debug_peer_on_timeout",
210 .data = &obd_debug_peer_on_timeout,
211 .maxlen = sizeof(int),
213 .proc_handler = &proc_dointvec
216 .ctl_name = OBD_DUMP_ON_TIMEOUT,
217 .procname = "dump_on_timeout",
218 .data = &obd_dump_on_timeout,
219 .maxlen = sizeof(int),
221 .proc_handler = &proc_dointvec
224 .ctl_name = OBD_DUMP_ON_EVICTION,
225 .procname = "dump_on_eviction",
226 .data = &obd_dump_on_eviction,
227 .maxlen = sizeof(int),
229 .proc_handler = &proc_dointvec
232 .ctl_name = OBD_MEMUSED,
233 .procname = "memused",
237 .proc_handler = &proc_memory_alloc
240 .ctl_name = OBD_PAGESUSED,
241 .procname = "pagesused",
245 .proc_handler = &proc_pages_alloc
248 .ctl_name = OBD_MAXMEMUSED,
249 .procname = "memused_max",
253 .proc_handler = &proc_mem_max
256 .ctl_name = OBD_MAXPAGESUSED,
257 .procname = "pagesused_max",
261 .proc_handler = &proc_pages_max
264 .ctl_name = OBD_LDLM_TIMEOUT,
265 .procname = "ldlm_timeout",
266 .data = &ldlm_timeout,
267 .maxlen = sizeof(int),
269 .proc_handler = &proc_set_timeout
274 static cfs_sysctl_table_t parent_table[] = {
276 .ctl_name = OBD_SYSCTL,
277 .procname = "lustre",
286 void obd_sysctl_init (void)
289 if ( !obd_table_header )
290 obd_table_header = cfs_register_sysctl_table(parent_table, 0);
294 void obd_sysctl_clean (void)
297 if ( obd_table_header )
298 cfs_unregister_sysctl_table(obd_table_header);
299 obd_table_header = NULL;