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