From: Alex Zhuravlev Date: Wed, 23 May 2012 08:17:44 +0000 (+0400) Subject: LU-1305 build: support for osd-zfs X-Git-Tag: 2.2.59~10 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=6d57017bcb81a8cff88fa049ab662b4c0677f625 LU-1305 build: support for osd-zfs changes to enable building of spl, zfs and osd-zfs. Signed-off-by: Alex Zhuravlev Change-Id: I01dcc211b6943b3ed19eaf8756397a97095bbc59 Reviewed-on: http://review.whamcloud.com/2885 Tested-by: Hudson Reviewed-by: Johann Lombardi Reviewed-by: Andreas Dilger --- diff --git a/build/autoconf/Makefile.am b/build/autoconf/Makefile.am index 10f7b4e..8822fe2 100644 --- a/build/autoconf/Makefile.am +++ b/build/autoconf/Makefile.am @@ -1,2 +1,2 @@ EXTRA_DIST = lustre-build.m4 lustre-build-linux.m4 lustre-build-darwin.m4 -EXTRA_DIST += lustre-build-ldiskfs.m4 +EXTRA_DIST += lustre-build-ldiskfs.m4 lustre-build-zfs.m4 diff --git a/build/autoconf/lustre-build-zfs.m4 b/build/autoconf/lustre-build-zfs.m4 new file mode 100644 index 0000000..b636cb3 --- /dev/null +++ b/build/autoconf/lustre-build-zfs.m4 @@ -0,0 +1,429 @@ +# +# LB_PATH_SPL +# +# --with-spl - Enable spl support and attempt to autodetect the spl +# --with-spl=yes headers in one of the following places in this order: +# * ./spl +# * /usr/src/spl-*/$LINUXRELEASE +# * ../spl +# +# --with-spl=path - Enable spl support and use the spl headers in the +# provided path. No autodetection is performed. +# +# --with-spl-obj - When spl support is enabled the object directory +# will be based on the --with-spl directory. If this +# is detected incorrectly it can be explicitly +# specified using this option. +# +# NOTE: As with all external packages spl is expected to already be +# configured and built. However, if the spl tree is located in-tree +# (./spl) then it will be configured and built recursively as part of +# the lustre build system. +# +AC_DEFUN([LB_PATH_SPL], +[ +AC_ARG_WITH([spl], + AC_HELP_STRING([--with-spl=path], [set path to spl sources]), + [],[ + if test x$enable_server = xyes && test x$enable_dist = xno; then + with_spl='yes' + else + with_spl='no' + fi + ]) + +case x$with_spl in + xno) + AC_MSG_ERROR([spl must be enabled when building zfs.]) + ;; + xyes) + SPL_DIR= + + # Check ./spl + spl_src=$PWD/spl + if test -e "$spl_src"; then + SPL_DIR=$(readlink -f $spl_src) + else + # Check /usr/src/spl-*/$LINUXRELEASE + spl_src=$(ls -1d /usr/src/spl-*/$LINUXRELEASE \ + 2>/dev/null | tail -1) + if test -e "$spl_src"; then + SPL_DIR=$(readlink -f $spl_src) + else + # Check ../spl + spl_src=$PWD/../spl + if test -e "$spl_src"; then + SPL_DIR=$(readlink -f $spl_src) + else + # Fatal spl required for zfs builds + AC_MSG_ERROR([Could not locate spl.]) + fi + fi + fi + + ;; + *) + SPL_DIR=$(readlink -f $with_spl) + with_spl='yes' + ;; +esac + +AC_ARG_WITH([spl-obj], + AC_HELP_STRING([--with-spl-obj=path], [set path to spl objects]), + [ + if test x$with_spl = xyes; then + SPL_OBJ="$withval" + fi + ],[ + if test x$with_spl = xyes; then + SPL_OBJ=$SPL_DIR + fi + ]) + +AC_MSG_CHECKING([spl source directory]) +AC_MSG_RESULT([$SPL_DIR]) +AC_SUBST(SPL_DIR) + +AC_MSG_CHECKING([spl object directory]) +AC_MSG_RESULT([$SPL_OBJ]) +AC_SUBST(SPL_OBJ) + +LB_SPL_SYMVERS +LB_SPL_RELEASE +]) + +# +# LB_SPL_BUILD +# +# Optionally configure/make the spl sources. If the sources are +# determined to reside in-tree this feature will automatically be +# enabled. If the sources are not in-tree it will be disabled. +# Use --enable-spl-build or --disable-spl-build if you need to +# override this behavior. +# +AC_DEFUN([LB_SPL_BUILD], +[ +AC_ARG_ENABLE([spl-build], + AC_HELP_STRING([--enable-spl-build], [enable spl configure/make]), + [], [ + SPL_DIR_INTREE=$(readlink -f $PWD/spl) + if test x$SPL_DIR = x$SPL_DIR_INTREE; then + enable_spl_build='yes' + else + enable_spl_build='no' + fi + ]) + +AC_MSG_CHECKING([whether to build spl]) +if test x$enable_spl_build = xyes; then + AC_MSG_RESULT([$enable_spl_build]) + + LB_CHECK_FILE([$SPL_DIR/module/spl/spl-generic.c], [], [ + AC_MSG_ERROR([Complete spl source must exist when building.])]) + + LB_CHECK_FILE([$SPL_DIR/configure], [], [ + AC_MSG_ERROR([Complete spl source must exist when building.])]) + + SPL_SUBDIR="$SPL_DIR" + AC_SUBST(SPL_SUBDIR) + AC_CONFIG_SUBDIRS("spl") +else + enable_spl_build='no' + AC_MSG_RESULT([$enable_spl_build]) +fi +]) + +# +# LB_SPL_SYMVERS +# +AC_DEFUN([LB_SPL_SYMVERS], +[ +AC_MSG_CHECKING([spl module symbols]) +if test -r $SPL_OBJ/Module.symvers; then + SPL_SYMBOLS=Module.symvers +elif test -r $SPL_OBJ/Modules.symvers; then + SPL_SYMBOLS=Modules.symvers +elif test -r $SPL_OBJ/module/Module.symvers; then + SPL_SYMBOLS=Module.symvers +elif test -r $SPL_OBJ/module/Modules.symvers; then + SPL_SYMBOLS=Modules.symvers +else + SPL_SYMBOLS=$SYMVERFILE +fi + +AC_MSG_RESULT([$SPL_SYMBOLS]) +AC_SUBST(SPL_SYMBOLS) +]) + +# +# LB_SPL_RELEASE +# +AC_DEFUN([LB_SPL_RELEASE], +[ +AC_MSG_CHECKING([spl source release]) +if test -r $SPL_OBJ/spl_config.h; then + tmp_flags="$EXTRA_KCFLAGS" + EXTRA_KCFLAGS="-I$SPL_DIR $EXTRA_KCFLAGS" + LB_LINUX_TRY_MAKE([ + #include <$SPL_OBJ/spl_config.h> + ],[ + char *SPL_RELEASE; + SPL_RELEASE=SPL_META_VERSION; + ],[ + $makerule LUSTRE_KERNEL_TEST=conftest.i + ],[ + test -s build/conftest.i + ],[ + eval $(grep "SPL_RELEASE=" build/conftest.i) + ],[ + AC_MSG_RESULT([unknown]) + AC_MSG_ERROR([Could not preprocess test program.]) + ]) + EXTRA_KCFLAGS="$tmp_flags" + rm build/conftest.i +elif test -r $SPL_DIR/META; then + SPL_RELEASE=$(awk '/Version/ { print [$]2 }' $SPL_DIR/META) +else + AC_MSG_RESULT([unknown]) + AC_MSG_ERROR([Could not locate spl_config.h or META to check release.]) +fi + +if test x$SPL_RELEASE = x; then + AC_MSG_RESULT([unknown]) + AC_MSG_ERROR([Could not determine spl release.]) +fi + +AC_MSG_RESULT([$SPL_RELEASE]) +AC_SUBST(SPL_RELEASE) +]) + + +# +# LB_PATH_ZFS +# +# --without-zfs - Disable zfs support. +# --with-zfs=no +# +# --with-zfs - Enable zfs support and attempt to autodetect the zfs +# --with-zfs=yes headers in one of the following places in this order: +# * ./zfs +# * /usr/src/zfs-*/$LINUXRELEASE +# * ../zfs +# +# --with-zfs=path - Enable zfs support and use the zfs headers in the +# provided path. No autodetection is performed. +# +# --with-zfs-obj - When zfs support is enabled the object directory +# will be based on the --with-zfs directory. If this +# is detected incorrectly it can be explicitly +# specified using this option. +# +# NOTE: As with all external packages zfs is expected to already be +# configured and built. However, if the zfs tree is located in-tree +# (./zfs) then it will be configured and built recursively as part of +# the lustre build system. +# +AC_DEFUN([LB_PATH_ZFS], +[ +AC_ARG_WITH([zfs], + AC_HELP_STRING([--with-zfs=path], [set path to zfs sources]), + [],[ + if test x$enable_server = xyes && test x$enable_dist = xno; then + with_zfs='yes' + else + with_zfs='no' + fi + ]) + +case x$with_zfs in + xno) + ZFS_DIR= + ;; + xyes) + ZFS_DIR= + + # Check ./zfs + zfs_src=$PWD/zfs + if test -e "$zfs_src"; then + ZFS_DIR=$(readlink -f $zfs_src) + else + # Check /usr/src/zfs-*/$LINUXRELEASE + zfs_src=$(ls -1d /usr/src/zfs-*/$LINUXRELEASE \ + 2>/dev/null|tail -1) + if test -e "$zfs_src"; then + ZFS_DIR=$(readlink -f $zfs_src) + else + # Check ../zfs + zfs_src=$PWD/../zfs + if test -e "$zfs_src"; then + ZFS_DIR=$(readlink -f $zfs_src) + else + # Disable zfs failed to detect sources + with_zfs='no' + fi + fi + fi + + ;; + *) + ZFS_DIR=$(readlink -f $with_zfs) + with_zfs='yes' + ;; +esac + +AC_MSG_CHECKING([whether to enable zfs]) +AC_MSG_RESULT([$with_zfs]) + +AC_ARG_WITH([zfs-obj], + AC_HELP_STRING([--with-zfs-obj=path], [set path to zfs objects]), + [ + if test x$with_zfs = xyes; then + ZFS_OBJ="$withval" + fi + ],[ + if test x$with_zfs = xyes; then + ZFS_OBJ=$ZFS_DIR + fi + ]) + +if test x$with_zfs = xyes; then + LB_ZFS_DEFINE_OPTIONS + + AC_MSG_CHECKING([zfs source directory]) + AC_MSG_RESULT([$ZFS_DIR]) + AC_SUBST(ZFS_DIR) + + AC_MSG_CHECKING([zfs object directory]) + AC_MSG_RESULT([$ZFS_OBJ]) + AC_SUBST(ZFS_OBJ) + + LB_ZFS_SYMVERS + LB_ZFS_RELEASE + + LB_PATH_SPL + + LB_SPL_BUILD + LB_ZFS_BUILD + +fi + +AM_CONDITIONAL(SPL_BUILD, test x$enable_spl_build = xyes) +AM_CONDITIONAL(ZFS_BUILD, test x$enable_zfs_build = xyes) +AM_CONDITIONAL(ZFS_ENABLED, test x$with_zfs = xyes) +]) + +# +# LB_ZFS_BUILD +# +# Optionally configure/make the zfs sources. If the sources are +# determined to reside in-tree this feature will automatically be +# enabled. If the sources are not in-tree it will be disabled. +# Use --enable-zfs-build or --disable-zfs-build if you need to +# override this behavior. +# +AC_DEFUN([LB_ZFS_BUILD], +[ +AC_ARG_ENABLE([zfs-build], + AC_HELP_STRING([--enable-zfs-build], [enable zfs configure/make]), + [], [ + ZFS_DIR_INTREE=$(readlink -f $PWD/zfs) + if test x$ZFS_DIR = x$ZFS_DIR_INTREE; then + enable_zfs_build='yes' + else + enable_zfs_build='no' + fi + ]) + +AC_MSG_CHECKING([whether to build zfs]) +if test x$enable_zfs_build = xyes; then + AC_MSG_RESULT([$enable_zfs_build]) + + LB_CHECK_FILE([$ZFS_DIR/module/zfs/dmu.c], [], [ + AC_MSG_ERROR([Complete zfs sources must exist when building.])]) + + LB_CHECK_FILE([$ZFS_DIR/configure], [], [ + AC_MSG_ERROR([Complete zfs sources must exist when building.])]) + + ZFS_SUBDIR="$ZFS_DIR" + AC_SUBST(ZFS_SUBDIR) + AC_CONFIG_SUBDIRS("zfs") + + ac_configure_args="$ac_configure_args --with-spl=$SPL_DIR" + ac_configure_args="$ac_configure_args --with-spl-obj=$SPL_OBJ" +else + enable_zfs_build='no' + AC_MSG_RESULT([$enable_zfs_build]) +fi +]) + +# +# LB_ZFS_SYMVERS +# +AC_DEFUN([LB_ZFS_SYMVERS], +[ +AC_MSG_CHECKING([zfs module symbols]) +if test -r $ZFS_OBJ/Module.symvers; then + ZFS_SYMBOLS=Module.symvers +elif test -r $ZFS_OBJ/Modules.symvers; then + ZFS_SYMBOLS=Modules.symvers +elif test -r $ZFS_OBJ/module/Module.symvers; then + ZFS_SYMBOLS=Module.symvers +elif test -r $ZFS_OBJ/module/Modules.symvers; then + ZFS_SYMBOLS=Modules.symvers +else + ZFS_SYMBOLS=$SYMVERFILE +fi + +AC_MSG_RESULT([$ZFS_SYMBOLS]) +AC_SUBST(ZFS_SYMBOLS) +]) + +# +# LB_ZFS_RELEASE +# +AC_DEFUN([LB_ZFS_RELEASE], +[ +AC_MSG_CHECKING([zfs source release]) +if test -r $ZFS_OBJ/zfs_config.h; then + tmp_flags="$EXTRA_KCFLAGS" + EXTRA_KCFLAGS="-I$ZFS_DIR $EXTRA_KCFLAGS" + LB_LINUX_TRY_MAKE([ + #include <$ZFS_OBJ/zfs_config.h> + ],[ + char *ZFS_RELEASE; + ZFS_RELEASE=ZFS_META_VERSION; + ],[ + $makerule LUSTRE_KERNEL_TEST=conftest.i + ],[ + test -s build/conftest.i + ],[ + eval $(grep "ZFS_RELEASE=" build/conftest.i) + ],[ + AC_MSG_RESULT([unknown]) + AC_MSG_ERROR([Could not preprocess test program.]) + ]) + EXTRA_KCFLAGS="$tmp_flags" + rm build/conftest.i +elif test -r $ZFS_DIR/META; then + ZFS_RELEASE=$(awk '/Version/ { print [$]2 }' $ZFS_DIR/META) +else + AC_MSG_RESULT([unknown]) + AC_MSG_ERROR([Could not locate zfs_config.h or META to check release.]) +fi + +if test x$ZFS_RELEASE = x; then + AC_MSG_RESULT([unknown]) + AC_MSG_ERROR([Could not determine zfs release.]) +fi + +AC_MSG_RESULT([$ZFS_RELEASE]) +AC_SUBST(ZFS_RELEASE) +]) + +# +# LB_ZFS_DEFINE_OPTIONS +# +AC_DEFUN([LB_ZFS_DEFINE_OPTIONS], +[ +AC_DEFINE(HAVE_ZFS_OSD, 1, Enable zfs osd) +]) diff --git a/build/autoconf/lustre-build.m4 b/build/autoconf/lustre-build.m4 index 3878359..1f355f3 100644 --- a/build/autoconf/lustre-build.m4 +++ b/build/autoconf/lustre-build.m4 @@ -795,6 +795,7 @@ LB_PATH_DMU LB_PATH_LIBSYSIO LB_PATH_SNMP LB_PATH_LDISKFS +LB_PATH_ZFS LB_PATH_LUSTREIOKIT LB_DEFINE_E2FSPROGS_NAMES diff --git a/build/lbuild b/build/lbuild index 4869509..3bac48e 100755 --- a/build/lbuild +++ b/build/lbuild @@ -829,6 +829,17 @@ build_lustre() { echo NORPM mode. Only compiling. fi + # If server we now build the spl and zfs modules against the lustre kernel. + # These are required prior to the building of lustre server. Client does + # not require spl/zfs. Use !PATCHLESS to indicate server which follows the + # line above so is at least consistant. + if [ $PATCHLESS == false ] && [ "x$ZFSNOTSUPPORTED" == "x" ]; then + if ! build_spl_zfs; then + popd >/dev/null # pushd lustre + return 255 + fi + fi + ( $(skeep_ldiskfs_rpm $TAG) ) || { pushd ldiskfs > /dev/null || return 255 @@ -933,6 +944,118 @@ build_lustre() { } +### +# build_spl_zfs +# +# Fetch spl/zfs from the git repo and prepare for lustre build +# +# return 0 if successful, else 255 +build_spl_zfs() { + # make sure the RPM build environment is set up + create_rpmbuild_dirs + + # The spl/zfs spec files expect RPM_BUILD_ROOT to point to the root of the + # destination for the rpms + export RPM_BUILD_ROOT=$TOPDIR + + # The files expect a kver to be set to the kernel version . + kver=$(cat ${LINUX}/include/config/kernel.release) + + # build and install the spl and zfs (and -devel) RPMs for lustre to use + local pkg + for pkg in spl zfs; do + + local rpmmod spldir + + [ "$pkg" == "zfs" ] && spldir="$(ls -d $TOPDIR/usr/src/spl-*/*)" + rpmmod=$pkg-modules + + # need to fetch the repo in order to build it. + # default to github but allow override + git clone ${SPLZFSGITREPO:-"git@github.com:zfsonlinux"}/$pkg.git $pkg 2>&1 + + pushd $pkg || return 255 + + # XXX - _having_ to give a package a kernel just to have it configure + # enough to do a "make dist" is truely bogus! + if ! ./configure --with-linux=${LINUX} \ + ${spldir:+--with-spl="${spldir}"} 2>&1 || + ! make dist 2>&1; then + popd + return 255 + fi + popd + + # XXX - dirty hack time. ~sigh~ + # because the spl tarball contains two .spec files, we cannot + # simply rebuild the tarball + ln $pkg/$pkg-*.tar.gz $TOPDIR/SOURCES || + error "failed to link $pkg/$pkg-*.tar.gz into $TOPDIR/SOURCES" + + # First build the userspace tools RPMs + if ! $RPMBUILD $targets -bb $pkg/$pkg.spec \ + --nodeps -v \ + --define "configure_args ${CONFIGURE_FLAGS}" \ + --define "_tmppath /var/tmp" \ + --define "_topdir $TOPDIR" 2>&1; then + return 255 + fi + + if $DO_SRC; then + if ! $RPMBUILD -bs $pkg/$pkg.spec \ + --nodeps -v \ + --define "configure_args ${CONFIGURE_FLAGS}" \ + --define "_tmppath /var/tmp" \ + --define "_topdir $TOPDIR" 2>&1; then + return 255 + fi + fi + + # Now the kernel module RPMs + # Need to provide pointers to the lustre kernel source, objects, usr/src + if ! $RPMBUILD $targets -bb $pkg/$rpmmod.spec \ + --nodeps -v \ + --define "require_kdir ${linux}" \ + ${linuxobj:+--define "require_kobj ${linuxobj}"} \ + ${spldir:+--define "require_spldir ${spldir}"} \ + --define "configure_args ${CONFIGURE_FLAGS}" \ + --define "_usrsrc $TOPDIR/usr/src" \ + --define "kver $kver" \ + --define "_tmppath /var/tmp" \ + --define "_topdir $TOPDIR" 2>&1; then + return 255 + fi + + if $DO_SRC; then + if ! $RPMBUILD -bs $pkg/$rpmmod.spec \ + --nodeps -v \ + --define "require_kdir ${linux}" \ + ${linuxobj:+--define "require_kobj ${linuxobj}"} \ + ${spldir:+--define "require_spldir ${spldir}"} \ + --define "configure_args ${CONFIGURE_FLAGS}" \ + --define "_usrsrc $TOPDIR/usr/src" \ + --define "kver $kver" \ + --define "_tmppath /var/tmp" \ + --define "_topdir $TOPDIR" 2>&1; then + return 255 + fi + fi + + # We have built the rpms for the package. No we need to extract the + # contained files so we can build further things against them + local rpm=$(ls $TOPDIR/RPMS/*/$rpmmod-devel-*.rpm) + + # cpio only extract to pwd so we need to go there. + pushd $TOPDIR + rpm2cpio < $rpm | cpio -id + popd + + CONFIGURE_FLAGS="--with-$pkg=$(ls -d $TOPDIR/usr/src/$pkg-*/*) ${CONFIGURE_FLAGS}" + done + + return 0 +} + stage() { [ "$STAGEDIR" ] || return 0 diff --git a/build/lbuild-rhel5 b/build/lbuild-rhel5 index 473347f..111f816 100644 --- a/build/lbuild-rhel5 +++ b/build/lbuild-rhel5 @@ -7,6 +7,10 @@ # distributions, update the BUILD_GEN variable in build/lbuild) BUILD_GEN+=".0" +# This distro does not support zfs, so define ZFSNOTSUPPORTED +# use words that make the bash log readable. +ZFSNOTSUPPORTED="Zfs Not Supported" + source ${0%/*}/lbuild-rhel SPEC_NAME="kernel-2.6.spec" diff --git a/lustre/Makefile.in b/lustre/Makefile.in index 621324d..1eb7682 100644 --- a/lustre/Makefile.in +++ b/lustre/Makefile.in @@ -9,5 +9,6 @@ subdir-m += mgc @SERVER_TRUE@subdir-m += mds obdfilter ost mgs mdt cmm mdd ofd osd-ldiskfs quota @CLIENT_TRUE@subdir-m += mdc lmv llite fld +@ZFS_ENABLED_TRUE@subdir-m += osd-zfs @INCLUDE_RULES@ diff --git a/lustre/autoMakefile.am b/lustre/autoMakefile.am index 2526d27..31b6109 100644 --- a/lustre/autoMakefile.am +++ b/lustre/autoMakefile.am @@ -42,7 +42,7 @@ AUTOMAKE_OPTIONS = foreign ALWAYS_SUBDIRS := include lvfs obdclass ldlm ptlrpc osc lov obdecho \ mgc fid fld doc utils tests scripts autoconf contrib conf -SERVER_SUBDIRS := obdfilter ost mds mgs mdt cmm mdd ofd osd-ldiskfs quota +SERVER_SUBDIRS := obdfilter ost mds mgs mdt cmm mdd ofd osd-zfs osd-ldiskfs quota CLIENT_SUBDIRS := mdc lmv llite lclient diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index dfb0c0e..f6d3433 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -2694,6 +2694,8 @@ lustre/ost/Makefile lustre/ost/autoMakefile lustre/osd-ldiskfs/Makefile lustre/osd-ldiskfs/autoMakefile +lustre/osd-zfs/Makefile +lustre/osd-zfs/autoMakefile lustre/mgc/Makefile lustre/mgc/autoMakefile lustre/mgs/Makefile