%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
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}
%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}
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
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}
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}
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
--- /dev/null
+#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