From 783002035ae9612b5b0aa80f2342a2ee9e81c374 Mon Sep 17 00:00:00 2001 From: Jian Yu Date: Mon, 12 Apr 2021 22:12:27 -0700 Subject: [PATCH] LU-13783 libcfs: add cfs_kallsyms_lookup_name() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The inline kallsyms_lookup_name() added by commit d7249d9d70a caused the following failures: libcfs/include/libcfs/linux/linux-misc.h:150:21: error: conflicting types for ‘kallsyms_lookup_name’ 150 | static inline void *kallsyms_lookup_name(char *func) | ^~~~~~~~~~~~~~~~~~~~ include/linux/kallsyms.h:76:15: note: previous declaration of ‘kallsyms_lookup_name’ was here 76 | unsigned long kallsyms_lookup_name(const char *name); | ^~~~~~~~~~~~~~~~~~~~ This patch removes the inline kallsyms_lookup_name() definition from linux-misc.h and adds cfs_kallsyms_lookup_name() to wrap kallsyms_lookup_name() if it is exported or return NULL in case of kallsyms_lookup_name() is not exported. Fixes: d7249d9d70a ("LU-13783 libcfs: provide fallback kallsyms_lookup_name()") Change-Id: I4b2d4499948a8586b48db68484491ec76c3a609d Signed-off-by: Jian Yu Reviewed-on: https://review.whamcloud.com/43296 Tested-by: jenkins Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Oleg Drokin --- libcfs/include/libcfs/linux/linux-misc.h | 10 ++++++++-- libcfs/libcfs/debug.c | 2 +- libcfs/libcfs/linux/linux-prim.c | 6 +++--- lustre/llite/vvp_dev.c | 3 +-- lustre/llite/vvp_io.c | 3 ++- lustre/osd-ldiskfs/osd_handler.c | 2 +- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/libcfs/include/libcfs/linux/linux-misc.h b/libcfs/include/libcfs/linux/linux-misc.h index 282e6ab..242105b 100644 --- a/libcfs/include/libcfs/linux/linux-misc.h +++ b/libcfs/include/libcfs/linux/linux-misc.h @@ -40,6 +40,7 @@ #include #include #include +#include #ifndef HAVE_IOV_ITER_TYPE #ifdef HAVE_IOV_ITER_HAS_TYPE_MEMBER @@ -145,8 +146,13 @@ void cfs_arch_init(void); #define sizeof_field(type, member) FIELD_SIZEOF(type, member) #endif -#ifndef HAVE_KALLSYMS_LOOKUP_NAME -static inline void *kallsyms_lookup_name(char *func) +#ifdef HAVE_KALLSYMS_LOOKUP_NAME +static inline void *cfs_kallsyms_lookup_name(const char *name) +{ + return (void *)kallsyms_lookup_name(name); +} +#else +static inline void *cfs_kallsyms_lookup_name(const char *name) { return NULL; } diff --git a/libcfs/libcfs/debug.c b/libcfs/libcfs/debug.c index 52e3bde..10e3eee 100644 --- a/libcfs/libcfs/debug.c +++ b/libcfs/libcfs/debug.c @@ -515,7 +515,7 @@ void __init cfs_debug_init(void) { #ifdef CONFIG_ARCH_STACKWALK task_dump_stack = (void *) - kallsyms_lookup_name("stack_trace_save_tsk"); + cfs_kallsyms_lookup_name("stack_trace_save_tsk"); #endif } diff --git a/libcfs/libcfs/linux/linux-prim.c b/libcfs/libcfs/linux/linux-prim.c index 7a7a534..c5918ad 100644 --- a/libcfs/libcfs/linux/linux-prim.c +++ b/libcfs/libcfs/linux/linux-prim.c @@ -31,7 +31,6 @@ #define DEBUG_SUBSYSTEM S_LNET -#include #include #include #include @@ -47,6 +46,7 @@ #include #include +#include #ifndef HAVE_KTIME_GET_TS64 void ktime_get_ts64(struct timespec64 *ts) @@ -124,10 +124,10 @@ void __init cfs_arch_init(void) wait_bit_init(); #endif cfs_apply_workqueue_attrs_t = - (void *)kallsyms_lookup_name("apply_workqueue_attrs"); + (void *)cfs_kallsyms_lookup_name("apply_workqueue_attrs"); #ifndef HAVE_XARRAY_SUPPORT radix_tree_node_cachep = - (void *)kallsyms_lookup_name("radix_tree_node_cachep"); + (void *)cfs_kallsyms_lookup_name("radix_tree_node_cachep"); #endif } diff --git a/lustre/llite/vvp_dev.c b/lustre/llite/vvp_dev.c index 272437d..4ded8b4 100644 --- a/lustre/llite/vvp_dev.c +++ b/lustre/llite/vvp_dev.c @@ -291,8 +291,7 @@ int vvp_global_init(void) * Kernel v5.2-5678-gac1c3e4 no longer exports account_page_dirtied */ vvp_account_page_dirtied = (void *) - kallsyms_lookup_name("account_page_dirtied"); - BUG_ON(!vvp_account_page_dirtied); + cfs_kallsyms_lookup_name("account_page_dirtied"); #endif return 0; diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index 297d7ba..c001d85 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -959,7 +959,8 @@ static inline void ll_account_page_dirtied(struct page *page, #elif defined(HAVE_ACCOUNT_PAGE_DIRTIED_EXPORT) account_page_dirtied(page, mapping); #else - vvp_account_page_dirtied(page, mapping); + if (vvp_account_page_dirtied) + vvp_account_page_dirtied(page, mapping); #endif } diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 03dee69..2971dec 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -8406,7 +8406,7 @@ static int __init osd_init(void) #ifdef CONFIG_KALLSYMS priv_security_file_alloc = - (void *)kallsyms_lookup_name("security_file_alloc"); + (void *)cfs_kallsyms_lookup_name("security_file_alloc"); #endif rc = class_register_type(&osd_obd_device_ops, NULL, true, -- 1.8.3.1