1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
37 #include <sys/param.h>
38 #include <sys/kernel.h>
39 #include <sys/malloc.h>
40 #include <sys/systm.h>
41 #include <sys/sysctl.h>
43 #include <sys/unistd.h>
44 #include <mach/mach_types.h>
45 #include <lustre/lustre_build_version.h>
47 #define DEBUG_SUBSYSTEM S_CLASS
49 #include <libcfs/libcfs.h>
51 #define BUILD_VERSION "Unknown"
53 #ifndef LUSTRE_KERNEL_VERSION
54 #define LUSTRE_KERNEL_VERSION "Unknown Darwin version"
57 cfs_sysctl_table_header_t *obd_table_header = NULL;
59 int proc_obd_timeout SYSCTL_HANDLER_ARGS;
60 extern unsigned int obd_dump_on_timeout;
61 extern unsigned int obd_timeout;
62 extern unsigned int ldlm_timeout;
63 extern unsigned int obd_sync_filter;
64 extern atomic_t obd_memory;
66 int read_build_version SYSCTL_HANDLER_ARGS;
67 int read_lustre_kernel_version SYSCTL_HANDLER_ARGS;
69 SYSCTL_NODE (, OID_AUTO, lustre, CTLFLAG_RW,
70 0, "lustre sysctl top");
71 SYSCTL_PROC(_lustre, OID_AUTO, timeout,
72 CTLTYPE_INT | CTLFLAG_RW , &obd_timeout,
73 0, &proc_obd_timeout, "I", "obd_timeout");
74 SYSCTL_PROC(_lustre, OID_AUTO, build_version,
75 CTLTYPE_STRING | CTLFLAG_RD , NULL,
76 0, &read_build_version, "A", "lustre_build_version");
77 SYSCTL_PROC(_lustre, OID_AUTO, lustre_kernel_version,
78 CTLTYPE_STRING | CTLFLAG_RD , NULL,
79 0, &read_lustre_kernel_version, "A", "lustre_build_version");
80 SYSCTL_INT(_lustre, OID_AUTO, dump_on_timeout,
81 CTLTYPE_INT | CTLFLAG_RW, &obd_dump_on_timeout,
82 0, "lustre_dump_on_timeout");
83 SYSCTL_INT(_lustre, OID_AUTO, debug_peer_on_timeout,
84 CTLTYPE_INT | CTLFLAG_RW, &obd_debug_peer_on_timeout,
85 0, "lustre_debug_peer_on_timeout");
86 SYSCTL_INT(_lustre, OID_AUTO, memused,
87 CTLTYPE_INT | CTLFLAG_RW, (int *)&obd_memory.counter,
88 0, "lustre_memory_used");
89 SYSCTL_INT(_lustre, OID_AUTO, ldlm_timeout,
90 CTLTYPE_INT | CTLFLAG_RW, &ldlm_timeout,
93 static cfs_sysctl_table_t parent_table[] = {
95 &sysctl__lustre_timeout,
96 &sysctl__lustre_dump_on_timeout,
97 &sysctl__lustre_debug_peer_on_timeout,
98 &sysctl__lustre_upcall,
99 &sysctl__lustre_memused,
100 &sysctl__lustre_filter_sync_on_commit,
101 &sysctl__lustre_ldlm_timeout,
104 int proc_obd_timeout SYSCTL_HANDLER_ARGS
108 error = sysctl_handle_long(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
109 if (!error && req->newptr != USER_ADDR_NULL) {
110 if (ldlm_timeout >= obd_timeout)
111 ldlm_timeout = max(obd_timeout / 3, 1U);
112 } else if (req->newptr != USER_ADDR_NULL) {
113 printf ("sysctl fail obd_timeout: %d.\n", error);
116 error = SYSCTL_OUT(req, &obd_timeout, sizeof obd_timeout);
121 int read_build_version SYSCTL_HANDLER_ARGS
125 error = sysctl_handle_long(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
126 if ( req->newptr != USER_ADDR_NULL) {
127 printf("sysctl read_build_version is read-only!\n");
129 error = SYSCTL_OUT(req, BUILD_VERSION, strlen(BUILD_VERSION));
134 int read_lustre_kernel_version SYSCTL_HANDLER_ARGS
138 error = sysctl_handle_long(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
139 if ( req->newptr != NULL) {
140 printf("sysctl lustre_kernel_version is read-only!\n");
142 error = SYSCTL_OUT(req, LUSTRE_KERNEL_VERSION, strlen(LUSTRE_KERNEL_VERSION));
147 void obd_sysctl_init (void)
150 if ( !obd_table_header )
151 obd_table_header = cfs_register_sysctl_table(parent_table, 0);
155 void obd_sysctl_clean (void)
158 if ( obd_table_header )
159 cfs_unregister_sysctl_table(obd_table_header);
160 obd_table_header = NULL;