From 14842473f5970eaf86e950739d943ebee266cf30 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Tue, 16 Oct 2012 07:44:03 -0400 Subject: [PATCH] LU-1930 build: Back end file system fixes. Currently Lustre for ZFS requires the zfs development rpm for its userland support to be installed on the build machine so we can create the lustre zfs utilities. What this patch does is allow a user to be able to build against the zfs/spl source drops as well as the rpms. A work around is provided so we can point the lustre build system to were a user can temporary install the zfs user land headers. Signed-off-by: James Simmons Change-Id: I8e5586ed22956a9dd4799826a442b8f5a895d872 Reviewed-on: http://review.whamcloud.com/3980 Reviewed-by: Brian J. Murrell Tested-by: Hudson Reviewed-by: Andreas Dilger Tested-by: Maloo --- build/autoconf/lustre-build-zfs.m4 | 22 +++++++++++++++++++--- lustre/osd-zfs/Makefile.in | 2 +- lustre/utils/Makefile.am | 6 +++--- lustre/utils/mkfs_lustre.c | 2 +- lustre/utils/mount_lustre.c | 2 +- lustre/utils/mount_utils.c | 2 +- lustre/utils/mount_utils.h | 11 +++++++++++ lustre/utils/mount_utils_ldiskfs.c | 2 +- lustre/utils/mount_utils_zfs.c | 6 ++---- 9 files changed, 40 insertions(+), 15 deletions(-) diff --git a/build/autoconf/lustre-build-zfs.m4 b/build/autoconf/lustre-build-zfs.m4 index b636cb3..bfc647f 100644 --- a/build/autoconf/lustre-build-zfs.m4 +++ b/build/autoconf/lustre-build-zfs.m4 @@ -263,7 +263,6 @@ case x$with_zfs in fi fi fi - ;; *) ZFS_DIR=$(readlink -f $with_zfs) @@ -274,6 +273,24 @@ esac AC_MSG_CHECKING([whether to enable zfs]) AC_MSG_RESULT([$with_zfs]) +if test x$with_zfs = xyes; then + AC_MSG_CHECKING([for location of zfs library headers]) + if test -e "$ZFS_DIR/include/libzfs.h"; then + EXTRA_LIBZFS_INCLUDE="$EXTRA_LIBZFS_INCLUDE -I $ZFS_DIR/lib/libspl/include -I $ZFS_DIR/include" + AC_MSG_RESULT([$ZFS_DIR]) + elif test -e "$ZFS_DIR/libzfs/libzfs.h"; then + EXTRA_LIBZFS_INCLUDE="$EXTRA_LIBZFS_INCLUDE -I $ZFS_DIR/libspl -I $ZFS_DIR/libzfs" + AC_MSG_RESULT([$ZFS_DIR]) + elif test -e "/usr/include/libzfs/libzfs.h"; then + AC_MSG_RESULT([/usr/include]) + EXTRA_LIBZFS_INCLUDE="$EXTRA_LIBZFS_INCLUDE -I /usr/include/libspl -I /usr/include/libzfs" + else + AC_MSG_RESULT([unknown]) + AC_MSG_ERROR([Could not locate zfs library headers.]) + fi + AC_SUBST(EXTRA_LIBZFS_INCLUDE) +fi + AC_ARG_WITH([zfs-obj], AC_HELP_STRING([--with-zfs-obj=path], [set path to zfs objects]), [ @@ -304,7 +321,6 @@ if test x$with_zfs = xyes; then LB_SPL_BUILD LB_ZFS_BUILD - fi AM_CONDITIONAL(SPL_BUILD, test x$enable_spl_build = xyes) @@ -386,7 +402,7 @@ 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" + EXTRA_KCFLAGS="-I$ZFS_OBJ $EXTRA_KCFLAGS" LB_LINUX_TRY_MAKE([ #include <$ZFS_OBJ/zfs_config.h> ],[ diff --git a/lustre/osd-zfs/Makefile.in b/lustre/osd-zfs/Makefile.in index 2d8e190..0a2dceb 100644 --- a/lustre/osd-zfs/Makefile.in +++ b/lustre/osd-zfs/Makefile.in @@ -4,7 +4,7 @@ osd_zfs-objs += osd_object.o osd_io.o osd_oi.o osd_xattr.o osd_index.o EXTRA_PRE_CFLAGS += -I@SPL_DIR@ -I@SPL_DIR@/include EXTRA_PRE_CFLAGS += -include @SPL_OBJ@/spl_config.h -EXTRA_PRE_CFLAGS += -I@ZFS_DIR@ -I@ZFS_DIR@/include +EXTRA_PRE_CFLAGS += -I@ZFS_OBJ@ -I@ZFS_OBJ@/include EXTRA_PRE_CFLAGS += -include @ZFS_OBJ@/zfs_config.h @INCLUDE_RULES@ diff --git a/lustre/utils/Makefile.am b/lustre/utils/Makefile.am index 5ab641d..e7c52a3 100644 --- a/lustre/utils/Makefile.am +++ b/lustre/utils/Makefile.am @@ -130,7 +130,7 @@ endif if ZFS_ENABLED mount_lustre_SOURCES += mount_utils_zfs.c mount_lustre_CPPFLAGS = -DHAVE_IOCTL_IN_UNISTD_H -mount_lustre_CPPFLAGS += -I /usr/include/libspl -I /usr/include/libzfs +mount_lustre_CPPFLAGS += $(EXTRA_LIBZFS_INCLUDE) mount_lustre_LDFLAGS = -pthread -rdynamic -ldl endif @@ -146,7 +146,7 @@ endif if ZFS_ENABLED mkfs_lustre_SOURCES += mount_utils_zfs.c mkfs_lustre_CPPFLAGS += -DHAVE_IOCTL_IN_UNISTD_H -mkfs_lustre_CPPFLAGS += -I /usr/include/libspl -I /usr/include/libzfs +mkfs_lustre_CPPFLAGS += $(EXTRA_LIBZFS_INCLUDE) mkfs_lustre_LDFLAGS = -pthread -rdynamic -ldl endif @@ -160,7 +160,7 @@ endif if ZFS_ENABLED tunefs_lustre_SOURCES += mount_utils_zfs.c tunefs_lustre_CPPFLAGS += -DHAVE_IOCTL_IN_UNISTD_H -tunefs_lustre_CPPFLAGS += -I /usr/include/libspl -I /usr/include/libzfs +tunefs_lustre_CPPFLAGS += $(EXTRA_LIBZFS_INCLUDE) tunefs_lustre_LDFLAGS = -pthread -rdynamic -ldl endif diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index 45ad45f..e3cfa81 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -47,6 +47,7 @@ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif +#include "mount_utils.h" #include #include #include @@ -77,7 +78,6 @@ #include #include #include -#include "mount_utils.h" #ifndef PATH_MAX #define PATH_MAX 4096 diff --git a/lustre/utils/mount_lustre.c b/lustre/utils/mount_lustre.c index 042fac1..1df69b0 100644 --- a/lustre/utils/mount_lustre.c +++ b/lustre/utils/mount_lustre.c @@ -42,6 +42,7 @@ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif +#include "mount_utils.h" #include #include #include @@ -52,7 +53,6 @@ #include #include #include -#include "mount_utils.h" #define MAXOPT 4096 #define MAX_RETRIES 99 diff --git a/lustre/utils/mount_utils.c b/lustre/utils/mount_utils.c index 565ed85..ae0316e 100644 --- a/lustre/utils/mount_utils.c +++ b/lustre/utils/mount_utils.c @@ -37,6 +37,7 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include "mount_utils.h" #include #include #include @@ -45,7 +46,6 @@ #include #include #include -#include "mount_utils.h" extern char *progname; extern int verbose; diff --git a/lustre/utils/mount_utils.h b/lustre/utils/mount_utils.h index b583f5c..72e2f0a 100644 --- a/lustre/utils/mount_utils.h +++ b/lustre/utils/mount_utils.h @@ -37,6 +37,17 @@ #ifndef _MOUNT_UTILS_H_ #define _MOUNT_UTILS_H_ +/* Some of the userland headers for libzfs also require + * zfs/spl linux kernel headers, but including these pull + * in linux kernel headers which conflicts with the + * userland version of libcfs. So the solution is tell the + * libzfs user land headrs that the zfs/spl kernel headers + * are already included even if this is not the case. + */ +#ifdef HAVE_ZFS_OSD +#define _SPL_ZFS_H +#define _SPL_SIGNAL_H +#endif #include #include diff --git a/lustre/utils/mount_utils_ldiskfs.c b/lustre/utils/mount_utils_ldiskfs.c index c7f551f..c6e6e8c 100644 --- a/lustre/utils/mount_utils_ldiskfs.c +++ b/lustre/utils/mount_utils_ldiskfs.c @@ -47,6 +47,7 @@ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif +#include "mount_utils.h" #include #include #include @@ -78,7 +79,6 @@ #include #include #include -#include "mount_utils.h" #define MAX_HW_SECTORS_KB_PATH "queue/max_hw_sectors_kb" #define MAX_SECTORS_KB_PATH "queue/max_sectors_kb" diff --git a/lustre/utils/mount_utils_zfs.c b/lustre/utils/mount_utils_zfs.c index 88d7a0c..d347d89 100644 --- a/lustre/utils/mount_utils_zfs.c +++ b/lustre/utils/mount_utils_zfs.c @@ -27,14 +27,12 @@ /* * Author: Brian Behlendorf */ - +#include "mount_utils.h" #include #include -#include +#include #include -#include "mount_utils.h" - /* Persistent mount data is stored in these user attributes */ #define LDD_VERSION_PROP "lustre:version" #define LDD_FLAGS_PROP "lustre:flags" -- 1.8.3.1