From bfa4bc911208f7a7a447984a40266c70ad8814ab Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Mon, 14 Sep 2015 22:34:52 +0300 Subject: [PATCH] LU-7042 lnet: Handle OFED 3.18 packaging definitions Starting with OFED 3.18 the OFED package started to use config.h provided by autoconf tool. This lead to clash between PACKAGE_* macros which are defined in OFED and Lustre headers. Also dealing with kernels that have lustre enabled already required to undefine the common macros that used by in-kernel Lustre client and this sources. This fix undefine all symbols that are generated by Lustre autoconf to avoid conflicts with kernel defines or OFEDs. They are undefined right before new definition in config.h. The list of symbols to undef is automatically generated by autoconf and should not be extended in the future. Also undefine clashed macros in autoconf checks. Change-Id: I0d93adac19573328e905ba536db0dbd842ed2aab Signed-off-by: Dmitry Eremin Reviewed-on: http://review.whamcloud.com/16418 Tested-by: Jenkins Reviewed-by: James Simmons Reviewed-by: Bob Glossman Tested-by: Maloo Reviewed-by: Oleg Drokin --- .gitignore | 1 + autoMakefile.am | 15 ++++---- config/.gitignore | 1 + config/lustre-build.m4 | 4 +-- lnet/autoconf/lustre-lnet.m4 | 80 ++++++++++++++++++++++++++++++++++-------- lnet/klnds/gnilnd/Makefile.in | 2 +- lnet/klnds/o2iblnd/Makefile.in | 2 +- lnet/klnds/socklnd/Makefile.in | 2 +- lnet/lnet/Makefile.in | 2 +- 9 files changed, 83 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 16c65d3..377d546 100644 --- a/.gitignore +++ b/.gitignore @@ -69,6 +69,7 @@ TAGS /config.cache /config.h /config.h.in +/undef.h /INSTALL /libtool /lustre.spec diff --git a/autoMakefile.am b/autoMakefile.am index 54fa798..689bee7 100644 --- a/autoMakefile.am +++ b/autoMakefile.am @@ -74,7 +74,7 @@ lustre-sources: if LINUX all-am: modules -modules: ldiskfs-sources lustre-sources +modules: undef.h ldiskfs-sources lustre-sources $(MAKE) CC="$(CC)" $(CROSS_VARS) -C $(LINUX_OBJ) \ -f $(PWD)/build/Makefile LUSTRE_LINUX_CONFIG=$(LINUX_CONFIG) \ LINUXINCLUDE='-I$$(srctree)/arch/$$(SRCARCH)/include -Iarch/$$(SRCARCH)/include/generated -Iinclude $$(if $$(KBUILD_SRC),-Iinclude2 -I$$(srctree)/include) -I$$(srctree)/arch/$$(SRCARCH)/include/uapi -Iarch/$$(SRCARCH)/include/generated/uapi -I$$(srctree)/include/uapi -Iinclude/generated/uapi -include $(CONFIG_INCLUDE)' \ @@ -84,7 +84,10 @@ endif # LINUX endif # MODULES -dist-hook: +undef.h: config.h.in + grep -v config.h.in config.h.in > $@ + +dist-hook: undef.h find $(distdir) -name .deps -o \ -name CVS -o \ -name .svn -o \ @@ -97,7 +100,9 @@ dist-hook: EXTRA_DIST = @PACKAGE_TARNAME@.spec \ build/Makefile \ build/Rules.in \ - build/gen_filelist.sh + build/gen_filelist.sh \ + config.h.in \ + undef.h rpm-local: @(if test -z "$(RPMBUILD)"; then \ @@ -148,7 +153,7 @@ srpm: @PACKAGE_TARNAME@.spec dist Makefile # However, one cannot really run "make debs" without having done a # configure first, so we could use the easier method of digging the # version out of the config.h file. -debs: +debs: undef.h lversion=$$(sed -ne 's/^#define VERSION "\(.*\)"$$/\1/p' config.h); \ cversion=$$(sed -ne '1s/^lustre (\(.*\)-[0-9][0-9]*).*$$/\1/p' debian/changelog); \ if [ "$$lversion" != "$$cversion" ]; then \ @@ -194,8 +199,6 @@ debs: ../lustre_$${VER}_*.changes ../lustre_$${VER}.tar.gz \ ../lustre-client-modules-$${KVERS}_$${VER}_*.deb debs/ -EXTRA_DIST += config.h.in - if USES_DPKG EXTRA_DIST += debian/* endif diff --git a/config/.gitignore b/config/.gitignore index 01131af..e9653c4 100644 --- a/config/.gitignore +++ b/config/.gitignore @@ -1,4 +1,5 @@ /Makefile.in +/compile /config.guess /config.sub /depcomp diff --git a/config/lustre-build.m4 b/config/lustre-build.m4 index 0bae36a..4957050 100644 --- a/config/lustre-build.m4 +++ b/config/lustre-build.m4 @@ -336,8 +336,8 @@ fi # AC_DEFUN([LB_CONFIG_HEADERS], [ AC_CONFIG_HEADERS([config.h]) -CPPFLAGS="-include $PWD/config.h $CPPFLAGS" -EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS" +CPPFLAGS="-include $PWD/undef.h -include $PWD/config.h $CPPFLAGS" +EXTRA_KCFLAGS="-include $PWD/undef.h -include $PWD/config.h $EXTRA_KCFLAGS" AC_SUBST(EXTRA_KCFLAGS) ]) # LB_CONFIG_HEADERS diff --git a/lnet/autoconf/lustre-lnet.m4 b/lnet/autoconf/lustre-lnet.m4 index 147727b..842873d1 100644 --- a/lnet/autoconf/lustre-lnet.m4 +++ b/lnet/autoconf/lustre-lnet.m4 @@ -206,7 +206,7 @@ AS_IF([test $ENABLEO2IB = "no"], [ AC_MSG_RESULT([yes]) compatrdma_found=true AC_DEFINE(HAVE_COMPAT_RDMA, 1, [compat rdma found]) - EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -include ${O2IBPATH}/include/linux/compat-2.6.h" + EXTRA_OFED_CONFIG="$EXTRA_OFED_CONFIG -include ${O2IBPATH}/include/linux/compat-2.6.h" if test -f "$O2IBPATH/include/linux/compat_autoconf.h"; then COMPAT_AUTOCONF="$O2IBPATH/include/linux/compat_autoconf.h" fi @@ -234,19 +234,6 @@ AS_IF([test $ENABLEO2IB = "no"], [ fi fi - LB_CHECK_COMPILE([if Linux kernel has kthread_worker], - linux_kthread_worker, [ - #include - ],[ - struct kthread_work *kth_wrk __attribute__ ((unused)); - flush_kthread_work(kth_wrk); - ],[ - AC_DEFINE(HAVE_KTHREAD_WORK, 1, [kthread_worker found]) - if test -z "$COMPAT_AUTOCONF"; then - EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_IS_KTHREAD" - fi - ]) - AC_MSG_CHECKING([whether to use any OFED backport headers]) if test -n "$BACKPORT_INCLUDES"; then AC_MSG_RESULT([yes]) @@ -262,6 +249,12 @@ AS_IF([test $ENABLEO2IB = "no"], [ LB_CHECK_COMPILE([whether to enable OpenIB gen2 support], openib_gen2_support, [ #ifdef HAVE_COMPAT_RDMA + #undef PACKAGE_NAME + #undef PACKAGE_TARNAME + #undef PACKAGE_VERSION + #undef PACKAGE_STRING + #undef PACKAGE_BUGREPORT + #undef PACKAGE_URL #include #endif #include @@ -306,8 +299,31 @@ AS_IF([test $ENABLEO2IB = "no"], [ AC_MSG_ERROR([an external source tree was, either specified or detected, for o2iblnd however I could not find a $O2IBPATH/Module.symvers there]) fi fi + + LB_CHECK_COMPILE([if Linux kernel has kthread_worker], + linux_kthread_worker, [ + #ifdef HAVE_COMPAT_RDMA + #undef PACKAGE_NAME + #undef PACKAGE_TARNAME + #undef PACKAGE_VERSION + #undef PACKAGE_STRING + #undef PACKAGE_BUGREPORT + #undef PACKAGE_URL + #include + #endif + #include + ],[ + struct kthread_work *kth_wrk __attribute__ ((unused)); + flush_kthread_work(kth_wrk); + ],[ + AC_DEFINE(HAVE_KTHREAD_WORK, 1, [kthread_worker found]) + if test -z "$COMPAT_AUTOCONF"; then + EXTRA_OFED_INCLUDE="$EXTRA_OFED_INCLUDE -DCONFIG_COMPAT_IS_KTHREAD" + fi + ]) fi ]) +AC_SUBST(EXTRA_OFED_CONFIG) AC_SUBST(EXTRA_OFED_INCLUDE) AC_SUBST(O2IBLND) AC_SUBST(O2IBPATH) @@ -318,6 +334,12 @@ AS_IF([test $ENABLEO2IB != "no"], [ LB_CHECK_COMPILE([if 'rdma_create_id' wants four args], rdma_create_id_4args, [ #ifdef HAVE_COMPAT_RDMA + #undef PACKAGE_NAME + #undef PACKAGE_TARNAME + #undef PACKAGE_VERSION + #undef PACKAGE_STRING + #undef PACKAGE_BUGREPORT + #undef PACKAGE_URL #include #endif #include @@ -339,6 +361,12 @@ AS_IF([test $ENABLEO2IB != "no"], [ LB_CHECK_COMPILE([if 'struct ib_cq_init_attr' is used], ib_cq_init_attr, [ #ifdef HAVE_COMPAT_RDMA + #undef PACKAGE_NAME + #undef PACKAGE_TARNAME + #undef PACKAGE_VERSION + #undef PACKAGE_STRING + #undef PACKAGE_BUGREPORT + #undef PACKAGE_URL #include #endif #include @@ -422,6 +450,12 @@ AC_DEFUN([LN_CONFIG_SK_SLEEP], [ LB_CHECK_COMPILE([if Linux kernel has 'sk_sleep'], sk_sleep, [ #ifdef HAVE_COMPAT_RDMA + #undef PACKAGE_NAME + #undef PACKAGE_TARNAME + #undef PACKAGE_VERSION + #undef PACKAGE_STRING + #undef PACKAGE_BUGREPORT + #undef PACKAGE_URL #include #endif #include @@ -443,6 +477,15 @@ tmp_flags="$EXTRA_KCFLAGS" EXTRA_KCFLAGS="-Werror" LB_CHECK_COMPILE([if 'tcp_sendpage' first parameter is socket], tcp_sendpage_socket, [ + #ifdef HAVE_COMPAT_RDMA + #undef PACKAGE_NAME + #undef PACKAGE_TARNAME + #undef PACKAGE_VERSION + #undef PACKAGE_STRING + #undef PACKAGE_BUGREPORT + #undef PACKAGE_URL + #include + #endif #include #include ],[ @@ -464,6 +507,15 @@ tmp_flags="$EXTRA_KCFLAGS" EXTRA_KCFLAGS="-Werror" LB_CHECK_COMPILE([if 'sk_data_ready' takes only one argument], sk_data_ready, [ + #ifdef HAVE_COMPAT_RDMA + #undef PACKAGE_NAME + #undef PACKAGE_TARNAME + #undef PACKAGE_VERSION + #undef PACKAGE_STRING + #undef PACKAGE_BUGREPORT + #undef PACKAGE_URL + #include + #endif #include #include ],[ diff --git a/lnet/klnds/gnilnd/Makefile.in b/lnet/klnds/gnilnd/Makefile.in index d957195..5f9e4df 100644 --- a/lnet/klnds/gnilnd/Makefile.in +++ b/lnet/klnds/gnilnd/Makefile.in @@ -4,7 +4,7 @@ kgnilnd-objs := gnilnd.o gnilnd_cb.o gnilnd_modparams.o gnilnd_debug.o gnilnd_pr # Need to make sure that an external OFED source pool overrides # any in-kernel OFED sources -NOSTDINC_FLAGS += @EXTRA_OFED_INCLUDE@ +NOSTDINC_FLAGS += @EXTRA_OFED_CONFIG@ @EXTRA_OFED_INCLUDE@ EXTRA_POST_CFLAGS := -D"SVN_CODE_REV=KBUILD_STR(${SVN_CODE_REV})" @GNICPPFLAGS@ diff --git a/lnet/klnds/o2iblnd/Makefile.in b/lnet/klnds/o2iblnd/Makefile.in index 31c3821..34b82fe 100644 --- a/lnet/klnds/o2iblnd/Makefile.in +++ b/lnet/klnds/o2iblnd/Makefile.in @@ -3,6 +3,6 @@ ko2iblnd-objs := o2iblnd.o o2iblnd_cb.o o2iblnd_modparams.o # Need to make sure that an external OFED source pool overrides # any in-kernel OFED sources -NOSTDINC_FLAGS += @EXTRA_OFED_INCLUDE@ +NOSTDINC_FLAGS += @EXTRA_OFED_CONFIG@ @EXTRA_OFED_INCLUDE@ @INCLUDE_RULES@ diff --git a/lnet/klnds/socklnd/Makefile.in b/lnet/klnds/socklnd/Makefile.in index 469ba0f..dbd783a1 100644 --- a/lnet/klnds/socklnd/Makefile.in +++ b/lnet/klnds/socklnd/Makefile.in @@ -2,7 +2,7 @@ MODULES := ksocklnd # Need to make sure that an external OFED source pool overrides # # any in-kernel OFED sources -NOSTDINC_FLAGS += @EXTRA_OFED_INCLUDE@ +NOSTDINC_FLAGS += @EXTRA_OFED_CONFIG@ @EXTRA_OFED_INCLUDE@ ksocklnd-objs := \ socklnd.o \ diff --git a/lnet/lnet/Makefile.in b/lnet/lnet/Makefile.in index f04d8a1..592d2d7 100644 --- a/lnet/lnet/Makefile.in +++ b/lnet/lnet/Makefile.in @@ -9,6 +9,6 @@ default: all # Need to make sure that an external OFED source pool overrides # # any in-kernel OFED sources -NOSTDINC_FLAGS += @EXTRA_OFED_INCLUDE@ +NOSTDINC_FLAGS += @EXTRA_OFED_CONFIG@ @EXTRA_OFED_INCLUDE@ @INCLUDE_RULES@ -- 1.8.3.1