Whamcloud - gitweb
LU-15122 osd-ldiskfs: Fix ASSERTION( iobuf->dr_rw == 0 ) with 64KB PAGE_SIZE
[fs/lustre-release.git] / config / lustre-build-zfs.m4
index eb82bb4..27b0c0f 100644 (file)
@@ -111,7 +111,7 @@ AC_DEFUN([LB_SPL], [
        dnl #
        AC_MSG_CHECKING([spl build directory])
        AS_IF([test -z "$splobj"], [
-               last_spl_obj_dir=$(ls -d ${splsrc}/[[0-9]]*/ | tail -n 1 | sed 's|/$||')
+               last_spl_obj_dir=$(ls -d ${splsrc}/[[0-9]]*/  2> /dev/null | tail -n 1 | sed 's|/$||')
                AS_IF([test "${splsrc}" = "${spldkms}/source"], [
                        AS_IF([test -e "${spldkms}/${LINUXRELEASE}/${target_cpu}/spl_config.h"], [
                                splobj=${spldkms}/${LINUXRELEASE}/${target_cpu}
@@ -169,14 +169,17 @@ AC_DEFUN([LB_SPL], [
                AC_MSG_RESULT([$splsym])
        ])
 
-       SPL=${splsrc}
-       SPL_OBJ=${splobj}
-       SPL_VERSION=${splver}
+       AS_IF([test x$enable_zfs = xyes], [
+               SPL=${splsrc}
+               SPL_OBJ=${splobj}
+               SPL_VERSION=${splver}
+
+               AC_SUBST(SPL)
+               AC_SUBST(SPL_OBJ)
+               AC_SUBST(SPL_VERSION)
+               AC_SUBST(EXTRA_SYMBOLS)
+       ])
 
-       AC_SUBST(SPL)
-       AC_SUBST(SPL_OBJ)
-       AC_SUBST(SPL_VERSION)
-       AC_SUBST(EXTRA_SYMBOLS)
 ])
 
 AC_DEFUN([LB_ZFS], [
@@ -229,7 +232,7 @@ AC_DEFUN([LB_ZFS], [
        dnl #
        AC_MSG_CHECKING([zfs build directory])
        AS_IF([test -z "$zfsobj"], [
-               last_zfs_obj_dir=$(ls -d ${zfssrc}/[[0-9]]*/ | tail -n 1 | sed 's|/$||')
+               last_zfs_obj_dir=$(ls -d ${zfssrc}/[[0-9]]*/ 2> /dev/null | tail -n 1 | sed 's|/$||')
                AS_IF([test "${zfssrc}" = "${zfsdkms}/source"], [
                        AS_IF([test -e "${zfsdkms}/${LINUXRELEASE}/${target_cpu}/zfs_config.h"], [
                                zfsobj=${zfsdkms}/${LINUXRELEASE}/${target_cpu}
@@ -287,14 +290,17 @@ AC_DEFUN([LB_ZFS], [
                AC_MSG_RESULT([$zfssym])
        ])
 
-       ZFS=${zfssrc}
-       ZFS_OBJ=${zfsobj}
-       ZFS_VERSION=${zfsver}
+       AS_IF([test x$enable_zfs = xyes], [
+               ZFS=${zfssrc}
+               ZFS_OBJ=${zfsobj}
+               ZFS_VERSION=${zfsver}
+
+               AC_SUBST(ZFS)
+               AC_SUBST(ZFS_OBJ)
+               AC_SUBST(ZFS_VERSION)
+               AC_SUBST(EXTRA_SYMBOLS)
+       ])
 
-       AC_SUBST(ZFS)
-       AC_SUBST(ZFS_OBJ)
-       AC_SUBST(ZFS_VERSION)
-       AC_SUBST(EXTRA_SYMBOLS)
 ])
 
 AC_DEFUN([LB_ZFS_DEVEL], [
@@ -322,8 +328,8 @@ AC_DEFUN([LB_ZFS_USER], [
        AC_MSG_CHECKING([zfs devel headers])
        AS_IF([test -z "${zfsinc}"], [
                AS_IF([test -e "${zfssrc}/include/libzfs.h" && test -e "${zfssrc}/lib/libspl/include"], [
-                       zfsinc="-I $zfssrc/lib/libspl/include -I $zfssrc/include"
-                       zfslib="-L$zfssrc/lib/libzfs/.libs/ -L$zfssrc/lib/libnvpair/.libs"
+                       zfsinc="-I $zfssrc/lib/libspl/include -I $zfssrc/lib/libspl/include/os/linux -I $zfssrc/include"
+                       zfslib="-L$zfssrc/lib/libzfs/.libs/ -L$zfssrc/lib/libnvpair/.libs/ -L$zfssrc/lib/libzpool/.libs/"
                ], [test -d /usr/include/libzfs && test -d /usr/include/libspl], [
                        zfsinc="-I/usr/include/libspl -I /usr/include/libzfs"
                        zfslib=""
@@ -337,7 +343,7 @@ AC_DEFUN([LB_ZFS_USER], [
 
        ZFS_LIBZFS_INCLUDE=${zfsinc}
        ZFS_LIBZFS_LDFLAGS=${zfslib}
-       ZFS_LIBZFS_LIBS="-lzfs -lnvpair"
+       ZFS_LIBZFS_LIBS="-lzfs -lnvpair -lzpool"
        AC_SUBST(ZFS_LIBZFS_INCLUDE)
        AC_SUBST(ZFS_LIBZFS_LDFLAGS)
        AC_SUBST(ZFS_LIBZFS_LIBS)
@@ -348,21 +354,26 @@ AC_DEFUN([LB_CONFIG_ZFS], [
                [AS_HELP_STRING([--with-zfs=PATH], [Path to zfs source])],
                [
                        AS_IF([test x$withval = xno], [
+                               enable_spl=no
                                enable_zfs=no
                                require_zfs=no
                        ], [test x$withval = xyes], [
+                               enable_spl=yes
                                enable_zfs=yes
                                require_zfs=yes
                        ], [
+                               enable_spl=yes
                                enable_zfs=yes
                                require_zfs=yes
                                zfssrc="$withval"
                        ])
                ], [
                        AS_IF([test x$enable_server != xno], [
+                               enable_spl=yes
                                require_zfs=no
                                enable_zfs=yes
                        ], [
+                               enable_spl=no
                                require_zfs=no
                                enable_zfs=no
                        ])
@@ -373,13 +384,36 @@ AC_DEFUN([LB_CONFIG_ZFS], [
 
        AS_IF([test x$enable_zfs = xyes], [
                AS_IF([test x$enable_modules = xyes], [
-                       LB_SPL
                        LB_ZFS
                ])
                LB_ZFS_DEVEL
                LB_ZFS_USER
 
                dnl #
+               dnl # Define zfs source code version
+               dnl #
+               ZFS_MAJOR=$(echo $zfsver | sed -re ['s/([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?.*/\1/'])
+               ZFS_MINOR=$(echo $zfsver | sed -re ['s/([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?.*/\2/'])
+               ZFS_PATCH=$(echo $zfsver | sed -re ['s/([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?.*/\3/'])
+               ZFS_FIX=$(echo $zfsver   | sed -re ['s/([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?.*/\5/'])
+               AS_IF([test -z "$ZFS_FIX"], [ZFS_FIX="0"])
+
+               AC_DEFINE_UNQUOTED([ZFS_MAJOR], [$ZFS_MAJOR], [zfs major version])
+               AC_DEFINE_UNQUOTED([ZFS_MINOR], [$ZFS_MINOR], [zfs minor version])
+               AC_DEFINE_UNQUOTED([ZFS_PATCH], [$ZFS_PATCH], [zfs patch version])
+               AC_DEFINE_UNQUOTED([ZFS_FIX],   [$ZFS_FIX],   [zfs fix version])
+
+               dnl #
+               dnl # SPL is only needed if ZFS is prior to 0.8.0
+               dnl #
+               AS_IF([test x$enable_modules = xyes && test -n "$ZFS_MAJOR" &&
+                           test $ZFS_MAJOR -eq 0 && test $ZFS_MINOR -lt 8], [
+                       LB_SPL
+               ],[
+                       enable_spl=no
+               ])
+
+               dnl #
                dnl # enable_zfs will be set to no in LB_SPL or LB_ZFS if
                dnl # one of more of the build requirements is not met.
                dnl #
@@ -408,21 +442,6 @@ your distribution.
                ])
        ])
 
-       dnl #
-       dnl # Define zfs source code version
-       dnl #
-       AS_IF([test x$enable_zfs = xyes], [
-               ZFS_MAJOR=$(echo $zfsver | sed -re ['s/([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?.*/\1/'])
-               ZFS_MINOR=$(echo $zfsver | sed -re ['s/([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?.*/\2/'])
-               ZFS_PATCH=$(echo $zfsver | sed -re ['s/([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?.*/\3/'])
-               ZFS_FIX=$(echo $zfsver   | sed -re ['s/([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?.*/\5/'])
-               AS_IF([test -z "$ZFS_FIX"], [ZFS_FIX="0"])
-
-               AC_DEFINE_UNQUOTED([ZFS_MAJOR], [$ZFS_MAJOR], [zfs major version])
-               AC_DEFINE_UNQUOTED([ZFS_MINOR], [$ZFS_MINOR], [zfs minor version])
-               AC_DEFINE_UNQUOTED([ZFS_PATCH], [$ZFS_PATCH], [zfs patch version])
-               AC_DEFINE_UNQUOTED([ZFS_FIX],   [$ZFS_FIX],   [zfs fix version])
-       ])
 
        AS_IF([test "x$enable_zfs" = xyes], [
                LB_CHECK_COMPILE([if zfs defines dsl_pool_config_enter/exit],
@@ -533,6 +552,28 @@ your distribution.
                        AC_DEFINE(HAVE_DMU_USEROBJ_ACCOUNTING, 1,
                                [Have native dnode accounting in ZFS])
                ])
+               dnl #
+               dnl # ZFS 0.7.0 feature: MULTIHOST
+               dnl #
+               restore_CFLAGS=$CFLAGS
+               CFLAGS="$CFLAGS $ZFS_LIBZFS_INCLUDE -Werror"
+               AC_MSG_CHECKING([[if ZFS has multihost protection]])
+               AC_COMPILE_IFELSE([
+                 AC_LANG_PROGRAM(
+                 [[
+                   #define _LARGEFILE64_SOURCE 1
+                   #include <sys/sysmacros.h>
+                   #include <sys/spa.h>
+                 ]], [[
+                       spa_multihost(NULL);
+                 ]])
+                 ],[
+                 AC_DEFINE(HAVE_ZFS_MULTIHOST, 1,
+                       [Have multihost protection in ZFS])
+                 spa_multihost_fn="yes"],[spa_multihost_fn="no"]),
+               AC_MSG_RESULT([$spa_multihost_fn])
+               CFLAGS=$restore_CFLAGS
+               dnl #
                dnl # ZFS 0.7.x adds new method zap_lookup_by_dnode
                dnl #
                LB_CHECK_COMPILE([if ZFS has 'zap_lookup_by_dnode'],
@@ -631,33 +672,6 @@ your distribution.
                                [Have dmu_read_by_dnode() in ZFS])
                ])
                dnl #
-               dnl # ZFS 0.8.x changes dmu_objset_own for encryption
-               dnl #
-               LB_CHECK_COMPILE([if ZFS has 'dmu_objset_own' with 6 args],
-               dmu_objset_own, [
-                       #include <sys/dmu_objset.h>
-               ],[
-                       objset_t *os = NULL;
-                       dmu_objset_type_t type = DMU_OST_ANY;
-                       dmu_objset_own(NULL, type, B_FALSE, B_FALSE, FTAG, &os);
-               ],[
-                       AC_DEFINE(HAVE_DMU_OBJSET_OWN_6ARG, 1,
-                               [Have dmu_objset_own() with 6 args])
-               ])
-               dnl #
-               dnl # ZFS 0.8.x changes dmu_objset_disown for encryption
-               dnl #
-               LB_CHECK_COMPILE([if ZFS has 'dmu_objset_disown' with 3 args],
-               dmu_objset_disown, [
-                       #include <sys/dmu_objset.h>
-               ],[
-                       objset_t *os = NULL;
-                       dmu_objset_disown(os, B_FALSE, FTAG);
-               ],[
-                       AC_DEFINE(HAVE_DMU_OBJSET_DISOWN_3ARG, 1,
-                               [Have dmu_objset_disown() with 3 args])
-               ])
-               dnl #
                dnl # ZFS 0.7.2 adds new method dmu_tx_mark_netfree
                dnl #
                LB_CHECK_COMPILE([if ZFS has 'dmu_tx_mark_netfree'],
@@ -684,17 +698,75 @@ your distribution.
                                [Have inode_timespec_t])
                ])
                dnl # ZFS 0.7.12/0.8.x uses zfs_refcount_add() instead of
-               dnl # refcount_add().
+               dnl # refcount_add().  ZFS 2.0 renamed sys/refcount.h to
+               dnl # sys/zfs_refcount.h, rather the add another check to
+               dnl # determine the correct header name include it
+               dnl # indirectly through sys/dnode.h.
                dnl #
                LB_CHECK_COMPILE([if ZFS has 'zfs_refcount_add'],
                zfs_refcount_add, [
-                       #include <sys/refcount.h>
+                       #include <sys/dnode.h>
                ],[
                        zfs_refcount_add((zfs_refcount_t *) NULL, NULL);
                ],[
                        AC_DEFINE(HAVE_ZFS_REFCOUNT_ADD, 1,
                                [Have zfs_refcount_add])
                ])
+               dnl #
+               dnl # ZFS 0.8.x changes dmu_objset_own for encryption
+               dnl #
+               LB_CHECK_COMPILE([if ZFS has 'dmu_objset_own' with 6 args],
+               dmu_objset_own, [
+                       #include <sys/dmu_objset.h>
+               ],[
+                       objset_t *os = NULL;
+                       dmu_objset_type_t type = DMU_OST_ANY;
+                       dmu_objset_own(NULL, type, B_FALSE, B_TRUE, FTAG, &os);
+               ],[
+                       AC_DEFINE(HAVE_DMU_OBJSET_OWN_6ARG, 1,
+                               [Have dmu_objset_own() with 6 args])
+               ])
+               dnl #
+               dnl # ZFS 0.8.x changes dmu_objset_disown for encryption
+               dnl #
+               LB_CHECK_COMPILE([if ZFS has 'dmu_objset_disown' with 3 args],
+               dmu_objset_disown, [
+                       #include <sys/dmu_objset.h>
+               ],[
+                       objset_t *os = NULL;
+                       dmu_objset_disown(os, B_TRUE, FTAG);
+               ],[
+                       AC_DEFINE(HAVE_DMU_OBJSET_DISOWN_3ARG, 1,
+                               [Have dmu_objset_disown() with 3 args])
+               ])
+               dnl #
+               dnl # ZFS exports dmu_offet_next
+               dnl #
+               AC_CACHE_CHECK([if ZFS exports 'dmu_offset_next'],
+               [lb_cv_dmu_offset_next], [
+               lb_cv_dmu_offset_next="no"
+               AS_IF([grep -q -E "EXPORT_SYMBOL.*\(dmu_offset_next\)" "$zfssrc/module/zfs/dmu.c" 2>/dev/null],
+                       [lb_cv_dmu_offset_next="yes"])
+               ])
+               AS_IF([test "x$lb_cv_dmu_offset_next" = "xyes"], [
+                       AC_DEFINE(HAVE_DMU_OFFSET_NEXT, 1,
+                               [Have dmu_offset_next() exported])
+               ])
+               dnl #
+               dnl # ZFS 2.0 replaced .db_last_dirty / .dr_next with a list_t
+               dnl # and list_node_t named .db_dirty_records / .dr_dbuf_node.
+               dnl #
+               LB_CHECK_COMPILE([if ZFS has 'db_dirty_records' list_t],
+               db_dirty_records, [
+                       #include <sys/dbuf.h>
+               ],[
+                       dmu_buf_impl_t db;
+                       dbuf_dirty_record_t *dr;
+                       dr = list_head(&db.db_dirty_records);
+               ],[
+                       AC_DEFINE(HAVE_DB_DIRTY_RECORDS_LIST, 1,
+                               [Have db_dirty_records list_t])
+               ])
        ])
 
        AS_IF([test "x$enable_zfs" = xyes], [
@@ -703,4 +775,5 @@ your distribution.
                AC_SUBST(ENABLE_ZFS, no)
        ])
        AM_CONDITIONAL(ZFS_ENABLED, [test "x$enable_zfs" = xyes])
+       AM_CONDITIONAL(SPL_ENABLED, [test "x$enable_spl" = xyes])
 ])