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