From: Shaun Tancheff Date: Sun, 28 Jun 2020 03:06:28 +0000 (-0500) Subject: LU-13581 build: xarray and lockdep_is_held const clash X-Git-Tag: 2.13.55~41 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=3fcceea0e301c51a29d641c287bd36302a706bbe LU-13581 build: xarray and lockdep_is_held const clash 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 Signed-off-by: Shaun Tancheff Change-Id: Icd51cfb111be6b30adf6f720fb680459ca8cf5b4 Reviewed-on: https://review.whamcloud.com/39150 Tested-by: jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/config/lustre-build-linux.m4 b/config/lustre-build-linux.m4 index 9040a81..832bd15 100644 --- a/config/lustre-build-linux.m4 +++ b/config/lustre-build-linux.m4 @@ -544,6 +544,15 @@ m4_define([LB_LANG_PROGRAM], [ #include #include + +#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) diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index b42c9a7..0152d51 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -1045,6 +1045,31 @@ LB_CHECK_EXPORT([save_stack_trace_tsk], [arch/$SUBARCH/kernel/stacktrace.c], ]) # 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 +],[ +#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 @@ -1135,12 +1160,12 @@ tmp_flags="$EXTRA_KCFLAGS" EXTRA_KCFLAGS="-Werror" LB_CHECK_COMPILE([if page cache uses Xarray], xarray_support, [ - #include + #include ],[ - 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 @@ -1367,6 +1392,7 @@ LIBCFS_NEW_KERNEL_WRITE 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 diff --git a/libcfs/include/libcfs/linux/xarray.h b/libcfs/include/libcfs/linux/xarray.h index 735fc15..74397ab 100644 --- a/libcfs/include/libcfs/linux/xarray.h +++ b/libcfs/include/libcfs/linux/xarray.h @@ -14,7 +14,16 @@ * * 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 #include #include @@ -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); } -#endif /* HAVE_RADIX_TREE_EXCEPTIONAL_ENTRY */ +#endif /* !HAVE_XARRAY_SUPPORT */ #endif /* _LINUX_XARRAY_H */ diff --git a/libcfs/libcfs/linux/xarray.c b/libcfs/libcfs/linux/xarray.c index 95063fb..fea97fe 100644 --- a/libcfs/libcfs/linux/xarray.c +++ b/libcfs/libcfs/linux/xarray.c @@ -10,7 +10,7 @@ * * at kernel verison 5.2-rc2 */ -#ifdef HAVE_RADIX_TREE_EXCEPTIONAL_ENTRY +#ifndef HAVE_XARRAY_SUPPORT #include #include #include @@ -2098,4 +2098,4 @@ void xa_dump(const struct xarray *xa) xa_dump_entry(entry, 0, shift); } #endif -#endif /* HAVE_RADIX_TREE_EXCEPTIONAL_ENTRY */ +#endif /* !HAVE_XARRAY_SUPPORT */ diff --git a/lnet/klnds/o2iblnd/o2iblnd.h b/lnet/klnds/o2iblnd/o2iblnd.h index f165e07..6d7c9e5 100644 --- a/lnet/klnds/o2iblnd/o2iblnd.h +++ b/lnet/klnds/o2iblnd/o2iblnd.h @@ -34,6 +34,17 @@ * Author: Eric Barton */ +#include +#include + +#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 @@ -46,8 +57,6 @@ #endif -#include -#include #include #include #include diff --git a/lustre/include/lustre_compat.h b/lustre/include/lustre_compat.h index f046d6c..5defcfd 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -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. */ -#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); diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 9e5dae1..ffba742 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -4703,6 +4703,10 @@ test_63() { 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