Whamcloud - gitweb
LU-13581 build: xarray and lockdep_is_held const clash 50/39150/4
authorShaun Tancheff <shaun.tancheff@hpe.com>
Sun, 28 Jun 2020 03:06:28 +0000 (22:06 -0500)
committerOleg Drokin <green@whamcloud.com>
Sun, 5 Jul 2020 00:18:06 +0000 (00:18 +0000)
xarray support added to lustre breaks building with RHEL
debug kernels. The root cause is due to an change in
the signature of lock_is_held when CONFIG_LOCKDEP is enabled.

Provide a workaround when the const mismatch conditions
exist to enable building RHEL debug kernel packages.

Also narrow the test for xarray support to explicitly require
xa_is_value be defined to protect against relying on
incomplete xarray support.

The same xarray issue is present in MOFED 5 so the same
scheme is used to protect lock_is_held change to require
const parameter from breaking.

Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: Icd51cfb111be6b30adf6f720fb680459ca8cf5b4
Reviewed-on: https://review.whamcloud.com/39150
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
config/lustre-build-linux.m4
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/linux/xarray.h
libcfs/libcfs/linux/xarray.c
lnet/klnds/o2iblnd/o2iblnd.h
lustre/include/lustre_compat.h
lustre/tests/conf-sanity.sh

index 9040a81..832bd15 100644 (file)
@@ -544,6 +544,15 @@ m4_define([LB_LANG_PROGRAM],
 [
 #include <linux/kernel.h>
 #include <linux/module.h>
 [
 #include <linux/kernel.h>
 #include <linux/module.h>
+
+#if defined(NEED_LOCKDEP_IS_HELD_DISCARD_CONST) \
+ && defined(CONFIG_LOCKDEP) \
+ && defined(lockdep_is_held)
+#undef lockdep_is_held
+       #define lockdep_is_held(lock) \
+               lock_is_held((struct lockdep_map *)&(lock)->dep_map)
+#endif
+
 $1
 int
 main (void)
 $1
 int
 main (void)
index b42c9a7..0152d51 100644 (file)
@@ -1045,6 +1045,31 @@ LB_CHECK_EXPORT([save_stack_trace_tsk], [arch/$SUBARCH/kernel/stacktrace.c],
 ]) # LIBCFS_EXPORT_SAVE_STACK_TRACE_TSK
 
 #
 ]) # LIBCFS_EXPORT_SAVE_STACK_TRACE_TSK
 
 #
+# LIBCFS_LOCKDEP_IS_HELD
+#
+# Kernel v4.15-rc8-106-g08f36ff64234
+# lockdep: Make lockdep checking constant
+#
+AC_DEFUN([LIBCFS_LOCKDEP_IS_HELD], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if 'lockdep_is_held()' uses const argument],
+lockdep_is_held, [
+       #include <linux/lockdep.h>
+],[
+#ifdef CONFIG_LOCKDEP
+       const struct spinlock *lock = NULL;
+
+       lockdep_is_held(lock);
+#endif
+],[],[
+       AC_DEFINE(NEED_LOCKDEP_IS_HELD_DISCARD_CONST, 1,
+               [lockdep_is_held() argument is const])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LIBCFS_LOCKDEP_IS_HELD
+
+#
 # LIBCFS_TIMER_SETUP
 #
 # Kernel version 4.15 commit e99e88a9d2b067465adaa9c111ada99a041bef9a
 # LIBCFS_TIMER_SETUP
 #
 # Kernel version 4.15 commit e99e88a9d2b067465adaa9c111ada99a041bef9a
@@ -1135,12 +1160,12 @@ tmp_flags="$EXTRA_KCFLAGS"
 EXTRA_KCFLAGS="-Werror"
 LB_CHECK_COMPILE([if page cache uses Xarray],
 xarray_support, [
 EXTRA_KCFLAGS="-Werror"
 LB_CHECK_COMPILE([if page cache uses Xarray],
 xarray_support, [
-       #include <linux/radix-tree.h>
+       #include <linux/xarray.h>
 ],[
 ],[
-       radix_tree_exceptional_entry(NULL);
+       xa_is_value(NULL);
 ],[
 ],[
-       AC_DEFINE(HAVE_RADIX_TREE_EXCEPTIONAL_ENTRY, 1,
-               [kernel lacks 'xa_is_value'])
+       AC_DEFINE(HAVE_XARRAY_SUPPORT, 1,
+               [kernel Xarray implementation lacks 'xa_is_value'])
 ])
 EXTRA_KCFLAGS="$tmp_flags"
 ]) # LIBCFS_XARRAY_SUPPORT
 ])
 EXTRA_KCFLAGS="$tmp_flags"
 ]) # LIBCFS_XARRAY_SUPPORT
@@ -1367,6 +1392,7 @@ LIBCFS_NEW_KERNEL_WRITE
 LIBCFS_NEW_KERNEL_READ
 LIBCFS_EXPORT_SAVE_STACK_TRACE_TSK
 # 4.15
 LIBCFS_NEW_KERNEL_READ
 LIBCFS_EXPORT_SAVE_STACK_TRACE_TSK
 # 4.15
+LIBCFS_LOCKDEP_IS_HELD
 LIBCFS_TIMER_SETUP
 # 4.16
 LIBCFS_WAIT_VAR_EVENT
 LIBCFS_TIMER_SETUP
 # 4.16
 LIBCFS_WAIT_VAR_EVENT
index 735fc15..74397ab 100644 (file)
  *
  * See Documentation/core-api/xarray.rst for how to use the XArray.
  */
  *
  * See Documentation/core-api/xarray.rst for how to use the XArray.
  */
-#ifdef HAVE_RADIX_TREE_EXCEPTIONAL_ENTRY
+#ifndef HAVE_XARRAY_SUPPORT
+
+#if defined(NEED_LOCKDEP_IS_HELD_DISCARD_CONST) \
+ && defined(CONFIG_LOCKDEP) \
+ && defined(lockdep_is_held)
+#undef lockdep_is_held
+       #define lockdep_is_held(lock) \
+               lock_is_held((struct lockdep_map *)&(lock)->dep_map)
+#endif
+
 #include <linux/bug.h>
 #include <linux/compiler.h>
 #include <linux/gfp.h>
 #include <linux/bug.h>
 #include <linux/compiler.h>
 #include <linux/gfp.h>
@@ -1752,6 +1761,6 @@ static inline void *xas_next(struct xa_state *xas)
        xas->xa_offset++;
        return xa_entry(xas->xa, node, xas->xa_offset);
 }
        xas->xa_offset++;
        return xa_entry(xas->xa, node, xas->xa_offset);
 }
-#endif /* HAVE_RADIX_TREE_EXCEPTIONAL_ENTRY */
+#endif /* !HAVE_XARRAY_SUPPORT */
 
 #endif /* _LINUX_XARRAY_H */
 
 #endif /* _LINUX_XARRAY_H */
index 95063fb..fea97fe 100644 (file)
@@ -10,7 +10,7 @@
  *
  * at kernel verison 5.2-rc2
  */
  *
  * at kernel verison 5.2-rc2
  */
-#ifdef HAVE_RADIX_TREE_EXCEPTIONAL_ENTRY
+#ifndef HAVE_XARRAY_SUPPORT
 #include <linux/bitmap.h>
 #include <linux/export.h>
 #include <linux/list.h>
 #include <linux/bitmap.h>
 #include <linux/export.h>
 #include <linux/list.h>
@@ -2098,4 +2098,4 @@ void xa_dump(const struct xarray *xa)
        xa_dump_entry(entry, 0, shift);
 }
 #endif
        xa_dump_entry(entry, 0, shift);
 }
 #endif
-#endif /* HAVE_RADIX_TREE_EXCEPTIONAL_ENTRY */
+#endif /* !HAVE_XARRAY_SUPPORT */
index f165e07..6d7c9e5 100644 (file)
  * Author: Eric Barton <eric@bartonsoftware.com>
  */
 
  * Author: Eric Barton <eric@bartonsoftware.com>
  */
 
+#include <linux/module.h>
+#include <linux/kernel.h>
+
+#if defined(NEED_LOCKDEP_IS_HELD_DISCARD_CONST) \
+ && defined(CONFIG_LOCKDEP) \
+ && defined(lockdep_is_held)
+#undef lockdep_is_held
+       #define lockdep_is_held(lock) \
+               lock_is_held((struct lockdep_map *)&(lock)->dep_map)
+#endif
+
 #ifdef HAVE_COMPAT_RDMA
 #include <linux/compat-2.6.h>
 
 #ifdef HAVE_COMPAT_RDMA
 #include <linux/compat-2.6.h>
 
@@ -46,8 +57,6 @@
 
 #endif
 
 
 #endif
 
-#include <linux/module.h>
-#include <linux/kernel.h>
 #include <linux/kthread.h>
 #include <linux/mm.h>
 #include <linux/string.h>
 #include <linux/kthread.h>
 #include <linux/mm.h>
 #include <linux/string.h>
index f046d6c..5defcfd 100644 (file)
@@ -147,7 +147,7 @@ static inline bool d_is_positive(const struct dentry *dentry)
  * the page cache interaction. Lets keep xa_is_value() separate
  * in old kernels for Xarray support and page cache handling.
  */
  * the page cache interaction. Lets keep xa_is_value() separate
  * in old kernels for Xarray support and page cache handling.
  */
-#ifdef HAVE_RADIX_TREE_EXCEPTIONAL_ENTRY
+#ifndef HAVE_XARRAY_SUPPORT
 static inline bool ll_xa_is_value(void *entry)
 {
        return radix_tree_exceptional_entry(entry);
 static inline bool ll_xa_is_value(void *entry)
 {
        return radix_tree_exceptional_entry(entry);
index 9e5dae1..ffba742 100644 (file)
@@ -4703,6 +4703,10 @@ test_63() {
                skip "ldiskfs module has not been loaded"
        fi
 
                skip "ldiskfs module has not been loaded"
        fi
 
+       if grep -q "CONFIG_DEBUG_LOCK_ALLOC=y" /boot/config-$(uname -r); then
+               skip "test is not compatible with CONFIG_DEBUG_LOCK_ALLOC=y"
+       fi
+
        echo "$inode_slab ldiskfs inodes per page"
        [ "${inode_slab%.*}" -ge "3" ] && return 0
 
        echo "$inode_slab ldiskfs inodes per page"
        [ "${inode_slab%.*}" -ge "3" ] && return 0