diff options
Diffstat (limited to 'drivers/staging/lustre/lustre/libcfs')
-rw-r--r-- | drivers/staging/lustre/lustre/libcfs/Makefile | 2 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/libcfs/debug.c | 4 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/libcfs/hash.c | 13 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c | 102 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c | 2 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/libcfs/linux/linux-module.c | 2 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c | 24 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c | 577 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c | 10 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/libcfs/module.c | 566 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/libcfs/tracefile.c | 28 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/libcfs/workitem.c | 2 |
12 files changed, 641 insertions, 691 deletions
diff --git a/drivers/staging/lustre/lustre/libcfs/Makefile b/drivers/staging/lustre/lustre/libcfs/Makefile index fcecbd2271af..2996a48a31fb 100644 --- a/drivers/staging/lustre/lustre/libcfs/Makefile +++ b/drivers/staging/lustre/lustre/libcfs/Makefile @@ -3,7 +3,7 @@ obj-$(CONFIG_LUSTRE_FS) += libcfs.o libcfs-linux-objs := linux-tracefile.o linux-debug.o libcfs-linux-objs += linux-prim.o linux-cpu.o libcfs-linux-objs += linux-tcpip.o -libcfs-linux-objs += linux-proc.o linux-curproc.o +libcfs-linux-objs += linux-curproc.o libcfs-linux-objs += linux-module.o libcfs-linux-objs += linux-crypto.o libcfs-linux-objs += linux-crypto-adler.o diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c index 76c62e87a415..021c92fa0333 100644 --- a/drivers/staging/lustre/lustre/libcfs/debug.c +++ b/drivers/staging/lustre/lustre/libcfs/debug.c @@ -409,8 +409,8 @@ int libcfs_debug_init(unsigned long bufsize) if (max > cfs_trace_max_debug_mb() || max < num_possible_cpus()) { max = TCD_MAX_PAGES; } else { - max = (max / num_possible_cpus()); - max = max << (20 - PAGE_CACHE_SHIFT); + max = max / num_possible_cpus(); + max <<= (20 - PAGE_CACHE_SHIFT); } rc = cfs_tracefile_init(max); diff --git a/drivers/staging/lustre/lustre/libcfs/hash.c b/drivers/staging/lustre/lustre/libcfs/hash.c index ec3a2a8b8b2c..a55567e0de9e 100644 --- a/drivers/staging/lustre/lustre/libcfs/hash.c +++ b/drivers/staging/lustre/lustre/libcfs/hash.c @@ -2008,13 +2008,10 @@ void cfs_hash_rehash_key(struct cfs_hash *hs, const void *old_key, } EXPORT_SYMBOL(cfs_hash_rehash_key); -int cfs_hash_debug_header(struct seq_file *m) +void cfs_hash_debug_header(struct seq_file *m) { - return seq_printf(m, "%-*s%6s%6s%6s%6s%6s%6s%6s%7s%8s%8s%8s%s\n", - CFS_HASH_BIGNAME_LEN, - "name", "cur", "min", "max", "theta", "t-min", "t-max", - "flags", "rehash", "count", "maxdep", "maxdepb", - " distribution"); + seq_printf(m, "%-*s cur min max theta t-min t-max flags rehash count maxdep maxdepb distribution\n", + CFS_HASH_BIGNAME_LEN, "name"); } EXPORT_SYMBOL(cfs_hash_debug_header); @@ -2042,7 +2039,7 @@ cfs_hash_full_nbkt(struct cfs_hash *hs) CFS_HASH_RH_NBKT(hs) : CFS_HASH_NBKT(hs); } -int cfs_hash_debug_str(struct cfs_hash *hs, struct seq_file *m) +void cfs_hash_debug_str(struct cfs_hash *hs, struct seq_file *m) { int dist[8] = { 0, }; int maxdep = -1; @@ -2097,7 +2094,5 @@ int cfs_hash_debug_str(struct cfs_hash *hs, struct seq_file *m) seq_printf(m, "%d%c", dist[i], (i == 7) ? '\n' : '/'); cfs_hash_unlock(hs, 0); - - return 0; } EXPORT_SYMBOL(cfs_hash_debug_str); diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c index 05f7595f18aa..cc3ab351943e 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c @@ -204,7 +204,7 @@ cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len) } tmp += rc; - for_each_cpu_mask(j, *cptab->ctb_parts[i].cpt_cpumask) { + for_each_cpu(j, cptab->ctb_parts[i].cpt_cpumask) { rc = snprintf(tmp, len, "%d ", j); len -= rc; if (len <= 0) { @@ -240,8 +240,8 @@ cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt) LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts)); return cpt == CFS_CPT_ANY ? - cpus_weight(*cptab->ctb_cpumask) : - cpus_weight(*cptab->ctb_parts[cpt].cpt_cpumask); + cpumask_weight(cptab->ctb_cpumask) : + cpumask_weight(cptab->ctb_parts[cpt].cpt_cpumask); } EXPORT_SYMBOL(cfs_cpt_weight); @@ -251,8 +251,10 @@ cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt) LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts)); return cpt == CFS_CPT_ANY ? - any_online_cpu(*cptab->ctb_cpumask) != NR_CPUS : - any_online_cpu(*cptab->ctb_parts[cpt].cpt_cpumask) != NR_CPUS; + cpumask_any_and(cptab->ctb_cpumask, + cpu_online_mask) < nr_cpu_ids : + cpumask_any_and(cptab->ctb_parts[cpt].cpt_cpumask, + cpu_online_mask) < nr_cpu_ids; } EXPORT_SYMBOL(cfs_cpt_online); @@ -283,7 +285,7 @@ cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) LASSERT(cpt >= 0 && cpt < cptab->ctb_nparts); - if (cpu < 0 || cpu >= NR_CPUS || !cpu_online(cpu)) { + if (cpu < 0 || cpu >= nr_cpu_ids || !cpu_online(cpu)) { CDEBUG(D_INFO, "CPU %d is invalid or it's offline\n", cpu); return 0; } @@ -296,11 +298,11 @@ cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) cptab->ctb_cpu2cpt[cpu] = cpt; - LASSERT(!cpu_isset(cpu, *cptab->ctb_cpumask)); - LASSERT(!cpu_isset(cpu, *cptab->ctb_parts[cpt].cpt_cpumask)); + LASSERT(!cpumask_test_cpu(cpu, cptab->ctb_cpumask)); + LASSERT(!cpumask_test_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask)); - cpu_set(cpu, *cptab->ctb_cpumask); - cpu_set(cpu, *cptab->ctb_parts[cpt].cpt_cpumask); + cpumask_set_cpu(cpu, cptab->ctb_cpumask); + cpumask_set_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask); node = cpu_to_node(cpu); @@ -324,7 +326,7 @@ cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts)); - if (cpu < 0 || cpu >= NR_CPUS) { + if (cpu < 0 || cpu >= nr_cpu_ids) { CDEBUG(D_INFO, "Invalid CPU id %d\n", cpu); return; } @@ -344,11 +346,11 @@ cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) return; } - LASSERT(cpu_isset(cpu, *cptab->ctb_parts[cpt].cpt_cpumask)); - LASSERT(cpu_isset(cpu, *cptab->ctb_cpumask)); + LASSERT(cpumask_test_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask)); + LASSERT(cpumask_test_cpu(cpu, cptab->ctb_cpumask)); - cpu_clear(cpu, *cptab->ctb_parts[cpt].cpt_cpumask); - cpu_clear(cpu, *cptab->ctb_cpumask); + cpumask_clear_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask); + cpumask_clear_cpu(cpu, cptab->ctb_cpumask); cptab->ctb_cpu2cpt[cpu] = -1; node = cpu_to_node(cpu); @@ -356,22 +358,22 @@ cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) LASSERT(node_isset(node, *cptab->ctb_parts[cpt].cpt_nodemask)); LASSERT(node_isset(node, *cptab->ctb_nodemask)); - for_each_cpu_mask(i, *cptab->ctb_parts[cpt].cpt_cpumask) { + for_each_cpu(i, cptab->ctb_parts[cpt].cpt_cpumask) { /* this CPT has other CPU belonging to this node? */ if (cpu_to_node(i) == node) break; } - if (i == NR_CPUS) + if (i >= nr_cpu_ids) node_clear(node, *cptab->ctb_parts[cpt].cpt_nodemask); - for_each_cpu_mask(i, *cptab->ctb_cpumask) { + for_each_cpu(i, cptab->ctb_cpumask) { /* this CPT-table has other CPU belonging to this node? */ if (cpu_to_node(i) == node) break; } - if (i == NR_CPUS) + if (i >= nr_cpu_ids) node_clear(node, *cptab->ctb_nodemask); return; @@ -383,13 +385,14 @@ cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask) { int i; - if (cpus_weight(*mask) == 0 || any_online_cpu(*mask) == NR_CPUS) { + if (cpumask_weight(mask) == 0 || + cpumask_any_and(mask, cpu_online_mask) >= nr_cpu_ids) { CDEBUG(D_INFO, "No online CPU is found in the CPU mask for CPU partition %d\n", cpt); return 0; } - for_each_cpu_mask(i, *mask) { + for_each_cpu(i, mask) { if (!cfs_cpt_set_cpu(cptab, cpt, i)) return 0; } @@ -403,7 +406,7 @@ cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask) { int i; - for_each_cpu_mask(i, *mask) + for_each_cpu(i, mask) cfs_cpt_unset_cpu(cptab, cpt, i); } EXPORT_SYMBOL(cfs_cpt_unset_cpumask); @@ -493,7 +496,7 @@ cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt) } for (; cpt <= last; cpt++) { - for_each_cpu_mask(i, *cptab->ctb_parts[cpt].cpt_cpumask) + for_each_cpu(i, cptab->ctb_parts[cpt].cpt_cpumask) cfs_cpt_unset_cpu(cptab, cpt, i); } } @@ -554,7 +557,7 @@ EXPORT_SYMBOL(cfs_cpt_current); int cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu) { - LASSERT(cpu >= 0 && cpu < NR_CPUS); + LASSERT(cpu >= 0 && cpu < nr_cpu_ids); return cptab->ctb_cpu2cpt[cpu]; } @@ -578,14 +581,14 @@ cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt) nodemask = cptab->ctb_parts[cpt].cpt_nodemask; } - if (any_online_cpu(*cpumask) == NR_CPUS) { + if (cpumask_any_and(cpumask, cpu_online_mask) >= nr_cpu_ids) { CERROR("No online CPU found in CPU partition %d, did someone do CPU hotplug on system? You might need to reload Lustre modules to keep system working well.\n", cpt); return -EINVAL; } for_each_online_cpu(i) { - if (cpu_isset(i, *cpumask)) + if (cpumask_test_cpu(i, cpumask)) continue; rc = set_cpus_allowed_ptr(current, cpumask); @@ -616,14 +619,14 @@ cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt, LASSERT(number > 0); - if (number >= cpus_weight(*node)) { - while (!cpus_empty(*node)) { - cpu = first_cpu(*node); + if (number >= cpumask_weight(node)) { + while (!cpumask_empty(node)) { + cpu = cpumask_first(node); rc = cfs_cpt_set_cpu(cptab, cpt, cpu); if (!rc) return -EINVAL; - cpu_clear(cpu, *node); + cpumask_clear_cpu(cpu, node); } return 0; } @@ -636,27 +639,27 @@ cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt, goto out; } - while (!cpus_empty(*node)) { - cpu = first_cpu(*node); + while (!cpumask_empty(node)) { + cpu = cpumask_first(node); /* get cpumask for cores in the same socket */ cfs_cpu_core_siblings(cpu, socket); - cpus_and(*socket, *socket, *node); + cpumask_and(socket, socket, node); - LASSERT(!cpus_empty(*socket)); + LASSERT(!cpumask_empty(socket)); - while (!cpus_empty(*socket)) { + while (!cpumask_empty(socket)) { int i; /* get cpumask for hts in the same core */ cfs_cpu_ht_siblings(cpu, core); - cpus_and(*core, *core, *node); + cpumask_and(core, core, node); - LASSERT(!cpus_empty(*core)); + LASSERT(!cpumask_empty(core)); - for_each_cpu_mask(i, *core) { - cpu_clear(i, *socket); - cpu_clear(i, *node); + for_each_cpu(i, core) { + cpumask_clear_cpu(i, socket); + cpumask_clear_cpu(i, node); rc = cfs_cpt_set_cpu(cptab, cpt, i); if (!rc) { @@ -667,7 +670,7 @@ cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt, if (--number == 0) goto out; } - cpu = first_cpu(*socket); + cpu = cpumask_first(socket); } } @@ -767,7 +770,7 @@ cfs_cpt_table_create(int ncpt) for_each_online_node(i) { cfs_node_to_cpumask(i, mask); - while (!cpus_empty(*mask)) { + while (!cpumask_empty(mask)) { struct cfs_cpu_partition *part; int n; @@ -776,24 +779,24 @@ cfs_cpt_table_create(int ncpt) part = &cptab->ctb_parts[cpt]; - n = num - cpus_weight(*part->cpt_cpumask); + n = num - cpumask_weight(part->cpt_cpumask); LASSERT(n > 0); rc = cfs_cpt_choose_ncpus(cptab, cpt, mask, n); if (rc < 0) goto failed; - LASSERT(num >= cpus_weight(*part->cpt_cpumask)); - if (num == cpus_weight(*part->cpt_cpumask)) + LASSERT(num >= cpumask_weight(part->cpt_cpumask)); + if (num == cpumask_weight(part->cpt_cpumask)) cpt++; } } if (cpt != ncpt || - num != cpus_weight(*cptab->ctb_parts[ncpt - 1].cpt_cpumask)) { + num != cpumask_weight(cptab->ctb_parts[ncpt - 1].cpt_cpumask)) { CERROR("Expect %d(%d) CPU partitions but got %d(%d), CPU hotplug/unplug while setting?\n", cptab->ctb_nparts, num, cpt, - cpus_weight(*cptab->ctb_parts[ncpt - 1].cpt_cpumask)); + cpumask_weight(cptab->ctb_parts[ncpt - 1].cpt_cpumask)); goto failed; } @@ -845,7 +848,7 @@ cfs_cpt_table_create_pattern(char *pattern) return NULL; } - high = node ? MAX_NUMNODES - 1 : NR_CPUS - 1; + high = node ? MAX_NUMNODES - 1 : nr_cpu_ids - 1; cptab = cfs_cpt_table_alloc(ncpt); if (cptab == NULL) { @@ -965,7 +968,8 @@ cfs_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) mutex_lock(&cpt_data.cpt_mutex); /* if all HTs in a core are offline, it may break affinity */ cfs_cpu_ht_siblings(cpu, cpt_data.cpt_cpumask); - warn = any_online_cpu(*cpt_data.cpt_cpumask) >= nr_cpu_ids; + warn = cpumask_any_and(cpt_data.cpt_cpumask, + cpu_online_mask) >= nr_cpu_ids; mutex_unlock(&cpt_data.cpt_mutex); CDEBUG(warn ? D_WARNING : D_INFO, "Lustre: can't support CPU plug-out well now, performance and stability could be impacted [CPU %u action: %lx]\n", diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c index 12005a71aa73..4545d54f71c6 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c @@ -50,7 +50,7 @@ #include <linux/interrupt.h> #include <linux/completion.h> #include <linux/fs.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/miscdevice.h> # define DEBUG_SUBSYSTEM S_LNET diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c index a5effcd9c679..e962f89683a6 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c @@ -57,7 +57,7 @@ int libcfs_ioctl_getdata(char *buf, char *end, void *arg) return -EINVAL; } - if (hdr->ioc_len + buf >= end) { + if (hdr->ioc_len >= end - buf) { CERROR("PORTALS: user buffer exceeds kernel buffer\n"); return -EINVAL; } diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c index 19f405e64e68..838f5f3bd6af 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c @@ -43,7 +43,7 @@ #include "../../../include/linux/libcfs/libcfs.h" #if defined(CONFIG_KGDB) -#include <asm/kgdb.h> +#include <linux/kgdb.h> #endif /** @@ -117,11 +117,12 @@ EXPORT_SYMBOL(cfs_timer_deadline); void cfs_enter_debugger(void) { #if defined(CONFIG_KGDB) -// BREAKPOINT(); + /* BREAKPOINT(); */ #else /* nothing */ #endif } +EXPORT_SYMBOL(cfs_enter_debugger); sigset_t @@ -138,6 +139,7 @@ cfs_block_allsigs(void) return old; } +EXPORT_SYMBOL(cfs_block_allsigs); sigset_t cfs_block_sigs(unsigned long sigs) { @@ -151,6 +153,7 @@ sigset_t cfs_block_sigs(unsigned long sigs) spin_unlock_irqrestore(¤t->sighand->siglock, flags); return old; } +EXPORT_SYMBOL(cfs_block_sigs); /* Block all signals except for the @sigs */ sigset_t cfs_block_sigsinv(unsigned long sigs) @@ -166,9 +169,10 @@ sigset_t cfs_block_sigsinv(unsigned long sigs) return old; } +EXPORT_SYMBOL(cfs_block_sigsinv); void -cfs_restore_sigs (sigset_t old) +cfs_restore_sigs(sigset_t old) { unsigned long flags; @@ -177,12 +181,14 @@ cfs_restore_sigs (sigset_t old) recalc_sigpending(); spin_unlock_irqrestore(¤t->sighand->siglock, flags); } +EXPORT_SYMBOL(cfs_restore_sigs); int cfs_signal_pending(void) { return signal_pending(current); } +EXPORT_SYMBOL(cfs_signal_pending); void cfs_clear_sigpending(void) @@ -193,25 +199,19 @@ cfs_clear_sigpending(void) clear_tsk_thread_flag(current, TIF_SIGPENDING); spin_unlock_irqrestore(¤t->sighand->siglock, flags); } +EXPORT_SYMBOL(cfs_clear_sigpending); int libcfs_arch_init(void) { return 0; } +EXPORT_SYMBOL(libcfs_arch_init); void libcfs_arch_cleanup(void) { return; } - -EXPORT_SYMBOL(libcfs_arch_init); EXPORT_SYMBOL(libcfs_arch_cleanup); -EXPORT_SYMBOL(cfs_enter_debugger); -EXPORT_SYMBOL(cfs_block_allsigs); -EXPORT_SYMBOL(cfs_block_sigs); -EXPORT_SYMBOL(cfs_block_sigsinv); -EXPORT_SYMBOL(cfs_restore_sigs); -EXPORT_SYMBOL(cfs_signal_pending); -EXPORT_SYMBOL(cfs_clear_sigpending); + diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c deleted file mode 100644 index c539e3741583..000000000000 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c +++ /dev/null @@ -1,577 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * 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. - * - * 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). - * - * 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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * libcfs/libcfs/linux/linux-proc.c - * - * Author: Zach Brown <zab@zabbo.net> - * Author: Peter J. Braam <braam@clusterfs.com> - * Author: Phil Schwan <phil@clusterfs.com> - */ - -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/mm.h> -#include <linux/string.h> -#include <linux/stat.h> -#include <linux/errno.h> -#include <linux/unistd.h> -#include <net/sock.h> -#include <linux/uio.h> - -#include <asm/uaccess.h> - -#include <linux/fs.h> -#include <linux/file.h> -#include <linux/list.h> - -#include <linux/proc_fs.h> -#include <linux/sysctl.h> - -# define DEBUG_SUBSYSTEM S_LNET - -#include "../../../include/linux/libcfs/libcfs.h" -#include <asm/div64.h> -#include "../tracefile.h" - -static struct ctl_table_header *lnet_table_header = NULL; -extern char lnet_upcall[1024]; -/** - * The path of debug log dump upcall script. - */ -extern char lnet_debug_log_upcall[1024]; - -#define CTL_LNET (0x100) -enum { - PSDEV_DEBUG = 1, /* control debugging */ - PSDEV_SUBSYSTEM_DEBUG, /* control debugging */ - PSDEV_PRINTK, /* force all messages to console */ - PSDEV_CONSOLE_RATELIMIT, /* ratelimit console messages */ - PSDEV_CONSOLE_MAX_DELAY_CS, /* maximum delay over which we skip messages */ - PSDEV_CONSOLE_MIN_DELAY_CS, /* initial delay over which we skip messages */ - PSDEV_CONSOLE_BACKOFF, /* delay increase factor */ - PSDEV_DEBUG_PATH, /* crashdump log location */ - PSDEV_DEBUG_DUMP_PATH, /* crashdump tracelog location */ - PSDEV_CPT_TABLE, /* information about cpu partitions */ - PSDEV_LNET_UPCALL, /* User mode upcall script */ - PSDEV_LNET_MEMUSED, /* bytes currently PORTAL_ALLOCated */ - PSDEV_LNET_CATASTROPHE, /* if we have LBUGged or panic'd */ - PSDEV_LNET_PANIC_ON_LBUG, /* flag to panic on LBUG */ - PSDEV_LNET_DUMP_KERNEL, /* snapshot kernel debug buffer to file */ - PSDEV_LNET_DAEMON_FILE, /* spool kernel debug buffer to file */ - PSDEV_LNET_DEBUG_MB, /* size of debug buffer */ - PSDEV_LNET_DEBUG_LOG_UPCALL, /* debug log upcall script */ - PSDEV_LNET_WATCHDOG_RATELIMIT, /* ratelimit watchdog messages */ - PSDEV_LNET_FORCE_LBUG, /* hook to force an LBUG */ - PSDEV_LNET_FAIL_LOC, /* control test failures instrumentation */ - PSDEV_LNET_FAIL_VAL, /* userdata for fail loc */ -}; - -static int proc_call_handler(void *data, int write, loff_t *ppos, - void __user *buffer, size_t *lenp, - int (*handler)(void *data, int write, - loff_t pos, void __user *buffer, int len)) -{ - int rc = handler(data, write, *ppos, buffer, *lenp); - - if (rc < 0) - return rc; - - if (write) { - *ppos += *lenp; - } else { - *lenp = rc; - *ppos += rc; - } - return 0; -} - -static int __proc_dobitmasks(void *data, int write, - loff_t pos, void __user *buffer, int nob) -{ - const int tmpstrlen = 512; - char *tmpstr; - int rc; - unsigned int *mask = data; - int is_subsys = (mask == &libcfs_subsystem_debug) ? 1 : 0; - int is_printk = (mask == &libcfs_printk) ? 1 : 0; - - rc = cfs_trace_allocate_string_buffer(&tmpstr, tmpstrlen); - if (rc < 0) - return rc; - - if (!write) { - libcfs_debug_mask2str(tmpstr, tmpstrlen, *mask, is_subsys); - rc = strlen(tmpstr); - - if (pos >= rc) { - rc = 0; - } else { - rc = cfs_trace_copyout_string(buffer, nob, - tmpstr + pos, "\n"); - } - } else { - rc = cfs_trace_copyin_string(tmpstr, tmpstrlen, buffer, nob); - if (rc < 0) { - cfs_trace_free_string_buffer(tmpstr, tmpstrlen); - return rc; - } - - rc = libcfs_debug_str2mask(mask, tmpstr, is_subsys); - /* Always print LBUG/LASSERT to console, so keep this mask */ - if (is_printk) - *mask |= D_EMERG; - } - - cfs_trace_free_string_buffer(tmpstr, tmpstrlen); - return rc; -} - -static int proc_dobitmasks(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) -{ - return proc_call_handler(table->data, write, ppos, buffer, lenp, - __proc_dobitmasks); -} - -static int min_watchdog_ratelimit = 0; /* disable ratelimiting */ -static int max_watchdog_ratelimit = (24*60*60); /* limit to once per day */ - -static int __proc_dump_kernel(void *data, int write, - loff_t pos, void __user *buffer, int nob) -{ - if (!write) - return 0; - - return cfs_trace_dump_debug_buffer_usrstr(buffer, nob); -} - -static int proc_dump_kernel(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) -{ - return proc_call_handler(table->data, write, ppos, buffer, lenp, - __proc_dump_kernel); -} - -static int __proc_daemon_file(void *data, int write, - loff_t pos, void __user *buffer, int nob) -{ - if (!write) { - int len = strlen(cfs_tracefile); - - if (pos >= len) - return 0; - - return cfs_trace_copyout_string(buffer, nob, - cfs_tracefile + pos, "\n"); - } - - return cfs_trace_daemon_command_usrstr(buffer, nob); -} - -static int proc_daemon_file(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) -{ - return proc_call_handler(table->data, write, ppos, buffer, lenp, - __proc_daemon_file); -} - -static int __proc_debug_mb(void *data, int write, - loff_t pos, void __user *buffer, int nob) -{ - if (!write) { - char tmpstr[32]; - int len = snprintf(tmpstr, sizeof(tmpstr), "%d", - cfs_trace_get_debug_mb()); - - if (pos >= len) - return 0; - - return cfs_trace_copyout_string(buffer, nob, tmpstr + pos, - "\n"); - } - - return cfs_trace_set_debug_mb_usrstr(buffer, nob); -} - -static int proc_debug_mb(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) -{ - return proc_call_handler(table->data, write, ppos, buffer, lenp, - __proc_debug_mb); -} - -static int proc_console_max_delay_cs(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, - loff_t *ppos) -{ - int rc, max_delay_cs; - struct ctl_table dummy = *table; - long d; - - dummy.data = &max_delay_cs; - dummy.proc_handler = &proc_dointvec; - - if (!write) { /* read */ - max_delay_cs = cfs_duration_sec(libcfs_console_max_delay * 100); - rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); - return rc; - } - - /* write */ - max_delay_cs = 0; - rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); - if (rc < 0) - return rc; - if (max_delay_cs <= 0) - return -EINVAL; - - d = cfs_time_seconds(max_delay_cs) / 100; - if (d == 0 || d < libcfs_console_min_delay) - return -EINVAL; - libcfs_console_max_delay = d; - - return rc; -} - -static int proc_console_min_delay_cs(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, - loff_t *ppos) -{ - int rc, min_delay_cs; - struct ctl_table dummy = *table; - long d; - - dummy.data = &min_delay_cs; - dummy.proc_handler = &proc_dointvec; - - if (!write) { /* read */ - min_delay_cs = cfs_duration_sec(libcfs_console_min_delay * 100); - rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); - return rc; - } - - /* write */ - min_delay_cs = 0; - rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); - if (rc < 0) - return rc; - if (min_delay_cs <= 0) - return -EINVAL; - - d = cfs_time_seconds(min_delay_cs) / 100; - if (d == 0 || d > libcfs_console_max_delay) - return -EINVAL; - libcfs_console_min_delay = d; - - return rc; -} - -static int proc_console_backoff(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) -{ - int rc, backoff; - struct ctl_table dummy = *table; - - dummy.data = &backoff; - dummy.proc_handler = &proc_dointvec; - - if (!write) { /* read */ - backoff= libcfs_console_backoff; - rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); - return rc; - } - - /* write */ - backoff = 0; - rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); - if (rc < 0) - return rc; - if (backoff <= 0) - return -EINVAL; - - libcfs_console_backoff = backoff; - - return rc; -} - -static int libcfs_force_lbug(struct ctl_table *table, int write, - void __user *buffer, - size_t *lenp, loff_t *ppos) -{ - if (write) - LBUG(); - return 0; -} - -static int proc_fail_loc(struct ctl_table *table, int write, - void __user *buffer, - size_t *lenp, loff_t *ppos) -{ - int rc; - long old_fail_loc = cfs_fail_loc; - - rc = proc_doulongvec_minmax(table, write, buffer, lenp, ppos); - if (old_fail_loc != cfs_fail_loc) - wake_up(&cfs_race_waitq); - return rc; -} - -static int __proc_cpt_table(void *data, int write, - loff_t pos, void __user *buffer, int nob) -{ - char *buf = NULL; - int len = 4096; - int rc = 0; - - if (write) - return -EPERM; - - LASSERT(cfs_cpt_table != NULL); - - while (1) { - LIBCFS_ALLOC(buf, len); - if (buf == NULL) - return -ENOMEM; - - rc = cfs_cpt_table_print(cfs_cpt_table, buf, len); - if (rc >= 0) - break; - - if (rc == -EFBIG) { - LIBCFS_FREE(buf, len); - len <<= 1; - continue; - } - goto out; - } - - if (pos >= rc) { - rc = 0; - goto out; - } - - rc = cfs_trace_copyout_string(buffer, nob, buf + pos, NULL); - out: - if (buf != NULL) - LIBCFS_FREE(buf, len); - return rc; -} - -static int proc_cpt_table(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, loff_t *ppos) -{ - return proc_call_handler(table->data, write, ppos, buffer, lenp, - __proc_cpt_table); -} - -static struct ctl_table lnet_table[] = { - /* - * NB No .strategy entries have been provided since sysctl(8) prefers - * to go via /proc for portability. - */ - { - .procname = "debug", - .data = &libcfs_debug, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &proc_dobitmasks, - }, - { - .procname = "subsystem_debug", - .data = &libcfs_subsystem_debug, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &proc_dobitmasks, - }, - { - .procname = "printk", - .data = &libcfs_printk, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &proc_dobitmasks, - }, - { - .procname = "console_ratelimit", - .data = &libcfs_console_ratelimit, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &proc_dointvec - }, - { - .procname = "console_max_delay_centisecs", - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &proc_console_max_delay_cs - }, - { - .procname = "console_min_delay_centisecs", - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &proc_console_min_delay_cs - }, - { - .procname = "console_backoff", - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &proc_console_backoff - }, - - { - .procname = "debug_path", - .data = libcfs_debug_file_path_arr, - .maxlen = sizeof(libcfs_debug_file_path_arr), - .mode = 0644, - .proc_handler = &proc_dostring, - }, - - { - .procname = "cpu_partition_table", - .maxlen = 128, - .mode = 0444, - .proc_handler = &proc_cpt_table, - }, - - { - .procname = "upcall", - .data = lnet_upcall, - .maxlen = sizeof(lnet_upcall), - .mode = 0644, - .proc_handler = &proc_dostring, - }, - { - .procname = "debug_log_upcall", - .data = lnet_debug_log_upcall, - .maxlen = sizeof(lnet_debug_log_upcall), - .mode = 0644, - .proc_handler = &proc_dostring, - }, - { - .procname = "lnet_memused", - .data = (int *)&libcfs_kmemory.counter, - .maxlen = sizeof(int), - .mode = 0444, - .proc_handler = &proc_dointvec, - }, - { - .procname = "catastrophe", - .data = &libcfs_catastrophe, - .maxlen = sizeof(int), - .mode = 0444, - .proc_handler = &proc_dointvec, - }, - { - .procname = "panic_on_lbug", - .data = &libcfs_panic_on_lbug, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &proc_dointvec, - }, - { - .procname = "dump_kernel", - .maxlen = 256, - .mode = 0200, - .proc_handler = &proc_dump_kernel, - }, - { - .procname = "daemon_file", - .mode = 0644, - .maxlen = 256, - .proc_handler = &proc_daemon_file, - }, - { - .procname = "debug_mb", - .mode = 0644, - .proc_handler = &proc_debug_mb, - }, - { - .procname = "watchdog_ratelimit", - .data = &libcfs_watchdog_ratelimit, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &proc_dointvec_minmax, - .extra1 = &min_watchdog_ratelimit, - .extra2 = &max_watchdog_ratelimit, - }, - { - .procname = "force_lbug", - .data = NULL, - .maxlen = 0, - .mode = 0200, - .proc_handler = &libcfs_force_lbug - }, - { - .procname = "fail_loc", - .data = &cfs_fail_loc, - .maxlen = sizeof(cfs_fail_loc), - .mode = 0644, - .proc_handler = &proc_fail_loc - }, - { - .procname = "fail_val", - .data = &cfs_fail_val, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &proc_dointvec - }, - { - } -}; - -static struct ctl_table top_table[] = { - { - .procname = "lnet", - .mode = 0555, - .data = NULL, - .maxlen = 0, - .child = lnet_table, - }, - { - } -}; - -int insert_proc(void) -{ - if (lnet_table_header == NULL) - lnet_table_header = register_sysctl_table(top_table); - return 0; -} - -void remove_proc(void) -{ - if (lnet_table_header != NULL) - unregister_sysctl_table(lnet_table_header); - - lnet_table_header = NULL; -} diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c index cd2fc01dea4c..f2462e7f04bc 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c @@ -543,19 +543,17 @@ libcfs_sock_accept (struct socket **newsockp, struct socket *sock) newsock->ops = sock->ops; - set_current_state(TASK_INTERRUPTIBLE); - add_wait_queue(sk_sleep(sock->sk), &wait); - rc = sock->ops->accept(sock, newsock, O_NONBLOCK); if (rc == -EAGAIN) { /* Nothing ready, so wait for activity */ + set_current_state(TASK_INTERRUPTIBLE); + add_wait_queue(sk_sleep(sock->sk), &wait); schedule(); + remove_wait_queue(sk_sleep(sock->sk), &wait); + set_current_state(TASK_RUNNING); rc = sock->ops->accept(sock, newsock, O_NONBLOCK); } - remove_wait_queue(sk_sleep(sock->sk), &wait); - set_current_state(TASK_RUNNING); - if (rc != 0) goto failed; diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index 7dc77dd402b8..f0ee76abfd5a 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -33,15 +33,82 @@ * This file is part of Lustre, http://www.lustre.org/ * Lustre is a trademark of Sun Microsystems, Inc. */ +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/mm.h> +#include <linux/string.h> +#include <linux/stat.h> +#include <linux/errno.h> +#include <linux/unistd.h> +#include <net/sock.h> +#include <linux/uio.h> -#define DEBUG_SUBSYSTEM S_LNET +#include <linux/uaccess.h> + +#include <linux/fs.h> +#include <linux/file.h> +#include <linux/list.h> + +#include <linux/proc_fs.h> +#include <linux/sysctl.h> + +# define DEBUG_SUBSYSTEM S_LNET #include "../../include/linux/libcfs/libcfs.h" +#include <asm/div64.h> + #include "../../include/linux/libcfs/libcfs_crypto.h" #include "../../include/linux/lnet/lib-lnet.h" #include "../../include/linux/lnet/lnet.h" #include "tracefile.h" +MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>"); +MODULE_DESCRIPTION("Portals v3.1"); +MODULE_LICENSE("GPL"); + +extern struct miscdevice libcfs_dev; +extern struct rw_semaphore cfs_tracefile_sem; +extern struct mutex cfs_trace_thread_mutex; +extern struct cfs_wi_sched *cfs_sched_rehash; +extern void libcfs_init_nidstrings(void); + +static int insert_proc(void); +static void remove_proc(void); + +static struct ctl_table_header *lnet_table_header; +extern char lnet_upcall[1024]; +/** + * The path of debug log dump upcall script. + */ +extern char lnet_debug_log_upcall[1024]; + +#define CTL_LNET (0x100) + +enum { + PSDEV_DEBUG = 1, /* control debugging */ + PSDEV_SUBSYSTEM_DEBUG, /* control debugging */ + PSDEV_PRINTK, /* force all messages to console */ + PSDEV_CONSOLE_RATELIMIT, /* ratelimit console messages */ + PSDEV_CONSOLE_MAX_DELAY_CS, /* maximum delay over which we skip messages */ + PSDEV_CONSOLE_MIN_DELAY_CS, /* initial delay over which we skip messages */ + PSDEV_CONSOLE_BACKOFF, /* delay increase factor */ + PSDEV_DEBUG_PATH, /* crashdump log location */ + PSDEV_DEBUG_DUMP_PATH, /* crashdump tracelog location */ + PSDEV_CPT_TABLE, /* information about cpu partitions */ + PSDEV_LNET_UPCALL, /* User mode upcall script */ + PSDEV_LNET_MEMUSED, /* bytes currently PORTAL_ALLOCated */ + PSDEV_LNET_CATASTROPHE, /* if we have LBUGged or panic'd */ + PSDEV_LNET_PANIC_ON_LBUG, /* flag to panic on LBUG */ + PSDEV_LNET_DUMP_KERNEL, /* snapshot kernel debug buffer to file */ + PSDEV_LNET_DAEMON_FILE, /* spool kernel debug buffer to file */ + PSDEV_LNET_DEBUG_MB, /* size of debug buffer */ + PSDEV_LNET_DEBUG_LOG_UPCALL, /* debug log upcall script */ + PSDEV_LNET_WATCHDOG_RATELIMIT, /* ratelimit watchdog messages */ + PSDEV_LNET_FORCE_LBUG, /* hook to force an LBUG */ + PSDEV_LNET_FAIL_LOC, /* control test failures instrumentation */ + PSDEV_LNET_FAIL_VAL, /* userdata for fail loc */ +}; + static void kportal_memhog_free (struct libcfs_device_userstate *ldu) { struct page **level0p = &ldu->ldu_memhog_root_page; @@ -320,19 +387,6 @@ struct cfs_psdev_ops libcfs_psdev_ops = { libcfs_ioctl }; -extern int insert_proc(void); -extern void remove_proc(void); -MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>"); -MODULE_DESCRIPTION("Portals v3.1"); -MODULE_LICENSE("GPL"); - -extern struct miscdevice libcfs_dev; -extern struct rw_semaphore cfs_tracefile_sem; -extern struct mutex cfs_trace_thread_mutex; -extern struct cfs_wi_sched *cfs_sched_rehash; - -extern void libcfs_init_nidstrings(void); - static int init_libcfs_module(void) { int rc; @@ -347,7 +401,7 @@ static int init_libcfs_module(void) rc = libcfs_debug_init(5 * 1024 * 1024); if (rc < 0) { - printk(KERN_ERR "LustreError: libcfs_debug_init: %d\n", rc); + pr_err("LustreError: libcfs_debug_init: %d\n", rc); return rc; } @@ -433,12 +487,490 @@ static void exit_libcfs_module(void) rc = libcfs_debug_cleanup(); if (rc) - printk(KERN_ERR "LustreError: libcfs_debug_cleanup: %d\n", - rc); + pr_err("LustreError: libcfs_debug_cleanup: %d\n", rc); libcfs_arch_cleanup(); } +static int proc_call_handler(void *data, int write, loff_t *ppos, + void __user *buffer, size_t *lenp, + int (*handler)(void *data, int write, + loff_t pos, void __user *buffer, int len)) +{ + int rc = handler(data, write, *ppos, buffer, *lenp); + + if (rc < 0) + return rc; + + if (write) { + *ppos += *lenp; + } else { + *lenp = rc; + *ppos += rc; + } + return 0; +} + +static int __proc_dobitmasks(void *data, int write, + loff_t pos, void __user *buffer, int nob) +{ + const int tmpstrlen = 512; + char *tmpstr; + int rc; + unsigned int *mask = data; + int is_subsys = (mask == &libcfs_subsystem_debug) ? 1 : 0; + int is_printk = (mask == &libcfs_printk) ? 1 : 0; + + rc = cfs_trace_allocate_string_buffer(&tmpstr, tmpstrlen); + if (rc < 0) + return rc; + + if (!write) { + libcfs_debug_mask2str(tmpstr, tmpstrlen, *mask, is_subsys); + rc = strlen(tmpstr); + + if (pos >= rc) { + rc = 0; + } else { + rc = cfs_trace_copyout_string(buffer, nob, + tmpstr + pos, "\n"); + } + } else { + rc = cfs_trace_copyin_string(tmpstr, tmpstrlen, buffer, nob); + if (rc < 0) { + cfs_trace_free_string_buffer(tmpstr, tmpstrlen); + return rc; + } + + rc = libcfs_debug_str2mask(mask, tmpstr, is_subsys); + /* Always print LBUG/LASSERT to console, so keep this mask */ + if (is_printk) + *mask |= D_EMERG; + } + + cfs_trace_free_string_buffer(tmpstr, tmpstrlen); + return rc; +} + +static int proc_dobitmasks(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + return proc_call_handler(table->data, write, ppos, buffer, lenp, + __proc_dobitmasks); +} + +static int min_watchdog_ratelimit; /* disable ratelimiting */ +static int max_watchdog_ratelimit = (24*60*60); /* limit to once per day */ + +static int __proc_dump_kernel(void *data, int write, + loff_t pos, void __user *buffer, int nob) +{ + if (!write) + return 0; + + return cfs_trace_dump_debug_buffer_usrstr(buffer, nob); +} + +static int proc_dump_kernel(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + return proc_call_handler(table->data, write, ppos, buffer, lenp, + __proc_dump_kernel); +} + +static int __proc_daemon_file(void *data, int write, + loff_t pos, void __user *buffer, int nob) +{ + if (!write) { + int len = strlen(cfs_tracefile); + + if (pos >= len) + return 0; + + return cfs_trace_copyout_string(buffer, nob, + cfs_tracefile + pos, "\n"); + } + + return cfs_trace_daemon_command_usrstr(buffer, nob); +} + +static int proc_daemon_file(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + return proc_call_handler(table->data, write, ppos, buffer, lenp, + __proc_daemon_file); +} + +static int __proc_debug_mb(void *data, int write, + loff_t pos, void __user *buffer, int nob) +{ + if (!write) { + char tmpstr[32]; + int len = snprintf(tmpstr, sizeof(tmpstr), "%d", + cfs_trace_get_debug_mb()); + + if (pos >= len) + return 0; + + return cfs_trace_copyout_string(buffer, nob, tmpstr + pos, + "\n"); + } + + return cfs_trace_set_debug_mb_usrstr(buffer, nob); +} + +static int proc_debug_mb(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + return proc_call_handler(table->data, write, ppos, buffer, lenp, + __proc_debug_mb); +} + +static int proc_console_max_delay_cs(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, + loff_t *ppos) +{ + int rc, max_delay_cs; + struct ctl_table dummy = *table; + long d; + + dummy.data = &max_delay_cs; + dummy.proc_handler = &proc_dointvec; + + if (!write) { /* read */ + max_delay_cs = cfs_duration_sec(libcfs_console_max_delay * 100); + rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); + return rc; + } + + /* write */ + max_delay_cs = 0; + rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); + if (rc < 0) + return rc; + if (max_delay_cs <= 0) + return -EINVAL; + + d = cfs_time_seconds(max_delay_cs) / 100; + if (d == 0 || d < libcfs_console_min_delay) + return -EINVAL; + libcfs_console_max_delay = d; + + return rc; +} + +static int proc_console_min_delay_cs(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, + loff_t *ppos) +{ + int rc, min_delay_cs; + struct ctl_table dummy = *table; + long d; + + dummy.data = &min_delay_cs; + dummy.proc_handler = &proc_dointvec; + + if (!write) { /* read */ + min_delay_cs = cfs_duration_sec(libcfs_console_min_delay * 100); + rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); + return rc; + } + + /* write */ + min_delay_cs = 0; + rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); + if (rc < 0) + return rc; + if (min_delay_cs <= 0) + return -EINVAL; + + d = cfs_time_seconds(min_delay_cs) / 100; + if (d == 0 || d > libcfs_console_max_delay) + return -EINVAL; + libcfs_console_min_delay = d; + + return rc; +} + +static int proc_console_backoff(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + int rc, backoff; + struct ctl_table dummy = *table; + + dummy.data = &backoff; + dummy.proc_handler = &proc_dointvec; + + if (!write) { /* read */ + backoff = libcfs_console_backoff; + rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); + return rc; + } + + /* write */ + backoff = 0; + rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); + if (rc < 0) + return rc; + if (backoff <= 0) + return -EINVAL; + + libcfs_console_backoff = backoff; + + return rc; +} + +static int libcfs_force_lbug(struct ctl_table *table, int write, + void __user *buffer, + size_t *lenp, loff_t *ppos) +{ + if (write) + LBUG(); + return 0; +} + +static int proc_fail_loc(struct ctl_table *table, int write, + void __user *buffer, + size_t *lenp, loff_t *ppos) +{ + int rc; + long old_fail_loc = cfs_fail_loc; + + rc = proc_doulongvec_minmax(table, write, buffer, lenp, ppos); + if (old_fail_loc != cfs_fail_loc) + wake_up(&cfs_race_waitq); + return rc; +} + +static int __proc_cpt_table(void *data, int write, + loff_t pos, void __user *buffer, int nob) +{ + char *buf = NULL; + int len = 4096; + int rc = 0; + + if (write) + return -EPERM; + + LASSERT(cfs_cpt_table != NULL); + + while (1) { + LIBCFS_ALLOC(buf, len); + if (buf == NULL) + return -ENOMEM; + + rc = cfs_cpt_table_print(cfs_cpt_table, buf, len); + if (rc >= 0) + break; + + if (rc == -EFBIG) { + LIBCFS_FREE(buf, len); + len <<= 1; + continue; + } + goto out; + } + + if (pos >= rc) { + rc = 0; + goto out; + } + + rc = cfs_trace_copyout_string(buffer, nob, buf + pos, NULL); + out: + if (buf != NULL) + LIBCFS_FREE(buf, len); + return rc; +} + +static int proc_cpt_table(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + return proc_call_handler(table->data, write, ppos, buffer, lenp, + __proc_cpt_table); +} + +static struct ctl_table lnet_table[] = { + /* + * NB No .strategy entries have been provided since sysctl(8) prefers + * to go via /proc for portability. + */ + { + .procname = "debug", + .data = &libcfs_debug, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dobitmasks, + }, + { + .procname = "subsystem_debug", + .data = &libcfs_subsystem_debug, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dobitmasks, + }, + { + .procname = "printk", + .data = &libcfs_printk, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dobitmasks, + }, + { + .procname = "console_ratelimit", + .data = &libcfs_console_ratelimit, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec + }, + { + .procname = "console_max_delay_centisecs", + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_console_max_delay_cs + }, + { + .procname = "console_min_delay_centisecs", + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_console_min_delay_cs + }, + { + .procname = "console_backoff", + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_console_backoff + }, + + { + .procname = "debug_path", + .data = libcfs_debug_file_path_arr, + .maxlen = sizeof(libcfs_debug_file_path_arr), + .mode = 0644, + .proc_handler = &proc_dostring, + }, + + { + .procname = "cpu_partition_table", + .maxlen = 128, + .mode = 0444, + .proc_handler = &proc_cpt_table, + }, + + { + .procname = "upcall", + .data = lnet_upcall, + .maxlen = sizeof(lnet_upcall), + .mode = 0644, + .proc_handler = &proc_dostring, + }, + { + .procname = "debug_log_upcall", + .data = lnet_debug_log_upcall, + .maxlen = sizeof(lnet_debug_log_upcall), + .mode = 0644, + .proc_handler = &proc_dostring, + }, + { + .procname = "lnet_memused", + .data = (int *)&libcfs_kmemory.counter, + .maxlen = sizeof(int), + .mode = 0444, + .proc_handler = &proc_dointvec, + }, + { + .procname = "catastrophe", + .data = &libcfs_catastrophe, + .maxlen = sizeof(int), + .mode = 0444, + .proc_handler = &proc_dointvec, + }, + { + .procname = "panic_on_lbug", + .data = &libcfs_panic_on_lbug, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, + { + .procname = "dump_kernel", + .maxlen = 256, + .mode = 0200, + .proc_handler = &proc_dump_kernel, + }, + { + .procname = "daemon_file", + .mode = 0644, + .maxlen = 256, + .proc_handler = &proc_daemon_file, + }, + { + .procname = "debug_mb", + .mode = 0644, + .proc_handler = &proc_debug_mb, + }, + { + .procname = "watchdog_ratelimit", + .data = &libcfs_watchdog_ratelimit, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec_minmax, + .extra1 = &min_watchdog_ratelimit, + .extra2 = &max_watchdog_ratelimit, + }, + { + .procname = "force_lbug", + .data = NULL, + .maxlen = 0, + .mode = 0200, + .proc_handler = &libcfs_force_lbug + }, + { + .procname = "fail_loc", + .data = &cfs_fail_loc, + .maxlen = sizeof(cfs_fail_loc), + .mode = 0644, + .proc_handler = &proc_fail_loc + }, + { + .procname = "fail_val", + .data = &cfs_fail_val, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec + }, + { + } +}; + +static struct ctl_table top_table[] = { + { + .procname = "lnet", + .mode = 0555, + .data = NULL, + .maxlen = 0, + .child = lnet_table, + }, + { + } +}; + +static int insert_proc(void) +{ + if (lnet_table_header == NULL) + lnet_table_header = register_sysctl_table(top_table); + return 0; +} + +static void remove_proc(void) +{ + if (lnet_table_header != NULL) + unregister_sysctl_table(lnet_table_header); + + lnet_table_header = NULL; +} + MODULE_VERSION("1.0.0"); + module_init(init_libcfs_module); module_exit(exit_libcfs_module); diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.c b/drivers/staging/lustre/lustre/libcfs/tracefile.c index eb65b50f832d..c86394f7f4d9 100644 --- a/drivers/staging/lustre/lustre/libcfs/tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/tracefile.c @@ -53,7 +53,7 @@ char cfs_tracefile[TRACEFILE_NAME_SIZE]; long long cfs_tracefile_size = CFS_TRACEFILE_SIZE; static struct tracefiled_ctl trace_tctl; struct mutex cfs_trace_thread_mutex; -static int thread_running = 0; +static int thread_running; static atomic_t cfs_tage_allocated = ATOMIC_INIT(0); @@ -224,8 +224,7 @@ static struct cfs_trace_page *cfs_trace_get_tage(struct cfs_trace_cpu_data *tcd, */ if (len > PAGE_CACHE_SIZE) { - printk(KERN_ERR - "cowardly refusing to write %lu bytes in a page\n", len); + pr_err("cowardly refusing to write %lu bytes in a page\n", len); return NULL; } @@ -688,8 +687,8 @@ int cfs_tracefile_dump_all_pages(char *filename) if (IS_ERR(filp)) { rc = PTR_ERR(filp); filp = NULL; - printk(KERN_ERR "LustreError: can't open %s for dump: rc %d\n", - filename, rc); + pr_err("LustreError: can't open %s for dump: rc %d\n", + filename, rc); goto out; } @@ -726,7 +725,7 @@ int cfs_tracefile_dump_all_pages(char *filename) MMSPACE_CLOSE; rc = vfs_fsync(filp, 1); if (rc) - printk(KERN_ERR "sync returns %d\n", rc); + pr_err("sync returns %d\n", rc); close: filp_close(filp, NULL); out: @@ -1048,22 +1047,21 @@ static int tracefiled(void *arg) int i; printk(KERN_ALERT "Lustre: trace pages aren't empty\n"); - printk(KERN_ERR "total cpus(%d): ", - num_possible_cpus()); + pr_err("total cpus(%d): ", + num_possible_cpus()); for (i = 0; i < num_possible_cpus(); i++) if (cpu_online(i)) - printk(KERN_ERR "%d(on) ", i); + pr_cont("%d(on) ", i); else - printk(KERN_ERR "%d(off) ", i); - printk(KERN_ERR "\n"); + pr_cont("%d(off) ", i); + pr_cont("\n"); i = 0; list_for_each_entry_safe(tage, tmp, &pc.pc_pages, linkage) - printk(KERN_ERR "page %d belongs to cpu %d\n", - ++i, tage->cpu); - printk(KERN_ERR "There are %d pages unwritten\n", - i); + pr_err("page %d belongs to cpu %d\n", + ++i, tage->cpu); + pr_err("There are %d pages unwritten\n", i); } __LASSERT(list_empty(&pc.pc_pages)); end_loop: diff --git a/drivers/staging/lustre/lustre/libcfs/workitem.c b/drivers/staging/lustre/lustre/libcfs/workitem.c index c4afaeaf8310..48009b775845 100644 --- a/drivers/staging/lustre/lustre/libcfs/workitem.c +++ b/drivers/staging/lustre/lustre/libcfs/workitem.c @@ -442,7 +442,7 @@ cfs_wi_startup(void) } void -cfs_wi_shutdown (void) +cfs_wi_shutdown(void) { struct cfs_wi_sched *sched; |