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) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
37 #include <linux/module.h>
38 #include <linux/sysctl.h>
39 #include <linux/sched.h>
41 #include <linux/sysctl.h>
42 #include <linux/version.h>
43 #include <linux/proc_fs.h>
44 #include <linux/slab.h>
45 #include <linux/stat.h>
46 #include <linux/ctype.h>
47 #include <asm/bitops.h>
48 #include <asm/uaccess.h>
49 #include <linux/utsname.h>
51 #define DEBUG_SUBSYSTEM S_CLASS
53 #include <obd_support.h>
54 #include <lprocfs_status.h>
57 struct ctl_table_header *obd_table_header = NULL;
60 int LL_PROC_PROTO(proc_set_timeout)
64 rc = proc_dointvec(table, write, buffer, lenp, ppos);
65 if (ldlm_timeout >= obd_timeout)
66 ldlm_timeout = max(obd_timeout / 3, 1U);
70 int LL_PROC_PROTO(proc_memory_alloc)
75 if (!*lenp || (*ppos && !write)) {
82 len = snprintf(buf, sizeof(buf), LPU64"\n", obd_memory_sum());
86 if (copy_to_user(buffer, buf, len))
93 int LL_PROC_PROTO(proc_pages_alloc)
98 if (!*lenp || (*ppos && !write)) {
105 len = snprintf(buf, sizeof(buf), LPU64"\n", obd_pages_sum());
109 if (copy_to_user(buffer, buf, len))
116 int LL_PROC_PROTO(proc_mem_max)
121 if (!*lenp || (*ppos && !write)) {
128 len = snprintf(buf, sizeof(buf), LPU64"\n", obd_memory_max());
132 if (copy_to_user(buffer, buf, len))
139 int LL_PROC_PROTO(proc_pages_max)
144 if (!*lenp || (*ppos && !write)) {
151 len = snprintf(buf, sizeof(buf), LPU64"\n", obd_pages_max());
155 if (copy_to_user(buffer, buf, len))
162 int LL_PROC_PROTO(proc_max_dirty_pages_in_mb)
166 if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) {
171 rc = lprocfs_write_frac_helper(buffer, *lenp,
172 (unsigned int *)table->data,
173 1 << (20 - PAGE_CACHE_SHIFT));
174 /* Don't allow them to let dirty pages exceed 90% of system
175 * memory and set a hard minimum of 4MB. */
176 if (obd_max_dirty_pages > ((totalram_pages / 10) * 9)) {
177 CERROR("Refusing to set max dirty pages to %u, which "
178 "is more than 90%% of available RAM; setting "
179 "to %lu\n", obd_max_dirty_pages,
180 ((totalram_pages / 10) * 9));
181 obd_max_dirty_pages = ((totalram_pages / 10) * 9);
182 } else if (obd_max_dirty_pages < 4 << (20 - PAGE_CACHE_SHIFT)) {
183 obd_max_dirty_pages = 4 << (20 - PAGE_CACHE_SHIFT);
189 len = lprocfs_read_frac_helper(buf, sizeof(buf),
190 *(unsigned int *)table->data,
191 1 << (20 - PAGE_CACHE_SHIFT));
195 if (copy_to_user(buffer, buf, len))
203 #ifdef RANDOM_FAIL_ALLOC
204 int proc_alloc_fail_rate(struct ctl_table *table, int write,
205 void __user *buffer, size_t *lenp, loff_t *ppos)
209 if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) {
214 rc = lprocfs_write_frac_helper(buffer, *lenp,
215 (unsigned int*)table->data,
216 OBD_ALLOC_FAIL_MULT);
221 len = lprocfs_read_frac_helper(buf, 21,
222 *(unsigned int*)table->data,
223 OBD_ALLOC_FAIL_MULT);
227 if (copy_to_user(buffer, buf, len))
236 int LL_PROC_PROTO(proc_bulk_timeout)
238 return proc_dointvec(table, write, buffer, lenp, ppos);
240 int LL_PROC_PROTO(proc_at_min)
242 return proc_dointvec(table, write, buffer, lenp, ppos);
244 int LL_PROC_PROTO(proc_at_max)
246 return proc_dointvec(table, write, buffer, lenp, ppos);
248 int LL_PROC_PROTO(proc_at_extra)
250 return proc_dointvec(table, write, buffer, lenp, ppos);
252 int LL_PROC_PROTO(proc_at_early_margin)
254 return proc_dointvec(table, write, buffer, lenp, ppos);
256 int LL_PROC_PROTO(proc_at_history)
258 return proc_dointvec(table, write, buffer, lenp, ppos);
262 static struct ctl_table obd_table[] = {
265 .procname = "timeout",
266 .data = &obd_timeout,
267 .maxlen = sizeof(int),
269 .proc_handler = &proc_set_timeout
273 .procname = "debug_peer_on_timeout",
274 .data = &obd_debug_peer_on_timeout,
275 .maxlen = sizeof(int),
277 .proc_handler = &proc_dointvec
281 .procname = "dump_on_timeout",
282 .data = &obd_dump_on_timeout,
283 .maxlen = sizeof(int),
285 .proc_handler = &proc_dointvec
289 .procname = "dump_on_eviction",
290 .data = &obd_dump_on_eviction,
291 .maxlen = sizeof(int),
293 .proc_handler = &proc_dointvec
297 .procname = "memused",
301 .proc_handler = &proc_memory_alloc
305 .procname = "pagesused",
309 .proc_handler = &proc_pages_alloc
313 .procname = "memused_max",
317 .proc_handler = &proc_mem_max
321 .procname = "pagesused_max",
325 .proc_handler = &proc_pages_max
329 .procname = "ldlm_timeout",
330 .data = &ldlm_timeout,
331 .maxlen = sizeof(int),
333 .proc_handler = &proc_set_timeout
335 #ifdef RANDOM_FAIL_ALLOC
338 .procname = "alloc_fail_rate",
339 .data = &obd_alloc_fail_rate,
340 .maxlen = sizeof(int),
342 .proc_handler = &proc_alloc_fail_rate
347 .procname = "max_dirty_mb",
348 .data = &obd_max_dirty_pages,
349 .maxlen = sizeof(int),
351 .proc_handler = &proc_max_dirty_pages_in_mb
355 .procname = "bulk_timeout",
356 .data = &bulk_timeout,
357 .maxlen = sizeof(int),
359 .proc_handler = &proc_bulk_timeout
363 .procname = "at_min",
365 .maxlen = sizeof(int),
367 .proc_handler = &proc_at_min
371 .procname = "at_max",
373 .maxlen = sizeof(int),
375 .proc_handler = &proc_at_max
379 .procname = "at_extra",
381 .maxlen = sizeof(int),
383 .proc_handler = &proc_at_extra
387 .procname = "at_early_margin",
388 .data = &at_early_margin,
389 .maxlen = sizeof(int),
391 .proc_handler = &proc_at_early_margin
395 .procname = "at_history",
397 .maxlen = sizeof(int),
399 .proc_handler = &proc_at_history
404 static struct ctl_table parent_table[] = {
407 .procname = "lustre",
417 void obd_sysctl_init (void)
420 if ( !obd_table_header )
421 obd_table_header = register_sysctl_table(parent_table);
425 void obd_sysctl_clean (void)
428 if ( obd_table_header )
429 unregister_sysctl_table(obd_table_header);
430 obd_table_header = NULL;