Whamcloud - gitweb
LU-16824 ldiskfs: add support for openEuler 22.03 LTS SP1
[fs/lustre-release.git] / config / lustre-build-zfs.m4
index 873ad8a..cd95e75 100644 (file)
@@ -71,7 +71,8 @@ AC_DEFUN([LB_SPL], [
        dnl # The existence of spl.release[.in] is used to identify a valid
        dnl # source directory.  In order of preference:
        dnl #
-       splver=$(ls -1 /usr/src/ | grep -m1 spl | cut -f2 -d'-')
+       splver=$(ls -1 /usr/src/ | grep ^spl- | cut -f2 -d'-' |
+                sort -V | head -n1)
        spldkms="/var/lib/dkms/spl/${splver}"
        splsrc1="/usr/src/spl-${splver}/${LINUXRELEASE}"
        splsrc2="/usr/src/spl-${splver}"
@@ -192,7 +193,8 @@ AC_DEFUN([LB_ZFS], [
        dnl # The existence of zfs.release[.in] is used to identify a valid
        dnl # source directory.  In order of preference:
        dnl #
-       zfsver=$(ls -1 /usr/src/ | grep -m1 zfs | cut -f2 -d'-')
+       zfsver=$(ls -1 /usr/src/ | grep ^zfs- | cut -f2 -d'-' |
+                sort -V | head -n1)
        zfsdkms="/var/lib/dkms/zfs/${zfsver}"
        zfssrc1="/usr/src/zfs-${zfsver}/${LINUXRELEASE}"
        zfssrc2="/usr/src/zfs-${zfsver}"
@@ -328,8 +330,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/.libs/ -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=""
@@ -343,7 +345,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)
@@ -698,11 +700,14 @@ 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);
                ],[
@@ -749,6 +754,34 @@ your distribution.
                        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])
+               ])
+               dnl #
+               dnl # ZFS 2.0 renamed sys/refcount.h to zfs_refcount.h
+               dnl # This build issue shows up with ZFS 2.0.7 and Lustre 2.12 LTS
+               dnl #
+               LB_CHECK_COMPILE([if ZFS renamed sys/refcount to zfs_refcount.h],
+               zfs_zfs_refcount, [
+                       #include <sys/zfs_refcount.h>
+               ],[
+                       zfs_refcount_add((zfs_refcount_t *) NULL, NULL);
+               ],[
+                       AC_DEFINE(HAVE_ZFS_REFCOUNT_HEADER, 1,
+                               [Have zfs_refcount.h])
+               ])
        ])
 
        AS_IF([test "x$enable_zfs" = xyes], [