diff options
Diffstat (limited to 'drivers/staging/lustre/lustre/libcfs')
23 files changed, 99 insertions, 830 deletions
diff --git a/drivers/staging/lustre/lustre/libcfs/Makefile b/drivers/staging/lustre/lustre/libcfs/Makefile index bf5c563dcacc..6e489d7aaa8b 100644 --- a/drivers/staging/lustre/lustre/libcfs/Makefile +++ b/drivers/staging/lustre/lustre/libcfs/Makefile @@ -11,7 +11,7 @@ libcfs-linux-objs += linux-crypto-adler.o libcfs-linux-objs := $(addprefix linux/,$(libcfs-linux-objs)) libcfs-all-objs := debug.o fail.o nidstrings.o module.o tracefile.o \ - watchdog.o libcfs_string.o hash.o kernel_user_comm.o \ + libcfs_string.o hash.o kernel_user_comm.o \ prng.o workitem.o upcall_cache.o libcfs_cpu.o \ libcfs_mem.o libcfs_lock.o diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c index 5a87b0832074..9b9c45116eee 100644 --- a/drivers/staging/lustre/lustre/libcfs/debug.c +++ b/drivers/staging/lustre/lustre/libcfs/debug.c @@ -335,9 +335,10 @@ libcfs_debug_str2mask(int *mask, const char *str, int is_subsys) */ void libcfs_debug_dumplog_internal(void *arg) { - DECL_JOURNAL_DATA; + void *journal_info; - PUSH_JOURNAL; + journal_info = current->journal_info; + current->journal_info = NULL; if (strncmp(libcfs_debug_file_path_arr, "NONE", 4) != 0) { snprintf(debug_file_name, sizeof(debug_file_name) - 1, @@ -348,7 +349,8 @@ void libcfs_debug_dumplog_internal(void *arg) cfs_tracefile_dump_all_pages(debug_file_name); libcfs_run_debug_log_upcall(debug_file_name); } - POP_JOURNAL; + + current->journal_info = journal_info; } int libcfs_debug_dumplog_thread(void *arg) @@ -361,8 +363,7 @@ int libcfs_debug_dumplog_thread(void *arg) void libcfs_debug_dumplog(void) { wait_queue_t wait; - task_t *dumper; - ENTRY; + struct task_struct *dumper; /* we're being careful to ensure that the kernel thread is * able to set our state to running as it exits before we @@ -459,14 +460,6 @@ void libcfs_debug_set_level(unsigned int debug_level) EXPORT_SYMBOL(libcfs_debug_set_level); -long libcfs_log_return(struct libcfs_debug_msg_data *msgdata, long rc) -{ - libcfs_debug_msg(msgdata, "Process leaving (rc=%lu : %ld : %lx)\n", - rc, rc, rc); - return rc; -} -EXPORT_SYMBOL(libcfs_log_return); - void libcfs_log_goto(struct libcfs_debug_msg_data *msgdata, const char *label, long_ptr_t rc) { diff --git a/drivers/staging/lustre/lustre/libcfs/hash.c b/drivers/staging/lustre/lustre/libcfs/hash.c index 98c76dfac3dd..0dd12c8c91b6 100644 --- a/drivers/staging/lustre/lustre/libcfs/hash.c +++ b/drivers/staging/lustre/lustre/libcfs/hash.c @@ -1026,8 +1026,6 @@ cfs_hash_create(char *name, unsigned cur_bits, unsigned max_bits, cfs_hash_t *hs; int len; - ENTRY; - CLASSERT(CFS_HASH_THETA_BITS < 15); LASSERT(name != NULL); @@ -1055,7 +1053,7 @@ cfs_hash_create(char *name, unsigned cur_bits, unsigned max_bits, CFS_HASH_NAME_LEN : CFS_HASH_BIGNAME_LEN; LIBCFS_ALLOC(hs, offsetof(cfs_hash_t, hs_name[len])); if (hs == NULL) - RETURN(NULL); + return NULL; strncpy(hs->hs_name, name, len); hs->hs_name[len - 1] = '\0'; @@ -1087,7 +1085,7 @@ cfs_hash_create(char *name, unsigned cur_bits, unsigned max_bits, return hs; LIBCFS_FREE(hs, offsetof(cfs_hash_t, hs_name[len])); - RETURN(NULL); + return NULL; } EXPORT_SYMBOL(cfs_hash_create); @@ -1101,7 +1099,6 @@ cfs_hash_destroy(cfs_hash_t *hs) struct hlist_node *pos; cfs_hash_bd_t bd; int i; - ENTRY; LASSERT(hs != NULL); LASSERT(!cfs_hash_is_exiting(hs) && @@ -1152,8 +1149,6 @@ cfs_hash_destroy(cfs_hash_t *hs) i = cfs_hash_with_bigname(hs) ? CFS_HASH_BIGNAME_LEN : CFS_HASH_NAME_LEN; LIBCFS_FREE(hs, offsetof(cfs_hash_t, hs_name[i])); - - EXIT; } cfs_hash_t *cfs_hash_getref(cfs_hash_t *hs) @@ -1449,7 +1444,6 @@ cfs_hash_for_each_tight(cfs_hash_t *hs, cfs_hash_for_each_cb_t func, int excl = !!remove_safe; int loop = 0; int i; - ENTRY; cfs_hash_for_each_enter(hs); @@ -1489,7 +1483,7 @@ cfs_hash_for_each_tight(cfs_hash_t *hs, cfs_hash_for_each_cb_t func, cfs_hash_unlock(hs, 0); cfs_hash_for_each_exit(hs); - RETURN(count); + return count; } typedef struct { @@ -1594,7 +1588,6 @@ cfs_hash_for_each_relax(cfs_hash_t *hs, cfs_hash_for_each_cb_t func, void *data) int stop_on_change; int rc; int i; - ENTRY; stop_on_change = cfs_hash_with_rehash_key(hs) || !cfs_hash_with_no_itemref(hs) || @@ -1649,23 +1642,21 @@ int cfs_hash_for_each_nolock(cfs_hash_t *hs, cfs_hash_for_each_cb_t func, void *data) { - ENTRY; - if (cfs_hash_with_no_lock(hs) || cfs_hash_with_rehash_key(hs) || !cfs_hash_with_no_itemref(hs)) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; if (CFS_HOP(hs, get) == NULL || (CFS_HOP(hs, put) == NULL && CFS_HOP(hs, put_locked) == NULL)) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; cfs_hash_for_each_enter(hs); cfs_hash_for_each_relax(hs, func, data); cfs_hash_for_each_exit(hs); - RETURN(0); + return 0; } EXPORT_SYMBOL(cfs_hash_for_each_nolock); @@ -1685,7 +1676,6 @@ cfs_hash_for_each_empty(cfs_hash_t *hs, cfs_hash_for_each_cb_t func, void *data) { unsigned i = 0; - ENTRY; if (cfs_hash_with_no_lock(hs)) return -EOPNOTSUPP; @@ -1701,7 +1691,7 @@ cfs_hash_for_each_empty(cfs_hash_t *hs, hs->hs_name, i++); } cfs_hash_for_each_exit(hs); - RETURN(0); + return 0; } EXPORT_SYMBOL(cfs_hash_for_each_empty); diff --git a/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c b/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c index d6d3b2e0f307..74a0db5c154a 100644 --- a/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c +++ b/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c @@ -246,10 +246,9 @@ EXPORT_SYMBOL(libcfs_kkuc_group_add); int libcfs_kkuc_group_rem(int uid, int group) { struct kkuc_reg *reg, *next; - ENTRY; if (kkuc_groups[group].next == NULL) - RETURN(0); + return 0; if (uid == 0) { /* Broadcast a shutdown message */ @@ -275,7 +274,7 @@ int libcfs_kkuc_group_rem(int uid, int group) } up_write(&kg_sem); - RETURN(0); + return 0; } EXPORT_SYMBOL(libcfs_kkuc_group_rem); @@ -284,7 +283,6 @@ int libcfs_kkuc_group_put(int group, void *payload) struct kkuc_reg *reg; int rc = 0; int one_success = 0; - ENTRY; down_read(&kg_sem); list_for_each_entry(reg, &kkuc_groups[group], kr_chain) { @@ -305,7 +303,7 @@ int libcfs_kkuc_group_put(int group, void *payload) if (one_success) rc = 0; - RETURN(rc); + return rc; } EXPORT_SYMBOL(libcfs_kkuc_group_put); @@ -320,16 +318,15 @@ int libcfs_kkuc_group_foreach(int group, libcfs_kkuc_cb_t cb_func, { struct kkuc_reg *reg; int rc = 0; - ENTRY; if (group > KUC_GRP_MAX) { CDEBUG(D_WARNING, "Kernelcomm: bad group %d\n", group); - RETURN(-EINVAL); + return -EINVAL; } /* no link for this group */ if (kkuc_groups[group].next == NULL) - RETURN(0); + return 0; down_read(&kg_sem); list_for_each_entry(reg, &kkuc_groups[group], kr_chain) { @@ -339,7 +336,7 @@ int libcfs_kkuc_group_foreach(int group, libcfs_kkuc_cb_t cb_func, } up_read(&kg_sem); - RETURN(rc); + return rc; } EXPORT_SYMBOL(libcfs_kkuc_group_foreach); diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c b/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c index 8e88eb59dd51..1fb37008cda2 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c @@ -33,9 +33,6 @@ * Author: liang@whamcloud.com */ -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif #define DEBUG_SUBSYSTEM S_LNET #include <linux/libcfs/libcfs.h> diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c b/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c index 8d6c4adf2ee6..a2ce4c0eb3dc 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c @@ -30,9 +30,6 @@ * Author: liang@whamcloud.com */ -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif #define DEBUG_SUBSYSTEM S_LNET #include <linux/libcfs/libcfs.h> diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c b/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c index 879137303482..feab537c728c 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c @@ -31,9 +31,6 @@ * Author: liang@whamcloud.com */ -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif #define DEBUG_SUBSYSTEM S_LNET #include <linux/libcfs/libcfs.h> diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c index 9edccc99683e..922debd0a412 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c @@ -69,7 +69,6 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit), const char *debugstr; char op = 0; int newmask = minmask, i, len, found = 0; - ENTRY; /* <str> must be a list of tokens separated by whitespace * and optionally an operator ('+' or '-'). If an operator @@ -132,54 +131,6 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit), } EXPORT_SYMBOL(cfs_str2mask); -/* Duplicate a string in a platform-independent way */ -char *cfs_strdup(const char *str, u_int32_t flags) -{ - size_t lenz; /* length of str + zero byte */ - char *dup_str; - - lenz = strlen(str) + 1; - - dup_str = kmalloc(lenz, flags); - if (dup_str == NULL) - return NULL; - - memcpy(dup_str, str, lenz); - - return dup_str; -} -EXPORT_SYMBOL(cfs_strdup); - -/** - * cfs_{v}snprintf() return the actual size that is printed rather than - * the size that would be printed in standard functions. - */ -/* safe vsnprintf */ -int cfs_vsnprintf(char *buf, size_t size, const char *fmt, va_list args) -{ - int i; - - LASSERT(size > 0); - i = vsnprintf(buf, size, fmt, args); - - return (i >= size ? size - 1 : i); -} -EXPORT_SYMBOL(cfs_vsnprintf); - -/* safe snprintf */ -int cfs_snprintf(char *buf, size_t size, const char *fmt, ...) -{ - va_list args; - int i; - - va_start(args, fmt); - i = cfs_vsnprintf(buf, size, fmt, args); - va_end(args); - - return i; -} -EXPORT_SYMBOL(cfs_snprintf); - /* get the first string out of @str */ char *cfs_firststr(char *str, size_t size) { diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c index 95142d190971..00ab8fdc1053 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c @@ -76,62 +76,22 @@ struct cfs_cpt_data { static struct cfs_cpt_data cpt_data; -void -cfs_cpu_core_siblings(int cpu, cpumask_t *mask) +static void cfs_cpu_core_siblings(int cpu, cpumask_t *mask) { /* return cpumask of cores in the same socket */ cpumask_copy(mask, topology_core_cpumask(cpu)); } -EXPORT_SYMBOL(cfs_cpu_core_siblings); - -/* return number of cores in the same socket of \a cpu */ -int -cfs_cpu_core_nsiblings(int cpu) -{ - int num; - - down(&cpt_data.cpt_mutex); - - cfs_cpu_core_siblings(cpu, cpt_data.cpt_cpumask); - num = cpus_weight(*cpt_data.cpt_cpumask); - - up(&cpt_data.cpt_mutex); - - return num; -} -EXPORT_SYMBOL(cfs_cpu_core_nsiblings); /* return cpumask of HTs in the same core */ -void -cfs_cpu_ht_siblings(int cpu, cpumask_t *mask) +static void cfs_cpu_ht_siblings(int cpu, cpumask_t *mask) { cpumask_copy(mask, topology_thread_cpumask(cpu)); } -EXPORT_SYMBOL(cfs_cpu_ht_siblings); -/* return number of HTs in the same core of \a cpu */ -int -cfs_cpu_ht_nsiblings(int cpu) -{ - int num; - - down(&cpt_data.cpt_mutex); - - cfs_cpu_ht_siblings(cpu, cpt_data.cpt_cpumask); - num = cpus_weight(*cpt_data.cpt_cpumask); - - up(&cpt_data.cpt_mutex); - - return num; -} -EXPORT_SYMBOL(cfs_cpu_ht_nsiblings); - -void -cfs_node_to_cpumask(int node, cpumask_t *mask) +static void cfs_node_to_cpumask(int node, cpumask_t *mask) { cpumask_copy(mask, cpumask_of_node(node)); } -EXPORT_SYMBOL(cfs_node_to_cpumask); void cfs_cpt_table_free(struct cfs_cpt_table *cptab) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c index 8e35777b4da5..b6c79bc177ad 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c @@ -274,6 +274,8 @@ static int adler32; int cfs_crypto_register(void) { + request_module("crc32c"); + adler32 = cfs_crypto_adler32_register(); /* check all algorithms and do performance test */ diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c index f236510a2f3f..ea9e9490031f 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c @@ -65,20 +65,6 @@ int cfs_curproc_groups_nr(void) return nr; } -void cfs_curproc_groups_dump(gid_t *array, int size) -{ - task_lock(current); - size = min_t(int, size, current_cred()->group_info->ngroups); - memcpy(array, current_cred()->group_info->blocks[0], size * sizeof(__u32)); - task_unlock(current); -} - - -int current_is_in_group(gid_t gid) -{ - return in_group_p(gid); -} - /* Currently all the CFS_CAP_* defines match CAP_* ones. */ #define cfs_cap_pack(cap) (cap) #define cfs_cap_unpack(cap) (cap) @@ -226,16 +212,15 @@ int cfs_get_environ(const char *key, char *value, int *val_len) int key_len = strlen(key); unsigned long addr; int rc; - ENTRY; buffer = kmalloc(buf_len, GFP_USER); if (!buffer) - RETURN(-ENOMEM); + return -ENOMEM; mm = get_task_mm(current); if (!mm) { kfree(buffer); - RETURN(-EINVAL); + return -EINVAL; } /* Avoid deadlocks on mmap_sem if called from sys_mmap_pgoff(), @@ -318,8 +303,6 @@ out: EXPORT_SYMBOL(cfs_get_environ); EXPORT_SYMBOL(cfs_curproc_groups_nr); -EXPORT_SYMBOL(cfs_curproc_groups_dump); -EXPORT_SYMBOL(current_is_in_group); EXPORT_SYMBOL(cfs_cap_raise); EXPORT_SYMBOL(cfs_cap_lower); EXPORT_SYMBOL(cfs_cap_raised); diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c index e2c195b8dd53..ab1e73168472 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c @@ -48,14 +48,10 @@ #include <linux/errno.h> #include <linux/unistd.h> #include <linux/interrupt.h> -#include <asm/uaccess.h> #include <linux/completion.h> - #include <linux/fs.h> -#include <linux/stat.h> #include <asm/uaccess.h> #include <linux/miscdevice.h> -#include <linux/version.h> # define DEBUG_SUBSYSTEM S_LNET @@ -82,7 +78,6 @@ void libcfs_run_debug_log_upcall(char *file) "HOME=/", "PATH=/sbin:/bin:/usr/sbin:/usr/bin", NULL}; - ENTRY; argv[0] = lnet_debug_log_upcall; @@ -100,8 +95,6 @@ void libcfs_run_debug_log_upcall(char *file) CDEBUG(D_HA, "Invoked LNET debug log upcall %s %s\n", argv[0], argv[1]); } - - EXIT; } void libcfs_run_upcall(char **argv) @@ -112,7 +105,6 @@ void libcfs_run_upcall(char **argv) "HOME=/", "PATH=/sbin:/bin:/usr/sbin:/usr/bin", NULL}; - ENTRY; argv[0] = lnet_upcall; argc = 1; @@ -145,7 +137,6 @@ void libcfs_run_lbug_upcall(struct libcfs_debug_msg_data *msgdata) char *argv[6]; char buf[32]; - ENTRY; snprintf (buf, sizeof buf, "%d", msgdata->msg_line); argv[1] = "LBUG"; @@ -168,7 +159,7 @@ void lbug_with_loc(struct libcfs_debug_msg_data *msgdata) /* not reached */ } - libcfs_debug_dumpstack(NULL); + dump_stack(); if (!libcfs_panic_on_lbug) libcfs_debug_dumplog(); libcfs_run_lbug_upcall(msgdata); @@ -179,54 +170,6 @@ void lbug_with_loc(struct libcfs_debug_msg_data *msgdata) schedule(); } - -#include <linux/nmi.h> -#include <asm/stacktrace.h> - - -static int print_trace_stack(void *data, char *name) -{ - printk(" <%s> ", name); - return 0; -} - -# define RELIABLE reliable -# define DUMP_TRACE_CONST const -static void print_trace_address(void *data, unsigned long addr, int reliable) -{ - char fmt[32]; - touch_nmi_watchdog(); - sprintf(fmt, " [<%016lx>] %s%%s\n", addr, RELIABLE ? "": "? "); - __print_symbol(fmt, addr); -} - -static DUMP_TRACE_CONST struct stacktrace_ops print_trace_ops = { - .stack = print_trace_stack, - .address = print_trace_address, - .walk_stack = print_context_stack, -}; - -void libcfs_debug_dumpstack(struct task_struct *tsk) -{ - /* dump_stack() */ - /* show_trace() */ - if (tsk == NULL) - tsk = current; - printk("Pid: %d, comm: %.20s\n", tsk->pid, tsk->comm); - /* show_trace_log_lvl() */ - printk("\nCall Trace:\n"); - dump_trace(tsk, NULL, NULL, - 0, - &print_trace_ops, NULL); - printk("\n"); -} - -task_t *libcfs_current(void) -{ - CWARN("current task struct is %p\n", current); - return current; -} - static int panic_notifier(struct notifier_block *self, unsigned long unused1, void *unused2) { @@ -240,9 +183,9 @@ static int panic_notifier(struct notifier_block *self, unsigned long unused1, } static struct notifier_block libcfs_panic_notifier = { - notifier_call : panic_notifier, - next : NULL, - priority : 10000 + .notifier_call = panic_notifier, + .next = NULL, + .priority = 10000, }; void libcfs_register_panic_notifier(void) @@ -255,10 +198,6 @@ void libcfs_unregister_panic_notifier(void) atomic_notifier_chain_unregister(&panic_notifier_list, &libcfs_panic_notifier); } -EXPORT_SYMBOL(libcfs_debug_dumpstack); -EXPORT_SYMBOL(libcfs_current); - - EXPORT_SYMBOL(libcfs_run_upcall); EXPORT_SYMBOL(libcfs_run_lbug_upcall); EXPORT_SYMBOL(lbug_with_loc); diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c index 2c7d4a3d660f..55296a3591d5 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c @@ -45,38 +45,37 @@ int libcfs_ioctl_getdata(char *buf, char *end, void *arg) struct libcfs_ioctl_hdr *hdr; struct libcfs_ioctl_data *data; int err; - ENTRY; hdr = (struct libcfs_ioctl_hdr *)buf; data = (struct libcfs_ioctl_data *)buf; err = copy_from_user(buf, (void *)arg, sizeof(*hdr)); if (err) - RETURN(err); + return err; if (hdr->ioc_version != LIBCFS_IOCTL_VERSION) { CERROR("PORTALS: version mismatch kernel vs application\n"); - RETURN(-EINVAL); + return -EINVAL; } if (hdr->ioc_len + buf >= end) { CERROR("PORTALS: user buffer exceeds kernel buffer\n"); - RETURN(-EINVAL); + return -EINVAL; } if (hdr->ioc_len < sizeof(struct libcfs_ioctl_data)) { CERROR("PORTALS: user buffer too small for ioctl\n"); - RETURN(-EINVAL); + return -EINVAL; } err = copy_from_user(buf, (void *)arg, hdr->ioc_len); if (err) - RETURN(err); + return err; if (libcfs_ioctl_is_invalid(data)) { CERROR("PORTALS: ioctl not correctly formatted\n"); - RETURN(-EINVAL); + return -EINVAL; } if (data->ioc_inllen1) @@ -86,7 +85,7 @@ int libcfs_ioctl_getdata(char *buf, char *end, void *arg) data->ioc_inlbuf2 = &data->ioc_bulk[0] + cfs_size_round(data->ioc_inllen1); - RETURN(0); + return 0; } int libcfs_ioctl_popdata(void *arg, void *data, int size) @@ -137,7 +136,7 @@ static long libcfs_ioctl(struct file *file, struct cfs_psdev_file pfile; int rc = 0; - if (current_fsuid() != 0) + if (!capable(CAP_SYS_ADMIN)) return -EACCES; if ( _IOC_TYPE(cmd) != IOC_LIBCFS_TYPE || @@ -171,13 +170,13 @@ static long libcfs_ioctl(struct file *file, } static struct file_operations libcfs_fops = { - unlocked_ioctl: libcfs_ioctl, - open : libcfs_psdev_open, - release : libcfs_psdev_release + .unlocked_ioctl = libcfs_ioctl, + .open = libcfs_psdev_open, + .release = libcfs_psdev_release, }; -psdev_t libcfs_dev = { - LNET_MINOR, - "lnet", - &libcfs_fops +struct miscdevice libcfs_dev = { + .minor = LNET_MINOR, + .name = "lnet", + .fops = &libcfs_fops, }; diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c index b652a79a4811..cc9829ffbdcb 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c @@ -81,22 +81,21 @@ add_wait_queue_exclusive_head(wait_queue_head_t *waitq, wait_queue_t *link) EXPORT_SYMBOL(add_wait_queue_exclusive_head); void -waitq_wait(wait_queue_t *link, cfs_task_state_t state) +waitq_wait(wait_queue_t *link, long state) { schedule(); } EXPORT_SYMBOL(waitq_wait); int64_t -waitq_timedwait(wait_queue_t *link, cfs_task_state_t state, - int64_t timeout) +waitq_timedwait(wait_queue_t *link, long state, int64_t timeout) { return schedule_timeout(timeout); } EXPORT_SYMBOL(waitq_timedwait); void -schedule_timeout_and_set_state(cfs_task_state_t state, int64_t timeout) +schedule_timeout_and_set_state(long state, int64_t timeout) { set_current_state(state); schedule_timeout(timeout); @@ -112,13 +111,13 @@ cfs_pause(cfs_duration_t ticks) } EXPORT_SYMBOL(cfs_pause); -void cfs_init_timer(timer_list_t *t) +void cfs_init_timer(struct timer_list *t) { init_timer(t); } EXPORT_SYMBOL(cfs_init_timer); -void cfs_timer_init(timer_list_t *t, cfs_timer_func_t *func, void *arg) +void cfs_timer_init(struct timer_list *t, cfs_timer_func_t *func, void *arg) { init_timer(t); t->function = func; @@ -126,31 +125,31 @@ void cfs_timer_init(timer_list_t *t, cfs_timer_func_t *func, void *arg) } EXPORT_SYMBOL(cfs_timer_init); -void cfs_timer_done(timer_list_t *t) +void cfs_timer_done(struct timer_list *t) { return; } EXPORT_SYMBOL(cfs_timer_done); -void cfs_timer_arm(timer_list_t *t, cfs_time_t deadline) +void cfs_timer_arm(struct timer_list *t, cfs_time_t deadline) { mod_timer(t, deadline); } EXPORT_SYMBOL(cfs_timer_arm); -void cfs_timer_disarm(timer_list_t *t) +void cfs_timer_disarm(struct timer_list *t) { del_timer(t); } EXPORT_SYMBOL(cfs_timer_disarm); -int cfs_timer_is_armed(timer_list_t *t) +int cfs_timer_is_armed(struct timer_list *t) { return timer_pending(t); } EXPORT_SYMBOL(cfs_timer_is_armed); -cfs_time_t cfs_timer_deadline(timer_list_t *t) +cfs_time_t cfs_timer_deadline(struct timer_list *t) { return t->expires; } diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c index 522b28e99e41..fc6c97749487 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c @@ -54,9 +54,7 @@ #include <linux/fs.h> #include <linux/file.h> -#include <linux/stat.h> #include <linux/list.h> -#include <asm/uaccess.h> #include <linux/proc_fs.h> #include <linux/sysctl.h> @@ -564,7 +562,7 @@ int insert_proc(void) { #ifdef CONFIG_SYSCTL if (lnet_table_header == NULL) - lnet_table_header = cfs_register_sysctl_table(top_table, 0); + lnet_table_header = register_sysctl_table(top_table); #endif return 0; } diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c index 855c7e87d96f..e6069d78af6b 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c @@ -36,7 +36,6 @@ #define DEBUG_SUBSYSTEM S_LNET #include <linux/libcfs/libcfs.h> -#include <linux/libcfs/libcfs.h> #include <linux/if.h> #include <linux/in.h> @@ -641,8 +640,8 @@ libcfs_sock_connect (struct socket **sockp, int *fatal, *fatal = !(rc == -EADDRNOTAVAIL); CDEBUG_LIMIT(*fatal ? D_NETERROR : D_NET, - "Error %d connecting %u.%u.%u.%u/%d -> %u.%u.%u.%u/%d\n", rc, - HIPQUAD(local_ip), local_port, HIPQUAD(peer_ip), peer_port); + "Error %d connecting %pI4h/%d -> %pI4h/%d\n", rc, + &local_ip, local_port, &peer_ip, peer_port); sock_release(*sockp); return rc; diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c index 6f563436a255..162beee24a73 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c @@ -51,7 +51,7 @@ char *cfs_trace_console_buffers[NR_CPUS][CFS_TCD_TYPE_MAX]; struct rw_semaphore cfs_tracefile_sem; -int cfs_tracefile_init_arch() +int cfs_tracefile_init_arch(void) { int i; int j; @@ -96,7 +96,7 @@ out: return -ENOMEM; } -void cfs_tracefile_fini_arch() +void cfs_tracefile_fini_arch(void) { int i; int j; @@ -116,27 +116,27 @@ void cfs_tracefile_fini_arch() fini_rwsem(&cfs_tracefile_sem); } -void cfs_tracefile_read_lock() +void cfs_tracefile_read_lock(void) { down_read(&cfs_tracefile_sem); } -void cfs_tracefile_read_unlock() +void cfs_tracefile_read_unlock(void) { up_read(&cfs_tracefile_sem); } -void cfs_tracefile_write_lock() +void cfs_tracefile_write_lock(void) { down_write(&cfs_tracefile_sem); } -void cfs_tracefile_write_unlock() +void cfs_tracefile_write_unlock(void) { up_write(&cfs_tracefile_sem); } -cfs_trace_buf_type_t cfs_trace_buf_idx_get() +cfs_trace_buf_type_t cfs_trace_buf_idx_get(void) { if (in_irq()) return CFS_TCD_TYPE_IRQ; @@ -269,7 +269,7 @@ void cfs_print_to_console(struct ptldebug_header *hdr, int mask, int cfs_trace_max_debug_mb(void) { - int total_mb = (num_physpages >> (20 - PAGE_SHIFT)); + int total_mb = (totalram_pages >> (20 - PAGE_SHIFT)); return MAX(512, (total_mb * 80)/100); } diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index 3372537c6f3b..f3108c7f818e 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -155,7 +155,6 @@ kportal_memhog_alloc (struct libcfs_device_userstate *ldu, int npages, int flags static int libcfs_psdev_open(unsigned long flags, void *args) { struct libcfs_device_userstate *ldu; - ENTRY; try_module_get(THIS_MODULE); @@ -166,14 +165,13 @@ static int libcfs_psdev_open(unsigned long flags, void *args) } *(struct libcfs_device_userstate **)args = ldu; - RETURN(0); + return 0; } /* called when closing /dev/device */ static int libcfs_psdev_release(unsigned long flags, void *args) { struct libcfs_device_userstate *ldu; - ENTRY; ldu = (struct libcfs_device_userstate *)args; if (ldu != NULL) { @@ -182,7 +180,7 @@ static int libcfs_psdev_release(unsigned long flags, void *args) } module_put(THIS_MODULE); - RETURN(0); + return 0; } static struct rw_semaphore ioctl_list_sem; @@ -222,12 +220,11 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile,unsigned long cmd, void *arg, struct libcfs_ioctl_data *data) { int err = -EINVAL; - ENTRY; switch (cmd) { case IOC_LIBCFS_CLEAR_DEBUG: libcfs_debug_clear_buffer(); - RETURN(0); + return 0; /* * case IOC_LIBCFS_PANIC: * Handled in arch/cfs_module.c @@ -235,9 +232,9 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile,unsigned long cmd, case IOC_LIBCFS_MARK_DEBUG: if (data->ioc_inlbuf1 == NULL || data->ioc_inlbuf1[data->ioc_inllen1 - 1] != '\0') - RETURN(-EINVAL); + return -EINVAL; libcfs_debug_mark_buffer(data->ioc_inlbuf1); - RETURN(0); + return 0; #if LWT_SUPPORT case IOC_LIBCFS_LWT_CONTROL: err = lwt_control ((data->ioc_flags & 1) != 0, @@ -301,7 +298,7 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile,unsigned long cmd, ping(data); symbol_put(kping_client); } - RETURN(0); + return 0; } default: { @@ -322,7 +319,7 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile,unsigned long cmd, } } - RETURN(err); + return err; } static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd, void *arg) @@ -330,11 +327,10 @@ static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd, void *a char *buf; struct libcfs_ioctl_data *data; int err = 0; - ENTRY; LIBCFS_ALLOC_GFP(buf, 1024, GFP_IOFS); if (buf == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* 'cmd' and permissions get checked in our arch-specific caller */ if (libcfs_ioctl_getdata(buf, buf + 800, (void *)arg)) { @@ -347,7 +343,7 @@ static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd, void *a out: LIBCFS_FREE(buf, 1024); - RETURN(err); + return err; } @@ -365,7 +361,7 @@ MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>"); MODULE_DESCRIPTION("Portals v3.1"); MODULE_LICENSE("GPL"); -extern psdev_t libcfs_dev; +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; @@ -495,4 +491,6 @@ static void exit_libcfs_module(void) libcfs_arch_cleanup(); } -cfs_module(libcfs, "1.0.0", init_libcfs_module, exit_libcfs_module); +MODULE_VERSION("1.0.0"); +module_init(init_libcfs_module); +module_exit(exit_libcfs_module); diff --git a/drivers/staging/lustre/lustre/libcfs/nidstrings.c b/drivers/staging/lustre/lustre/libcfs/nidstrings.c index ccfd1078a906..99c9e9d2493f 100644 --- a/drivers/staging/lustre/lustre/libcfs/nidstrings.c +++ b/drivers/staging/lustre/lustre/libcfs/nidstrings.c @@ -785,7 +785,6 @@ cfs_parse_nidlist(char *str, int len, struct list_head *nidlist) struct cfs_lstr src; struct cfs_lstr res; int rc; - ENTRY; src.ls_str = str; src.ls_len = len; @@ -794,15 +793,15 @@ cfs_parse_nidlist(char *str, int len, struct list_head *nidlist) rc = cfs_gettok(&src, ' ', &res); if (rc == 0) { cfs_free_nidlist(nidlist); - RETURN(0); + return 0; } rc = parse_nidrange(&res, nidlist); if (rc == 0) { cfs_free_nidlist(nidlist); - RETURN(0); + return 0; } } - RETURN(1); + return 1; } /* @@ -834,7 +833,6 @@ int cfs_match_nid(lnet_nid_t nid, struct list_head *nidlist) { struct nidrange *nr; struct addrrange *ar; - ENTRY; list_for_each_entry(nr, nidlist, nr_link) { if (nr->nr_netstrfns->nf_type != LNET_NETTYP(LNET_NIDNET(nid))) @@ -842,13 +840,13 @@ int cfs_match_nid(lnet_nid_t nid, struct list_head *nidlist) if (nr->nr_netnum != LNET_NETNUM(LNET_NIDNET(nid))) continue; if (nr->nr_all) - RETURN(1); + return 1; list_for_each_entry(ar, &nr->nr_addrranges, ar_link) if (nr->nr_netstrfns->nf_match_addr(LNET_NIDADDR(nid), &ar->ar_numaddr_ranges)) - RETURN(1); + return 1; } - RETURN(0); + return 0; } diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.c b/drivers/staging/lustre/lustre/libcfs/tracefile.c index 439e71dfae33..357f40079ae0 100644 --- a/drivers/staging/lustre/lustre/libcfs/tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/tracefile.c @@ -275,12 +275,9 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata, int i; int remain; int mask = msgdata->msg_mask; - char *file = (char *)msgdata->msg_file; + const char *file = kbasename(msgdata->msg_file); cfs_debug_limit_state_t *cdls = msgdata->msg_cdls; - if (strchr(file, '/')) - file = strrchr(file, '/') + 1; - tcd = cfs_trace_get_tcd(); /* cfs_trace_get_tcd() grabs a lock, which disables preemption and @@ -529,7 +526,7 @@ static void collect_pages_on_all_cpus(struct page_collection *pc) int i, cpu; spin_lock(&pc->pc_lock); - cfs_for_each_possible_cpu(cpu) { + for_each_possible_cpu(cpu) { cfs_tcd_for_each_type_lock(tcd, i, cpu) { list_splice_init(&tcd->tcd_pages, &pc->pc_pages); tcd->tcd_cur_pages = 0; @@ -562,7 +559,7 @@ static void put_pages_back_on_all_cpus(struct page_collection *pc) int i, cpu; spin_lock(&pc->pc_lock); - cfs_for_each_possible_cpu(cpu) { + for_each_possible_cpu(cpu) { cfs_tcd_for_each_type_lock(tcd, i, cpu) { cur_head = tcd->tcd_pages.next; @@ -630,7 +627,7 @@ static void put_pages_on_daemon_list(struct page_collection *pc) struct cfs_trace_cpu_data *tcd; int i, cpu; - cfs_for_each_possible_cpu(cpu) { + for_each_possible_cpu(cpu) { cfs_tcd_for_each_type_lock(tcd, i, cpu) put_pages_on_tcd_daemon_list(pc, tcd); } @@ -1159,7 +1156,7 @@ static void trace_cleanup_on_all_cpus(void) struct cfs_trace_page *tmp; int i, cpu; - cfs_for_each_possible_cpu(cpu) { + for_each_possible_cpu(cpu) { cfs_tcd_for_each_type_lock(tcd, i, cpu) { tcd->tcd_shutting_down = 1; diff --git a/drivers/staging/lustre/lustre/libcfs/upcall_cache.c b/drivers/staging/lustre/lustre/libcfs/upcall_cache.c index 18c68c3493b8..245b46f0dd96 100644 --- a/drivers/staging/lustre/lustre/libcfs/upcall_cache.c +++ b/drivers/staging/lustre/lustre/libcfs/upcall_cache.c @@ -152,7 +152,6 @@ struct upcall_cache_entry *upcall_cache_get_entry(struct upcall_cache *cache, struct list_head *head; wait_queue_t wait; int rc, found; - ENTRY; LASSERT(cache); @@ -176,7 +175,7 @@ find_again: new = alloc_entry(cache, key, args); if (!new) { CERROR("fail to alloc entry\n"); - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); } goto find_again; } else { @@ -266,17 +265,14 @@ find_again: /* Now we know it's good */ out: spin_unlock(&cache->uc_lock); - RETURN(entry); + return entry; } EXPORT_SYMBOL(upcall_cache_get_entry); void upcall_cache_put_entry(struct upcall_cache *cache, struct upcall_cache_entry *entry) { - ENTRY; - if (!entry) { - EXIT; return; } @@ -284,7 +280,6 @@ void upcall_cache_put_entry(struct upcall_cache *cache, spin_lock(&cache->uc_lock); put_entry(cache, entry); spin_unlock(&cache->uc_lock); - EXIT; } EXPORT_SYMBOL(upcall_cache_put_entry); @@ -294,7 +289,6 @@ int upcall_cache_downcall(struct upcall_cache *cache, __u32 err, __u64 key, struct upcall_cache_entry *entry = NULL; struct list_head *head; int found = 0, rc = 0; - ENTRY; LASSERT(cache); @@ -314,7 +308,7 @@ int upcall_cache_downcall(struct upcall_cache *cache, __u32 err, __u64 key, cache->uc_name, key); /* haven't found, it's possible */ spin_unlock(&cache->uc_lock); - RETURN(-EINVAL); + return -EINVAL; } if (err) { @@ -356,7 +350,7 @@ out: wake_up_all(&entry->ue_waitq); put_entry(cache, entry); - RETURN(rc); + return rc; } EXPORT_SYMBOL(upcall_cache_downcall); @@ -364,7 +358,6 @@ static void cache_flush(struct upcall_cache *cache, int force) { struct upcall_cache_entry *entry, *next; int i; - ENTRY; spin_lock(&cache->uc_lock); for (i = 0; i < UC_CACHE_HASH_SIZE; i++) { @@ -379,7 +372,6 @@ static void cache_flush(struct upcall_cache *cache, int force) } } spin_unlock(&cache->uc_lock); - EXIT; } void upcall_cache_flush_idle(struct upcall_cache *cache) @@ -399,7 +391,6 @@ void upcall_cache_flush_one(struct upcall_cache *cache, __u64 key, void *args) struct list_head *head; struct upcall_cache_entry *entry; int found = 0; - ENTRY; head = &cache->uc_hashtable[UC_CACHE_HASH_INDEX(key)]; @@ -431,11 +422,10 @@ struct upcall_cache *upcall_cache_init(const char *name, const char *upcall, { struct upcall_cache *cache; int i; - ENTRY; LIBCFS_ALLOC(cache, sizeof(*cache)); if (!cache) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); spin_lock_init(&cache->uc_lock); rwlock_init(&cache->uc_upcall_rwlock); @@ -448,7 +438,7 @@ struct upcall_cache *upcall_cache_init(const char *name, const char *upcall, cache->uc_acquire_expire = 30; cache->uc_ops = ops; - RETURN(cache); + return cache; } EXPORT_SYMBOL(upcall_cache_init); diff --git a/drivers/staging/lustre/lustre/libcfs/watchdog.c b/drivers/staging/lustre/lustre/libcfs/watchdog.c deleted file mode 100644 index 7c385ada3e10..000000000000 --- a/drivers/staging/lustre/lustre/libcfs/watchdog.c +++ /dev/null @@ -1,516 +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) 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * libcfs/libcfs/watchdog.c - * - * Author: Jacob Berkman <jacob@clusterfs.com> - */ - -#define DEBUG_SUBSYSTEM S_LNET - -#include <linux/libcfs/libcfs.h> -#include "tracefile.h" - -struct lc_watchdog { - spinlock_t lcw_lock; /* check or change lcw_list */ - int lcw_refcount; /* must hold lcw_pending_timers_lock */ - timer_list_t lcw_timer; /* kernel timer */ - struct list_head lcw_list; /* chain on pending list */ - cfs_time_t lcw_last_touched; /* last touched stamp */ - task_t *lcw_task; /* owner task */ - void (*lcw_callback)(pid_t, void *); - void *lcw_data; - - pid_t lcw_pid; - - enum { - LC_WATCHDOG_DISABLED, - LC_WATCHDOG_ENABLED, - LC_WATCHDOG_EXPIRED - } lcw_state; -}; - -#ifdef WITH_WATCHDOG -/* - * The dispatcher will complete lcw_start_completion when it starts, - * and lcw_stop_completion when it exits. - * Wake lcw_event_waitq to signal timer callback dispatches. - */ -static struct completion lcw_start_completion; -static struct completion lcw_stop_completion; -static wait_queue_head_t lcw_event_waitq; - -/* - * Set this and wake lcw_event_waitq to stop the dispatcher. - */ -enum { - LCW_FLAG_STOP = 0 -}; -static unsigned long lcw_flags = 0; - -/* - * Number of outstanding watchdogs. - * When it hits 1, we start the dispatcher. - * When it hits 0, we stop the dispatcher. - */ -static __u32 lcw_refcount = 0; -static DEFINE_MUTEX(lcw_refcount_mutex); - -/* - * List of timers that have fired that need their callbacks run by the - * dispatcher. - */ -/* BH lock! */ -static DEFINE_SPINLOCK(lcw_pending_timers_lock); -static struct list_head lcw_pending_timers = LIST_HEAD_INIT(lcw_pending_timers); - -/* Last time a watchdog expired */ -static cfs_time_t lcw_last_watchdog_time; -static int lcw_recent_watchdog_count; - -static void -lcw_dump(struct lc_watchdog *lcw) -{ - ENTRY; - rcu_read_lock(); - if (lcw->lcw_task == NULL) { - LCONSOLE_WARN("Process " LPPID " was not found in the task " - "list; watchdog callback may be incomplete\n", - (int)lcw->lcw_pid); - } else { - libcfs_debug_dumpstack(lcw->lcw_task); - } - - rcu_read_unlock(); - EXIT; -} - -static void lcw_cb(ulong_ptr_t data) -{ - struct lc_watchdog *lcw = (struct lc_watchdog *)data; - ENTRY; - - if (lcw->lcw_state != LC_WATCHDOG_ENABLED) { - EXIT; - return; - } - - lcw->lcw_state = LC_WATCHDOG_EXPIRED; - - spin_lock_bh(&lcw->lcw_lock); - LASSERT(list_empty(&lcw->lcw_list)); - - spin_lock_bh(&lcw_pending_timers_lock); - lcw->lcw_refcount++; /* +1 for pending list */ - list_add(&lcw->lcw_list, &lcw_pending_timers); - wake_up(&lcw_event_waitq); - - spin_unlock_bh(&lcw_pending_timers_lock); - spin_unlock_bh(&lcw->lcw_lock); - EXIT; -} - -static int is_watchdog_fired(void) -{ - int rc; - - if (test_bit(LCW_FLAG_STOP, &lcw_flags)) - return 1; - - spin_lock_bh(&lcw_pending_timers_lock); - rc = !list_empty(&lcw_pending_timers); - spin_unlock_bh(&lcw_pending_timers_lock); - return rc; -} - -static void lcw_dump_stack(struct lc_watchdog *lcw) -{ - cfs_time_t current_time; - cfs_duration_t delta_time; - struct timeval timediff; - - current_time = cfs_time_current(); - delta_time = cfs_time_sub(current_time, lcw->lcw_last_touched); - cfs_duration_usec(delta_time, &timediff); - - /* - * Check to see if we should throttle the watchdog timer to avoid - * too many dumps going to the console thus triggering an NMI. - */ - delta_time = cfs_duration_sec(cfs_time_sub(current_time, - lcw_last_watchdog_time)); - - if (delta_time < libcfs_watchdog_ratelimit && - lcw_recent_watchdog_count > 3) { - LCONSOLE_WARN("Service thread pid %u was inactive for " - "%lu.%.02lus. Watchdog stack traces are limited " - "to 3 per %d seconds, skipping this one.\n", - (int)lcw->lcw_pid, - timediff.tv_sec, - timediff.tv_usec / 10000, - libcfs_watchdog_ratelimit); - } else { - if (delta_time < libcfs_watchdog_ratelimit) { - lcw_recent_watchdog_count++; - } else { - memcpy(&lcw_last_watchdog_time, ¤t_time, - sizeof(current_time)); - lcw_recent_watchdog_count = 0; - } - - LCONSOLE_WARN("Service thread pid %u was inactive for " - "%lu.%.02lus. The thread might be hung, or it " - "might only be slow and will resume later. " - "Dumping the stack trace for debugging purposes:" - "\n", - (int)lcw->lcw_pid, - timediff.tv_sec, - timediff.tv_usec / 10000); - lcw_dump(lcw); - } -} - -static int lcw_dispatch_main(void *data) -{ - int rc = 0; - struct lc_watchdog *lcw; - LIST_HEAD (zombies); - - ENTRY; - - complete(&lcw_start_completion); - - while (1) { - int dumplog = 1; - - cfs_wait_event_interruptible(lcw_event_waitq, - is_watchdog_fired(), rc); - CDEBUG(D_INFO, "Watchdog got woken up...\n"); - if (test_bit(LCW_FLAG_STOP, &lcw_flags)) { - CDEBUG(D_INFO, "LCW_FLAG_STOP set, shutting down...\n"); - - spin_lock_bh(&lcw_pending_timers_lock); - rc = !list_empty(&lcw_pending_timers); - spin_unlock_bh(&lcw_pending_timers_lock); - if (rc) { - CERROR("pending timers list was not empty at " - "time of watchdog dispatch shutdown\n"); - } - break; - } - - spin_lock_bh(&lcw_pending_timers_lock); - while (!list_empty(&lcw_pending_timers)) { - int is_dumplog; - - lcw = list_entry(lcw_pending_timers.next, - struct lc_watchdog, lcw_list); - /* +1 ref for callback to make sure lwc wouldn't be - * deleted after releasing lcw_pending_timers_lock */ - lcw->lcw_refcount++; - spin_unlock_bh(&lcw_pending_timers_lock); - - /* lock ordering */ - spin_lock_bh(&lcw->lcw_lock); - spin_lock_bh(&lcw_pending_timers_lock); - - if (list_empty(&lcw->lcw_list)) { - /* already removed from pending list */ - lcw->lcw_refcount--; /* -1 ref for callback */ - if (lcw->lcw_refcount == 0) - list_add(&lcw->lcw_list, &zombies); - spin_unlock_bh(&lcw->lcw_lock); - /* still hold lcw_pending_timers_lock */ - continue; - } - - list_del_init(&lcw->lcw_list); - lcw->lcw_refcount--; /* -1 ref for pending list */ - - spin_unlock_bh(&lcw_pending_timers_lock); - spin_unlock_bh(&lcw->lcw_lock); - - CDEBUG(D_INFO, "found lcw for pid " LPPID "\n", - lcw->lcw_pid); - lcw_dump_stack(lcw); - - is_dumplog = lcw->lcw_callback == lc_watchdog_dumplog; - if (lcw->lcw_state != LC_WATCHDOG_DISABLED && - (dumplog || !is_dumplog)) { - lcw->lcw_callback(lcw->lcw_pid, lcw->lcw_data); - if (dumplog && is_dumplog) - dumplog = 0; - } - - spin_lock_bh(&lcw_pending_timers_lock); - lcw->lcw_refcount--; /* -1 ref for callback */ - if (lcw->lcw_refcount == 0) - list_add(&lcw->lcw_list, &zombies); - } - spin_unlock_bh(&lcw_pending_timers_lock); - - while (!list_empty(&zombies)) { - lcw = list_entry(lcw_pending_timers.next, - struct lc_watchdog, lcw_list); - list_del(&lcw->lcw_list); - LIBCFS_FREE(lcw, sizeof(*lcw)); - } - } - - complete(&lcw_stop_completion); - - RETURN(rc); -} - -static void lcw_dispatch_start(void) -{ - task_t *task; - - ENTRY; - LASSERT(lcw_refcount == 1); - - init_completion(&lcw_stop_completion); - init_completion(&lcw_start_completion); - init_waitqueue_head(&lcw_event_waitq); - - CDEBUG(D_INFO, "starting dispatch thread\n"); - task = kthread_run(lcw_dispatch_main, NULL, "lc_watchdogd"); - if (IS_ERR(task)) { - CERROR("error spawning watchdog dispatch thread: %ld\n", - PTR_ERR(task)); - EXIT; - return; - } - wait_for_completion(&lcw_start_completion); - CDEBUG(D_INFO, "watchdog dispatcher initialization complete.\n"); - - EXIT; -} - -static void lcw_dispatch_stop(void) -{ - ENTRY; - LASSERT(lcw_refcount == 0); - - CDEBUG(D_INFO, "trying to stop watchdog dispatcher.\n"); - - set_bit(LCW_FLAG_STOP, &lcw_flags); - wake_up(&lcw_event_waitq); - - wait_for_completion(&lcw_stop_completion); - - CDEBUG(D_INFO, "watchdog dispatcher has shut down.\n"); - - EXIT; -} - -struct lc_watchdog *lc_watchdog_add(int timeout, - void (*callback)(pid_t, void *), - void *data) -{ - struct lc_watchdog *lcw = NULL; - ENTRY; - - LIBCFS_ALLOC(lcw, sizeof(*lcw)); - if (lcw == NULL) { - CDEBUG(D_INFO, "Could not allocate new lc_watchdog\n"); - RETURN(ERR_PTR(-ENOMEM)); - } - - spin_lock_init(&lcw->lcw_lock); - lcw->lcw_refcount = 1; /* refcount for owner */ - lcw->lcw_task = current; - lcw->lcw_pid = current_pid(); - lcw->lcw_callback = (callback != NULL) ? callback : lc_watchdog_dumplog; - lcw->lcw_data = data; - lcw->lcw_state = LC_WATCHDOG_DISABLED; - - INIT_LIST_HEAD(&lcw->lcw_list); - cfs_timer_init(&lcw->lcw_timer, lcw_cb, lcw); - - mutex_lock(&lcw_refcount_mutex); - if (++lcw_refcount == 1) - lcw_dispatch_start(); - mutex_unlock(&lcw_refcount_mutex); - - /* Keep this working in case we enable them by default */ - if (lcw->lcw_state == LC_WATCHDOG_ENABLED) { - lcw->lcw_last_touched = cfs_time_current(); - cfs_timer_arm(&lcw->lcw_timer, cfs_time_seconds(timeout) + - cfs_time_current()); - } - - RETURN(lcw); -} -EXPORT_SYMBOL(lc_watchdog_add); - -static void lcw_update_time(struct lc_watchdog *lcw, const char *message) -{ - cfs_time_t newtime = cfs_time_current();; - - if (lcw->lcw_state == LC_WATCHDOG_EXPIRED) { - struct timeval timediff; - cfs_time_t delta_time = cfs_time_sub(newtime, - lcw->lcw_last_touched); - cfs_duration_usec(delta_time, &timediff); - - LCONSOLE_WARN("Service thread pid %u %s after %lu.%.02lus. " - "This indicates the system was overloaded (too " - "many service threads, or there were not enough " - "hardware resources).\n", - lcw->lcw_pid, - message, - timediff.tv_sec, - timediff.tv_usec / 10000); - } - lcw->lcw_last_touched = newtime; -} - -static void lc_watchdog_del_pending(struct lc_watchdog *lcw) -{ - spin_lock_bh(&lcw->lcw_lock); - if (unlikely(!list_empty(&lcw->lcw_list))) { - spin_lock_bh(&lcw_pending_timers_lock); - list_del_init(&lcw->lcw_list); - lcw->lcw_refcount--; /* -1 ref for pending list */ - spin_unlock_bh(&lcw_pending_timers_lock); - } - - spin_unlock_bh(&lcw->lcw_lock); -} - -void lc_watchdog_touch(struct lc_watchdog *lcw, int timeout) -{ - ENTRY; - LASSERT(lcw != NULL); - - lc_watchdog_del_pending(lcw); - - lcw_update_time(lcw, "resumed"); - lcw->lcw_state = LC_WATCHDOG_ENABLED; - - cfs_timer_arm(&lcw->lcw_timer, cfs_time_current() + - cfs_time_seconds(timeout)); - - EXIT; -} -EXPORT_SYMBOL(lc_watchdog_touch); - -void lc_watchdog_disable(struct lc_watchdog *lcw) -{ - ENTRY; - LASSERT(lcw != NULL); - - lc_watchdog_del_pending(lcw); - - lcw_update_time(lcw, "completed"); - lcw->lcw_state = LC_WATCHDOG_DISABLED; - - EXIT; -} -EXPORT_SYMBOL(lc_watchdog_disable); - -void lc_watchdog_delete(struct lc_watchdog *lcw) -{ - int dead; - - ENTRY; - LASSERT(lcw != NULL); - - cfs_timer_disarm(&lcw->lcw_timer); - - lcw_update_time(lcw, "stopped"); - - spin_lock_bh(&lcw->lcw_lock); - spin_lock_bh(&lcw_pending_timers_lock); - if (unlikely(!list_empty(&lcw->lcw_list))) { - list_del_init(&lcw->lcw_list); - lcw->lcw_refcount--; /* -1 ref for pending list */ - } - - lcw->lcw_refcount--; /* -1 ref for owner */ - dead = lcw->lcw_refcount == 0; - spin_unlock_bh(&lcw_pending_timers_lock); - spin_unlock_bh(&lcw->lcw_lock); - - if (dead) - LIBCFS_FREE(lcw, sizeof(*lcw)); - - mutex_lock(&lcw_refcount_mutex); - if (--lcw_refcount == 0) - lcw_dispatch_stop(); - mutex_unlock(&lcw_refcount_mutex); - - EXIT; -} -EXPORT_SYMBOL(lc_watchdog_delete); - -/* - * Provided watchdog handlers - */ - -void lc_watchdog_dumplog(pid_t pid, void *data) -{ - libcfs_debug_dumplog_internal((void *)((long_ptr_t)pid)); -} -EXPORT_SYMBOL(lc_watchdog_dumplog); - -#else /* !defined(WITH_WATCHDOG) */ - -struct lc_watchdog *lc_watchdog_add(int timeout, - void (*callback)(pid_t pid, void *), - void *data) -{ - static struct lc_watchdog watchdog; - return &watchdog; -} -EXPORT_SYMBOL(lc_watchdog_add); - -void lc_watchdog_touch(struct lc_watchdog *lcw, int timeout) -{ -} -EXPORT_SYMBOL(lc_watchdog_touch); - -void lc_watchdog_disable(struct lc_watchdog *lcw) -{ -} -EXPORT_SYMBOL(lc_watchdog_disable); - -void lc_watchdog_delete(struct lc_watchdog *lcw) -{ -} -EXPORT_SYMBOL(lc_watchdog_delete); - -#endif diff --git a/drivers/staging/lustre/lustre/libcfs/workitem.c b/drivers/staging/lustre/lustre/libcfs/workitem.c index b533666c1900..462172d1a756 100644 --- a/drivers/staging/lustre/lustre/libcfs/workitem.c +++ b/drivers/staging/lustre/lustre/libcfs/workitem.c @@ -376,7 +376,8 @@ cfs_wi_sched_create(char *name, struct cfs_cpt_table *cptab, rc = 0; while (nthrs > 0) { char name[16]; - task_t *task; + struct task_struct *task; + spin_lock(&cfs_wi_data.wi_glock); while (sched->ws_starting > 0) { spin_unlock(&cfs_wi_data.wi_glock); |