4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
31 * This file is part of Lustre, http://www.lustre.org/
32 * Lustre is a trademark of Sun Microsystems, Inc.
35 #include <sys/param.h>
36 #include <sys/kernel.h>
37 #include <sys/malloc.h>
38 #include <sys/systm.h>
39 #include <sys/sysctl.h>
41 #include <sys/unistd.h>
42 #include <mach/mach_types.h>
43 #include <lustre/lustre_build_version.h>
45 #define DEBUG_SUBSYSTEM S_CLASS
47 #include <libcfs/libcfs.h>
49 #define BUILD_VERSION "Unknown"
52 struct ctl_table_header *obd_table_header = NULL;
54 int proc_obd_timeout SYSCTL_HANDLER_ARGS;
55 extern unsigned int obd_dump_on_timeout;
56 extern unsigned int obd_timeout;
57 extern unsigned int ldlm_timeout;
58 extern atomic_t obd_memory;
60 int read_build_version SYSCTL_HANDLER_ARGS;
62 SYSCTL_NODE (, OID_AUTO, lustre, CTLFLAG_RW,
63 0, "lustre sysctl top");
64 SYSCTL_PROC(_lustre, OID_AUTO, timeout,
65 CTLTYPE_INT | CTLFLAG_RW , &obd_timeout,
66 0, &proc_obd_timeout, "I", "obd_timeout");
67 SYSCTL_PROC(_lustre, OID_AUTO, build_version,
68 CTLTYPE_STRING | CTLFLAG_RD , NULL,
69 0, &read_build_version, "A", "lustre_build_version");
70 SYSCTL_INT(_lustre, OID_AUTO, dump_on_timeout,
71 CTLTYPE_INT | CTLFLAG_RW, &obd_dump_on_timeout,
72 0, "lustre_dump_on_timeout");
73 SYSCTL_INT(_lustre, OID_AUTO, debug_peer_on_timeout,
74 CTLTYPE_INT | CTLFLAG_RW, &obd_debug_peer_on_timeout,
75 0, "lustre_debug_peer_on_timeout");
76 SYSCTL_INT(_lustre, OID_AUTO, memused,
77 CTLTYPE_INT | CTLFLAG_RW, (int *)&obd_memory.counter,
78 0, "lustre_memory_used");
79 SYSCTL_INT(_lustre, OID_AUTO, ldlm_timeout,
80 CTLTYPE_INT | CTLFLAG_RW, &ldlm_timeout,
83 static struct ctl_table parent_table[] = {
85 &sysctl__lustre_timeout,
86 &sysctl__lustre_dump_on_timeout,
87 &sysctl__lustre_debug_peer_on_timeout,
88 &sysctl__lustre_upcall,
89 &sysctl__lustre_memused,
90 &sysctl__lustre_filter_sync_on_commit,
91 &sysctl__lustre_ldlm_timeout,
94 int proc_obd_timeout SYSCTL_HANDLER_ARGS
98 error = sysctl_handle_long(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
99 if (!error && req->newptr != USER_ADDR_NULL) {
100 if (ldlm_timeout >= obd_timeout)
101 ldlm_timeout = max(obd_timeout / 3, 1U);
102 } else if (req->newptr != USER_ADDR_NULL) {
103 printf ("sysctl fail obd_timeout: %d.\n", error);
106 error = SYSCTL_OUT(req, &obd_timeout, sizeof obd_timeout);
111 int read_build_version SYSCTL_HANDLER_ARGS
115 error = sysctl_handle_long(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
116 if ( req->newptr != USER_ADDR_NULL) {
117 printf("sysctl read_build_version is read-only!\n");
119 error = SYSCTL_OUT(req, BUILD_VERSION, strlen(BUILD_VERSION));
124 void obd_sysctl_init (void)
127 if ( !obd_table_header )
128 obd_table_header = register_sysctl_table(parent_table);
132 void obd_sysctl_clean (void)
135 if ( obd_table_header )
136 unregister_sysctl_table(obd_table_header);
137 obd_table_header = NULL;