Whamcloud - gitweb
LU-18254 dkms: optional support for weak-modules 52/56452/11
authorShaun Tancheff <shaun.tancheff@hpe.com>
Thu, 3 Apr 2025 07:26:16 +0000 (14:26 +0700)
committerOleg Drokin <green@whamcloud.com>
Tue, 8 Jul 2025 03:55:05 +0000 (03:55 +0000)
Conditionally support weak modules by setting:
   LUSTRE_DKMS_NO_WEAK_MODULES=no
in /etc/sysconfig/dkms-lustre before installing the dkms
package.

Duplicate the o2ib and kfi detection from lustre-dkms_pre-build.sh
into dkms.mkconf and dkms.conf.in for rpm and deb packaging

Test-Parameters: trivial clientextra_install_params="--dkms" \
  serverextra_install_params="--dkms" testgroup=full-dkms

Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: I09502ad4a2e4930694725cf00b847ecacc4ca043
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56452
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
debian/dkms.conf.in
lustre-dkms.spec.in
lustre-dkms_pre-build.sh
lustre.spec.in
lustre/conf/Makefile.am
lustre/conf/dkms-lustre [new file with mode: 0644]
lustre/scripts/dkms.mkconf

index 0297cc3..826131d 100644 (file)
 #
 
 PACKAGE_NAME="lustre-client-modules"
-PACKAGE_CONFIG="/etc/sysconfig/lustre"
+PACKAGE_CONFIG="/etc/sysconfig/dkms-lustre"
+PACKAGE_CONFIG_FALLBACK="/etc/sysconfig/lustre"
 PACKAGE_VERSION="@UPVERSION@"
 
+no_weak_modules=yes
+strip_default=no
 OPTS=""
 if [[ "x${PACKAGE_NAME}" = "xlustre-client-modules" ]] ; then
     OPTS="${OPTS} --disable-server --disable-quilt"
 fi
+[[ -f /usr/src/kfabric/default/Module.symvers ]] &&
+    OPTS="${OPTS} --with-kfi=/usr/src/kfabric/default"
+[[ -d /usr/src/ofa_kernel/default ]] &&
+    OPTS="${OPTS} --with-o2ib=/usr/src/ofa_kernel/default"
 OPTS="${OPTS} --disable-dependency-tracking --disable-doc"
 OPTS="${OPTS} --disable-utils --disable-iokit --disable-tests"
 OPTS="${OPTS} --enable-quota --with-kmp-moddir=updates"
 
+[[ -r ${PACKAGE_CONFIG} ]] || PACKAGE_CONFIG=${PACKAGE_CONFIG_FALLBACK}
 if [[ -r ${PACKAGE_CONFIG} ]] ; then
    source ${PACKAGE_CONFIG}
    shopt -q -s extglob
+   if [[ -n \${LUSTRE_DKMS_DISABLE_STRIP} ]] ; then
+        [[ \${LUSTRE_DKMS_DISABLE_STRIP,,} == @(y|yes) ]] && strip_default=no
+   fi
+   if [[ -n \${LUSTRE_DKMS_ENABLE_STRIP} ]] ; then
+        [[ \${LUSTRE_DKMS_ENABLE_STRIP,,} == @(y|yes) ]] && strip_default=yes
+   fi
    if [[ -n ${LUSTRE_DKMS_DISABLE_CDEBUG} ]] ; then
       [[ ${LUSTRE_DKMS_DISABLE_CDEBUG,,} == @(y|yes) ]] &&
          OPTS="${OPTS} --disable-libcfs-cdebug" ||
@@ -61,6 +75,10 @@ if [[ -r ${PACKAGE_CONFIG} ]] ; then
    fi
    [[ -n ${LUSTRE_DKMS_CONFIGURE_EXTRA} ]] &&
        OPTS="${OPTS} ${LUSTRE_DKMS_CONFIGURE_EXTRA}"
+   if [[ -n ${LUSTRE_DKMS_WEAK_MODULES} ]] ; then
+      [[ ${LUSTRE_DKMS_WEAK_MODULES,,} == @(y|yes) ]] &&
+         no_weak_modules="no"
+   fi
 fi
 echo "${OPTS} " | grep -E -q -- '--disable-gss[^-]|--enable-gss[^-]' ||
   dpkg -l | grep libkrb5-dev | grep -q ^ii &&
@@ -75,7 +93,7 @@ CONFIGURE="${CONFIGURE} --with-linux-obj=$kernel_source_dir ${OPTS}"
 MAKE="${AUTOGEN} && ${CONFIGURE} && make -j `nproc`"
 CLEAN="make distclean || true"
 
-NO_WEAK_MODULES="yes"
+NO_WEAK_MODULES="$no_weak_modules"
 AUTOINSTALL="yes"
 STRIP="no"
 
@@ -121,7 +139,7 @@ int_mofed=no
 o2ib=$(echo ${OPTS} | tr ' ' '\\n' | grep -- '--with-o2ib=' | cut -c 13-)
 if [[ "x$o2ib" = "xno" ]] ; then
    can_o2ib_in_kernel=no
-elif [[ -f $o2ib ]] ; then
+elif [[ -d $o2ib ]] ; then
    # User specified path, if the build completes it will be ext_ofed
    can_o2ib_mofed=yes
    ext_mofed=yes
index 0e87fd3..42b16ce 100644 (file)
@@ -155,6 +155,8 @@ the repository with other debuginfo rpms.
 if [ "$RPM_BUILD_ROOT" != "/" ]; then
     rm -rf $RPM_BUILD_ROOT
 fi
+mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig
+cp lustre/conf/dkms-lustre $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig
 mkdir -p $RPM_BUILD_ROOT/usr/src/
 cp -rfp ${RPM_BUILD_DIR}/@PACKAGE@-%{version} $RPM_BUILD_ROOT/usr/src/
 mv $RPM_BUILD_ROOT/usr/src/@PACKAGE@-%{version} $RPM_BUILD_ROOT/usr/src/%{module}-%{version}
@@ -167,6 +169,7 @@ fi
 %files
 %defattr(-,root,root)
 /usr/src/%{module}-%{version}
+%config(noreplace) %{_sysconfdir}/sysconfig/dkms-lustre
 
 %post
 dkms add -m %{module} -v %{version} %{!?not_rpm:--rpm_safe_upgrade} ||:
index 7a4c2d2..d639a59 100755 (executable)
@@ -80,8 +80,10 @@ case $1 in
        ;;
 esac
 
-PACKAGE_CONFIG="/etc/sysconfig/lustre"
+PACKAGE_CONFIG="/etc/sysconfig/dkms-lustre"
+PACKAGE_CONFIG_FALLBACK="/etc/sysconfig/lustre"
 DKMS_CONFIG_OPTS=$(
+    [[ -r ${PACKAGE_CONFIG} ]] || PACKAGE_CONFIG=${PACKAGE_CONFIG_FALLBACK}
     [[ -r ${PACKAGE_CONFIG} ]] \
     && source ${PACKAGE_CONFIG} \
     && shopt -q -s extglob \
index 26aa264..3f85a18 100644 (file)
@@ -898,6 +898,7 @@ echo '%{_unitdir}/lnet.service' >>lustre.files
 echo '%{_unitdir}/lsvcgss.service' >>lustre.files
 %endif
 
+# vendor is redhat
 %if "%{_vendor}" == "redhat" || 0%{?openEuler}
 # The following scripts are Red Hat specific
 %if %{with servers}
@@ -913,6 +914,8 @@ echo '%config(noreplace) %{_sysconfdir}/sysconfig/lsvcgss' >>lustre.files
 echo '%{_sysconfdir}/init.d/lnet' >>lustre.files
 %endif
 %endif
+# End: vendor is redhat
+
 %if %{with gss_keyring}
 echo '%config(noreplace) %{_sysconfdir}/request-key.d/lgssc.conf' >>lustre.files
 %endif
@@ -1004,6 +1007,7 @@ echo '%{_libdir}/lustre/tests/lutf/*' >>lustre-tests.files
 
 %files -f lustre.files
 %defattr(-,root,root)
+%exclude %{_sysconfdir}/sysconfig/dkms-lustre
 %{_sbindir}/*
 %if %{with lustre_tests}
 %exclude %{_sbindir}/wirecheck
index dde1133..b26bc94 100644 (file)
@@ -15,10 +15,12 @@ SUBDIRS = resource
 DIST_SUBDIRS = resource
 
 EXTRA_DIST = lustre.xml 99-lustre.rules lustre ldev.conf ko2iblnd.conf \
-             lsvcgss lnet_routes.conf lnet.conf lgssc.conf \
+             lsvcgss lnet_routes.conf lnet.conf lgssc.conf dkms-lustre \
              lnet-sysctl.conf 99-lustre-server.rules mount.client.params
 
 sysconf_DATA = lnet.conf
+sysconfigdir = $(sysconfdir)/sysconfig
+sysconfig_DATA = dkms-lustre
 
 if UTILS
 sysconf_DATA += lnet_routes.conf
@@ -37,8 +39,7 @@ if ZFS_ENABLED
 sysconf_DATA += ldev.conf
 endif
 if RHEL
-sysconfigdir = $(sysconfdir)/sysconfig
-sysconfig_DATA = lustre
+sysconfig_DATA += lustre
 if GSS_KEYRING
 sysconfig_DATA += lsvcgss
 endif
diff --git a/lustre/conf/dkms-lustre b/lustre/conf/dkms-lustre
new file mode 100644 (file)
index 0000000..c31c2a2
--- /dev/null
@@ -0,0 +1,49 @@
+
+## DKMS ##
+
+# Options specific to DKMS configure and install:
+
+# Installation options
+
+#LUSTRE_DKMS_WEAK_MODULES=no
+# default is to not use weak-modules
+# specify yes here invoke weak-modules support
+
+#LUSTRE_DKMS_DISABLE_STRIP=y
+#LUSTRE_DKMS_ENABLE_STRIP=n
+# if kernel modules are to be stripped of debugging information
+# unset: default is not strip kernel objects
+
+# Configuration options
+
+#LUSTRE_DKMS_DISABLE_CDEBUG=yes
+# yes: configure with --disable-libcfs-cdebug
+# no: configure with --enable-libcfs-cdebug
+# unset: use configure default
+
+#LUSTRE_DKMS_DISABLE_TRACE=y
+# yes: configure with --disable-libcfs-trace
+# no: configure with --enable-libcfs-trace
+# unset: use configure default
+
+#LUSTRE_DKMS_DISABLE_ASSERT=y
+# yes: configure with --disable-libcfs-assert
+# no: configure with --enable-libcfs-assert
+# unset: use configure default
+
+#LUSTRE_DKMS_ENABLE_GSS=y
+# yes: configure with --enable-gss
+# unset:
+#   if krb5-devel or libkb5-dev package installed configure with --enable-gss
+#   otherwise use configure default
+
+#LUSTRE_DKMS_ENABLE_GSS_KEYRING=y
+# yes: configure with --enable-gss-keyring
+# unset: use configure default
+
+#LUSTRE_DKMS_ENABLE_CRYPTO=y
+# yes: configure with --enable-crypto
+# unset, or no: configure with --disable-crypto
+
+#LUSTRE_DKMS_CONFIGURE_EXTRA='--enable-cache'
+# adds any user specified arguments to configure
index 875f6a8..697afa6 100755 (executable)
@@ -21,7 +21,8 @@ fi
 cat >${filename} <<EOF
 PACKAGE_NAME="${pkgname}"
 PACKAGE_VERSION="${pkgver}"
-PACKAGE_CONFIG="/etc/sysconfig/lustre"
+PACKAGE_CONFIG="/etc/sysconfig/dkms-lustre"
+PACKAGE_CONFIG_FALLBACK="/etc/sysconfig/lustre"
 # re-evaluate/create dkms.conf on-target based on local build-time products/dependencies
 # (like krb5-devel presence) and also upon configure results/errors before dkms builds
 PRE_BUILD="lustre-dkms_pre-build.sh \$module \$module_version \$kernelver \$kernel_source_dir \
@@ -38,13 +39,25 @@ BUILD_DEPENDS[0]="zfs"
 EOF
 fi
 cat >>${filename} <<EOF
-NO_WEAK_MODULES="yes"
-AUTOINSTALL="yes"
-NO_WEAK_MODULES="yes"
-MAKE[0]="make -j \`nproc\`"
-
 OPTS=""
+flavor=\$(echo \$kernelver | tr '-' '\\n' | tail -1)
+if grep -F -q '.' <<< \$flavor ; then
+   flavor=default;
+fi
+if [ -f /usr/src/kfabric/\${flavor}/Module.symvers ]; then
+    OPTS="\${OPTS} --with-kfi=/usr/src/kfabric/\${flavor}"
+elif [ -f /usr/src/kfabric/default/Module.symvers ]; then
+    OPTS="\${OPTS} --with-kfi=/usr/src/kfabric/default"
+fi
+if [ -d /usr/src/ofa_kernel/\${flavor} ]; then
+    OPTS="\${OPTS} --with-o2ib=/usr/src/ofa_kernel/\${flavor}"
+elif [ -d /usr/src/ofa_kernel/default ]; then
+    OPTS="\${OPTS} --with-o2ib=/usr/src/ofa_kernel/default"
+fi
+# Default is to not enable weak-modules
+no_weak_modules=yes
 strip_default=no
+[[ -r \${PACKAGE_CONFIG} ]] || PACKAGE_CONFIG=\${PACKAGE_CONFIG_FALLBACK}
 if [[ -r \${PACKAGE_CONFIG} ]] ; then
    source \${PACKAGE_CONFIG}
    shopt -q -s extglob
@@ -61,6 +74,10 @@ if [[ -r \${PACKAGE_CONFIG} ]] ; then
    fi
    [[ -n \${LUSTRE_DKMS_CONFIGURE_EXTRA} ]] &&
       OPTS="\${OPTS} \${LUSTRE_DKMS_CONFIGURE_EXTRA}"
+   if [[ -n \${LUSTRE_DKMS_WEAK_MODULES} ]] ; then
+      [[ \${LUSTRE_DKMS_WEAK_MODULES,,} == @(y|yes) ]] &&
+         no_weak_modules="no"
+   fi
 fi
 echo "\${OPTS} " | grep -E -q -- '--disable-gss[^-]|--enable-gss[^-]'
 if [[ \$? != 0 ]] ; then
@@ -70,7 +87,9 @@ if [[ \$? != 0 ]] ; then
          OPTS="\${OPTS} --enable-gss" ||
          OPTS="\${OPTS} --disable-gss"
 fi
-
+NO_WEAK_MODULES="\$no_weak_modules"
+AUTOINSTALL="yes"
+MAKE[0]="make -j \`nproc\`"
 # Determine which, if any, o2ib to install:
 can_o2ib_mofed=no
 can_o2ib_in_kernel=no
@@ -86,7 +105,7 @@ ksrc=\$(dirname \${kernel_source_dir})/source
 o2ib=\$(echo \${OPTS} | tr ' ' '\\n' | grep -- '--with-o2ib=' | cut -c 13-)
 if [[ "x\$o2ib" = "xno" ]] ; then
    can_o2ib_in_kernel=no
-elif [[ -f \$o2ib ]] ; then
+elif [[ -d \$o2ib ]] ; then
    # User specified path, if the build completes it will be ext_ofed
    can_o2ib_mofed=yes
    ext_mofed=yes
@@ -123,7 +142,7 @@ module() {
   BUILT_MODULE_NAME[\${#BUILT_MODULE_NAME[@]}]="\${built_name}"
   BUILT_MODULE_LOCATION[\${#BUILT_MODULE_LOCATION[@]}]="\${built_loc}/"
   DEST_MODULE_LOCATION[\${#DEST_MODULE_LOCATION[@]}]="/${kmoddir}/\${dest}/"
-  STRIP[\${#STRIP[@]}]=\${strip_default}
+  STRIP[\${#STRIP[@]}]=\${do_strip}
 }
 # Common modules for both Client & Server
 module lnet_selftest lnet/selftest      lnet