Whamcloud - gitweb
LU-17705 ptlrpc: replace synchronize_rcu() with rcu_barrier()
[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                 LB_CHECK_COMPILE([if zfs defines dsl_sync_task_do_nowait],
459                 dsl_sync_task_do_nowait, [
460                         #include <sys/dsl_synctask.h>
461                 ],[
462                         dsl_sync_task_do_nowait(NULL, NULL, NULL, NULL, NULL, 0, NULL);
463                 ],[
464                         AC_DEFINE(HAVE_DSL_SYNC_TASK_DO_NOWAIT, 1,
465                                 [Have dsl_sync_task_do_nowait in ZFS])
466                 ])
467                 LB_CHECK_COMPILE([if zfs defines sa_spill_alloc],
468                 sa_spill_alloc, [
469                         #include <sys/kmem.h>
470                         #include <sys/sa.h>
471                 ],[
472                         void *ptr;
473
474                         ptr = sa_spill_alloc(KM_SLEEP);
475                         sa_spill_free(ptr);
476                 ],[
477                         AC_DEFINE(HAVE_SA_SPILL_ALLOC, 1,
478                                 [Have sa_spill_alloc in ZFS])
479                 ])
480                 LB_CHECK_COMPILE([if zfs defines spa_maxblocksize],
481                 spa_maxblocksize, [
482                         #include <sys/spa.h>
483                 ],[
484                         spa_t *spa = NULL;
485                         int size;
486
487                         size = spa_maxblocksize(spa);
488                 ],[
489                         AC_DEFINE(HAVE_SPA_MAXBLOCKSIZE, 1,
490                                 [Have spa_maxblocksize in ZFS])
491                 ])
492
493                 dnl #
494                 dnl # ZFS 0.7.x adds support for large dnodes.  This
495                 dnl # allows Lustre to optionally specify the size of a
496                 dnl # dnode which ZFS will then use to store metadata such
497                 dnl # as xattrs. The default dnode size specified by the
498                 dnl # 'dnodesize' dataset property will be used unless a
499                 dnl # specific value is provided.
500                 dnl #
501                 LB_CHECK_COMPILE([if zfs defines dmu_object_alloc_dnsize],
502                 dmu_object_alloc_dnsize, [
503                         #include <sys/dmu.h>
504                         #include <sys/dnode.h>
505                 ],[
506                         objset_t *os = NULL;
507                         dmu_object_type_t objtype = DMU_OT_NONE;
508                         int blocksize = 0;
509                         dmu_object_type_t bonustype = DMU_OT_SA;
510                         int dnodesize = DNODE_MIN_SIZE;
511                         dmu_tx_t *tx = NULL;
512                         uint64_t id;
513
514                         id = dmu_object_alloc_dnsize(os, objtype, blocksize,
515                                                      bonustype,
516                                                      DN_BONUS_SIZE(dnodesize),
517                                                      dnodesize, tx);
518                 ],[
519                         AC_DEFINE(HAVE_DMU_OBJECT_ALLOC_DNSIZE, 1,
520                                 [Have dmu_object_alloc_dnsize in ZFS])
521                 ])
522
523                 dnl #
524                 dnl # ZFS 0.7.x extended dmu_prefetch() to take an additional
525                 dnl # 'level' and 'priority' argument.  Use a level of 0 and a
526                 dnl # priority of ZIO_PRIORITY_SYNC_READ to replicate the
527                 dnl # behavior of the four argument version.
528                 dnl #
529                 LB_CHECK_COMPILE([if ZFS has 'dmu_prefetch' with 6 args],
530                 dmu_prefetch, [
531                         #include <sys/dmu.h>
532                 ],[
533                         objset_t *os = NULL;
534                         uint64_t object = 0;
535                         int64_t level = 0;
536                         uint64_t offset = 0;
537                         uint64_t len = 0;
538                         enum zio_priority pri = ZIO_PRIORITY_SYNC_READ;
539
540                         dmu_prefetch(os, object, level, offset, len, pri);
541                 ],[
542                         AC_DEFINE(HAVE_DMU_PREFETCH_6ARG, 1,
543                                 [Have 6 argument dmu_pretch in ZFS])
544                 ])
545                 dnl #
546                 dnl # ZFS 0.7.0 feature: SPA_FEATURE_USEROBJ_ACCOUNTING
547                 dnl #
548                 LB_CHECK_COMPILE([if ZFS has native dnode accounting supported],
549                 dmu_objset_userobjused_enabled, [
550                         #include <sys/dmu_objset.h>
551                 ],[
552                         dmu_objset_userobjused_enabled(NULL);
553                 ],[
554                         AC_DEFINE(HAVE_DMU_USEROBJ_ACCOUNTING, 1,
555                                 [Have native dnode accounting in ZFS])
556                 ])
557                 dnl #
558                 dnl # ZFS 0.7.0 feature: MULTIHOST
559                 dnl #
560                 restore_CFLAGS=$CFLAGS
561                 CFLAGS="$CFLAGS $ZFS_LIBZFS_INCLUDE -Werror"
562                 AC_MSG_CHECKING([[if ZFS has multihost protection]])
563                 AC_COMPILE_IFELSE([
564                   AC_LANG_PROGRAM(
565                   [[
566                     #define _LARGEFILE64_SOURCE 1
567                     #include <sys/sysmacros.h>
568                     #include <sys/spa.h>
569                   ]], [[
570                         spa_multihost(NULL);
571                   ]])
572                   ],[
573                   AC_DEFINE(HAVE_ZFS_MULTIHOST, 1,
574                         [Have multihost protection in ZFS])
575                   spa_multihost_fn="yes"],[spa_multihost_fn="no"]),
576                 AC_MSG_RESULT([$spa_multihost_fn])
577                 CFLAGS=$restore_CFLAGS
578                 dnl #
579                 dnl # ZFS 0.7.x adds new method zap_lookup_by_dnode
580                 dnl #
581                 LB_CHECK_COMPILE([if ZFS has 'zap_lookup_by_dnode'],
582                 zap_lookup_by_dnode, [
583                         #include <sys/zap.h>
584                         #include <sys/dnode.h>
585                 ],[
586                         dnode_t *dn = NULL;
587                         zap_lookup_by_dnode(dn, NULL, 1, 1, NULL);
588                 ],[
589                         AC_DEFINE(HAVE_ZAP_LOOKUP_BY_DNODE, 1,
590                                 [Have zap_lookup_by_dnode() in ZFS])
591                 ])
592                 dnl #
593                 dnl # ZFS 0.7.x adds new method zap_add_by_dnode
594                 dnl #
595                 LB_CHECK_COMPILE([if ZFS has 'zap_add_by_dnode'],
596                 zap_add_by_dnode, [
597                         #include <sys/zap.h>
598                         #include <sys/dnode.h>
599                 ],[
600                         dnode_t *dn = NULL;
601                         zap_add_by_dnode(dn, NULL, 1, 1, NULL, NULL);
602                 ],[
603                         AC_DEFINE(HAVE_ZAP_ADD_BY_DNODE, 1,
604                                 [Have zap_add_by_dnode() in ZFS])
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                 dnl #
621                 dnl # ZFS 0.7.x adds new method dmu_tx_hold_zap_by_dnode
622                 dnl #
623                 LB_CHECK_COMPILE([if ZFS has 'dmu_tx_hold_zap_by_dnode'],
624                 dmu_tx_hold_zap_by_dnode, [
625                         #include <sys/zap.h>
626                         #include <sys/dnode.h>
627                 ],[
628                         dnode_t *dn = NULL;
629                         dmu_tx_hold_zap_by_dnode(NULL, dn, TRUE, NULL);
630                 ],[
631                         AC_DEFINE(HAVE_DMU_TX_HOLD_ZAP_BY_DNODE, 1,
632                                 [Have dmu_tx_hold_zap_by_dnode() in ZFS])
633                 ])
634                 dnl #
635                 dnl # ZFS 0.7.x adds new method dmu_tx_hold_write_by_dnode
636                 dnl #
637                 LB_CHECK_COMPILE([if ZFS has 'dmu_tx_hold_write_by_dnode'],
638                 dmu_tx_hold_write_by_dnode, [
639                         #include <sys/zap.h>
640                         #include <sys/dnode.h>
641                 ],[
642                         dnode_t *dn = NULL;
643                         dmu_tx_hold_write_by_dnode(NULL, dn, 0, 0);
644                 ],[
645                         AC_DEFINE(HAVE_DMU_TX_HOLD_WRITE_BY_DNODE, 1,
646                                 [Have dmu_tx_hold_write_by_dnode() in ZFS])
647                 ])
648                 dnl #
649                 dnl # ZFS 0.7.x adds new method dmu_write_by_dnode
650                 dnl #
651                 LB_CHECK_COMPILE([if ZFS has 'dmu_write_by_dnode'],
652                 dmu_write_by_dnode, [
653                         #include <sys/zap.h>
654                         #include <sys/dnode.h>
655                 ],[
656                         dnode_t *dn = NULL;
657                         dmu_write_by_dnode(dn, 0, 0, NULL, NULL);
658                 ],[
659                         AC_DEFINE(HAVE_DMU_WRITE_BY_DNODE, 1,
660                                 [Have dmu_write_by_dnode() in ZFS])
661                 ])
662                 dnl #
663                 dnl # ZFS 0.7.x adds new method dmu_read_by_dnode
664                 dnl #
665                 LB_CHECK_COMPILE([if ZFS has 'dmu_read_by_dnode'],
666                 dmu_read_by_dnode, [
667                         #include <sys/zap.h>
668                         #include <sys/dnode.h>
669                 ],[
670                         dnode_t *dn = NULL;
671                         dmu_read_by_dnode(dn, 0, 0, NULL, 0);
672                 ],[
673                         AC_DEFINE(HAVE_DMU_READ_BY_DNODE, 1,
674                                 [Have dmu_read_by_dnode() in ZFS])
675                 ])
676                 dnl #
677                 dnl # ZFS 0.7.2 adds new method dmu_tx_mark_netfree
678                 dnl #
679                 LB_CHECK_COMPILE([if ZFS has 'dmu_tx_mark_netfree'],
680                 dmu_tx_mark_netfree, [
681                         #include <sys/dmu.h>
682                 ],[
683                         dmu_tx_t *tx = NULL;
684                         dmu_tx_mark_netfree(tx);
685                 ],[
686                         AC_DEFINE(HAVE_DMU_TX_MARK_NETFREE, 1,
687                                 [Have dmu_tx_mark_netfree])
688                 ])
689                 dnl #
690                 dnl # ZFS 0.7.10 changes timestruc_t to inode_timespec_t
691                 dnl #
692                 LB_CHECK_COMPILE([if SPL has 'inode_timespec_t'],
693                 zfs_have_inode_timespec, [
694                         #include <sys/fs/zfs.h>
695                 ],[
696                         inode_timespec_t now;
697                         gethrestime(&now);
698                 ],[
699                         AC_DEFINE(HAVE_ZFS_INODE_TIMESPEC, 1,
700                                 [Have inode_timespec_t])
701                 ])
702                 dnl # ZFS 0.7.12/0.8.x uses zfs_refcount_add() instead of
703                 dnl # refcount_add().  ZFS 2.0 renamed sys/refcount.h to
704                 dnl # sys/zfs_refcount.h, rather the add another check to
705                 dnl # determine the correct header name include it
706                 dnl # indirectly through sys/dnode.h.
707                 dnl #
708                 LB_CHECK_COMPILE([if ZFS has 'zfs_refcount_add'],
709                 zfs_refcount_add, [
710                         #include <sys/dnode.h>
711                 ],[
712                         zfs_refcount_add((zfs_refcount_t *) NULL, NULL);
713                 ],[
714                         AC_DEFINE(HAVE_ZFS_REFCOUNT_ADD, 1,
715                                 [Have zfs_refcount_add])
716                 ])
717                 dnl #
718                 dnl # ZFS 0.8.x changes dmu_objset_own for encryption
719                 dnl #
720                 LB_CHECK_COMPILE([if ZFS has 'dmu_objset_own' with 6 args],
721                 dmu_objset_own, [
722                         #include <sys/dmu_objset.h>
723                 ],[
724                         objset_t *os = NULL;
725                         dmu_objset_type_t type = DMU_OST_ANY;
726                         dmu_objset_own(NULL, type, B_FALSE, B_TRUE, FTAG, &os);
727                 ],[
728                         AC_DEFINE(HAVE_DMU_OBJSET_OWN_6ARG, 1,
729                                 [Have dmu_objset_own() with 6 args])
730                 ])
731                 dnl #
732                 dnl # ZFS 0.8.x changes dmu_objset_disown for encryption
733                 dnl #
734                 LB_CHECK_COMPILE([if ZFS has 'dmu_objset_disown' with 3 args],
735                 dmu_objset_disown, [
736                         #include <sys/dmu_objset.h>
737                 ],[
738                         objset_t *os = NULL;
739                         dmu_objset_disown(os, B_TRUE, FTAG);
740                 ],[
741                         AC_DEFINE(HAVE_DMU_OBJSET_DISOWN_3ARG, 1,
742                                 [Have dmu_objset_disown() with 3 args])
743                 ])
744                 dnl #
745                 dnl # ZFS exports dmu_offet_next
746                 dnl #
747                 AC_CACHE_CHECK([if ZFS exports 'dmu_offset_next'],
748                 [lb_cv_dmu_offset_next], [
749                 lb_cv_dmu_offset_next="no"
750                 AS_IF([grep -q -E "EXPORT_SYMBOL.*\(dmu_offset_next\)" "$zfssrc/module/zfs/dmu.c" 2>/dev/null],
751                         [lb_cv_dmu_offset_next="yes"])
752                 ])
753                 AS_IF([test "x$lb_cv_dmu_offset_next" = "xyes"], [
754                         AC_DEFINE(HAVE_DMU_OFFSET_NEXT, 1,
755                                 [Have dmu_offset_next() exported])
756                 ])
757                 dnl #
758                 dnl # ZFS 2.0 replaced .db_last_dirty / .dr_next with a list_t
759                 dnl # and list_node_t named .db_dirty_records / .dr_dbuf_node.
760                 dnl #
761                 LB_CHECK_COMPILE([if ZFS has 'db_dirty_records' list_t],
762                 db_dirty_records, [
763                         #include <sys/dbuf.h>
764                 ],[
765                         dmu_buf_impl_t db;
766                         dbuf_dirty_record_t *dr;
767                         dr = list_head(&db.db_dirty_records);
768                 ],[
769                         AC_DEFINE(HAVE_DB_DIRTY_RECORDS_LIST, 1,
770                                 [Have db_dirty_records list_t])
771                 ])
772                 dnl #
773                 dnl # ZFS 2.0 renamed sys/refcount.h to zfs_refcount.h
774                 dnl # This build issue shows up with ZFS 2.0.7 and Lustre 2.12 LTS
775                 dnl #
776                 LB_CHECK_COMPILE([if ZFS renamed sys/refcount to zfs_refcount.h],
777                 zfs_zfs_refcount, [
778                         #include <sys/zfs_refcount.h>
779                 ],[
780                         zfs_refcount_add((zfs_refcount_t *) NULL, NULL);
781                 ],[
782                         AC_DEFINE(HAVE_ZFS_REFCOUNT_HEADER, 1,
783                                 [Have zfs_refcount.h])
784                 ])
785         ])
786
787         AS_IF([test "x$enable_zfs" = xyes], [
788                 AC_SUBST(ENABLE_ZFS, yes)
789         ], [
790                 AC_SUBST(ENABLE_ZFS, no)
791         ])
792         AM_CONDITIONAL(ZFS_ENABLED, [test "x$enable_zfs" = xyes])
793         AM_CONDITIONAL(SPL_ENABLED, [test "x$enable_spl" = xyes])
794 ])