Whamcloud - gitweb
RM-844 lbuild: add support for building kmod-lustre-o2ib-ofed
authorWang Shilong <wshilong@ddn.com>
Wed, 4 Apr 2018 01:15:27 +0000 (09:15 +0800)
committerAndreas Dilger <adilger@whamcloud.com>
Sun, 7 Mar 2021 05:54:40 +0000 (05:54 +0000)
With this patch, we will be able to build ofed
and mlnx lustre RPMS at the same time.

Introduce extra option --enable-o2ib_kernel
to lbuild enable ofed RPMS, in default, it won't be built.

This is a quick walkaround solution that we could
support both MLNX and OFED KMOD RPMS, for the long
term, we should handle this more gracefully

Test-Parameters: trivial
Change-Id: I581535d2e13b5d412a9b6e057294eb146f4ef086
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-on: https://review.whamcloud.com/41875
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
config/lustre-build.m4
lnet/autoconf/lustre-lnet.m4
lustre.spec.in
rpm/kmp-lustre-o2ib-mlnx.preamble
rpm/kmp-lustre-o2ib-ofed.files [new file with mode: 0644]
rpm/kmp-lustre-o2ib-ofed.preamble [new file with mode: 0644]

index 4d089bd..8ab2144 100644 (file)
@@ -551,6 +551,7 @@ for arg; do
                --enable-utils | --disable-utils ) ;;
                --enable-iokit | --disable-iokit ) ;;
                --enable-manpages | --disable-manpages ) ;;
+               --enable-o2ib_kernel| --disable-o2ib_kernel ) ;;
                * ) CONFIGURE_ARGS="$CONFIGURE_ARGS '$arg'" ;;
        esac
 done
@@ -619,6 +620,9 @@ fi
 if test x$enable_mpitests != xyes ; then
        RPMBINARGS="$RPMBINARGS --without mpi"
 fi
+if test x$enable_o2ib_kernel = xyes ; then
+       RPMBINARGS="$RPMBINARGS --with ofed"
+fi
 
 RPMBUILD_BINARY_ARGS=$RPMBINARGS
 
index a9f05e3..625aa07 100644 (file)
@@ -40,6 +40,20 @@ AC_DEFUN([LN_CONFIG_DLC], [
 ])
 
 #
+# LN_CONFIG_O2IB_KERNEL
+#
+# check whether to enable kernel ofed RPMS
+#
+AC_DEFUN([LN_CONFIG_O2IB_KERNEL], [
+AC_MSG_CHECKING([whether to enable kernel ofed])
+AC_ARG_ENABLE([o2ib_kernel],
+       AC_HELP_STRING([--enable-o2ib_kernel=[yes|no]],
+               [enable ofed kernel]),
+       [], [enable_o2ib_kernel="no"])
+AC_MSG_RESULT([$enable_o2ib_kernel])
+]) # LN_CONFIG_O2IB_KERNEL
+
+#
 # LN_CONFIG_O2IB
 #
 # If current OFED installed (assume with "ofed_info") and devel
@@ -845,6 +859,7 @@ AC_MSG_NOTICE([LNet kernel checks
 
 LN_CONFIG_BACKOFF
 LN_CONFIG_O2IB
+LN_CONFIG_O2IB_KERNEL
 LN_CONFIG_GNILND
 # 3.10
 LN_EXPORT_KMAP_TO_PAGE
index 1c345d3..554734d 100644 (file)
@@ -19,6 +19,7 @@
 %bcond_without mpi
 %bcond_with kabi
 %bcond_without mlnx
+%bcond_with ofed
 
 # By default both gss and gss keyring are disabled.
 # gss keyring requires the gss core. If the builder
 %endif
 
 %undefine with_mlnx
-# check whether to enable mlnx
+# check whether to enable mlnx or ofed
 %if "%{o2ibpath}" != "no"
        %if "%(grep mlnx %{o2ibpath}/Module.symvers >&/dev/null && echo yes)" == "yes"
                %define with_mlnx 1
@@ -202,6 +203,8 @@ Source6: kmp-lustre-osd-zfs.files
 Source7: kmp-lustre-tests.files
 Source8: kmp-lustre-o2ib-mlnx.preamble
 Source9: kmp-lustre-o2ib-mlnx.files
+Source10: kmp-lustre-o2ib-ofed.preamble
+Source11: kmp-lustre-o2ib-ofed.files
 URL: https://wiki.whamcloud.com/
 BuildRoot: %{_tmppath}/lustre-%{version}-root
 %if %{with lustre_modules}
@@ -290,6 +293,10 @@ echo $TMPFILE
 %kernel_module_package -n %{name}-o2ib-mlnx%{?mlnx_kabi_name:-%{mlnx_kabi_name}} -p %{SOURCE8} -f %{SOURCE9} default
 %endif
 
+%if %{with ofed}
+%kernel_module_package -n %{name}-o2ib-ofed -p %{SOURCE10} -f %{SOURCE11} default
+%endif
+
 %if %{with ldiskfs}
 %kernel_module_package -n %{name}-osd-ldiskfs -p %SOURCE3 -f %SOURCE4 %{_flavor}
 %if %{with lustre_utils}
@@ -489,7 +496,7 @@ mv Makefile.in Makefile.in.in
 sed -i 's/\@INCLUDE_RULES\@//' Makefile.in.in
 # Make sure our config.h is included after the lustre's one (from Rules)
 cat >> Makefile.in.in <<EOF
-KBUILD_EXTRA_SYMBOLS += @EXTRA_SYMBOLS@
+#KBUILD_EXTRA_SYMBOLS += @EXTRA_SYMBOLS@
 @INCLUDE_RULES@
 EXTRA_CFLAGS += @EXTRA_KCFLAGS@ @CFLAGS@
 EOF
@@ -504,6 +511,73 @@ cp config.h.in undef.h
 cd -
 %endif #with mlnx
 
+# Copy IB driver to a new dir, make kernel build system catch it
+%if %{with ofed}
+cp -a $RPM_BUILD_DIR/lustre-%{version}/lnet/klnds/o2iblnd \
+       $RPM_BUILD_DIR/lustre-%{version}/lnet/klnds/o2iblnd-ofed
+
+cd $RPM_BUILD_DIR/lustre-%{version}/lnet/klnds/o2iblnd-ofed
+mkdir {config,build}
+cp ../../../build/Makefile build
+
+for f in ../..//autoconf/lustre-lnet.m4 \
+         ../../../config/lustre-build.m4 \
+        ../../../config/lustre-build-linux.m4
+do
+       cp ${f} config/
+done
+
+cat >configure.ac <<\EOF
+AC_PREREQ([2.57])
+AC_INIT([o2iblnd-ofed], [LUSTRE_VERSION.DDN_LUSTRE_VERSION.DDN_BUILD_TAG], [https://jira.hpdd.intel.com/], [lustre])
+
+AC_CONFIG_AUX_DIR([../../../config])
+AC_CONFIG_MACRO_DIR([config])
+
+AC_CANONICAL_SYSTEM
+
+AM_INIT_AUTOMAKE([1.10 tar-ustar -Wno-portability])
+AM_MAINTAINER_MODE([enable])
+
+AC_PROG_CC
+LB_PROG_LINUX
+LN_PROG_LINUX
+LB_LINUX_PATH
+LN_PATH_DEFAULTS
+LN_CONDITIONALS
+
+LN_CONFIG_O2IB
+AC_CONFIG_HEADERS([config.h])
+# Override specific vars from "main" config.h (pulled in by manually including Rules)
+EXTRA_KCFLAGS="-include $PWD/undef.h -include $PWD/config.h $EXTRA_KCFLAGS"
+AC_SUBST(EXTRA_KCFLAGS)
+AC_SUBST(EXTRA_SYMBOLS)
+AC_CONFIG_FILES([Makefile.in])
+AC_OUTPUT
+EOF
+
+mv Makefile.in Makefile.in.in
+
+# Remove inclusion of main Rules file here, as it contains reference toModule.symvers from the
+# kernel (with its IB symbols). That reference should go AFTER ofed one.
+sed -i 's/\@INCLUDE_RULES\@//' Makefile.in.in
+# Make sure our config.h is included after the lustre's one (from Rules)
+cat >> Makefile.in.in <<EOF
+#KBUILD_EXTRA_SYMBOLS += @EXTRA_SYMBOLS@
+@INCLUDE_RULES@
+EXTRA_CFLAGS += @EXTRA_KCFLAGS@ -include $PWD/undef.h -include $PWD/config.h @CFLAGS@
+EOF
+
+# Now build a build system
+libtoolize -q
+aclocal -I ./config
+autoheader
+autoconf
+
+cp config.h.in undef.h
+cd -
+%endif #with ofed
+
 %build
 # Set an explicit path to our Linux tree, if we can.
 cd $RPM_BUILD_DIR/lustre-%{version}
@@ -598,6 +672,25 @@ EOF
        popd
 %endif
 
+%if %{with ofed}
+       # Now build MOFED variant of o2iblnd
+       ROOT_BUILD_DIR=${PWD}
+       pushd lnet/klnds/o2iblnd-ofed
+       ./configure --with-linux=%{kdir} --with-o2ib=%{kdir}
+       grep -v mlnx-ofa_kernel $PWD/../../../Module.symvers >& lustre.symvers
+       # Also instruct kernel build system to use Module.symvers from a main lustre build
+       cat >> Makefile.in <<EOF
+KBUILD_EXTRA_SYMBOLS +=  ${PWD}/lustre.symvers
+EOF
+       cp ${ROOT_BUILD_DIR}/Rules Rules
+       sed -i '/KBUILD_EXTRA_SYMBOLS/d' Rules
+       # Finish fixup of what our small autoconf system cannot detect
+       sed "s#@INCLUDE_RULES@#include $PWD/Rules#" Makefile.in > Makefile
+
+       make %{?_smp_mflags} -C %{kdir} modules M=$PWD
+       popd
+%endif
+
 %install
 %{?_openmpi_load}
 %{?_mpich_load}
@@ -623,6 +716,14 @@ basemodpath=$RPM_BUILD_ROOT%{modules_fs_path}/%{name}
        popd
 %endif
 
+%if %{with ofed}
+       cp lnet/klnds/o2iblnd/autoMakefile lnet/klnds/o2iblnd-ofed
+       pushd lnet/klnds/o2iblnd-ofed
+       make install DESTDIR=$RPM_BUILD_ROOT
+       mkdir -p $basemodpath-o2ib-ofed/net
+       mv $basemodpath/net/ko2iblnd.ko $basemodpath-o2ib-ofed/net/ko2iblnd.ko
+       popd
+%endif
 %if %{with ldiskfs}
 mkdir -p $basemodpath-osd-ldiskfs/fs
 mv $basemodpath/fs/osd_ldiskfs.ko $basemodpath-osd-ldiskfs/fs/osd_ldiskfs.ko
index f49c8cf..56fed5d 100644 (file)
@@ -3,6 +3,7 @@ Requires:       %{requires_kmod_name} = %{requires_kmod_version}
 Requires:       kmod-%{name} = %{version}
 Provides:      %{name}-o2ib-mlnx = %{version}
 Requires:      kmod-mlnx-ofa_kernel
+Conflicts:     kmod-%{name}-o2ib-ofed
 
 # kmod-lustre should be already on-disk when post(un) scriptlet is run (which run depmod), yum may mess that up
 # See https://www.redhat.com/archives/rpm-list/2008-September/msg00022.html
diff --git a/rpm/kmp-lustre-o2ib-ofed.files b/rpm/kmp-lustre-o2ib-ofed.files
new file mode 100644 (file)
index 0000000..9b3071c
--- /dev/null
@@ -0,0 +1,2 @@
+%defattr(-,root,root)
+%{modules_fs_path}/%{lustre_name}-o2ib-ofed/net/ko2iblnd.ko
diff --git a/rpm/kmp-lustre-o2ib-ofed.preamble b/rpm/kmp-lustre-o2ib-ofed.preamble
new file mode 100644 (file)
index 0000000..1b39b1a
--- /dev/null
@@ -0,0 +1,18 @@
+#Requires: kmod-lustre%{?kmod_kabi_name:-%{kmod_kabi_name}}${kmod_variant:+-${kmod_variant}} = %{version}-%{release}
+Requires:       %{requires_kmod_name} = %{requires_kmod_version}
+Requires:       kmod-%{name} = %{version}
+Provides:      %{name}-o2ib-ofed = %{version}
+Conflicts:     kmod-%{name}-o2ib-mlnx
+#Requires: kmod-mlnx-ofa_kernel${reqdashvariant}
+
+# kmod-lustre should be already on-disk when post(un) scriptlet is run (which run depmod), yum may mess that up
+# See https://www.redhat.com/archives/rpm-list/2008-September/msg00022.html
+#Requires(post): kmod-lustre%{?kmod_kabi_name:-%{kmod_kabi_name}}${kmod_variant:+-${kmod_variant}} = %{version}-%{release}
+#Provides: kmod-lustre${kmod_variant:+-${kmod_variant}}-o2ib-mlnx = %{version}-%{release}
+#%if ! 0%{?_maint_release}
+#Provides: kmod-lustre-latest${kmod_variant:+-${kmod_variant}}-o2ib-mlnx = %{version}-%{release}
+#%endif
+# Mellanox modules should be there too
+#Requires: kmod-mlnx-ofa_kernel${reqdashvariant}
+#Requires(post): kmod-mlnx-ofa_kernel${reqdashvariant}
+#Conflicts: kmod-lustre%{?kmod_kabi_name:-%{kmod_kabi_name}}${kmod_variant:+-${kmod_variant}}-o2ib-mlnx