/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
+ * GPL HEADER START
*
- * This file is part of the Lustre file system, http://www.lustre.org
- * Lustre is a trademark of Cluster File Systems, Inc.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
- * You may have signed or agreed to another license before downloading
- * this software. If so, you are bound by the terms and conditions
- * of that agreement, and the following does not apply to you. See the
- * LICENSE file included with this distribution for more information.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
*
- * If you did not agree to a different license, then this copy of Lustre
- * is open source software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
*
- * In either case, Lustre is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * license text for more details.
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
*
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
*/
#include <linux/module.h>
#include <linux/stat.h>
#include <linux/ctype.h>
#include <asm/bitops.h>
-#include <asm/segment.h>
#include <asm/uaccess.h>
#include <linux/utsname.h>
OBD_DUMP_ON_EVICTION, /* dump kernel debug log upon eviction */
OBD_DEBUG_PEER_ON_TIMEOUT, /* dump peer debug when RPC times out */
OBD_ALLOC_FAIL_RATE, /* memory allocation random failure rate */
+ OBD_MAX_DIRTY_PAGES, /* maximum dirty pages */
};
int LL_PROC_PROTO(proc_fail_loc)
{
int rc;
- int old_fail_loc = obd_fail_loc;
+ long old_fail_loc = obd_fail_loc;
rc = ll_proc_dointvec(table, write, filp, buffer, lenp, ppos);
if (old_fail_loc != obd_fail_loc)
*lenp = 0;
return 0;
}
- if (write)
+ if (write)
return -EINVAL;
-
+
len = snprintf(buf, sizeof(buf), LPU64"\n", obd_memory_sum());
if (len > *lenp)
len = *lenp;
return 0;
}
+int LL_PROC_PROTO(proc_max_dirty_pages_in_mb)
+{
+ int rc = 0;
+ DECLARE_LL_PROC_PPOS_DECL;
+
+ if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) {
+ *lenp = 0;
+ return 0;
+ }
+ if (write) {
+ rc = lprocfs_write_frac_helper(buffer, *lenp,
+ (unsigned int*)table->data,
+ 1 << (20 - CFS_PAGE_SHIFT));
+ /* Don't allow them to let dirty pages exceed 90% of system memory,
+ * and set a hard minimum of 4MB. */
+ if (obd_max_dirty_pages > ((num_physpages / 10) * 9)) {
+ CERROR("Refusing to set max dirty pages to %u, which "
+ "is more than 90%% of available RAM; setting to %lu\n",
+ obd_max_dirty_pages, ((num_physpages / 10) * 9));
+ obd_max_dirty_pages = ((num_physpages / 10) * 9);
+ } else if (obd_max_dirty_pages < 4 << (20 - CFS_PAGE_SHIFT)) {
+ obd_max_dirty_pages = 4 << (20 - CFS_PAGE_SHIFT);
+ }
+ } else {
+ char buf[21];
+ int len;
+
+ len = lprocfs_read_frac_helper(buf, sizeof(buf),
+ *(unsigned int*)table->data,
+ 1 << (20 - CFS_PAGE_SHIFT));
+ if (len > *lenp)
+ len = *lenp;
+ buf[len] = '\0';
+ if (copy_to_user(buffer, buf, len))
+ return -EFAULT;
+ *lenp = len;
+ }
+ *ppos += *lenp;
+ return rc;
+}
+
#ifdef RANDOM_FAIL_ALLOC
int LL_PROC_PROTO(proc_alloc_fail_rate)
{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8)
- loff_t *ppos = &filp->f_pos;
-#endif
int rc = 0;
+ DECLARE_LL_PROC_PPOS_DECL;
if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) {
*lenp = 0;
return 0;
}
if (write) {
- rc = lprocfs_write_frac_helper(buffer, *lenp,
+ rc = lprocfs_write_frac_helper(buffer, *lenp,
(unsigned int*)table->data,
OBD_ALLOC_FAIL_MULT);
} else {
.mode = 0644,
.proc_handler = &proc_set_timeout
},
-#ifdef RANDOM_FAIL_LOC
+#ifdef RANDOM_FAIL_ALLOC
{
.ctl_name = OBD_ALLOC_FAIL_RATE,
.procname = "alloc_fail_rate",
.proc_handler = &proc_alloc_fail_rate
},
#endif
+ {
+ .ctl_name = OBD_MAX_DIRTY_PAGES,
+ .procname = "max_dirty_mb",
+ .data = &obd_max_dirty_pages,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = &proc_max_dirty_pages_in_mb
+ },
{ 0 }
};