From d7249d9d70ac0fcfa665ece78634b495bc9a22cd Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Tue, 2 Mar 2021 11:49:01 +1100 Subject: [PATCH 1/1] LU-13783 libcfs: provide fallback kallsyms_lookup_name() Since Linux 5.7, kallsyms_lookup_name() is no longer exported, so we cannot rely on it. So test for this, and when not available provide a fallback which just returns NULL. As this was the only way to access apply_workqueue_attrs() in recent kernels, we need to cope with the absence of that function. Signed-off-by: Mr NeilBrown Change-Id: I09cc00047ec163a9395c5acd415505a8586e4e99 Reviewed-on: https://review.whamcloud.com/40826 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Andreas Dilger --- libcfs/autoconf/lustre-libcfs.m4 | 13 +++++++++++++ libcfs/include/libcfs/linux/linux-misc.h | 7 +++++++ libcfs/libcfs/linux/linux-prim.c | 4 +++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index 6b20241..d3dcc6c 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -1290,6 +1290,17 @@ EXTRA_KCFLAGS="$tmp_flags" ]) # LIBCFS_CACHE_DETAIL_WRITERS # +# LIBCFS_KALLSYMS_LOOKUP +# +# kernel v5.6-11591-g0bd476e6c671 +# kallsyms: unexport kallsyms_lookup_name() and kallsyms_on_each_symbol() +AC_DEFUN([LIBCFS_KALLSYMS_LOOKUP], [ +LB_CHECK_EXPORT([kallsyms_lookup_name], [kernel/kallsyms.c], + [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1, + [kallsyms_lookup_name is exported by kernel])]) +]) # LIBCFS_KALLSYMS_LOOKUP + +# # LIBCFS_VMALLOC_2ARGS # # kernel v5.8-rc1~201^2~19 @@ -1475,6 +1486,8 @@ LIBCFS_LOOKUP_USER_KEY LIBCFS_FORCE_SIG_WITH_TASK LIBCFS_CACHE_DETAIL_WRITERS LIBCFS_HAVE_NR_UNSTABLE_NFS +# 5.7 +LIBCFS_KALLSYMS_LOOKUP # 5.8 LIBCFS_HAVE_MMAP_LOCK LIBCFS_KERNEL_SETSOCKOPT diff --git a/libcfs/include/libcfs/linux/linux-misc.h b/libcfs/include/libcfs/linux/linux-misc.h index 2309c6d..1db78bb 100644 --- a/libcfs/include/libcfs/linux/linux-misc.h +++ b/libcfs/include/libcfs/linux/linux-misc.h @@ -146,4 +146,11 @@ 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) +{ + return NULL; +} +#endif + #endif /* __LIBCFS_LINUX_MISC_H__ */ diff --git a/libcfs/libcfs/linux/linux-prim.c b/libcfs/libcfs/linux/linux-prim.c index 7fe3df3..0940c80 100644 --- a/libcfs/libcfs/linux/linux-prim.c +++ b/libcfs/libcfs/linux/linux-prim.c @@ -109,7 +109,9 @@ static int (*cfs_apply_workqueue_attrs_t)(struct workqueue_struct *wq, int cfs_apply_workqueue_attrs(struct workqueue_struct *wq, const struct workqueue_attrs *attrs) { - return cfs_apply_workqueue_attrs_t(wq, attrs); + if (cfs_apply_workqueue_attrs_t) + return cfs_apply_workqueue_attrs_t(wq, attrs); + return 0; } EXPORT_SYMBOL_GPL(cfs_apply_workqueue_attrs); -- 1.8.3.1