From: Shraddha Barke Date: Wed, 16 Mar 2016 16:40:20 +0000 (-0400) Subject: LU-4423 libcfs: remove some unused code and wrappers in libcfs X-Git-Tag: 2.8.51~22 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=53aee2559638e25dd6dc664ceab2b023eaac1cb5 LU-4423 libcfs: remove some unused code and wrappers in libcfs Remove code that is not used by anyone anymore in the libcfs module. Also simplify the code by removing several one line wrappers. This is a collection of work done upstream by Shraddha Barke. The linux commits are: Linux-commit : 8eefa1c028f5b16f33ce1b3c7bbabdf74efc63b1 Linux-commit : d11f8cc4bb7ff4ee8cc89d2799cdda206da0f434 Linux-commit : 7fb6f46b14d01a185dfe563a8ba20cda514d4f9a Linux-commit : 7cbf673d8b4a68916fe362fe9a9c3a55a604700e Linux-commit : e4ce7f7779313ff23f958049b91cc7ac1b24d8e8 Linux-commit : 5a2f464af23bc90a77df6b9b30815e602efb99af Linux-commit : 87af1d2e0c29ce4f025da0cdbb9c74a3958fd71d Linux-commit : 9561c25c590afdcb27002dc168bcecbf5a757308 Linux-commit : 7d6e398ca61427e903246f1c11853f6f967bbb5e Linux-commit : 90f8b4643023b23061a15229c0c0b8ee747438a8 Linux-commit : a2aadf23d1437ddcce86fa0673a6ecb5f932d3ec Signed-off-by: James Simmons Signed-off-by: Shraddha Barke Signed-off-by: Greg Kroah-Hartman Change-Id: I667f98b3c73d4ac9e884d6ada6fed0733a3f6451 Reviewed-on: http://review.whamcloud.com/17375 Reviewed-by: Dmitry Eremin Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bob Glossman Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- diff --git a/libcfs/libcfs/debug.c b/libcfs/libcfs/debug.c index e533b8b..2b6c84b 100644 --- a/libcfs/libcfs/debug.c +++ b/libcfs/libcfs/debug.c @@ -340,13 +340,6 @@ int libcfs_debug_mark_buffer(const char *text) #undef DEBUG_SUBSYSTEM #define DEBUG_SUBSYSTEM S_LNET -void libcfs_debug_set_level(unsigned int debug_level) -{ - printk(KERN_WARNING "Lustre: Setting portals debug level to %08x\n", - debug_level); - libcfs_debug = debug_level; -} - long libcfs_log_return(struct libcfs_debug_msg_data *msgdata, long rc) { libcfs_debug_msg(msgdata, "Process leaving (rc=%lu : %ld : %lx)\n", diff --git a/libcfs/libcfs/hash.c b/libcfs/libcfs/hash.c index 9c37ee1..5133628 100644 --- a/libcfs/libcfs/hash.c +++ b/libcfs/libcfs/hash.c @@ -681,25 +681,6 @@ cfs_hash_bd_peek_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd, } EXPORT_SYMBOL(cfs_hash_bd_peek_locked); -struct hlist_node * -cfs_hash_bd_findadd_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd, - const void *key, struct hlist_node *hnode, - int noref) -{ - return cfs_hash_bd_lookup_intent(hs, bd, key, hnode, - CFS_HS_LOOKUP_IT_ADD | - (!noref * CFS_HS_LOOKUP_MASK_REF)); -} - -struct hlist_node * -cfs_hash_bd_finddel_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd, - const void *key, struct hlist_node *hnode) -{ - /* hnode can be NULL, we find the first item with @key */ - return cfs_hash_bd_lookup_intent(hs, bd, key, hnode, - CFS_HS_LOOKUP_IT_FINDDEL); -} - static void cfs_hash_multi_bd_lock(struct cfs_hash *hs, struct cfs_hash_bd *bds, unsigned n, int excl) diff --git a/libcfs/libcfs/linux/linux-cpu.c b/libcfs/libcfs/linux/linux-cpu.c index d3b8e76..82e0e73 100644 --- a/libcfs/libcfs/linux/linux-cpu.c +++ b/libcfs/libcfs/linux/linux-cpu.c @@ -79,13 +79,6 @@ struct cfs_cpt_data { static struct cfs_cpt_data cpt_data; -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)); -} - /* return number of cores in the same socket of \a cpu */ int cfs_cpu_core_nsiblings(int cpu) @@ -94,7 +87,7 @@ cfs_cpu_core_nsiblings(int cpu) mutex_lock(&cpt_data.cpt_mutex); - cfs_cpu_core_siblings(cpu, cpt_data.cpt_cpumask); + cpumask_copy(cpt_data.cpt_cpumask, topology_core_cpumask(cpu)); num = cpumask_weight(cpt_data.cpt_cpumask); mutex_unlock(&cpt_data.cpt_mutex); @@ -681,7 +674,7 @@ cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt, cpu = cpumask_first(node); /* get cpumask for cores in the same socket */ - cfs_cpu_core_siblings(cpu, socket); + cpumask_copy(socket, topology_core_cpumask(cpu)); cpumask_and(socket, socket, node); LASSERT(!cpumask_empty(socket)); @@ -690,7 +683,7 @@ cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt, int i; /* get cpumask for hts in the same core */ - cfs_cpu_ht_siblings(cpu, core); + cpumask_copy(core, topology_sibling_cpumask(cpu)); cpumask_and(core, core, node); LASSERT(!cpumask_empty(core)); @@ -1038,7 +1031,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); + cpumask_copy(cpt_data.cpt_cpumask, + topology_sibling_cpumask(cpu)); warn = cpumask_any_and(cpt_data.cpt_cpumask, cpu_online_mask) >= nr_cpu_ids; mutex_unlock(&cpt_data.cpt_mutex); diff --git a/libcfs/libcfs/linux/linux-crypto-adler.c b/libcfs/libcfs/linux/linux-crypto-adler.c index 10b91fc..90f502f 100644 --- a/libcfs/libcfs/linux/linux-crypto-adler.c +++ b/libcfs/libcfs/linux/linux-crypto-adler.c @@ -34,16 +34,9 @@ #include #include - #define CHKSUM_BLOCK_SIZE 1 #define CHKSUM_DIGEST_SIZE 4 - -static u32 __adler32(u32 cksum, unsigned char const *p, size_t len) -{ - return zlib_adler32(cksum, p, len); -} - static int adler32_cra_init(struct crypto_tfm *tfm) { u32 *key = crypto_tfm_ctx(tfm); @@ -81,13 +74,13 @@ static int adler32_update(struct shash_desc *desc, const u8 *data, { u32 *cksump = shash_desc_ctx(desc); - *cksump = __adler32(*cksump, data, len); + *cksump = zlib_adler32(*cksump, data, len); return 0; } static int __adler32_finup(u32 *cksump, const u8 *data, unsigned int len, u8 *out) { - *(u32 *)out = __adler32(*cksump, data, len); + *(u32 *)out = zlib_adler32(*cksump, data, len); return 0; } diff --git a/libcfs/libcfs/linux/linux-prim.c b/libcfs/libcfs/linux/linux-prim.c index dd2ac35..1204c1c 100644 --- a/libcfs/libcfs/linux/linux-prim.c +++ b/libcfs/libcfs/linux/linux-prim.c @@ -84,16 +84,6 @@ cfs_time_t cfs_timer_deadline(struct timer_list *t) } EXPORT_SYMBOL(cfs_timer_deadline); -void cfs_enter_debugger(void) -{ -#if defined(CONFIG_KGDB) -// BREAKPOINT(); -#else - /* nothing */ -#endif -} -EXPORT_SYMBOL(cfs_enter_debugger); - sigset_t cfs_block_allsigs(void) { diff --git a/libcfs/libcfs/tracefile.c b/libcfs/libcfs/tracefile.c index 0c721a9..2baecb8 100644 --- a/libcfs/libcfs/tracefile.c +++ b/libcfs/libcfs/tracefile.c @@ -449,7 +449,7 @@ console: cfs_print_to_console(&header, mask, string_buf, needed, file, msgdata->msg_fn); - cfs_trace_put_console_buffer(string_buf); + put_cpu(); } if (cdls != NULL && cdls->cdls_count != 0) { @@ -463,7 +463,7 @@ console: cfs_print_to_console(&header, mask, string_buf, needed, file, msgdata->msg_fn); - cfs_trace_put_console_buffer(string_buf); + put_cpu(); cdls->cdls_count = 0; } @@ -800,11 +800,6 @@ int cfs_trace_allocate_string_buffer(char **str, int nob) return 0; } -void cfs_trace_free_string_buffer(char *str, int nob) -{ - kfree(str); -} - int cfs_trace_dump_debug_buffer_usrstr(void __user *usr_str, int usr_str_nob) { char *str; @@ -825,7 +820,7 @@ int cfs_trace_dump_debug_buffer_usrstr(void __user *usr_str, int usr_str_nob) } rc = cfs_tracefile_dump_all_pages(str); out: - cfs_trace_free_string_buffer(str, usr_str_nob + 1); + kfree(str); return rc; } @@ -881,7 +876,7 @@ int cfs_trace_daemon_command_usrstr(void __user *usr_str, int usr_str_nob) if (rc == 0) rc = cfs_trace_daemon_command(str); - cfs_trace_free_string_buffer(str, usr_str_nob + 1); + kfree(str); return rc; } diff --git a/libcfs/libcfs/tracefile.h b/libcfs/libcfs/tracefile.h index d2d92c8..7c570fa 100644 --- a/libcfs/libcfs/tracefile.h +++ b/libcfs/libcfs/tracefile.h @@ -83,7 +83,6 @@ int cfs_trace_copyin_string(char *knl_buffer, int knl_buffer_nob, int cfs_trace_copyout_string(char __user *usr_buffer, int usr_buffer_nob, const char *knl_str, char *append); int cfs_trace_allocate_string_buffer(char **str, int nob); -void cfs_trace_free_string_buffer(char *str, int nob); int cfs_trace_dump_debug_buffer_usrstr(void __user *usr_str, int usr_str_nob); int cfs_trace_daemon_command(char *str); int cfs_trace_daemon_command_usrstr(void __user *usr_str, int usr_str_nob); @@ -277,12 +276,6 @@ static inline char *cfs_trace_get_console_buffer(void) return cfs_trace_console_buffers[i][j]; } -static inline void -cfs_trace_put_console_buffer(char *buffer) -{ - put_cpu(); -} - static inline struct cfs_trace_cpu_data *cfs_trace_get_tcd(void) { struct cfs_trace_cpu_data *tcd = diff --git a/libcfs/libcfs/workitem.c b/libcfs/libcfs/workitem.c index 386ba17..168fea5 100644 --- a/libcfs/libcfs/workitem.c +++ b/libcfs/libcfs/workitem.c @@ -87,32 +87,20 @@ static struct cfs_workitem_data { int wi_stopping; } cfs_wi_data; -static inline void -cfs_wi_sched_lock(struct cfs_wi_sched *sched) -{ - spin_lock(&sched->ws_lock); -} - -static inline void -cfs_wi_sched_unlock(struct cfs_wi_sched *sched) -{ - spin_unlock(&sched->ws_lock); -} - static inline int cfs_wi_sched_cansleep(struct cfs_wi_sched *sched) { - cfs_wi_sched_lock(sched); + spin_lock(&sched->ws_lock); if (sched->ws_stopping) { - cfs_wi_sched_unlock(sched); + spin_unlock(&sched->ws_lock); return 0; } if (!list_empty(&sched->ws_runq)) { - cfs_wi_sched_unlock(sched); + spin_unlock(&sched->ws_lock); return 0; } - cfs_wi_sched_unlock(sched); + spin_unlock(&sched->ws_lock); return 1; } @@ -126,7 +114,7 @@ cfs_wi_exit(struct cfs_wi_sched *sched, struct cfs_workitem *wi) LASSERT(!in_interrupt()); /* because we use plain spinlock */ LASSERT(!sched->ws_stopping); - cfs_wi_sched_lock(sched); + spin_lock(&sched->ws_lock); LASSERT(wi->wi_running); @@ -141,7 +129,7 @@ cfs_wi_exit(struct cfs_wi_sched *sched, struct cfs_workitem *wi) LASSERT(list_empty(&wi->wi_list)); wi->wi_scheduled = 1; /* LBUG future schedule attempts */ - cfs_wi_sched_unlock(sched); + spin_unlock(&sched->ws_lock); return; } @@ -163,7 +151,7 @@ cfs_wi_deschedule(struct cfs_wi_sched *sched, struct cfs_workitem *wi) * means the workitem will not be scheduled and will not have * any race with wi_action. */ - cfs_wi_sched_lock(sched); + spin_lock(&sched->ws_lock); rc = !(wi->wi_running); @@ -179,7 +167,7 @@ cfs_wi_deschedule(struct cfs_wi_sched *sched, struct cfs_workitem *wi) LASSERT (list_empty(&wi->wi_list)); - cfs_wi_sched_unlock(sched); + spin_unlock(&sched->ws_lock); return rc; } EXPORT_SYMBOL(cfs_wi_deschedule); @@ -197,7 +185,7 @@ cfs_wi_schedule(struct cfs_wi_sched *sched, struct cfs_workitem *wi) LASSERT(!in_interrupt()); /* because we use plain spinlock */ LASSERT(!sched->ws_stopping); - cfs_wi_sched_lock(sched); + spin_lock(&sched->ws_lock); if (!wi->wi_scheduled) { LASSERT (list_empty(&wi->wi_list)); @@ -213,7 +201,7 @@ cfs_wi_schedule(struct cfs_wi_sched *sched, struct cfs_workitem *wi) } LASSERT (!list_empty(&wi->wi_list)); - cfs_wi_sched_unlock(sched); + spin_unlock(&sched->ws_lock); return; } EXPORT_SYMBOL(cfs_wi_schedule); @@ -239,7 +227,7 @@ cfs_wi_scheduler(void *arg) spin_unlock(&cfs_wi_data.wi_glock); - cfs_wi_sched_lock(sched); + spin_lock(&sched->ws_lock); while (!sched->ws_stopping) { int nloops = 0; @@ -260,13 +248,12 @@ cfs_wi_scheduler(void *arg) wi->wi_running = 1; wi->wi_scheduled = 0; - - cfs_wi_sched_unlock(sched); + spin_unlock(&sched->ws_lock); nloops++; rc = (*wi->wi_action) (wi); - cfs_wi_sched_lock(sched); + spin_lock(&sched->ws_lock); if (rc != 0) /* WI should be dead, even be freed! */ continue; @@ -281,21 +268,21 @@ cfs_wi_scheduler(void *arg) } if (!list_empty(&sched->ws_runq)) { - cfs_wi_sched_unlock(sched); + spin_unlock(&sched->ws_lock); /* don't sleep because some workitems still * expect me to come back soon */ cond_resched(); - cfs_wi_sched_lock(sched); + spin_lock(&sched->ws_lock); continue; } - cfs_wi_sched_unlock(sched); + spin_unlock(&sched->ws_lock); rc = wait_event_interruptible_exclusive(sched->ws_waitq, !cfs_wi_sched_cansleep(sched)); - cfs_wi_sched_lock(sched); + spin_lock(&sched->ws_lock); } - cfs_wi_sched_unlock(sched); + spin_unlock(&sched->ws_lock); spin_lock(&cfs_wi_data.wi_glock); sched->ws_nthreads--;