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 unsigned int obd_sync_filter;
59 extern atomic_t obd_memory;
61 int read_build_version SYSCTL_HANDLER_ARGS;
63 SYSCTL_NODE (, OID_AUTO, lustre, CTLFLAG_RW,
64 0, "lustre sysctl top");
65 SYSCTL_PROC(_lustre, OID_AUTO, timeout,
66 CTLTYPE_INT | CTLFLAG_RW , &obd_timeout,
67 0, &proc_obd_timeout, "I", "obd_timeout");
68 SYSCTL_PROC(_lustre, OID_AUTO, build_version,
69 CTLTYPE_STRING | CTLFLAG_RD , NULL,
70 0, &read_build_version, "A", "lustre_build_version");
71 SYSCTL_INT(_lustre, OID_AUTO, dump_on_timeout,
72 CTLTYPE_INT | CTLFLAG_RW, &obd_dump_on_timeout,
73 0, "lustre_dump_on_timeout");
74 SYSCTL_INT(_lustre, OID_AUTO, debug_peer_on_timeout,
75 CTLTYPE_INT | CTLFLAG_RW, &obd_debug_peer_on_timeout,
76 0, "lustre_debug_peer_on_timeout");
77 SYSCTL_INT(_lustre, OID_AUTO, memused,
78 CTLTYPE_INT | CTLFLAG_RW, (int *)&obd_memory.counter,
79 0, "lustre_memory_used");
80 SYSCTL_INT(_lustre, OID_AUTO, ldlm_timeout,
81 CTLTYPE_INT | CTLFLAG_RW, &ldlm_timeout,
84 static struct ctl_table parent_table[] = {
86 &sysctl__lustre_timeout,
87 &sysctl__lustre_dump_on_timeout,
88 &sysctl__lustre_debug_peer_on_timeout,
89 &sysctl__lustre_upcall,
90 &sysctl__lustre_memused,
91 &sysctl__lustre_filter_sync_on_commit,
92 &sysctl__lustre_ldlm_timeout,
95 int proc_obd_timeout SYSCTL_HANDLER_ARGS
99 error = sysctl_handle_long(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
100 if (!error && req->newptr != USER_ADDR_NULL) {
101 if (ldlm_timeout >= obd_timeout)
102 ldlm_timeout = max(obd_timeout / 3, 1U);
103 } else if (req->newptr != USER_ADDR_NULL) {
104 printf ("sysctl fail obd_timeout: %d.\n", error);
107 error = SYSCTL_OUT(req, &obd_timeout, sizeof obd_timeout);
112 int read_build_version SYSCTL_HANDLER_ARGS
116 error = sysctl_handle_long(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
117 if ( req->newptr != USER_ADDR_NULL) {
118 printf("sysctl read_build_version is read-only!\n");
120 error = SYSCTL_OUT(req, BUILD_VERSION, strlen(BUILD_VERSION));
125 void obd_sysctl_init (void)
128 if ( !obd_table_header )
129 obd_table_header = register_sysctl_table(parent_table);
133 void obd_sysctl_clean (void)
136 if ( obd_table_header )
137 unregister_sysctl_table(obd_table_header);
138 obd_table_header = NULL;