Whamcloud - gitweb
LU-16356 hsm: add running ref to the coordinator
[fs/lustre-release.git] / config / lustre-build-zfs.m4
1 # SPDX-License-Identifier: NOASSERTION
2
3 #
4 # This file is part of Lustre, http://www.lustre.org/
5 #
6 # config/lustre-build-zfs.m4
7 #
8 # openZFS OSD related configuration
9 #
10
11 #
12 # Supported configure options.  When no options are specified support
13 # for ZFS OSDs will be autodetected assuming server support is enabled.
14 # If the ZFS OSD cannot be built support for it is disabled and a
15 # warning is issued but the configure process is allowed to continue.
16 #
17 # --without-zfs   - Disable zfs support.
18 # --with-zfs=no
19 #
20 # --with-zfs      - Enable zfs support and attempt to autodetect the zfs
21 # --with-zfs=yes    headers in one of the following places.  Because zfs
22 #                   support was explicitly required if the headers cannot
23 #                   be located it is treated as a fatal error.
24 #
25 #                       * /var/lib/dkms/zfs/${VERSION}/source
26 #                       * /usr/src/zfs-${VERSION}/${LINUXRELEASE}
27 #                       * /usr/src/zfs-${VERSION}
28 #                       * ../zfs/
29 #                       * $LINUX/zfs
30 #
31 # --with-zfs-devel=path
32 #                 - User provided directory where zfs development headers
33 #                   are located. This option is typically used when user
34 #                   uses rpm2cpio to unpack src rpm.
35 #                   Assumes layout of:
36 #                     ${zfs-devel-path}/usr/include/libzfs
37 #                     ${zfs-devel-path}/usr/include/libspl
38 #                     ${zfs-devel-path}/lib64/libzfs.so.* or
39 #                     ${zfs-devel-path}/lib/libzfs.so.*
40 #
41 # --with-zfs=path - Enable zfs support and use the zfs headers in the
42 #                   provided path.  No autodetection is performed and
43 #                   if no headers are found this is a fatal error.
44 #
45 # --with-zfs-obj  - When zfs support is enabled the object directory
46 #                   will be based on the --with-zfs directory.  If this
47 #                   is detected incorrectly it can be explicitly
48 #                   specified using this option.
49 #
50 # --without-spl   - Disable spl support.
51 # --with-spl=no
52 #
53 # --with-spl      - Enable spl support and attempt to autodetect the spl
54 # --with-spl=yes    headers in one of the following places in this order:
55 #                   * /var/lib/dkms/spl/${VERSION}/source
56 #                   * /usr/src/spl-${VERSION}/${LINUXRELEASE}
57 #                   * /usr/src/spl-${VERSION}
58 #                   * ../spl/
59 #                   * $LINUX/spl
60 #
61 # --with-spl=path - Enable spl support and use the spl headers in the
62 #                   provided path.  No autodetection is performed.
63 #
64 # --with-spl-obj  - When spl support is enabled the object directory
65 #                   will be based on the --with-spl directory.  If this
66 #                   is detected incorrectly it can be explicitly
67 #                   specified using this option.
68 #
69
70 #
71 # LB_SPL
72 #
73 AC_DEFUN([LB_SPL], [
74         AC_ARG_WITH([spl],
75                 AS_HELP_STRING([--with-spl=PATH],
76                 [Path to spl source]),
77                 [splsrc="$withval"])
78
79         AC_ARG_WITH([spl-obj],
80                 AS_HELP_STRING([--with-spl-obj=PATH],
81                 [Path to spl build objects]),
82                 [splobj="$withval"])
83
84         #
85         # The existence of spl.release[.in] is used to identify a valid
86         # source directory.  In order of preference:
87         #
88         splver=$(ls -1 /usr/src/ | grep ^spl- | cut -f2 -d'-' |
89                  sort -V | head -n1)
90         spldkms="/var/lib/dkms/spl/${splver}"
91         splsrc1="/usr/src/spl-${splver}/${LINUXRELEASE}"
92         splsrc2="/usr/src/spl-${splver}"
93         splsrc3="../spl/"
94         splsrc4="$LINUX/spl"
95
96         AC_MSG_CHECKING([spl source directory])
97         AS_IF([test -z "${splsrc}"], [
98                 AS_IF([test -e "${spldkms}/source/spl.release.in"], [
99                         splsrc=${spldkms}/source
100                 ], [test -e "${splsrc1}/spl.release.in"], [
101                         splsrc=${splsrc1}
102                 ], [test -e "${splsrc2}/spl.release.in"], [
103                         splsrc=${splsrc2}
104                 ], [test -e "${splsrc3}/spl.release.in"], [
105                         splsrc=$(readlink -f "${splsrc3}")
106                 ], [test -e "${splsrc4}/spl.release.in"], [
107                         splsrc=${splsrc4}
108                 ], [
109                         splsrc="[Not found]"
110                 ])
111         ])
112         AC_MSG_RESULT([$splsrc])
113
114         AS_IF([test ! -e "$splsrc/spl.release" &&
115             test ! -e "$splsrc/spl.release.in"], [
116                 enable_zfs=no
117         ])
118
119         #
120         # The existence of the spl_config.h is used to identify a valid
121         # spl object directory.  In many cases the object and source
122         # directory are the same, however the objects may also reside
123         # is a subdirectory named after the kernel version.  When
124         # weak modules are used, the kernel version may not be the
125         # same as the LINUXRELEASE against which we are building lustre.
126         #
127         AC_MSG_CHECKING([spl build directory])
128         AS_IF([test -z "$splobj"], [
129                 last_spl_obj_dir=$(ls -d ${splsrc}/[[0-9]]*/  2> /dev/null | tail -n 1 | sed 's|/$||')
130                 AS_IF([test "${splsrc}" = "${spldkms}/source"], [
131                         AS_IF([test -e "${spldkms}/${LINUXRELEASE}/${target_cpu}/spl_config.h"], [
132                                 splobj=${spldkms}/${LINUXRELEASE}/${target_cpu}
133                         ], [
134                                 splobj="[Not found]"
135                         ])
136                 ],[test -e "${splsrc}/${LINUXRELEASE}/spl_config.h"], [
137                         splobj="${splsrc}/${LINUXRELEASE}"
138                 ], [test -e "${splsrc}/spl_config.h"], [
139                         splobj="${splsrc}"
140                 ], [test -e "${last_spl_obj_dir}/spl_config.h"], [
141                         splobj="${last_spl_obj_dir}"
142                 ], [
143                         splobj="[Not found]"
144                 ])
145         ])
146         AC_MSG_RESULT([$splobj])
147
148         AS_IF([test ! -e "$splobj/spl_config.h"], [
149                 enable_zfs=no
150         ])
151
152         #
153         # Verify the source version using SPL_META_VERSION in spl_config.h
154         #
155         AS_IF([test x$enable_zfs = xyes], [
156                 AC_MSG_CHECKING([spl source version])
157                 AS_IF([fgrep -q SPL_META_VERSION $splobj/spl_config.h], [
158                         splver=$((echo "#include <spl_config.h>";
159                             echo "splver=SPL_META_VERSION-SPL_META_RELEASE") |
160                             cpp -I $splobj |
161                             grep "^splver=" | tr -d \" | cut -d= -f2)
162                 ], [
163                         splver="[Not found]"
164                         enable_zfs=no
165                 ])
166                 AC_MSG_RESULT([$splver])
167         ])
168
169         #
170         # Verify the modules systems exist by the expect name.
171         #
172         AS_IF([test x$enable_zfs = xyes], [
173                 AC_MSG_CHECKING([spl file name for module symbols])
174                 AS_IF([test -r $splobj/$SYMVERFILE], [
175                         splsym=$SYMVERFILE
176                         EXTRA_SYMBOLS="$EXTRA_SYMBOLS $splobj/$SYMVERFILE"
177                 ], [test -r $splobj/module/$SYMVERFILE], [
178                         splsym=$SYMVERFILE
179                         EXTRA_SYMBOLS="$EXTRA_SYMBOLS $splobj/module/$SYMVERFILE"
180                 ], [
181                         splsym="[Not found]"
182                         enable_zfs=no
183                 ])
184                 AC_MSG_RESULT([$splsym])
185         ])
186
187         AS_IF([test x$enable_zfs = xyes], [
188                 SPL=${splsrc}
189                 SPL_OBJ=${splobj}
190                 SPL_VERSION=${splver}
191
192                 AC_SUBST(SPL)
193                 AC_SUBST(SPL_OBJ)
194                 AC_SUBST(SPL_VERSION)
195                 AC_SUBST(EXTRA_SYMBOLS)
196         ])
197
198 ]) # LB_SPL
199
200 #
201 # LB_ZFS
202 #
203 AC_DEFUN([LB_ZFS], [
204         AC_ARG_WITH([zfs-obj],
205                 AS_HELP_STRING([--with-zfs-obj=PATH],
206                 [Path to zfs build objects]),
207                 [zfsobj="$withval"])
208
209         #
210         # The existence of zfs.release[.in] is used to identify a valid
211         # source directory.  In order of preference:
212         #
213         zfsver=$(ls -1 /usr/src/ | grep ^zfs- | cut -f2 -d'-' |
214                  sort -V | head -n1)
215         zfsdkms="/var/lib/dkms/zfs/${zfsver}"
216         zfssrc1="/usr/src/zfs-${zfsver}/${LINUXRELEASE}"
217         zfssrc2="/usr/src/zfs-${zfsver}"
218         zfssrc3="../zfs/"
219         zfssrc4="$LINUX/zfs"
220
221         AC_MSG_CHECKING([zfs source directory])
222         AS_IF([test -z "${zfssrc}"], [
223                 AS_IF([test -e "${zfsdkms}/source/zfs.release.in"], [
224                         zfssrc=${zfsdkms}/source
225                 ], [test -e "${zfssrc1}/zfs.release.in"], [
226                         zfssrc=${zfssrc1}
227                 ], [test -e "${zfssrc2}/zfs.release.in"], [
228                         zfssrc=${zfssrc2}
229                 ], [test -e "${zfssrc3}/zfs.release.in"], [
230                         zfssrc=$(readlink -f "${zfssrc3}")
231                 ], [test -e "${zfssrc4}/zfs.release.in"], [
232                         zfssrc=${zfssrc4}
233                 ], [
234                         zfssrc="[Not found]"
235                 ])
236         ])
237         AC_MSG_RESULT([$zfssrc])
238
239         AS_IF([test ! -e "$zfssrc/zfs.release.in" &&
240             test ! -e "$zfssrc/zfs.release"], [
241                 enable_zfs=no
242         ])
243
244         #
245         # The existence of the zfs_config.h is used to identify a valid
246         # zfs object directory.  In many cases the object and source
247         # directory are the same, however the objects may also reside
248         # is a subdirectory named after the kernel version.  When
249         # weak modules are used, the kernel version may not be the
250         # same as the LINUXRELEASE against which we are building lustre.
251         #
252         AC_MSG_CHECKING([zfs build directory])
253         AS_IF([test -z "$zfsobj"], [
254                 last_zfs_obj_dir=$(ls -d ${zfssrc}/[[0-9]]*/ 2> /dev/null | tail -n 1 | sed 's|/$||')
255                 AS_IF([test "${zfssrc}" = "${zfsdkms}/source"], [
256                         AS_IF([test -e "${zfsdkms}/${LINUXRELEASE}/${target_cpu}/zfs_config.h"], [
257                                 zfsobj=${zfsdkms}/${LINUXRELEASE}/${target_cpu}
258                         ], [
259                                 zfsobj="[Not found]"
260                         ])
261                 ], [test -e "${zfssrc}/${LINUXRELEASE}/zfs_config.h"], [
262                         zfsobj="${zfssrc}/${LINUXRELEASE}"
263                 ], [test -e "${zfssrc}/zfs_config.h"], [
264                         zfsobj="${zfssrc}"
265                 ], [test -e "${last_zfs_obj_dir}/zfs_config.h"], [
266                         zfsobj="${last_zfs_obj_dir}"
267                 ], [
268                         zfsobj="[Not found]"
269                 ])
270         ])
271
272         AC_MSG_RESULT([$zfsobj])
273         AS_IF([test ! -e "$zfsobj/zfs_config.h"], [
274                 enable_zfs=no
275         ])
276
277         #
278         # Verify the source version using SPL_META_VERSION in spl_config.h
279         #
280         AS_IF([test x$enable_zfs = xyes], [
281                 AC_MSG_CHECKING([zfs source version])
282                 AS_IF([fgrep -q ZFS_META_VERSION $zfsobj/zfs_config.h], [
283                         zfsver=$((echo "#include <zfs_config.h>";
284                             echo "zfsver=ZFS_META_VERSION-ZFS_META_RELEASE") |
285                             cpp -I $zfsobj |
286                             grep "^zfsver=" | tr -d \" | cut -d= -f2)
287                 ],[
288                         zfsver="[Not found]"
289                         enable_zfs=no
290                 ])
291                 AC_MSG_RESULT([$zfsver])
292         ])
293
294         #
295         # Verify the modules systems exist by the expect name.
296         #
297         AS_IF([test x$enable_zfs = xyes], [
298                 AC_MSG_CHECKING([zfs file name for module symbols])
299                 AS_IF([test -r $zfsobj/$SYMVERFILE], [
300                         zfssym=$SYMVERFILE
301                         EXTRA_SYMBOLS="$EXTRA_SYMBOLS $zfsobj/$SYMVERFILE"
302                 ], [test -r $zfsobj/module/$SYMVERFILE], [
303                         zfssym=$SYMVERFILE
304                         EXTRA_SYMBOLS="$EXTRA_SYMBOLS $zfsobj/module/$SYMVERFILE"
305                 ], [
306                         zfssym="[Not found]"
307                         enable_zfs=no
308                 ])
309                 AC_MSG_RESULT([$zfssym])
310         ])
311
312         AS_IF([test x$enable_zfs = xyes], [
313                 ZFS=${zfssrc}
314                 ZFS_OBJ=${zfsobj}
315                 ZFS_VERSION=${zfsver}
316
317                 AC_SUBST(ZFS)
318                 AC_SUBST(ZFS_OBJ)
319                 AC_SUBST(ZFS_VERSION)
320                 AC_SUBST(EXTRA_SYMBOLS)
321         ])
322
323 ]) # LB_ZFS
324
325 #
326 # LB_ZFS_DEVEL
327 #
328 AC_DEFUN([LB_ZFS_DEVEL], [
329         AC_ARG_WITH([zfs-devel],
330                 [AS_HELP_STRING([--with-zfs-devel=PATH],
331                 [Path to zfs development headers])],
332                 [zfsdevel="$withval"])
333
334         AC_MSG_CHECKING([user provided zfs devel headers])
335         AS_IF([test ! -z "${zfsdevel}"], [
336                 AS_IF([test -d "${zfsdevel}/usr/include/libspl" && test -d "${zfsdevel}/usr/include/libzfs"], [
337                         zfsinc="-I $zfsdevel/usr/include/libspl -I $zfsdevel/usr/include/libzfs"
338                         zfslib="-L$zfsdevel/usr/lib64 -L$zfsdevel/usr/lib -L$zfsdevel/lib64 -L$zfsdevel/lib"
339                 ], [
340                         AC_MSG_ERROR([Path to development headers directory does not exist])
341                 ])
342         ])
343         AC_MSG_RESULT([$zfsinc])
344 ]) # LB_ZFS_DEVEL
345
346 #
347 # LB_ZFS_USER
348 #
349 AC_DEFUN([LB_ZFS_USER], [
350         #
351         # Detect user space zfs development headers.
352         #
353         AC_MSG_CHECKING([zfs devel headers])
354         AS_IF([test -z "${zfsinc}"], [
355                 AS_IF([test -e "${zfssrc}/include/libzfs.h" && test -e "${zfssrc}/lib/libspl/include"], [
356                         zfsinc="-I $zfssrc/lib/libspl/include -I $zfssrc/lib/libspl/include/os/linux -I $zfssrc/include"
357                         zfslib="-L$zfssrc/.libs/ -L$zfssrc/lib/libzfs/.libs/ -L$zfssrc/lib/libnvpair/.libs/ -L$zfssrc/lib/libzpool/.libs/"
358                 ], [test -d /usr/include/libzfs && test -d /usr/include/libspl], [
359                         zfsinc="-I/usr/include/libspl -I /usr/include/libzfs"
360                         zfslib=""
361                 ], [
362                         zfsinc="[Not Found]"
363                         zfslib=""
364                         enable_zfs=no
365                 ])
366         ])
367         AC_MSG_RESULT([$zfsinc])
368
369         ZFS_LIBZFS_INCLUDE=${zfsinc}
370         ZFS_LIBZFS_LDFLAGS=${zfslib}
371         ZFS_LIBZFS_LIBS="-lzfs -lnvpair -lzpool"
372         AC_SUBST(ZFS_LIBZFS_INCLUDE)
373         AC_SUBST(ZFS_LIBZFS_LDFLAGS)
374         AC_SUBST(ZFS_LIBZFS_LIBS)
375 ]) # LB_ZFS_USER
376
377 #
378 # LB_CONFIG_ZFS
379 #
380 AC_DEFUN([LB_CONFIG_ZFS], [
381         AC_ARG_WITH([zfs],
382                 [AS_HELP_STRING([--with-zfs=PATH], [Path to zfs source])],
383                 [
384                         AS_IF([test x$withval = xno], [
385                                 enable_spl=no
386                                 enable_zfs=no
387                                 require_zfs=no
388                         ], [test x$withval = xyes], [
389                                 enable_spl=yes
390                                 enable_zfs=yes
391                                 require_zfs=yes
392                         ], [
393                                 enable_spl=yes
394                                 enable_zfs=yes
395                                 require_zfs=yes
396                                 zfssrc="$withval"
397                         ])
398                 ], [
399                         AS_IF([test x$enable_server != xno], [
400                                 enable_spl=yes
401                                 require_zfs=no
402                                 enable_zfs=yes
403                         ], [
404                                 enable_spl=no
405                                 require_zfs=no
406                                 enable_zfs=no
407                         ])
408                 ])
409
410         AC_MSG_CHECKING([whether to enable zfs])
411         AC_MSG_RESULT([$enable_zfs])
412
413         AS_IF([test x$enable_zfs = xyes], [
414                 AS_IF([test x$enable_modules = xyes], [
415                         LB_ZFS
416                 ])
417                 LB_ZFS_DEVEL
418                 LB_ZFS_USER
419
420                 #
421                 # Define zfs source code version
422                 #
423                 ZFS_MAJOR=$(echo $zfsver | sed -re ['s/([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?.*/\1/'])
424                 ZFS_MINOR=$(echo $zfsver | sed -re ['s/([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?.*/\2/'])
425                 ZFS_PATCH=$(echo $zfsver | sed -re ['s/([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?.*/\3/'])
426                 ZFS_FIX=$(echo $zfsver   | sed -re ['s/([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?.*/\5/'])
427                 AS_IF([test -z "$ZFS_FIX"], [ZFS_FIX="0"])
428
429                 AC_DEFINE_UNQUOTED([ZFS_MAJOR], [$ZFS_MAJOR], [zfs major version])
430                 AC_DEFINE_UNQUOTED([ZFS_MINOR], [$ZFS_MINOR], [zfs minor version])
431                 AC_DEFINE_UNQUOTED([ZFS_PATCH], [$ZFS_PATCH], [zfs patch version])
432                 AC_DEFINE_UNQUOTED([ZFS_FIX],   [$ZFS_FIX],   [zfs fix version])
433
434                 #
435                 # SPL is only needed if ZFS is prior to 0.8.0
436                 #
437                 AS_IF([test x$enable_modules = xyes && test -n "$ZFS_MAJOR" &&
438                             test $ZFS_MAJOR -eq 0 && test $ZFS_MINOR -lt 8], [
439                         LB_SPL
440                 ],[
441                         enable_spl=no
442                 ])
443
444                 #
445                 # enable_zfs will be set to no in LB_SPL or LB_ZFS if
446                 # one of more of the build requirements is not met.
447                 #
448                 AS_IF([test x$enable_zfs = xyes], [
449                         AC_DEFINE(HAVE_ZFS_OSD, 1, Enable zfs osd)
450                 ],[
451                         AS_IF([test x$require_zfs = xyes], [
452                                 AC_MSG_ERROR([
453
454 Required zfs osd cannot be built due to missing zfs development headers.
455
456 Support for zfs can be enabled by downloading the required packages for your
457 distribution.  See http://zfsonlinux.org/ to determine is zfs is supported by
458 your distribution.
459                                 ])
460                         ], [
461                                 AC_MSG_WARN([
462
463 Disabling optional zfs osd due to missing development headers.
464
465 Support for zfs can be enabled by downloading the required packages for your
466 distribution.  See http://zfsonlinux.org/ to determine is zfs is supported by
467 your distribution.
468                                 ])
469                         ])
470                 ])
471         ])
472
473
474         AS_IF([test "x$enable_zfs" = xyes], [
475                 LB_CHECK_COMPILE([if zfs defines dsl_pool_config_enter/exit],
476                 dsl_pool_config_enter, [
477                         #include <sys/dsl_pool.h>
478                 ],[
479                         dsl_pool_config_enter(NULL, FTAG);
480                 ],[
481                         AC_DEFINE(HAVE_DSL_POOL_CONFIG, 1,
482                                 [Have dsl_pool_config_enter/exit in ZFS])
483                 ],[
484                         AC_MSG_ERROR([dsl_pool_config_enter/exit do not exist])
485                 ])
486                 LB_CHECK_COMPILE([if zfs defines zio_buf_alloc/free],
487                 zio_buf_alloc, [
488                         #include <sys/zio.h>
489                 ],[
490                         void *ptr = zio_buf_alloc(1024);
491
492                         (void)ptr;
493                 ],[
494                         AC_DEFINE(HAVE_ZIO_BUF_ALLOC, 1,
495                                 [Have zio_buf_alloc/free in ZFS])
496                 ],[
497                         AC_MSG_ERROR([zio_buf_alloc/free do not exist])
498                 ])
499                 LB_CHECK_COMPILE([if zfs defines spa_maxblocksize],
500                 spa_maxblocksize, [
501                         #include <sys/spa.h>
502                 ],[
503                         spa_t *spa = NULL;
504                         int size = spa_maxblocksize(spa);
505
506                         (void)size;
507                 ],[
508                         AC_DEFINE(HAVE_SPA_MAXBLOCKSIZE, 1,
509                                 [Have spa_maxblocksize in ZFS])
510                 ],[
511                         AC_MSG_ERROR([spa_maxblocksize does not exist])
512                 ])
513
514                 #
515                 # ZFS 0.7.x adds support for large dnodes.  This
516                 # allows Lustre to optionally specify the size of a
517                 # dnode which ZFS will then use to store metadata such
518                 # as xattrs. The default dnode size specified by the
519                 # 'dnodesize' dataset property will be used unless a
520                 # specific value is provided.
521                 #
522                 LB_CHECK_COMPILE([if zfs defines dmu_object_alloc_dnsize],
523                 dmu_object_alloc_dnsize, [
524                         #include <sys/dmu.h>
525                         #include <sys/dnode.h>
526                 ],[
527                         objset_t *os = NULL;
528                         dmu_object_type_t objtype = DMU_OT_NONE;
529                         int blocksize = 0;
530                         dmu_object_type_t bonustype = DMU_OT_SA;
531                         int dnodesize = DNODE_MIN_SIZE;
532                         dmu_tx_t *tx = NULL;
533                         uint64_t id;
534
535                         id = dmu_object_alloc_dnsize(os, objtype, blocksize,
536                                                      bonustype,
537                                                      DN_BONUS_SIZE(dnodesize),
538                                                      dnodesize, tx);
539                 ],[
540                         AC_DEFINE(HAVE_DMU_OBJECT_ALLOC_DNSIZE, 1,
541                                 [Have dmu_object_alloc_dnsize in ZFS])
542                 ],[
543                         AC_MSG_ERROR([dmu_object_alloc_dnsize does not exist])
544                 ])
545
546                 #
547                 # ZFS 0.7.x extended dmu_prefetch() to take an additional
548                 # 'level' and 'priority' argument.  Use a level of 0 and a
549                 # priority of ZIO_PRIORITY_SYNC_READ to replicate the
550                 # behavior of the four argument version.
551                 #
552                 LB_CHECK_COMPILE([if ZFS has 'dmu_prefetch' with 6 args],
553                 dmu_prefetch, [
554                         #include <sys/dmu.h>
555                 ],[
556                         objset_t *os = NULL;
557                         uint64_t object = 0;
558                         int64_t level = 0;
559                         uint64_t offset = 0;
560                         uint64_t len = 0;
561                         enum zio_priority pri = ZIO_PRIORITY_SYNC_READ;
562
563                         dmu_prefetch(os, object, level, offset, len, pri);
564                 ],[
565                         AC_DEFINE(HAVE_DMU_PREFETCH_6ARG, 1,
566                                 [Have 6 argument dmu_pretch in ZFS])
567                 ],[
568                         AC_MSG_ERROR([6 argument dmu_pretch does not exist])
569                 ])
570                 #
571                 # ZFS 0.7.0 feature: SPA_FEATURE_USEROBJ_ACCOUNTING
572                 #
573                 LB_CHECK_COMPILE([if ZFS has native dnode accounting supported],
574                 dmu_objset_userobjused_enabled, [
575                         #include <sys/dmu_objset.h>
576                 ],[
577                         dmu_objset_userobjused_enabled(NULL);
578                 ],[
579                         AC_DEFINE(HAVE_DMU_USEROBJ_ACCOUNTING, 1,
580                                 [Have native dnode accounting in ZFS])
581                 ],[
582                         AC_MSG_ERROR([native dnode accounting does not exist])
583                 ])
584                 #
585                 # ZFS 0.7.0 feature: MULTIHOST
586                 #
587                 LB_CHECK_COMPILE([if ZFS has multihost protection],
588                 spa_multihost, [
589                         #include <sys/fs/zfs.h>
590                 ],[
591                         zpool_prop_t prop = ZPOOL_PROP_MULTIHOST;
592
593                         (void)prop;
594                 ],[
595                         AC_DEFINE(HAVE_ZFS_MULTIHOST, 1,
596                                 [Have multihost protection in ZFS])
597                 ],[
598                         AC_MSG_ERROR([multihost protection does not exist])
599                 ])
600                 #
601                 # ZFS 0.7.x adds new method zap_lookup_by_dnode
602                 #
603                 LB_CHECK_COMPILE([if ZFS has 'zap_lookup_by_dnode'],
604                 zap_lookup_by_dnode, [
605                         #include <sys/zap.h>
606                         #include <sys/dnode.h>
607                 ],[
608                         dnode_t *dn = NULL;
609                         zap_lookup_by_dnode(dn, NULL, 1, 1, NULL);
610                 ],[
611                         AC_DEFINE(HAVE_ZAP_LOOKUP_BY_DNODE, 1,
612                                 [Have zap_lookup_by_dnode() in ZFS])
613                 ],[
614                         AC_MSG_ERROR([zap_lookup_by_dnode does not exist])
615                 ])
616                 #
617                 # ZFS 0.7.x adds new method zap_add_by_dnode
618                 #
619                 LB_CHECK_COMPILE([if ZFS has 'zap_add_by_dnode'],
620                 zap_add_by_dnode, [
621                         #include <sys/zap.h>
622                         #include <sys/dnode.h>
623                 ],[
624                         dnode_t *dn = NULL;
625                         zap_add_by_dnode(dn, NULL, 1, 1, NULL, NULL);
626                 ],[
627                         AC_DEFINE(HAVE_ZAP_ADD_BY_DNODE, 1,
628                                 [Have zap_add_by_dnode() in ZFS])
629                 ],[
630                         AC_MSG_ERROR([zap_add_by_dnode does not exist])
631                 ])
632                 #
633                 # ZFS 0.7.x adds new method zap_remove_by_dnode
634                 #
635                 LB_CHECK_COMPILE([if ZFS has 'zap_remove_by_dnode'],
636                 zap_remove_by_dnode, [
637                         #include <sys/zap.h>
638                         #include <sys/dnode.h>
639                 ],[
640                         dnode_t *dn = NULL;
641                         zap_remove_by_dnode(dn, NULL, NULL);
642                 ],[
643                         AC_DEFINE(HAVE_ZAP_REMOVE_ADD_BY_DNODE, 1,
644                                 [Have zap_remove_by_dnode() in ZFS])
645                 ],[
646                         AC_MSG_ERROR([zap_remove_by_dnode does not exist])
647                 ])
648                 #
649                 # ZFS 0.7.x adds new method dmu_tx_hold_zap_by_dnode
650                 #
651                 LB_CHECK_COMPILE([if ZFS has 'dmu_tx_hold_zap_by_dnode'],
652                 dmu_tx_hold_zap_by_dnode, [
653                         #include <sys/zap.h>
654                         #include <sys/dnode.h>
655                 ],[
656                         dnode_t *dn = NULL;
657                         dmu_tx_hold_zap_by_dnode(NULL, dn, TRUE, NULL);
658                 ],[
659                         AC_DEFINE(HAVE_DMU_TX_HOLD_ZAP_BY_DNODE, 1,
660                                 [Have dmu_tx_hold_zap_by_dnode() in ZFS])
661                 ],[
662                         AC_MSG_ERROR([dmu_tx_hold_zap_by_dnode does not exist])
663                 ])
664                 #
665                 # ZFS 0.7.x adds new method dmu_tx_hold_write_by_dnode
666                 #
667                 LB_CHECK_COMPILE([if ZFS has 'dmu_tx_hold_write_by_dnode'],
668                 dmu_tx_hold_write_by_dnode, [
669                         #include <sys/zap.h>
670                         #include <sys/dnode.h>
671                 ],[
672                         dnode_t *dn = NULL;
673                         dmu_tx_hold_write_by_dnode(NULL, dn, 0, 0);
674                 ],[
675                         AC_DEFINE(HAVE_DMU_TX_HOLD_WRITE_BY_DNODE, 1,
676                                 [Have dmu_tx_hold_write_by_dnode() in ZFS])
677                 ],[
678                         AC_MSG_ERROR([dmu_tx_hold_write_by_dnode does not exist])
679                 ])
680                 #
681                 # ZFS 0.7.x adds new method dmu_write_by_dnode
682                 #
683                 LB_CHECK_COMPILE([if ZFS has 'dmu_write_by_dnode'],
684                 dmu_write_by_dnode, [
685                         #include <sys/zap.h>
686                         #include <sys/dnode.h>
687                 ],[
688                         dnode_t *dn = NULL;
689                         dmu_write_by_dnode(dn, 0, 0, NULL, NULL);
690                 ],[
691                         AC_DEFINE(HAVE_DMU_WRITE_BY_DNODE, 1,
692                                 [Have dmu_write_by_dnode() in ZFS])
693                 ],[
694                         AC_MSG_ERROR([dmu_write_by_dnode does not exist])
695                 ])
696                 #
697                 # ZFS 0.7.x adds new method dmu_read_by_dnode
698                 #
699                 LB_CHECK_COMPILE([if ZFS has 'dmu_read_by_dnode'],
700                 dmu_read_by_dnode, [
701                         #include <sys/zap.h>
702                         #include <sys/dnode.h>
703                 ],[
704                         dnode_t *dn = NULL;
705                         dmu_read_by_dnode(dn, 0, 0, NULL, 0);
706                 ],[
707                         AC_DEFINE(HAVE_DMU_READ_BY_DNODE, 1,
708                                 [Have dmu_read_by_dnode() in ZFS])
709                 ],[
710                         AC_MSG_ERROR([dmu_read_by_dnode does not exist])
711                 ])
712                 #
713                 # ZFS 0.7.2 adds new method dmu_tx_mark_netfree
714                 #
715                 LB_CHECK_COMPILE([if ZFS has 'dmu_tx_mark_netfree'],
716                 dmu_tx_mark_netfree, [
717                         #include <sys/dmu.h>
718                 ],[
719                         dmu_tx_t *tx = NULL;
720                         dmu_tx_mark_netfree(tx);
721                 ],[
722                         AC_DEFINE(HAVE_DMU_TX_MARK_NETFREE, 1,
723                                 [Have dmu_tx_mark_netfree])
724                 ])
725                 #
726                 # ZFS 0.7.10 changes timestruc_t to inode_timespec_t
727                 #
728                 LB_CHECK_COMPILE([if SPL has 'inode_timespec_t'],
729                 zfs_have_inode_timespec, [
730                         #include <sys/fs/zfs.h>
731                 ],[
732                         inode_timespec_t now;
733                         gethrestime(&now);
734                 ],[
735                         AC_DEFINE(HAVE_ZFS_INODE_TIMESPEC, 1,
736                                 [Have inode_timespec_t])
737                 ])
738                 # ZFS 0.7.12/0.8.x uses zfs_refcount_add() instead of
739                 # refcount_add().  ZFS 2.0 renamed sys/refcount.h to
740                 # sys/zfs_refcount.h, rather the add another check to
741                 # determine the correct header name include it
742                 # indirectly through sys/dnode.h.
743                 #
744                 LB_CHECK_COMPILE([if ZFS has 'zfs_refcount_add'],
745                 zfs_refcount_add, [
746                         #include <sys/dnode.h>
747                 ],[
748                         zfs_refcount_add((zfs_refcount_t *) NULL, NULL);
749                 ],[
750                         AC_DEFINE(HAVE_ZFS_REFCOUNT_ADD, 1,
751                                 [Have zfs_refcount_add])
752                 ])
753                 #
754                 # ZFS 0.8.x changes dmu_objset_own for encryption
755                 #
756                 LB_CHECK_COMPILE([if ZFS has 'dmu_objset_own' with 6 args],
757                 dmu_objset_own, [
758                         #include <sys/dmu_objset.h>
759                 ],[
760                         objset_t *os = NULL;
761                         dmu_objset_type_t type = DMU_OST_ANY;
762                         dmu_objset_own(NULL, type, B_FALSE, B_TRUE, FTAG, &os);
763                 ],[
764                         AC_DEFINE(HAVE_DMU_OBJSET_OWN_6ARG, 1,
765                                 [Have dmu_objset_own() with 6 args])
766                 ])
767                 #
768                 # ZFS 0.8.x changes dmu_objset_disown for encryption
769                 #
770                 LB_CHECK_COMPILE([if ZFS has 'dmu_objset_disown' with 3 args],
771                 dmu_objset_disown, [
772                         #include <sys/dmu_objset.h>
773                 ],[
774                         objset_t *os = NULL;
775                         dmu_objset_disown(os, B_TRUE, FTAG);
776                 ],[
777                         AC_DEFINE(HAVE_DMU_OBJSET_DISOWN_3ARG, 1,
778                                 [Have dmu_objset_disown() with 3 args])
779                 ])
780                 #
781                 # ZFS exports dmu_offet_next
782                 #
783                 AC_CACHE_CHECK([if ZFS exports 'dmu_offset_next'],
784                 [lb_cv_dmu_offset_next], [
785                 lb_cv_dmu_offset_next="no"
786                 AS_IF([grep -q -E "EXPORT_SYMBOL.*\(dmu_offset_next\)" "$zfssrc/module/zfs/dmu.c" 2>/dev/null],
787                         [lb_cv_dmu_offset_next="yes"])
788                 ])
789                 AS_IF([test "x$lb_cv_dmu_offset_next" = "xyes"], [
790                         AC_DEFINE(HAVE_DMU_OFFSET_NEXT, 1,
791                                 [Have dmu_offset_next() exported])
792                 ])
793                 #
794                 # ZFS 2.0 replaced .db_last_dirty / .dr_next with a list_t
795                 # and list_node_t named .db_dirty_records / .dr_dbuf_node.
796                 #
797                 LB_CHECK_COMPILE([if ZFS has 'db_dirty_records' list_t],
798                 db_dirty_records, [
799                         #include <sys/dbuf.h>
800                 ],[
801                         dmu_buf_impl_t db;
802                         dbuf_dirty_record_t *dr;
803                         dr = list_head(&db.db_dirty_records);
804                 ],[
805                         AC_DEFINE(HAVE_DB_DIRTY_RECORDS_LIST, 1,
806                                 [Have db_dirty_records list_t])
807                 ])
808                 #
809                 # ZFS 2.0 renamed sys/refcount.h to zfs_refcount.h
810                 # This build issue shows up with ZFS 2.0.7 and Lustre 2.12 LTS
811                 #
812                 LB_CHECK_COMPILE([if ZFS renamed sys/refcount to zfs_refcount.h],
813                 zfs_zfs_refcount, [
814                         #include <sys/zfs_refcount.h>
815                 ],[
816                         zfs_refcount_add((zfs_refcount_t *) NULL, NULL);
817                 ],[
818                         AC_DEFINE(HAVE_ZFS_REFCOUNT_HEADER, 1,
819                                 [Have zfs_refcount.h])
820                 ])
821         ])
822
823         AS_IF([test "x$enable_zfs" = xyes], [
824                 AC_SUBST(ENABLE_ZFS, yes)
825         ], [
826                 AC_SUBST(ENABLE_ZFS, no)
827         ])
828         AM_CONDITIONAL(ZFS_ENABLED, [test "x$enable_zfs" = xyes])
829         AM_CONDITIONAL(SPL_ENABLED, [test "x$enable_spl" = xyes])
830 ]) # LB_CONFIG_ZFS