Whamcloud - gitweb
LU-13783 libcfs: provide fallback kallsyms_lookup_name()
authorMr NeilBrown <neilb@suse.de>
Tue, 11 May 2021 06:41:37 +0000 (23:41 -0700)
committerLi Xi <lixi@ddn.com>
Tue, 18 May 2021 01:47:16 +0000 (01:47 +0000)
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.

Lustre-change: https://review.whamcloud.com/40826
Lustre-commit: d7249d9d70ac0fcfa665ece78634b495bc9a22cd

Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I09cc00047ec163a9395c5acd415505a8586e4e99
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/43647
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/linux/linux-misc.h
libcfs/libcfs/linux/linux-prim.c

index a6d212d..44150ec 100644 (file)
@@ -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
@@ -1510,6 +1521,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
index 0f230d3..e547ce4 100644 (file)
@@ -148,4 +148,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__ */
index 7fe3df3..0940c80 100644 (file)
@@ -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);