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>
45 #include <lprocfs_status.h>
47 cfs_sysctl_table_header_t *obd_table_header = NULL;
49 #define OBD_SYSCTL 300
52 OBD_FAIL_LOC = 1, /* control test failures instrumentation */
53 OBD_FAIL_VAL, /* userdata for fail loc */
54 OBD_TIMEOUT, /* RPC timeout before recovery/intr */
55 OBD_DUMP_ON_TIMEOUT, /* dump kernel debug log upon eviction */
56 OBD_MEMUSED, /* bytes currently OBD_ALLOCated */
57 OBD_PAGESUSED, /* pages currently OBD_PAGE_ALLOCated */
58 OBD_MAXMEMUSED, /* maximum bytes OBD_ALLOCated concurrently */
59 OBD_MAXPAGESUSED, /* maximum pages OBD_PAGE_ALLOCated concurrently */
60 OBD_SYNCFILTER, /* XXX temporary, as we play with sync osts.. */
61 OBD_LDLM_TIMEOUT, /* LDLM timeout for ASTs before client eviction */
62 OBD_DUMP_ON_EVICTION, /* dump kernel debug log upon eviction */
63 OBD_DEBUG_PEER_ON_TIMEOUT, /* dump peer debug when RPC times out */
64 OBD_ALLOC_FAIL_RATE, /* memory allocation random failure rate */
67 int LL_PROC_PROTO(proc_fail_loc)
70 int old_fail_loc = obd_fail_loc;
72 rc = ll_proc_dointvec(table, write, filp, buffer, lenp, ppos);
73 if (old_fail_loc != obd_fail_loc)
74 wake_up(&obd_race_waitq);
78 int LL_PROC_PROTO(proc_set_timeout)
82 rc = ll_proc_dointvec(table, write, filp, buffer, lenp, ppos);
83 if (ldlm_timeout >= obd_timeout)
84 ldlm_timeout = max(obd_timeout / 3, 1U);
88 int LL_PROC_PROTO(proc_memory_alloc)
92 DECLARE_LL_PROC_PPOS_DECL;
94 if (!*lenp || (*ppos && !write)) {
101 len = snprintf(buf, sizeof(buf), LPU64"\n", obd_memory_sum());
105 if (copy_to_user(buffer, buf, len))
112 int LL_PROC_PROTO(proc_pages_alloc)
116 DECLARE_LL_PROC_PPOS_DECL;
118 if (!*lenp || (*ppos && !write)) {
125 len = snprintf(buf, sizeof(buf), LPU64"\n", obd_pages_sum());
129 if (copy_to_user(buffer, buf, len))
136 int LL_PROC_PROTO(proc_mem_max)
140 DECLARE_LL_PROC_PPOS_DECL;
142 if (!*lenp || (*ppos && !write)) {
149 len = snprintf(buf, sizeof(buf), LPU64"\n", obd_memory_max());
153 if (copy_to_user(buffer, buf, len))
160 int LL_PROC_PROTO(proc_pages_max)
164 DECLARE_LL_PROC_PPOS_DECL;
166 if (!*lenp || (*ppos && !write)) {
173 len = snprintf(buf, sizeof(buf), LPU64"\n", obd_pages_max());
177 if (copy_to_user(buffer, buf, len))
184 #ifdef RANDOM_FAIL_ALLOC
185 int LL_PROC_PROTO(proc_alloc_fail_rate)
188 DECLARE_LL_PROC_PPOS_DECL;
190 if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) {
195 rc = lprocfs_write_frac_helper(buffer, *lenp,
196 (unsigned int*)table->data,
197 OBD_ALLOC_FAIL_MULT);
202 len = lprocfs_read_frac_helper(buf, 21,
203 *(unsigned int*)table->data,
204 OBD_ALLOC_FAIL_MULT);
208 if (copy_to_user(buffer, buf, len))
217 static cfs_sysctl_table_t obd_table[] = {
219 .ctl_name = OBD_FAIL_LOC,
220 .procname = "fail_loc",
221 .data = &obd_fail_loc,
222 .maxlen = sizeof(int),
224 .proc_handler = &proc_fail_loc
227 .ctl_name = OBD_FAIL_VAL,
228 .procname = "fail_val",
229 .data = &obd_fail_val,
230 .maxlen = sizeof(int),
232 .proc_handler = &proc_dointvec
235 .ctl_name = OBD_TIMEOUT,
236 .procname = "timeout",
237 .data = &obd_timeout,
238 .maxlen = sizeof(int),
240 .proc_handler = &proc_set_timeout
243 .ctl_name = OBD_DEBUG_PEER_ON_TIMEOUT,
244 .procname = "debug_peer_on_timeout",
245 .data = &obd_debug_peer_on_timeout,
246 .maxlen = sizeof(int),
248 .proc_handler = &proc_dointvec
251 .ctl_name = OBD_DUMP_ON_TIMEOUT,
252 .procname = "dump_on_timeout",
253 .data = &obd_dump_on_timeout,
254 .maxlen = sizeof(int),
256 .proc_handler = &proc_dointvec
259 .ctl_name = OBD_DUMP_ON_EVICTION,
260 .procname = "dump_on_eviction",
261 .data = &obd_dump_on_eviction,
262 .maxlen = sizeof(int),
264 .proc_handler = &proc_dointvec
267 .ctl_name = OBD_MEMUSED,
268 .procname = "memused",
272 .proc_handler = &proc_memory_alloc
275 .ctl_name = OBD_PAGESUSED,
276 .procname = "pagesused",
280 .proc_handler = &proc_pages_alloc
283 .ctl_name = OBD_MAXMEMUSED,
284 .procname = "memused_max",
288 .proc_handler = &proc_mem_max
291 .ctl_name = OBD_MAXPAGESUSED,
292 .procname = "pagesused_max",
296 .proc_handler = &proc_pages_max
299 .ctl_name = OBD_LDLM_TIMEOUT,
300 .procname = "ldlm_timeout",
301 .data = &ldlm_timeout,
302 .maxlen = sizeof(int),
304 .proc_handler = &proc_set_timeout
306 #ifdef RANDOM_FAIL_LOC
308 .ctl_name = OBD_ALLOC_FAIL_RATE,
309 .procname = "alloc_fail_rate",
310 .data = &obd_alloc_fail_rate,
311 .maxlen = sizeof(int),
313 .proc_handler = &proc_alloc_fail_rate
319 static cfs_sysctl_table_t parent_table[] = {
321 .ctl_name = OBD_SYSCTL,
322 .procname = "lustre",
331 void obd_sysctl_init (void)
334 if ( !obd_table_header )
335 obd_table_header = cfs_register_sysctl_table(parent_table, 0);
339 void obd_sysctl_clean (void)
342 if ( obd_table_header )
343 cfs_unregister_sysctl_table(obd_table_header);
344 obd_table_header = NULL;