Tag 2.2.0-rc4
[zfs.git] / config / kernel.m4
blob1487fa2e7793873402be5a69bd8856dd117cca42
1 dnl #
2 dnl # Default ZFS kernel configuration
3 dnl #
4 AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
5         AM_COND_IF([BUILD_LINUX], [
6                 dnl # Setup the kernel build environment.
7                 ZFS_AC_KERNEL
8                 ZFS_AC_QAT
10                 dnl # Sanity checks for module building and CONFIG_* defines
11                 ZFS_AC_KERNEL_CONFIG_DEFINED
12                 ZFS_AC_MODULE_SYMVERS
14                 dnl # Sequential ZFS_LINUX_TRY_COMPILE tests
15                 ZFS_AC_KERNEL_FPU_HEADER
16                 ZFS_AC_KERNEL_OBJTOOL_HEADER
17                 ZFS_AC_KERNEL_WAIT_QUEUE_ENTRY_T
18                 ZFS_AC_KERNEL_MISC_MINOR
19                 ZFS_AC_KERNEL_DECLARE_EVENT_CLASS
21                 dnl # Parallel ZFS_LINUX_TEST_SRC / ZFS_LINUX_TEST_RESULT tests
22                 ZFS_AC_KERNEL_TEST_SRC
23                 ZFS_AC_KERNEL_TEST_RESULT
25                 AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
26                         KERNEL_MAKE="$KERNEL_MAKE O=$LINUX_OBJ"
27                 ])
29                 AC_SUBST(KERNEL_MAKE)
30         ])
33 dnl #
34 dnl # Generate and compile all of the kernel API test cases to determine
35 dnl # which interfaces are available.  By invoking the kernel build system
36 dnl # only once the compilation can be done in parallel significantly
37 dnl # speeding up the process.
38 dnl #
39 AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
40         ZFS_AC_KERNEL_SRC_OBJTOOL
41         ZFS_AC_KERNEL_SRC_GLOBAL_PAGE_STATE
42         ZFS_AC_KERNEL_SRC_ACCESS_OK_TYPE
43         ZFS_AC_KERNEL_SRC_PDE_DATA
44         ZFS_AC_KERNEL_SRC_FALLOCATE
45         ZFS_AC_KERNEL_SRC_FADVISE
46         ZFS_AC_KERNEL_SRC_GENERIC_FADVISE
47         ZFS_AC_KERNEL_SRC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
48         ZFS_AC_KERNEL_SRC_RWSEM
49         ZFS_AC_KERNEL_SRC_SCHED
50         ZFS_AC_KERNEL_SRC_USLEEP_RANGE
51         ZFS_AC_KERNEL_SRC_KMEM_CACHE
52         ZFS_AC_KERNEL_SRC_KVMALLOC
53         ZFS_AC_KERNEL_SRC_VMALLOC_PAGE_KERNEL
54         ZFS_AC_KERNEL_SRC_WAIT
55         ZFS_AC_KERNEL_SRC_INODE_TIMES
56         ZFS_AC_KERNEL_SRC_INODE_LOCK
57         ZFS_AC_KERNEL_SRC_GROUP_INFO_GID
58         ZFS_AC_KERNEL_SRC_RW
59         ZFS_AC_KERNEL_SRC_TIMER_SETUP
60         ZFS_AC_KERNEL_SRC_SUPER_USER_NS
61         ZFS_AC_KERNEL_SRC_PROC_OPERATIONS
62         ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS
63         ZFS_AC_KERNEL_SRC_BIO
64         ZFS_AC_KERNEL_SRC_BLKDEV
65         ZFS_AC_KERNEL_SRC_BLK_QUEUE
66         ZFS_AC_KERNEL_SRC_GENHD_FLAGS
67         ZFS_AC_KERNEL_SRC_REVALIDATE_DISK
68         ZFS_AC_KERNEL_SRC_GET_DISK_RO
69         ZFS_AC_KERNEL_SRC_GENERIC_READLINK_GLOBAL
70         ZFS_AC_KERNEL_SRC_DISCARD_GRANULARITY
71         ZFS_AC_KERNEL_SRC_INODE_OWNER_OR_CAPABLE
72         ZFS_AC_KERNEL_SRC_XATTR
73         ZFS_AC_KERNEL_SRC_ACL
74         ZFS_AC_KERNEL_SRC_INODE_SETATTR
75         ZFS_AC_KERNEL_SRC_INODE_GETATTR
76         ZFS_AC_KERNEL_SRC_INODE_SET_FLAGS
77         ZFS_AC_KERNEL_SRC_INODE_SET_IVERSION
78         ZFS_AC_KERNEL_SRC_SHOW_OPTIONS
79         ZFS_AC_KERNEL_SRC_FILE_INODE
80         ZFS_AC_KERNEL_SRC_FILE_DENTRY
81         ZFS_AC_KERNEL_SRC_FSYNC
82         ZFS_AC_KERNEL_SRC_AIO_FSYNC
83         ZFS_AC_KERNEL_SRC_EVICT_INODE
84         ZFS_AC_KERNEL_SRC_DIRTY_INODE
85         ZFS_AC_KERNEL_SRC_SHRINKER
86         ZFS_AC_KERNEL_SRC_MKDIR
87         ZFS_AC_KERNEL_SRC_LOOKUP_FLAGS
88         ZFS_AC_KERNEL_SRC_CREATE
89         ZFS_AC_KERNEL_SRC_PERMISSION
90         ZFS_AC_KERNEL_SRC_GET_LINK
91         ZFS_AC_KERNEL_SRC_PUT_LINK
92         ZFS_AC_KERNEL_SRC_TMPFILE
93         ZFS_AC_KERNEL_SRC_AUTOMOUNT
94         ZFS_AC_KERNEL_SRC_ENCODE_FH_WITH_INODE
95         ZFS_AC_KERNEL_SRC_COMMIT_METADATA
96         ZFS_AC_KERNEL_SRC_CLEAR_INODE
97         ZFS_AC_KERNEL_SRC_SETATTR_PREPARE
98         ZFS_AC_KERNEL_SRC_INSERT_INODE_LOCKED
99         ZFS_AC_KERNEL_SRC_DENTRY
100         ZFS_AC_KERNEL_SRC_DENTRY_ALIAS_D_U
101         ZFS_AC_KERNEL_SRC_TRUNCATE_SETSIZE
102         ZFS_AC_KERNEL_SRC_SECURITY_INODE
103         ZFS_AC_KERNEL_SRC_FST_MOUNT
104         ZFS_AC_KERNEL_SRC_BDI
105         ZFS_AC_KERNEL_SRC_SET_NLINK
106         ZFS_AC_KERNEL_SRC_SGET
107         ZFS_AC_KERNEL_SRC_LSEEK_EXECUTE
108         ZFS_AC_KERNEL_SRC_VFS_FILEMAP_DIRTY_FOLIO
109         ZFS_AC_KERNEL_SRC_VFS_READ_FOLIO
110         ZFS_AC_KERNEL_SRC_VFS_GETATTR
111         ZFS_AC_KERNEL_SRC_VFS_FSYNC_2ARGS
112         ZFS_AC_KERNEL_SRC_VFS_ITERATE
113         ZFS_AC_KERNEL_SRC_VFS_DIRECT_IO
114         ZFS_AC_KERNEL_SRC_VFS_READPAGES
115         ZFS_AC_KERNEL_SRC_VFS_SET_PAGE_DIRTY_NOBUFFERS
116         ZFS_AC_KERNEL_SRC_VFS_RW_ITERATE
117         ZFS_AC_KERNEL_SRC_VFS_GENERIC_WRITE_CHECKS
118         ZFS_AC_KERNEL_SRC_VFS_IOV_ITER
119         ZFS_AC_KERNEL_SRC_VFS_COPY_FILE_RANGE
120         ZFS_AC_KERNEL_SRC_VFS_GENERIC_COPY_FILE_RANGE
121         ZFS_AC_KERNEL_SRC_VFS_REMAP_FILE_RANGE
122         ZFS_AC_KERNEL_SRC_VFS_CLONE_FILE_RANGE
123         ZFS_AC_KERNEL_SRC_VFS_DEDUPE_FILE_RANGE
124         ZFS_AC_KERNEL_SRC_VFS_FILE_OPERATIONS_EXTEND
125         ZFS_AC_KERNEL_SRC_KMAP_ATOMIC_ARGS
126         ZFS_AC_KERNEL_SRC_FOLLOW_DOWN_ONE
127         ZFS_AC_KERNEL_SRC_MAKE_REQUEST_FN
128         ZFS_AC_KERNEL_SRC_GENERIC_IO_ACCT
129         ZFS_AC_KERNEL_SRC_FPU
130         ZFS_AC_KERNEL_SRC_FMODE_T
131         ZFS_AC_KERNEL_SRC_KUIDGID_T
132         ZFS_AC_KERNEL_SRC_KUID_HELPERS
133         ZFS_AC_KERNEL_SRC_RENAME
134         ZFS_AC_KERNEL_SRC_CURRENT_TIME
135         ZFS_AC_KERNEL_SRC_USERNS_CAPABILITIES
136         ZFS_AC_KERNEL_SRC_IN_COMPAT_SYSCALL
137         ZFS_AC_KERNEL_SRC_KTIME
138         ZFS_AC_KERNEL_SRC_TOTALRAM_PAGES_FUNC
139         ZFS_AC_KERNEL_SRC_TOTALHIGH_PAGES
140         ZFS_AC_KERNEL_SRC_KSTRTOUL
141         ZFS_AC_KERNEL_SRC_PERCPU
142         ZFS_AC_KERNEL_SRC_CPU_HOTPLUG
143         ZFS_AC_KERNEL_SRC_GENERIC_FILLATTR
144         ZFS_AC_KERNEL_SRC_MKNOD
145         ZFS_AC_KERNEL_SRC_SYMLINK
146         ZFS_AC_KERNEL_SRC_BIO_MAX_SEGS
147         ZFS_AC_KERNEL_SRC_SIGNAL_STOP
148         ZFS_AC_KERNEL_SRC_SIGINFO
149         ZFS_AC_KERNEL_SRC_SYSFS
150         ZFS_AC_KERNEL_SRC_SET_SPECIAL_STATE
151         ZFS_AC_KERNEL_SRC_STANDALONE_LINUX_STDARG
152         ZFS_AC_KERNEL_SRC_PAGEMAP_FOLIO_WAIT_BIT
153         ZFS_AC_KERNEL_SRC_ADD_DISK
154         ZFS_AC_KERNEL_SRC_KTHREAD
155         ZFS_AC_KERNEL_SRC_ZERO_PAGE
156         ZFS_AC_KERNEL_SRC___COPY_FROM_USER_INATOMIC
157         ZFS_AC_KERNEL_SRC_USER_NS_COMMON_INUM
158         ZFS_AC_KERNEL_SRC_IDMAP_MNT_API
159         ZFS_AC_KERNEL_SRC_IATTR_VFSID
160         ZFS_AC_KERNEL_SRC_FILEMAP
161         ZFS_AC_KERNEL_SRC_WRITEPAGE_T
162         ZFS_AC_KERNEL_SRC_RECLAIMED
163         case "$host_cpu" in
164                 powerpc*)
165                         ZFS_AC_KERNEL_SRC_CPU_HAS_FEATURE
166                         ZFS_AC_KERNEL_SRC_FLUSH_DCACHE_PAGE
167                         ;;
168         esac
170         AC_MSG_CHECKING([for available kernel interfaces])
171         ZFS_LINUX_TEST_COMPILE_ALL([kabi])
172         AC_MSG_RESULT([done])
175 dnl #
176 dnl # Check results of kernel interface tests.
177 dnl #
178 AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
179         ZFS_AC_KERNEL_ACCESS_OK_TYPE
180         ZFS_AC_KERNEL_GLOBAL_PAGE_STATE
181         ZFS_AC_KERNEL_OBJTOOL
182         ZFS_AC_KERNEL_PDE_DATA
183         ZFS_AC_KERNEL_FALLOCATE
184         ZFS_AC_KERNEL_FADVISE
185         ZFS_AC_KERNEL_GENERIC_FADVISE
186         ZFS_AC_KERNEL_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
187         ZFS_AC_KERNEL_RWSEM
188         ZFS_AC_KERNEL_SCHED
189         ZFS_AC_KERNEL_USLEEP_RANGE
190         ZFS_AC_KERNEL_KMEM_CACHE
191         ZFS_AC_KERNEL_KVMALLOC
192         ZFS_AC_KERNEL_VMALLOC_PAGE_KERNEL
193         ZFS_AC_KERNEL_WAIT
194         ZFS_AC_KERNEL_INODE_TIMES
195         ZFS_AC_KERNEL_INODE_LOCK
196         ZFS_AC_KERNEL_GROUP_INFO_GID
197         ZFS_AC_KERNEL_RW
198         ZFS_AC_KERNEL_TIMER_SETUP
199         ZFS_AC_KERNEL_SUPER_USER_NS
200         ZFS_AC_KERNEL_PROC_OPERATIONS
201         ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS
202         ZFS_AC_KERNEL_BIO
203         ZFS_AC_KERNEL_BLKDEV
204         ZFS_AC_KERNEL_BLK_QUEUE
205         ZFS_AC_KERNEL_GENHD_FLAGS
206         ZFS_AC_KERNEL_REVALIDATE_DISK
207         ZFS_AC_KERNEL_GET_DISK_RO
208         ZFS_AC_KERNEL_GENERIC_READLINK_GLOBAL
209         ZFS_AC_KERNEL_DISCARD_GRANULARITY
210         ZFS_AC_KERNEL_INODE_OWNER_OR_CAPABLE
211         ZFS_AC_KERNEL_XATTR
212         ZFS_AC_KERNEL_ACL
213         ZFS_AC_KERNEL_INODE_SETATTR
214         ZFS_AC_KERNEL_INODE_GETATTR
215         ZFS_AC_KERNEL_INODE_SET_FLAGS
216         ZFS_AC_KERNEL_INODE_SET_IVERSION
217         ZFS_AC_KERNEL_SHOW_OPTIONS
218         ZFS_AC_KERNEL_FILE_INODE
219         ZFS_AC_KERNEL_FILE_DENTRY
220         ZFS_AC_KERNEL_FSYNC
221         ZFS_AC_KERNEL_AIO_FSYNC
222         ZFS_AC_KERNEL_EVICT_INODE
223         ZFS_AC_KERNEL_DIRTY_INODE
224         ZFS_AC_KERNEL_SHRINKER
225         ZFS_AC_KERNEL_MKDIR
226         ZFS_AC_KERNEL_LOOKUP_FLAGS
227         ZFS_AC_KERNEL_CREATE
228         ZFS_AC_KERNEL_PERMISSION
229         ZFS_AC_KERNEL_GET_LINK
230         ZFS_AC_KERNEL_PUT_LINK
231         ZFS_AC_KERNEL_TMPFILE
232         ZFS_AC_KERNEL_AUTOMOUNT
233         ZFS_AC_KERNEL_ENCODE_FH_WITH_INODE
234         ZFS_AC_KERNEL_COMMIT_METADATA
235         ZFS_AC_KERNEL_CLEAR_INODE
236         ZFS_AC_KERNEL_SETATTR_PREPARE
237         ZFS_AC_KERNEL_INSERT_INODE_LOCKED
238         ZFS_AC_KERNEL_DENTRY
239         ZFS_AC_KERNEL_DENTRY_ALIAS_D_U
240         ZFS_AC_KERNEL_TRUNCATE_SETSIZE
241         ZFS_AC_KERNEL_SECURITY_INODE
242         ZFS_AC_KERNEL_FST_MOUNT
243         ZFS_AC_KERNEL_BDI
244         ZFS_AC_KERNEL_SET_NLINK
245         ZFS_AC_KERNEL_SGET
246         ZFS_AC_KERNEL_LSEEK_EXECUTE
247         ZFS_AC_KERNEL_VFS_FILEMAP_DIRTY_FOLIO
248         ZFS_AC_KERNEL_VFS_READ_FOLIO
249         ZFS_AC_KERNEL_VFS_GETATTR
250         ZFS_AC_KERNEL_VFS_FSYNC_2ARGS
251         ZFS_AC_KERNEL_VFS_ITERATE
252         ZFS_AC_KERNEL_VFS_DIRECT_IO
253         ZFS_AC_KERNEL_VFS_READPAGES
254         ZFS_AC_KERNEL_VFS_SET_PAGE_DIRTY_NOBUFFERS
255         ZFS_AC_KERNEL_VFS_RW_ITERATE
256         ZFS_AC_KERNEL_VFS_GENERIC_WRITE_CHECKS
257         ZFS_AC_KERNEL_VFS_IOV_ITER
258         ZFS_AC_KERNEL_VFS_COPY_FILE_RANGE
259         ZFS_AC_KERNEL_VFS_GENERIC_COPY_FILE_RANGE
260         ZFS_AC_KERNEL_VFS_REMAP_FILE_RANGE
261         ZFS_AC_KERNEL_VFS_CLONE_FILE_RANGE
262         ZFS_AC_KERNEL_VFS_DEDUPE_FILE_RANGE
263         ZFS_AC_KERNEL_VFS_FILE_OPERATIONS_EXTEND
264         ZFS_AC_KERNEL_KMAP_ATOMIC_ARGS
265         ZFS_AC_KERNEL_FOLLOW_DOWN_ONE
266         ZFS_AC_KERNEL_MAKE_REQUEST_FN
267         ZFS_AC_KERNEL_GENERIC_IO_ACCT
268         ZFS_AC_KERNEL_FPU
269         ZFS_AC_KERNEL_FMODE_T
270         ZFS_AC_KERNEL_KUIDGID_T
271         ZFS_AC_KERNEL_KUID_HELPERS
272         ZFS_AC_KERNEL_RENAME
273         ZFS_AC_KERNEL_CURRENT_TIME
274         ZFS_AC_KERNEL_USERNS_CAPABILITIES
275         ZFS_AC_KERNEL_IN_COMPAT_SYSCALL
276         ZFS_AC_KERNEL_KTIME
277         ZFS_AC_KERNEL_TOTALRAM_PAGES_FUNC
278         ZFS_AC_KERNEL_TOTALHIGH_PAGES
279         ZFS_AC_KERNEL_KSTRTOUL
280         ZFS_AC_KERNEL_PERCPU
281         ZFS_AC_KERNEL_CPU_HOTPLUG
282         ZFS_AC_KERNEL_GENERIC_FILLATTR
283         ZFS_AC_KERNEL_MKNOD
284         ZFS_AC_KERNEL_SYMLINK
285         ZFS_AC_KERNEL_BIO_MAX_SEGS
286         ZFS_AC_KERNEL_SIGNAL_STOP
287         ZFS_AC_KERNEL_SIGINFO
288         ZFS_AC_KERNEL_SYSFS
289         ZFS_AC_KERNEL_SET_SPECIAL_STATE
290         ZFS_AC_KERNEL_STANDALONE_LINUX_STDARG
291         ZFS_AC_KERNEL_PAGEMAP_FOLIO_WAIT_BIT
292         ZFS_AC_KERNEL_ADD_DISK
293         ZFS_AC_KERNEL_KTHREAD
294         ZFS_AC_KERNEL_ZERO_PAGE
295         ZFS_AC_KERNEL___COPY_FROM_USER_INATOMIC
296         ZFS_AC_KERNEL_USER_NS_COMMON_INUM
297         ZFS_AC_KERNEL_IDMAP_MNT_API
298         ZFS_AC_KERNEL_IATTR_VFSID
299         ZFS_AC_KERNEL_FILEMAP
300         ZFS_AC_KERNEL_WRITEPAGE_T
301         ZFS_AC_KERNEL_RECLAIMED
302         case "$host_cpu" in
303                 powerpc*)
304                         ZFS_AC_KERNEL_CPU_HAS_FEATURE
305                         ZFS_AC_KERNEL_FLUSH_DCACHE_PAGE
306                         ;;
307         esac
310 dnl #
311 dnl # Detect name used for Module.symvers file in kernel
312 dnl #
313 AC_DEFUN([ZFS_AC_MODULE_SYMVERS], [
314         modpost=$LINUX/scripts/Makefile.modpost
315         AC_MSG_CHECKING([kernel file name for module symbols])
316         AS_IF([test "x$enable_linux_builtin" != xyes -a -f "$modpost"], [
317                 AS_IF([grep -q Modules.symvers $modpost], [
318                         LINUX_SYMBOLS=Modules.symvers
319                 ], [
320                         LINUX_SYMBOLS=Module.symvers
321                 ])
323                 AS_IF([test ! -f "$LINUX_OBJ/$LINUX_SYMBOLS"], [
324                         AC_MSG_ERROR([
325         *** Please make sure the kernel devel package for your distribution
326         *** is installed.  If you are building with a custom kernel, make sure
327         *** the kernel is configured, built, and the '--with-linux=PATH'
328         *** configure option refers to the location of the kernel source.
329                         ])
330                 ])
331         ], [
332                 LINUX_SYMBOLS=NONE
333         ])
334         AC_MSG_RESULT($LINUX_SYMBOLS)
335         AC_SUBST(LINUX_SYMBOLS)
338 dnl #
339 dnl # Detect the kernel to be built against
340 dnl #
341 dnl # Most modern Linux distributions have separate locations for bare
342 dnl # source (source) and prebuilt (build) files. Additionally, there are
343 dnl # `source` and `build` symlinks in `/lib/modules/$(KERNEL_VERSION)`
344 dnl # pointing to them. The directory search order is now:
345 dnl # 
346 dnl # - `configure` command line values if both `--with-linux` and
347 dnl #   `--with-linux-obj` were defined
348 dnl # 
349 dnl # - If only `--with-linux` was defined, `--with-linux-obj` is assumed
350 dnl #   to have the same value as `--with-linux`
351 dnl # 
352 dnl # - If neither `--with-linux` nor `--with-linux-obj` were defined
353 dnl #   autodetection is used:
354 dnl # 
355 dnl #   - `/lib/modules/$(uname -r)/{source,build}` respectively, if exist.
356 dnl # 
357 dnl #   - If only `/lib/modules/$(uname -r)/build` exists, it is assumed
358 dnl #     to be both source and build directory.
359 dnl # 
360 dnl #   - The first directory in `/lib/modules` with the highest version
361 dnl #     number according to `sort -V` which contains both `source` and
362 dnl #     `build` symlinks/directories. If module directory contains only
363 dnl #     `build` component, it is assumed to be both source and build
364 dnl #     directory.
365 dnl # 
366 dnl #   - Last resort: the first directory matching `/usr/src/kernels/*`
367 dnl #     and `/usr/src/linux-*` with the highest version number according
368 dnl #     to `sort -V` is assumed to be both source and build directory.
369 dnl #
370 AC_DEFUN([ZFS_AC_KERNEL], [
371         AC_ARG_WITH([linux],
372                 AS_HELP_STRING([--with-linux=PATH],
373                 [Path to kernel source]),
374                 [kernelsrc="$withval"])
376         AC_ARG_WITH(linux-obj,
377                 AS_HELP_STRING([--with-linux-obj=PATH],
378                 [Path to kernel build objects]),
379                 [kernelbuild="$withval"])
381         AC_MSG_CHECKING([kernel source and build directories])
382         AS_IF([test -n "$kernelsrc" && test -z "$kernelbuild"], [
383                 kernelbuild="$kernelsrc"
384         ], [test -z "$kernelsrc"], [
385                 AS_IF([test -e "/lib/modules/$(uname -r)/source" && \
386                        test -e "/lib/modules/$(uname -r)/build"], [
387                         src="/lib/modules/$(uname -r)/source"
388                         build="/lib/modules/$(uname -r)/build"
389                 ], [test -e "/lib/modules/$(uname -r)/build"], [
390                         build="/lib/modules/$(uname -r)/build"
391                         src="$build"
392                 ], [
393                         src=
395                         for d in $(ls -1d /lib/modules/* 2>/dev/null | sort -Vr); do
396                                 if test -e "$d/source" && test -e "$d/build"; then
397                                         src="$d/source"
398                                         build="$d/build"
399                                         break
400                                 fi
402                                 if test -e "$d/build"; then
403                                         src="$d/build"
404                                         build="$d/build"
405                                         break
406                                 fi
407                         done
409                         # the least reliable method
410                         if test -z "$src"; then
411                                 src=$(ls -1d /usr/src/kernels/* /usr/src/linux-* \
412                                       2>/dev/null | grep -v obj | sort -Vr | head -1)
413                                 build="$src"
414                         fi
415                 ])
417                 AS_IF([test -n "$src" && test -e "$src"], [
418                         kernelsrc=$(readlink -e "$src")
419                 ], [
420                         kernelsrc="[Not found]"
421                 ])
422                 AS_IF([test -n "$build" && test -e "$build"], [
423                         kernelbuild=$(readlink -e "$build")
424                 ], [
425                         kernelbuild="[Not found]"
426                 ])
427         ], [
428                 AS_IF([test "$kernelsrc" = "NONE"], [
429                         kernsrcver=NONE
430                 ])
431                 withlinux=yes
432         ])
434         AC_MSG_RESULT([done])
435         AC_MSG_CHECKING([kernel source directory])
436         AC_MSG_RESULT([$kernelsrc])
437         AC_MSG_CHECKING([kernel build directory])
438         AC_MSG_RESULT([$kernelbuild])
439         AS_IF([test ! -d "$kernelsrc" || test ! -d "$kernelbuild"], [
440                 AC_MSG_ERROR([
441         *** Please make sure the kernel devel package for your distribution
442         *** is installed and then try again.  If that fails, you can specify the
443         *** location of the kernel source and build with the '--with-linux=PATH' and
444         *** '--with-linux-obj=PATH' options respectively.])
445         ])
447         AC_MSG_CHECKING([kernel source version])
448         utsrelease1=$kernelbuild/include/linux/version.h
449         utsrelease2=$kernelbuild/include/linux/utsrelease.h
450         utsrelease3=$kernelbuild/include/generated/utsrelease.h
451         AS_IF([test -r $utsrelease1 && grep -qF UTS_RELEASE $utsrelease1], [
452                 utsrelease=$utsrelease1
453         ], [test -r $utsrelease2 && grep -qF UTS_RELEASE $utsrelease2], [
454                 utsrelease=$utsrelease2
455         ], [test -r $utsrelease3 && grep -qF UTS_RELEASE $utsrelease3], [
456                 utsrelease=$utsrelease3
457         ])
459         AS_IF([test -n "$utsrelease"], [
460                 kernsrcver=$($AWK '/UTS_RELEASE/ { gsub(/"/, "", $[3]); print $[3] }' $utsrelease)
461                 AS_IF([test -z "$kernsrcver"], [
462                         AC_MSG_RESULT([Not found])
463                         AC_MSG_ERROR([
464         *** Cannot determine kernel version.
465                         ])
466                 ])
467         ], [
468                 AC_MSG_RESULT([Not found])
469                 if test "x$enable_linux_builtin" != xyes; then
470                         AC_MSG_ERROR([
471         *** Cannot find UTS_RELEASE definition.
472                         ])
473                 else
474                         AC_MSG_ERROR([
475         *** Cannot find UTS_RELEASE definition.
476         *** Please run 'make prepare' inside the kernel source tree.])
477                 fi
478         ])
480         AC_MSG_RESULT([$kernsrcver])
482         AS_VERSION_COMPARE([$kernsrcver], [$ZFS_META_KVER_MIN], [
483                  AC_MSG_ERROR([
484         *** Cannot build against kernel version $kernsrcver.
485         *** The minimum supported kernel version is $ZFS_META_KVER_MIN.
486                 ])
487         ])
489         LINUX=${kernelsrc}
490         LINUX_OBJ=${kernelbuild}
491         LINUX_VERSION=${kernsrcver}
493         AC_SUBST(LINUX)
494         AC_SUBST(LINUX_OBJ)
495         AC_SUBST(LINUX_VERSION)
498 dnl #
499 dnl # Detect the QAT module to be built against, QAT provides hardware
500 dnl # acceleration for data compression:
501 dnl #
502 dnl # https://01.org/intel-quickassist-technology
503 dnl #
504 dnl # 1) Download and install QAT driver from the above link
505 dnl # 2) Start QAT driver in your system:
506 dnl #    service qat_service start
507 dnl # 3) Enable QAT in ZFS, e.g.:
508 dnl #    ./configure --with-qat=<qat-driver-path>/QAT1.6
509 dnl #    make
510 dnl # 4) Set GZIP compression in ZFS dataset:
511 dnl #    zfs set compression = gzip <dataset>
512 dnl #
513 dnl # Then the data written to this ZFS pool is compressed by QAT accelerator
514 dnl # automatically, and de-compressed by QAT when read from the pool.
515 dnl #
516 dnl # 1) Get QAT hardware statistics with:
517 dnl #    cat /proc/icp_dh895xcc_dev/qat
518 dnl # 2) To disable QAT:
519 dnl #    insmod zfs.ko zfs_qat_disable=1
520 dnl #
521 AC_DEFUN([ZFS_AC_QAT], [
522         AC_ARG_WITH([qat],
523                 AS_HELP_STRING([--with-qat=PATH],
524                 [Path to qat source]),
525                 AS_IF([test "$withval" = "yes"],
526                         AC_MSG_ERROR([--with-qat=PATH requires a PATH]),
527                         [qatsrc="$withval"]))
529         AC_ARG_WITH([qat-obj],
530                 AS_HELP_STRING([--with-qat-obj=PATH],
531                 [Path to qat build objects]),
532                 [qatbuild="$withval"])
534         AS_IF([test ! -z "${qatsrc}"], [
535                 AC_MSG_CHECKING([qat source directory])
536                 AC_MSG_RESULT([$qatsrc])
537                 QAT_SRC="${qatsrc}/quickassist"
538                 AS_IF([ test ! -e "$QAT_SRC/include/cpa.h"], [
539                         AC_MSG_ERROR([
540         *** Please make sure the qat driver package is installed
541         *** and specify the location of the qat source with the
542         *** '--with-qat=PATH' option then try again. Failed to
543         *** find cpa.h in:
544         ${QAT_SRC}/include])
545                 ])
546         ])
548         AS_IF([test ! -z "${qatsrc}"], [
549                 AC_MSG_CHECKING([qat build directory])
550                 AS_IF([test -z "$qatbuild"], [
551                         qatbuild="${qatsrc}/build"
552                 ])
554                 AC_MSG_RESULT([$qatbuild])
555                 QAT_OBJ=${qatbuild}
556                 AS_IF([ ! test -e "$QAT_OBJ/icp_qa_al.ko" && ! test -e "$QAT_OBJ/qat_api.ko"], [
557                         AC_MSG_ERROR([
558         *** Please make sure the qat driver is installed then try again.
559         *** Failed to find icp_qa_al.ko or qat_api.ko in:
560         $QAT_OBJ])
561                 ])
563                 AC_SUBST(QAT_SRC)
564                 AC_SUBST(QAT_OBJ)
566                 AC_DEFINE(HAVE_QAT, 1,
567                 [qat is enabled and existed])
568         ])
570         dnl #
571         dnl # Detect the name used for the QAT Module.symvers file.
572         dnl #
573         AS_IF([test ! -z "${qatsrc}"], [
574                 AC_MSG_CHECKING([qat file for module symbols])
575                 QAT_SYMBOLS=$QAT_SRC/lookaside/access_layer/src/Module.symvers
577                 AS_IF([test -r $QAT_SYMBOLS], [
578                         AC_MSG_RESULT([$QAT_SYMBOLS])
579                         AC_SUBST(QAT_SYMBOLS)
580                 ],[
581                         AC_MSG_ERROR([
582         *** Please make sure the qat driver is installed then try again.
583         *** Failed to find Module.symvers in:
584         $QAT_SYMBOLS
585                         ])
586                 ])
587         ])
590 dnl #
591 dnl # ZFS_LINUX_CONFTEST_H
592 dnl #
593 AC_DEFUN([ZFS_LINUX_CONFTEST_H], [
594 test -d build/$2 || mkdir -p build/$2
595 cat - <<_ACEOF >build/$2/$2.h
597 _ACEOF
600 dnl #
601 dnl # ZFS_LINUX_CONFTEST_C
602 dnl #
603 AC_DEFUN([ZFS_LINUX_CONFTEST_C], [
604 test -d build/$2 || mkdir -p build/$2
605 cat confdefs.h - <<_ACEOF >build/$2/$2.c
607 _ACEOF
610 dnl #
611 dnl # ZFS_LINUX_CONFTEST_MAKEFILE
612 dnl #
613 dnl # $1 - test case name
614 dnl # $2 - add to top-level Makefile
615 dnl # $3 - additional build flags
616 dnl #
617 AC_DEFUN([ZFS_LINUX_CONFTEST_MAKEFILE], [
618         test -d build || mkdir -p build
619         test -d build/$1 || mkdir -p build/$1
621         file=build/$1/Makefile
623         dnl # Example command line to manually build source.
624         cat - <<_ACEOF >$file
625 # Example command line to manually build source
626 # make modules -C $LINUX_OBJ $ARCH_UM M=$PWD/build/$1
628 ccflags-y := -Werror $FRAME_LARGER_THAN
629 _ACEOF
631         dnl # Additional custom CFLAGS as requested.
632         m4_ifval($3, [echo "ccflags-y += $3" >>$file], [])
634         dnl # Test case source
635         echo "obj-m := $1.o" >>$file
637         AS_IF([test "x$2" = "xyes"], [echo "obj-m += $1/" >>build/Makefile], [])
640 dnl #
641 dnl # ZFS_LINUX_TEST_PROGRAM(C)([PROLOGUE], [BODY])
642 dnl #
643 m4_define([ZFS_LINUX_TEST_PROGRAM], [
644 #include <linux/module.h>
648 main (void)
651         ;
652         return 0;
655 MODULE_DESCRIPTION("conftest");
656 MODULE_AUTHOR(ZFS_META_AUTHOR);
657 MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE);
658 MODULE_LICENSE($3);
661 dnl #
662 dnl # ZFS_LINUX_TEST_REMOVE
663 dnl #
664 dnl # Removes the specified test source and results.
665 dnl #
666 AC_DEFUN([ZFS_LINUX_TEST_REMOVE], [
667         test -d build/$1 && rm -Rf build/$1
668         test -f build/Makefile && sed '/$1/d' build/Makefile
671 dnl #
672 dnl # ZFS_LINUX_COMPILE
673 dnl #
674 dnl # $1 - build dir
675 dnl # $2 - test command
676 dnl # $3 - pass command
677 dnl # $4 - fail command
678 dnl # $5 - set KBUILD_MODPOST_NOFINAL='yes'
679 dnl # $6 - set KBUILD_MODPOST_WARN='yes'
680 dnl #
681 dnl # Used internally by ZFS_LINUX_TEST_{COMPILE,MODPOST}
682 dnl #
683 AC_DEFUN([ZFS_LINUX_COMPILE], [
684         AC_ARG_VAR([KERNEL_CC], [C compiler for
685                 building kernel modules])
686         AC_ARG_VAR([KERNEL_LD], [Linker for
687                 building kernel modules])
688         AC_ARG_VAR([KERNEL_LLVM], [Binary option to
689                 build kernel modules with LLVM/CLANG toolchain])
690         AC_TRY_COMMAND([
691             KBUILD_MODPOST_NOFINAL="$5" KBUILD_MODPOST_WARN="$6"
692             make modules -k -j$TEST_JOBS ${KERNEL_CC:+CC=$KERNEL_CC}
693             ${KERNEL_LD:+LD=$KERNEL_LD} ${KERNEL_LLVM:+LLVM=$KERNEL_LLVM}
694             CONFIG_MODULES=y CFLAGS_MODULE=-DCONFIG_MODULES
695             -C $LINUX_OBJ $ARCH_UM M=$PWD/$1 >$1/build.log 2>&1])
696         AS_IF([AC_TRY_COMMAND([$2])], [$3], [$4])
699 dnl #
700 dnl # ZFS_LINUX_TEST_COMPILE
701 dnl #
702 dnl # Perform a full compile excluding the final modpost phase.
703 dnl #
704 AC_DEFUN([ZFS_LINUX_TEST_COMPILE], [
705         ZFS_LINUX_COMPILE([$2], [test -f $2/build.log], [
706                 mv $2/Makefile $2/Makefile.compile.$1
707                 mv $2/build.log $2/build.log.$1
708         ],[
709                 AC_MSG_ERROR([
710         *** Unable to compile test source to determine kernel interfaces.])
711         ], [yes], [])
714 dnl #
715 dnl # ZFS_LINUX_TEST_MODPOST
716 dnl #
717 dnl # Perform a full compile including the modpost phase.  This may
718 dnl # be an incremental build if the objects have already been built.
719 dnl #
720 AC_DEFUN([ZFS_LINUX_TEST_MODPOST], [
721         ZFS_LINUX_COMPILE([$2], [test -f $2/build.log], [
722                 mv $2/Makefile $2/Makefile.modpost.$1
723                 cat $2/build.log >>build/build.log.$1
724         ],[
725                 AC_MSG_ERROR([
726         *** Unable to modpost test source to determine kernel interfaces.])
727         ], [], [yes])
730 dnl #
731 dnl # Perform the compilation of the test cases in two phases.
732 dnl #
733 dnl # Phase 1) attempt to build the object files for all of the tests
734 dnl #          defined by the ZFS_LINUX_TEST_SRC macro.  But do not
735 dnl #          perform the final modpost stage.
736 dnl #
737 dnl # Phase 2) disable all tests which failed the initial compilation,
738 dnl #          then invoke the final modpost step for the remaining tests.
739 dnl #
740 dnl # This allows us efficiently build the test cases in parallel while
741 dnl # remaining resilient to build failures which are expected when
742 dnl # detecting the available kernel interfaces.
743 dnl #
744 dnl # The maximum allowed parallelism can be controlled by setting the
745 dnl # TEST_JOBS environment variable.  Otherwise, it default to $(nproc).
746 dnl #
747 AC_DEFUN([ZFS_LINUX_TEST_COMPILE_ALL], [
748         dnl # Phase 1 - Compilation only, final linking is skipped.
749         ZFS_LINUX_TEST_COMPILE([$1], [build])
751         dnl #
752         dnl # Phase 2 - When building external modules disable test cases
753         dnl # which failed to compile and invoke modpost to verify the
754         dnl # final linking.
755         dnl #
756         dnl # Test names suffixed with '_license' call modpost independently
757         dnl # to ensure that a single incompatibility does not result in the
758         dnl # modpost phase exiting early.  This check is not performed on
759         dnl # every symbol since the majority are compatible and doing so
760         dnl # would significantly slow down this phase.
761         dnl #
762         dnl # When configuring for builtin (--enable-linux-builtin)
763         dnl # fake the linking step artificially create the expected .ko
764         dnl # files for tests which did compile.  This is required for
765         dnl # kernels which do not have loadable module support or have
766         dnl # not yet been built.
767         dnl #
768         AS_IF([test "x$enable_linux_builtin" = "xno"], [
769                 for dir in $(awk '/^obj-m/ { print [$]3 }' \
770                     build/Makefile.compile.$1); do
771                         name=${dir%/}
772                         AS_IF([test -f build/$name/$name.o], [
773                                 AS_IF([test "${name##*_}" = "license"], [
774                                         ZFS_LINUX_TEST_MODPOST([$1],
775                                             [build/$name])
776                                         echo "obj-n += $dir" >>build/Makefile
777                                 ], [
778                                         echo "obj-m += $dir" >>build/Makefile
779                                 ])
780                         ], [
781                                 echo "obj-n += $dir" >>build/Makefile
782                         ])
783                 done
785                 ZFS_LINUX_TEST_MODPOST([$1], [build])
786         ], [
787                 for dir in $(awk '/^obj-m/ { print [$]3 }' \
788                     build/Makefile.compile.$1); do
789                         name=${dir%/}
790                         AS_IF([test -f build/$name/$name.o], [
791                                 touch build/$name/$name.ko
792                         ])
793                 done
794         ])
797 dnl #
798 dnl # ZFS_LINUX_TEST_SRC
799 dnl #
800 dnl # $1 - name
801 dnl # $2 - global
802 dnl # $3 - source
803 dnl # $4 - extra cflags
804 dnl # $5 - check license-compatibility
805 dnl #
806 dnl # Check if the test source is buildable at all and then if it is
807 dnl # license compatible.
808 dnl #
809 dnl # N.B because all of the test cases are compiled in parallel they
810 dnl # must never depend on the results of previous tests.  Each test
811 dnl # needs to be entirely independent.
812 dnl #
813 AC_DEFUN([ZFS_LINUX_TEST_SRC], [
814         ZFS_LINUX_CONFTEST_C([ZFS_LINUX_TEST_PROGRAM([[$2]], [[$3]],
815             [["Dual BSD/GPL"]])], [$1])
816         ZFS_LINUX_CONFTEST_MAKEFILE([$1], [yes], [$4])
818         AS_IF([ test -n "$5" ], [
819                 ZFS_LINUX_CONFTEST_C([ZFS_LINUX_TEST_PROGRAM(
820                     [[$2]], [[$3]], [[$5]])], [$1_license])
821                 ZFS_LINUX_CONFTEST_MAKEFILE([$1_license], [yes], [$4])
822         ])
825 dnl #
826 dnl # ZFS_LINUX_TEST_RESULT
827 dnl #
828 dnl # $1 - name of a test source (ZFS_LINUX_TEST_SRC)
829 dnl # $2 - run on success (valid .ko generated)
830 dnl # $3 - run on failure (unable to compile)
831 dnl #
832 AC_DEFUN([ZFS_LINUX_TEST_RESULT], [
833         AS_IF([test -d build/$1], [
834                 AS_IF([test -f build/$1/$1.ko], [$2], [$3])
835         ], [
836                 AC_MSG_ERROR([
837         *** No matching source for the "$1" test, check that
838         *** both the test source and result macros refer to the same name.
839                 ])
840         ])
843 dnl #
844 dnl # ZFS_LINUX_TEST_ERROR
845 dnl #
846 dnl # Generic error message which can be used when none of the expected
847 dnl # kernel interfaces were detected.
848 dnl #
849 AC_DEFUN([ZFS_LINUX_TEST_ERROR], [
850         AC_MSG_ERROR([
851         *** None of the expected "$1" interfaces were detected.
852         *** This may be because your kernel version is newer than what is
853         *** supported, or you are using a patched custom kernel with
854         *** incompatible modifications.
855         ***
856         *** ZFS Version: $ZFS_META_ALIAS
857         *** Compatible Kernels: $ZFS_META_KVER_MIN - $ZFS_META_KVER_MAX
858         ])
861 dnl #
862 dnl # ZFS_LINUX_TEST_RESULT_SYMBOL
863 dnl #
864 dnl # Like ZFS_LINUX_TEST_RESULT except ZFS_CHECK_SYMBOL_EXPORT is called to
865 dnl # verify symbol exports, unless --enable-linux-builtin was provided to
866 dnl # configure.
867 dnl #
868 AC_DEFUN([ZFS_LINUX_TEST_RESULT_SYMBOL], [
869         AS_IF([ ! test -f build/$1/$1.ko], [
870                 $5
871         ], [
872                 AS_IF([test "x$enable_linux_builtin" != "xyes"], [
873                         ZFS_CHECK_SYMBOL_EXPORT([$2], [$3], [$4], [$5])
874                 ], [
875                         $4
876                 ])
877         ])
880 dnl #
881 dnl # ZFS_LINUX_COMPILE_IFELSE
882 dnl #
883 AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [
884         ZFS_LINUX_TEST_REMOVE([conftest])
886         m4_ifvaln([$1], [ZFS_LINUX_CONFTEST_C([$1], [conftest])])
887         m4_ifvaln([$5], [ZFS_LINUX_CONFTEST_H([$5], [conftest])],
888             [ZFS_LINUX_CONFTEST_H([], [conftest])])
890         ZFS_LINUX_CONFTEST_MAKEFILE([conftest], [no],
891             [m4_ifvaln([$5], [-I$PWD/build/conftest], [])])
892         ZFS_LINUX_COMPILE([build/conftest], [$2], [$3], [$4], [], [])
895 dnl #
896 dnl # ZFS_LINUX_TRY_COMPILE
897 dnl #
898 dnl # $1 - global
899 dnl # $2 - source
900 dnl # $3 - run on success (valid .ko generated)
901 dnl # $4 - run on failure (unable to compile)
902 dnl #
903 dnl # When configuring as builtin (--enable-linux-builtin) for kernels
904 dnl # without loadable module support (CONFIG_MODULES=n) only the object
905 dnl # file is created.  See ZFS_LINUX_TEST_COMPILE_ALL for details.
906 dnl #
907 AC_DEFUN([ZFS_LINUX_TRY_COMPILE], [
908         AS_IF([test "x$enable_linux_builtin" = "xyes"], [
909                 ZFS_LINUX_COMPILE_IFELSE(
910                     [ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]],
911                     [[ZFS_META_LICENSE]])],
912                     [test -f build/conftest/conftest.o], [$3], [$4])
913         ], [
914                 ZFS_LINUX_COMPILE_IFELSE(
915                     [ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]],
916                     [[ZFS_META_LICENSE]])],
917                     [test -f build/conftest/conftest.ko], [$3], [$4])
918         ])
921 dnl #
922 dnl # ZFS_CHECK_SYMBOL_EXPORT
923 dnl #
924 dnl # Check if a symbol is exported on not by consulting the symbols
925 dnl # file, or optionally the source code.
926 dnl #
927 AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT], [
928         grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
929                 $LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null
930         rc=$?
931         if test $rc -ne 0; then
932                 export=0
933                 for file in $2; do
934                         grep -q -E "EXPORT_SYMBOL.*($1)" \
935                                 "$LINUX/$file" 2>/dev/null
936                         rc=$?
937                         if test $rc -eq 0; then
938                                 export=1
939                                 break;
940                         fi
941                 done
942                 if test $export -eq 0; then :
943                         $4
944                 else :
945                         $3
946                 fi
947         else :
948                 $3
949         fi
952 dnl #
953 dnl # ZFS_LINUX_TRY_COMPILE_SYMBOL
954 dnl #
955 dnl # Like ZFS_LINUX_TRY_COMPILER except ZFS_CHECK_SYMBOL_EXPORT is called
956 dnl # to verify symbol exports, unless --enable-linux-builtin was provided
957 dnl # to configure.
958 dnl #
959 AC_DEFUN([ZFS_LINUX_TRY_COMPILE_SYMBOL], [
960         ZFS_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
961         if test $rc -ne 0; then :
962                 $6
963         else
964                 if test "x$enable_linux_builtin" != xyes; then
965                         ZFS_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
966                 fi
967                 if test $rc -ne 0; then :
968                         $6
969                 else :
970                         $5
971                 fi
972         fi
975 dnl #
976 dnl # ZFS_LINUX_TRY_COMPILE_HEADER
977 dnl # like ZFS_LINUX_TRY_COMPILE, except the contents conftest.h are
978 dnl # provided via the fifth parameter
979 dnl #
980 AC_DEFUN([ZFS_LINUX_TRY_COMPILE_HEADER], [
981         AS_IF([test "x$enable_linux_builtin" = "xyes"], [
982                 ZFS_LINUX_COMPILE_IFELSE(
983                     [ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]],
984                     [[ZFS_META_LICENSE]])],
985                     [test -f build/conftest/conftest.o], [$3], [$4], [$5])
986         ], [
987                 ZFS_LINUX_COMPILE_IFELSE(
988                     [ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]],
989                     [[ZFS_META_LICENSE]])],
990                     [test -f build/conftest/conftest.ko], [$3], [$4], [$5])
991         ])
994 dnl #
995 dnl # AS_VERSION_COMPARE_LE
996 dnl # like AS_VERSION_COMPARE_LE, but runs $3 if (and only if) $1 <= $2
997 dnl # AS_VERSION_COMPARE_LE (version-1, version-2, [action-if-less-or-equal], [action-if-greater])
998 dnl #
999 AC_DEFUN([AS_VERSION_COMPARE_LE], [
1000         AS_VERSION_COMPARE([$1], [$2], [$3], [$3], [$4])
1003 dnl #
1004 dnl # ZFS_LINUX_REQUIRE_API
1005 dnl # like ZFS_LINUX_TEST_ERROR, except only fails if the kernel is
1006 dnl # at least some specified version.
1007 dnl #
1008 AC_DEFUN([ZFS_LINUX_REQUIRE_API], [
1009         AS_VERSION_COMPARE_LE([$2], [$kernsrcver], [
1010                 AC_MSG_ERROR([
1011                 *** None of the expected "$1" interfaces were detected. This
1012                 *** interface is expected for kernels version "$2" and above.
1013                 *** This may be because your kernel version is newer than what is
1014                 *** supported, or you are using a patched custom kernel with
1015                 *** incompatible modifications.  Newer kernels may have incompatible
1016                 *** APIs.
1017                 ***
1018                 *** ZFS Version: $ZFS_META_ALIAS
1019                 *** Compatible Kernels: $ZFS_META_KVER_MIN - $ZFS_META_KVER_MAX
1020                 ])
1021         ], [
1022                 AC_MSG_RESULT(no)
1023         ])