Whamcloud - gitweb
lu_site_fini(): break reference from lu_device to lu_site
[fs/lustre-release.git] / lustre / obdclass / sysctl.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2001, 2002 Cluster File Systems, Inc.
5  *
6  *   This file is part of the Lustre file system, http://www.lustre.org
7  *   Lustre is a trademark of Cluster File Systems, Inc.
8  *
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.
13  *
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.
18  *
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.
23  *
24  */
25
26 #include <linux/module.h>
27 #include <linux/autoconf.h>
28 #include <linux/sysctl.h>
29 #include <linux/sched.h>
30 #include <linux/mm.h>
31 #include <linux/sysctl.h>
32 #include <linux/version.h>
33 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
34 #include <linux/swapctl.h>
35 #endif
36 #include <linux/proc_fs.h>
37 #include <linux/slab.h>
38 #include <linux/stat.h>
39 #include <linux/ctype.h>
40 #include <asm/bitops.h>
41 #include <asm/segment.h>
42 #include <asm/uaccess.h>
43 #include <linux/utsname.h>
44
45 #define DEBUG_SUBSYSTEM S_CLASS
46
47 #include <linux/obd_support.h>
48
49 struct ctl_table_header *obd_table_header = NULL;
50
51 #define OBD_SYSCTL 300
52
53 enum {
54         OBD_FAIL_LOC = 1,       /* control test failures instrumentation */
55         OBD_TIMEOUT,            /* RPC timeout before recovery/intr */
56         OBD_DUMP_ON_TIMEOUT,    /* dump kernel debug log upon eviction */
57         OBD_UPCALL,             /* path to recovery upcall */
58         OBD_MEMUSED,            /* bytes currently OBD_ALLOCated */
59         OBD_SYNCFILTER,         /* XXX temporary, as we play with sync osts.. */
60         OBD_LDLM_TIMEOUT,       /* LDLM timeout for ASTs before client eviction */
61 };
62
63 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8)
64 #define ll_proc_dointvec(table,write,filp,buffer,lenp,ppos)             \
65         proc_dointvec(table,write,filp,buffer,lenp)
66 #define LL_PROC_PROTO(name)                                             \
67         name(ctl_table *table, int write, struct file *filp,   \
68                       void *buffer, size_t *lenp)
69 #else
70 #define ll_proc_dointvec(table,write,filp,buffer,lenp,ppos)             \
71         proc_dointvec(table,write,filp,buffer,lenp,ppos);
72 #define LL_PROC_PROTO(name)                                             \
73         name(ctl_table *table, int write, struct file *filp,            \
74                   void *buffer, size_t *lenp, loff_t *ppos)
75 #endif
76
77 int LL_PROC_PROTO(proc_fail_loc)
78 {
79         int rc;
80         int old_fail_loc = obd_fail_loc;
81
82         rc = ll_proc_dointvec(table, write, filp, buffer, lenp, ppos);
83         if (old_fail_loc != obd_fail_loc)
84                 wake_up(&obd_race_waitq);
85         return rc;
86 }
87
88 int LL_PROC_PROTO(proc_set_timeout)
89 {
90         int rc;
91
92         rc = ll_proc_dointvec(table, write, filp, buffer, lenp, ppos);
93         if (ldlm_timeout >= obd_timeout)
94                 ldlm_timeout = max(obd_timeout / 3, 1U);
95         return rc;
96 }
97
98 static ctl_table obd_table[] = {
99         {OBD_FAIL_LOC, "fail_loc", &obd_fail_loc, sizeof(int), 0644, NULL,
100                 &proc_fail_loc},
101         {OBD_TIMEOUT, "timeout", &obd_timeout, sizeof(int), 0644, NULL,
102                 &proc_set_timeout},
103         {OBD_DUMP_ON_TIMEOUT, "dump_on_timeout", &obd_dump_on_timeout,
104                 sizeof(int), 0644, NULL, &proc_dointvec},
105         /* XXX need to lock so we avoid update races with recovery upcall! */
106         {OBD_UPCALL, "upcall", obd_lustre_upcall, 128, 0644, NULL,
107                 &proc_dostring, &sysctl_string },
108         {OBD_MEMUSED, "memused", (int *)&obd_memory.counter,
109                 sizeof(int), 0644, NULL, &proc_dointvec},
110         {OBD_LDLM_TIMEOUT, "ldlm_timeout", &ldlm_timeout, sizeof(int), 0644,
111                 NULL, &proc_set_timeout},
112         { 0 }
113 };
114
115 static ctl_table parent_table[] = {
116        {OBD_SYSCTL, "lustre", NULL, 0, 0555, obd_table},
117        {0}
118 };
119
120 void obd_sysctl_init (void)
121 {
122 #ifdef CONFIG_SYSCTL
123         if ( !obd_table_header )
124                 obd_table_header = register_sysctl_table(parent_table, 0);
125 #endif
126 }
127
128 void obd_sysctl_clean (void)
129 {
130 #ifdef CONFIG_SYSCTL
131         if ( obd_table_header )
132                 unregister_sysctl_table(obd_table_header);
133         obd_table_header = NULL;
134 #endif
135 }