]> git.proxmox.com Git - mirror_zfs.git/blame - config/kernel.m4
Linux 5.12 compat: idmapped mounts
[mirror_zfs.git] / config / kernel.m4
CommitLineData
c9c0d073 1dnl #
fc0c72b1 2dnl # Default ZFS kernel configuration
c9c0d073
BB
3dnl #
4AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
9f0a21e6
MM
5 AM_COND_IF([BUILD_LINUX], [
6 dnl # Setup the kernel build environment.
7 ZFS_AC_KERNEL
8 ZFS_AC_QAT
608f8749 9
9f0a21e6
MM
10 dnl # Sanity checks for module building and CONFIG_* defines
11 ZFS_AC_KERNEL_TEST_MODULE
12 ZFS_AC_KERNEL_CONFIG_DEFINED
608f8749 13
9f0a21e6
MM
14 dnl # Sequential ZFS_LINUX_TRY_COMPILE tests
15 ZFS_AC_KERNEL_FPU_HEADER
8c7d604c 16 ZFS_AC_KERNEL_OBJTOOL_HEADER
9f0a21e6
MM
17 ZFS_AC_KERNEL_WAIT_QUEUE_ENTRY_T
18 ZFS_AC_KERNEL_MISC_MINOR
19 ZFS_AC_KERNEL_DECLARE_EVENT_CLASS
608f8749 20
9f0a21e6
MM
21 dnl # Parallel ZFS_LINUX_TEST_SRC / ZFS_LINUX_TEST_RESULT tests
22 ZFS_AC_KERNEL_TEST_SRC
23 ZFS_AC_KERNEL_TEST_RESULT
608f8749 24
9f0a21e6
MM
25 AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
26 KERNEL_MAKE="$KERNEL_MAKE O=$LINUX_OBJ"
27 ])
608f8749 28
9f0a21e6
MM
29 AC_SUBST(KERNEL_MAKE)
30 ])
608f8749
BB
31])
32
33dnl #
34dnl # Generate and compile all of the kernel API test cases to determine
35dnl # which interfaces are available. By invoking the kernel build system
36dnl # only once the compilation can be done in parallel significantly
37dnl # speeding up the process.
38dnl #
39AC_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
608f8749
BB
43 ZFS_AC_KERNEL_SRC_PDE_DATA
44 ZFS_AC_KERNEL_SRC_FALLOCATE
45 ZFS_AC_KERNEL_SRC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
46 ZFS_AC_KERNEL_SRC_RWSEM
47 ZFS_AC_KERNEL_SRC_SCHED
48 ZFS_AC_KERNEL_SRC_USLEEP_RANGE
49 ZFS_AC_KERNEL_SRC_KMEM_CACHE
66955885 50 ZFS_AC_KERNEL_SRC_KVMALLOC
080102a1 51 ZFS_AC_KERNEL_SRC_VMALLOC_PAGE_KERNEL
608f8749
BB
52 ZFS_AC_KERNEL_SRC_WAIT
53 ZFS_AC_KERNEL_SRC_INODE_TIMES
54 ZFS_AC_KERNEL_SRC_INODE_LOCK
55 ZFS_AC_KERNEL_SRC_GROUP_INFO_GID
56 ZFS_AC_KERNEL_SRC_RW
57 ZFS_AC_KERNEL_SRC_TIMER_SETUP
608f8749 58 ZFS_AC_KERNEL_SRC_SUPER_USER_NS
0dd73648 59 ZFS_AC_KERNEL_SRC_PROC_OPERATIONS
608f8749 60 ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS
066e8252
BB
61 ZFS_AC_KERNEL_SRC_BIO
62 ZFS_AC_KERNEL_SRC_BLKDEV
63 ZFS_AC_KERNEL_SRC_BLK_QUEUE
19697e45 64 ZFS_AC_KERNEL_SRC_REVALIDATE_DISK
608f8749
BB
65 ZFS_AC_KERNEL_SRC_GET_DISK_RO
66 ZFS_AC_KERNEL_SRC_GENERIC_READLINK_GLOBAL
67 ZFS_AC_KERNEL_SRC_DISCARD_GRANULARITY
68 ZFS_AC_KERNEL_SRC_INODE_OWNER_OR_CAPABLE
69 ZFS_AC_KERNEL_SRC_XATTR
70 ZFS_AC_KERNEL_SRC_ACL
71 ZFS_AC_KERNEL_SRC_INODE_GETATTR
72 ZFS_AC_KERNEL_SRC_INODE_SET_FLAGS
73 ZFS_AC_KERNEL_SRC_INODE_SET_IVERSION
74 ZFS_AC_KERNEL_SRC_SHOW_OPTIONS
75 ZFS_AC_KERNEL_SRC_FILE_INODE
76 ZFS_AC_KERNEL_SRC_FILE_DENTRY
77 ZFS_AC_KERNEL_SRC_FSYNC
78 ZFS_AC_KERNEL_SRC_AIO_FSYNC
79 ZFS_AC_KERNEL_SRC_EVICT_INODE
80 ZFS_AC_KERNEL_SRC_DIRTY_INODE
81 ZFS_AC_KERNEL_SRC_SHRINKER
e2a82961 82 ZFS_AC_KERNEL_SRC_MKDIR
066e8252 83 ZFS_AC_KERNEL_SRC_LOOKUP_FLAGS
e2a82961 84 ZFS_AC_KERNEL_SRC_CREATE
608f8749
BB
85 ZFS_AC_KERNEL_SRC_GET_LINK
86 ZFS_AC_KERNEL_SRC_PUT_LINK
87 ZFS_AC_KERNEL_SRC_TMPFILE
608f8749
BB
88 ZFS_AC_KERNEL_SRC_AUTOMOUNT
89 ZFS_AC_KERNEL_SRC_ENCODE_FH_WITH_INODE
90 ZFS_AC_KERNEL_SRC_COMMIT_METADATA
91 ZFS_AC_KERNEL_SRC_CLEAR_INODE
92 ZFS_AC_KERNEL_SRC_SETATTR_PREPARE
93 ZFS_AC_KERNEL_SRC_INSERT_INODE_LOCKED
94 ZFS_AC_KERNEL_SRC_DENTRY
95 ZFS_AC_KERNEL_SRC_TRUNCATE_SETSIZE
96 ZFS_AC_KERNEL_SRC_SECURITY_INODE
97 ZFS_AC_KERNEL_SRC_FST_MOUNT
98 ZFS_AC_KERNEL_SRC_BDI
99 ZFS_AC_KERNEL_SRC_SET_NLINK
608f8749
BB
100 ZFS_AC_KERNEL_SRC_SGET
101 ZFS_AC_KERNEL_SRC_LSEEK_EXECUTE
102 ZFS_AC_KERNEL_SRC_VFS_GETATTR
103 ZFS_AC_KERNEL_SRC_VFS_FSYNC_2ARGS
104 ZFS_AC_KERNEL_SRC_VFS_ITERATE
105 ZFS_AC_KERNEL_SRC_VFS_DIRECT_IO
106 ZFS_AC_KERNEL_SRC_VFS_RW_ITERATE
107 ZFS_AC_KERNEL_SRC_VFS_GENERIC_WRITE_CHECKS
1c2358c1 108 ZFS_AC_KERNEL_SRC_VFS_IOV_ITER
608f8749
BB
109 ZFS_AC_KERNEL_SRC_KMAP_ATOMIC_ARGS
110 ZFS_AC_KERNEL_SRC_FOLLOW_DOWN_ONE
111 ZFS_AC_KERNEL_SRC_MAKE_REQUEST_FN
112 ZFS_AC_KERNEL_SRC_GENERIC_IO_ACCT
113 ZFS_AC_KERNEL_SRC_FPU
114 ZFS_AC_KERNEL_SRC_FMODE_T
115 ZFS_AC_KERNEL_SRC_KUIDGID_T
116 ZFS_AC_KERNEL_SRC_KUID_HELPERS
117 ZFS_AC_KERNEL_SRC_MODULE_PARAM_CALL_CONST
e2a82961 118 ZFS_AC_KERNEL_SRC_RENAME
608f8749
BB
119 ZFS_AC_KERNEL_SRC_CURRENT_TIME
120 ZFS_AC_KERNEL_SRC_USERNS_CAPABILITIES
121 ZFS_AC_KERNEL_SRC_IN_COMPAT_SYSCALL
ff5587d6 122 ZFS_AC_KERNEL_SRC_KTIME
608f8749
BB
123 ZFS_AC_KERNEL_SRC_TOTALRAM_PAGES_FUNC
124 ZFS_AC_KERNEL_SRC_TOTALHIGH_PAGES
125 ZFS_AC_KERNEL_SRC_KSTRTOUL
ec1fea45 126 ZFS_AC_KERNEL_SRC_PERCPU
60a4c7d2 127 ZFS_AC_KERNEL_SRC_CPU_HOTPLUG
e2a82961
CK
128 ZFS_AC_KERNEL_SRC_GENERIC_FILLATTR_USERNS
129 ZFS_AC_KERNEL_SRC_MKNOD
130 ZFS_AC_KERNEL_SRC_SYMLINK
608f8749
BB
131
132 AC_MSG_CHECKING([for available kernel interfaces])
133 ZFS_LINUX_TEST_COMPILE_ALL([kabi])
134 AC_MSG_RESULT([done])
135])
136
137dnl #
138dnl # Check results of kernel interface tests.
139dnl #
140AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
141 ZFS_AC_KERNEL_ACCESS_OK_TYPE
142 ZFS_AC_KERNEL_GLOBAL_PAGE_STATE
650383f2 143 ZFS_AC_KERNEL_OBJTOOL
93ce2b4c 144 ZFS_AC_KERNEL_PDE_DATA
93ce2b4c
BB
145 ZFS_AC_KERNEL_FALLOCATE
146 ZFS_AC_KERNEL_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
608f8749
BB
147 ZFS_AC_KERNEL_RWSEM
148 ZFS_AC_KERNEL_SCHED
93ce2b4c 149 ZFS_AC_KERNEL_USLEEP_RANGE
608f8749 150 ZFS_AC_KERNEL_KMEM_CACHE
66955885 151 ZFS_AC_KERNEL_KVMALLOC
080102a1 152 ZFS_AC_KERNEL_VMALLOC_PAGE_KERNEL
608f8749 153 ZFS_AC_KERNEL_WAIT
6413c95f 154 ZFS_AC_KERNEL_INODE_TIMES
93ce2b4c
BB
155 ZFS_AC_KERNEL_INODE_LOCK
156 ZFS_AC_KERNEL_GROUP_INFO_GID
608f8749 157 ZFS_AC_KERNEL_RW
8b8b44d0 158 ZFS_AC_KERNEL_TIMER_SETUP
938cfeb0 159 ZFS_AC_KERNEL_SUPER_USER_NS
0dd73648 160 ZFS_AC_KERNEL_PROC_OPERATIONS
608f8749 161 ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS
066e8252
BB
162 ZFS_AC_KERNEL_BIO
163 ZFS_AC_KERNEL_BLKDEV
164 ZFS_AC_KERNEL_BLK_QUEUE
19697e45 165 ZFS_AC_KERNEL_REVALIDATE_DISK
c9c0d073 166 ZFS_AC_KERNEL_GET_DISK_RO
a5e046ea 167 ZFS_AC_KERNEL_GENERIC_READLINK_GLOBAL
ee5fd0bb 168 ZFS_AC_KERNEL_DISCARD_GRANULARITY
023699cd 169 ZFS_AC_KERNEL_INODE_OWNER_OR_CAPABLE
608f8749
BB
170 ZFS_AC_KERNEL_XATTR
171 ZFS_AC_KERNEL_ACL
172 ZFS_AC_KERNEL_INODE_GETATTR
a5248129 173 ZFS_AC_KERNEL_INODE_SET_FLAGS
18f57327 174 ZFS_AC_KERNEL_INODE_SET_IVERSION
47621f3d 175 ZFS_AC_KERNEL_SHOW_OPTIONS
534759fa 176 ZFS_AC_KERNEL_FILE_INODE
d9c97ec0 177 ZFS_AC_KERNEL_FILE_DENTRY
adcd70bd 178 ZFS_AC_KERNEL_FSYNC
7ca25051 179 ZFS_AC_KERNEL_AIO_FSYNC
608f8749
BB
180 ZFS_AC_KERNEL_EVICT_INODE
181 ZFS_AC_KERNEL_DIRTY_INODE
182 ZFS_AC_KERNEL_SHRINKER
e2a82961 183 ZFS_AC_KERNEL_MKDIR
066e8252 184 ZFS_AC_KERNEL_LOOKUP_FLAGS
e2a82961 185 ZFS_AC_KERNEL_CREATE
beeed459 186 ZFS_AC_KERNEL_GET_LINK
bd29109f 187 ZFS_AC_KERNEL_PUT_LINK
ace1eae8 188 ZFS_AC_KERNEL_TMPFILE
ebe7e575 189 ZFS_AC_KERNEL_AUTOMOUNT
756c3e5a 190 ZFS_AC_KERNEL_ENCODE_FH_WITH_INODE
393b44c7 191 ZFS_AC_KERNEL_COMMIT_METADATA
739a1a82 192 ZFS_AC_KERNEL_CLEAR_INODE
3b0ba3ba 193 ZFS_AC_KERNEL_SETATTR_PREPARE
bdf4328b 194 ZFS_AC_KERNEL_INSERT_INODE_LOCKED
608f8749 195 ZFS_AC_KERNEL_DENTRY
b3129792 196 ZFS_AC_KERNEL_TRUNCATE_SETSIZE
608f8749 197 ZFS_AC_KERNEL_SECURITY_INODE
93b43af1 198 ZFS_AC_KERNEL_FST_MOUNT
7dae2c81 199 ZFS_AC_KERNEL_BDI
28eb9213 200 ZFS_AC_KERNEL_SET_NLINK
608f8749 201 ZFS_AC_KERNEL_SGET
802e7b5f 202 ZFS_AC_KERNEL_LSEEK_EXECUTE
608f8749
BB
203 ZFS_AC_KERNEL_VFS_GETATTR
204 ZFS_AC_KERNEL_VFS_FSYNC_2ARGS
0f37d0c8 205 ZFS_AC_KERNEL_VFS_ITERATE
a584ef26 206 ZFS_AC_KERNEL_VFS_DIRECT_IO
608f8749
BB
207 ZFS_AC_KERNEL_VFS_RW_ITERATE
208 ZFS_AC_KERNEL_VFS_GENERIC_WRITE_CHECKS
1c2358c1 209 ZFS_AC_KERNEL_VFS_IOV_ITER
17888ae3 210 ZFS_AC_KERNEL_KMAP_ATOMIC_ARGS
278bee93 211 ZFS_AC_KERNEL_FOLLOW_DOWN_ONE
37f9dac5 212 ZFS_AC_KERNEL_MAKE_REQUEST_FN
608f8749 213 ZFS_AC_KERNEL_GENERIC_IO_ACCT
fc0c72b1 214 ZFS_AC_KERNEL_FPU
608f8749
BB
215 ZFS_AC_KERNEL_FMODE_T
216 ZFS_AC_KERNEL_KUIDGID_T
82a1b2d6 217 ZFS_AC_KERNEL_KUID_HELPERS
9cc1844a 218 ZFS_AC_KERNEL_MODULE_PARAM_CALL_CONST
e2a82961 219 ZFS_AC_KERNEL_RENAME
2946a1a1 220 ZFS_AC_KERNEL_CURRENT_TIME
0e85048f 221 ZFS_AC_KERNEL_USERNS_CAPABILITIES
e897a23e 222 ZFS_AC_KERNEL_IN_COMPAT_SYSCALL
ff5587d6 223 ZFS_AC_KERNEL_KTIME
031cea17 224 ZFS_AC_KERNEL_TOTALRAM_PAGES_FUNC
de3e0b91 225 ZFS_AC_KERNEL_TOTALHIGH_PAGES
8708fd88 226 ZFS_AC_KERNEL_KSTRTOUL
ec1fea45 227 ZFS_AC_KERNEL_PERCPU
60a4c7d2 228 ZFS_AC_KERNEL_CPU_HOTPLUG
e2a82961
CK
229 ZFS_AC_KERNEL_GENERIC_FILLATTR_USERNS
230 ZFS_AC_KERNEL_MKNOD
231 ZFS_AC_KERNEL_SYMLINK
c9c0d073
BB
232])
233
234dnl #
235dnl # Detect name used for Module.symvers file in kernel
236dnl #
237AC_DEFUN([ZFS_AC_MODULE_SYMVERS], [
238 modpost=$LINUX/scripts/Makefile.modpost
239 AC_MSG_CHECKING([kernel file name for module symbols])
319a99a3 240 AS_IF([test "x$enable_linux_builtin" != xyes -a -f "$modpost"], [
8366cd6a 241 AS_IF([grep -q Modules.symvers $modpost], [
c9c0d073 242 LINUX_SYMBOLS=Modules.symvers
8366cd6a 243 ], [
c9c0d073 244 LINUX_SYMBOLS=Module.symvers
8366cd6a 245 ])
a60b1c0a 246
8366cd6a 247 AS_IF([test ! -f "$LINUX_OBJ/$LINUX_SYMBOLS"], [
a60b1c0a
BB
248 AC_MSG_ERROR([
249 *** Please make sure the kernel devel package for your distribution
608f8749
BB
250 *** is installed. If you are building with a custom kernel, make sure
251 *** the kernel is configured, built, and the '--with-linux=PATH'
252 *** configure option refers to the location of the kernel source.
253 ])
8366cd6a
PS
254 ])
255 ], [
c9c0d073 256 LINUX_SYMBOLS=NONE
8366cd6a 257 ])
c9c0d073
BB
258 AC_MSG_RESULT($LINUX_SYMBOLS)
259 AC_SUBST(LINUX_SYMBOLS)
260])
261
262dnl #
263dnl # Detect the kernel to be built against
264dnl #
265AC_DEFUN([ZFS_AC_KERNEL], [
266 AC_ARG_WITH([linux],
267 AS_HELP_STRING([--with-linux=PATH],
268 [Path to kernel source]),
269 [kernelsrc="$withval"])
270
271 AC_ARG_WITH(linux-obj,
272 AS_HELP_STRING([--with-linux-obj=PATH],
273 [Path to kernel build objects]),
274 [kernelbuild="$withval"])
275
276 AC_MSG_CHECKING([kernel source directory])
8366cd6a
PS
277 AS_IF([test -z "$kernelsrc"], [
278 AS_IF([test -e "/lib/modules/$(uname -r)/source"], [
1b94c25c
BB
279 headersdir="/lib/modules/$(uname -r)/source"
280 sourcelink=$(readlink -f "$headersdir")
8366cd6a 281 ], [test -e "/lib/modules/$(uname -r)/build"], [
1b94c25c 282 headersdir="/lib/modules/$(uname -r)/build"
c9c0d073 283 sourcelink=$(readlink -f "$headersdir")
8366cd6a 284 ], [
c9c0d073 285 sourcelink=$(ls -1d /usr/src/kernels/* \
8366cd6a 286 /usr/src/linux-* \
c9c0d073 287 2>/dev/null | grep -v obj | tail -1)
8366cd6a 288 ])
c9c0d073 289
8366cd6a 290 AS_IF([test -n "$sourcelink" && test -e ${sourcelink}], [
c9c0d073 291 kernelsrc=`readlink -f ${sourcelink}`
8366cd6a 292 ], [
56a517ae 293 kernelsrc="[Not found]"
8366cd6a
PS
294 ])
295 ], [
296 AS_IF([test "$kernelsrc" = "NONE"], [
c9c0d073 297 kernsrcver=NONE
8366cd6a 298 ])
1d8da991 299 withlinux=yes
8366cd6a 300 ])
c9c0d073
BB
301
302 AC_MSG_RESULT([$kernelsrc])
56a517ae
BB
303 AS_IF([test ! -d "$kernelsrc"], [
304 AC_MSG_ERROR([
305 *** Please make sure the kernel devel package for your distribution
4e95cc99 306 *** is installed and then try again. If that fails, you can specify the
56a517ae
BB
307 *** location of the kernel source with the '--with-linux=PATH' option.])
308 ])
309
c9c0d073 310 AC_MSG_CHECKING([kernel build directory])
8366cd6a 311 AS_IF([test -z "$kernelbuild"], [
1d8da991 312 AS_IF([test x$withlinux != xyes -a -e "/lib/modules/$(uname -r)/build"], [
1b94c25c 313 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
8366cd6a 314 ], [test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}], [
c9c0d073 315 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
8366cd6a 316 ], [test -d ${kernelsrc}-obj/${target_cpu}/default], [
70574182 317 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
8366cd6a 318 ], [test -d `dirname ${kernelsrc}`/build-${target_cpu}], [
c9c0d073 319 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
8366cd6a 320 ], [
c9c0d073 321 kernelbuild=${kernelsrc}
8366cd6a
PS
322 ])
323 ])
c9c0d073
BB
324 AC_MSG_RESULT([$kernelbuild])
325
326 AC_MSG_CHECKING([kernel source version])
327 utsrelease1=$kernelbuild/include/linux/version.h
328 utsrelease2=$kernelbuild/include/linux/utsrelease.h
329 utsrelease3=$kernelbuild/include/generated/utsrelease.h
8366cd6a 330 AS_IF([test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1], [
06346cc5 331 utsrelease=$utsrelease1
8366cd6a 332 ], [test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2], [
06346cc5 333 utsrelease=$utsrelease2
8366cd6a 334 ], [test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3], [
06346cc5 335 utsrelease=$utsrelease3
8366cd6a 336 ])
c9c0d073 337
06346cc5
BB
338 AS_IF([test -n "$utsrelease"], [
339 kernsrcver=$($AWK '/UTS_RELEASE/ { gsub(/"/, "", $[3]); print $[3] }' $utsrelease)
8366cd6a 340 AS_IF([test -z "$kernsrcver"], [
c9c0d073 341 AC_MSG_RESULT([Not found])
608f8749
BB
342 AC_MSG_ERROR([
343 *** Cannot determine kernel version.
344 ])
8366cd6a
PS
345 ])
346 ], [
c9c0d073 347 AC_MSG_RESULT([Not found])
319a99a3 348 if test "x$enable_linux_builtin" != xyes; then
608f8749
BB
349 AC_MSG_ERROR([
350 *** Cannot find UTS_RELEASE definition.
351 ])
319a99a3
ED
352 else
353 AC_MSG_ERROR([
354 *** Cannot find UTS_RELEASE definition.
355 *** Please run 'make prepare' inside the kernel source tree.])
356 fi
8366cd6a 357 ])
c9c0d073
BB
358
359 AC_MSG_RESULT([$kernsrcver])
360
066e8252
BB
361 AS_VERSION_COMPARE([$kernsrcver], [$ZFS_META_KVER_MIN], [
362 AC_MSG_ERROR([
363 *** Cannot build against kernel version $kernsrcver.
364 *** The minimum supported kernel version is $ZFS_META_KVER_MIN.
365 ])
366 ])
367
c9c0d073
BB
368 LINUX=${kernelsrc}
369 LINUX_OBJ=${kernelbuild}
370 LINUX_VERSION=${kernsrcver}
371
372 AC_SUBST(LINUX)
373 AC_SUBST(LINUX_OBJ)
374 AC_SUBST(LINUX_VERSION)
375
376 ZFS_AC_MODULE_SYMVERS
377])
378
6a9d6359 379dnl #
608f8749
BB
380dnl # Detect the QAT module to be built against, QAT provides hardware
381dnl # acceleration for data compression:
382dnl #
383dnl # https://01.org/intel-quickassist-technology
384dnl #
385dnl # 1) Download and install QAT driver from the above link
386dnl # 2) Start QAT driver in your system:
387dnl # service qat_service start
388dnl # 3) Enable QAT in ZFS, e.g.:
389dnl # ./configure --with-qat=<qat-driver-path>/QAT1.6
390dnl # make
391dnl # 4) Set GZIP compression in ZFS dataset:
392dnl # zfs set compression = gzip <dataset>
393dnl #
394dnl # Then the data written to this ZFS pool is compressed by QAT accelerator
395dnl # automatically, and de-compressed by QAT when read from the pool.
396dnl #
397dnl # 1) Get QAT hardware statistics with:
398dnl # cat /proc/icp_dh895xcc_dev/qat
399dnl # 2) To disable QAT:
400dnl # insmod zfs.ko zfs_qat_disable=1
6a9d6359 401dnl #
402AC_DEFUN([ZFS_AC_QAT], [
403 AC_ARG_WITH([qat],
404 AS_HELP_STRING([--with-qat=PATH],
405 [Path to qat source]),
406 AS_IF([test "$withval" = "yes"],
407 AC_MSG_ERROR([--with-qat=PATH requires a PATH]),
408 [qatsrc="$withval"]))
409
410 AC_ARG_WITH([qat-obj],
411 AS_HELP_STRING([--with-qat-obj=PATH],
412 [Path to qat build objects]),
413 [qatbuild="$withval"])
414
415 AS_IF([test ! -z "${qatsrc}"], [
416 AC_MSG_CHECKING([qat source directory])
417 AC_MSG_RESULT([$qatsrc])
418 QAT_SRC="${qatsrc}/quickassist"
419 AS_IF([ test ! -e "$QAT_SRC/include/cpa.h"], [
420 AC_MSG_ERROR([
608f8749
BB
421 *** Please make sure the qat driver package is installed
422 *** and specify the location of the qat source with the
423 *** '--with-qat=PATH' option then try again. Failed to
424 *** find cpa.h in:
425 ${QAT_SRC}/include])
6a9d6359 426 ])
427 ])
428
429 AS_IF([test ! -z "${qatsrc}"], [
430 AC_MSG_CHECKING([qat build directory])
431 AS_IF([test -z "$qatbuild"], [
432 qatbuild="${qatsrc}/build"
433 ])
434
435 AC_MSG_RESULT([$qatbuild])
436 QAT_OBJ=${qatbuild}
1cfdb0e6 437 AS_IF([ ! test -e "$QAT_OBJ/icp_qa_al.ko" && ! test -e "$QAT_OBJ/qat_api.ko"], [
6a9d6359 438 AC_MSG_ERROR([
608f8749
BB
439 *** Please make sure the qat driver is installed then try again.
440 *** Failed to find icp_qa_al.ko or qat_api.ko in:
441 $QAT_OBJ])
6a9d6359 442 ])
443
444 AC_SUBST(QAT_SRC)
445 AC_SUBST(QAT_OBJ)
446
447 AC_DEFINE(HAVE_QAT, 1,
448 [qat is enabled and existed])
449 ])
450
451 dnl #
452 dnl # Detect the name used for the QAT Module.symvers file.
453 dnl #
454 AS_IF([test ! -z "${qatsrc}"], [
455 AC_MSG_CHECKING([qat file for module symbols])
456 QAT_SYMBOLS=$QAT_SRC/lookaside/access_layer/src/Module.symvers
457
458 AS_IF([test -r $QAT_SYMBOLS], [
459 AC_MSG_RESULT([$QAT_SYMBOLS])
460 AC_SUBST(QAT_SYMBOLS)
461 ],[
608f8749
BB
462 AC_MSG_ERROR([
463 *** Please make sure the qat driver is installed then try again.
464 *** Failed to find Module.symvers in:
465 $QAT_SYMBOLS
6a9d6359 466 ])
467 ])
468 ])
469])
470
319a99a3
ED
471dnl #
472dnl # Basic toolchain sanity check.
473dnl #
608f8749 474AC_DEFUN([ZFS_AC_KERNEL_TEST_MODULE], [
e33045ee 475 AC_MSG_CHECKING([whether modules can be built])
608f8749 476 ZFS_LINUX_TRY_COMPILE([], [], [
319a99a3
ED
477 AC_MSG_RESULT([yes])
478 ],[
479 AC_MSG_RESULT([no])
480 if test "x$enable_linux_builtin" != xyes; then
608f8749
BB
481 AC_MSG_ERROR([
482 *** Unable to build an empty module.
483 ])
319a99a3
ED
484 else
485 AC_MSG_ERROR([
486 *** Unable to build an empty module.
487 *** Please run 'make scripts' inside the kernel source tree.])
488 fi
489 ])
490])
491
15805c77 492dnl #
608f8749 493dnl # ZFS_LINUX_CONFTEST_H
15805c77 494dnl #
608f8749
BB
495AC_DEFUN([ZFS_LINUX_CONFTEST_H], [
496test -d build/$2 || mkdir -p build/$2
497cat - <<_ACEOF >build/$2/$2.h
498$1
499_ACEOF
500])
e5b85622 501
608f8749
BB
502dnl #
503dnl # ZFS_LINUX_CONFTEST_C
504dnl #
505AC_DEFUN([ZFS_LINUX_CONFTEST_C], [
506test -d build/$2 || mkdir -p build/$2
507cat confdefs.h - <<_ACEOF >build/$2/$2.c
508$1
509_ACEOF
e5b85622
BB
510])
511
b58986ee 512dnl #
608f8749 513dnl # ZFS_LINUX_CONFTEST_MAKEFILE
b58986ee 514dnl #
608f8749
BB
515dnl # $1 - test case name
516dnl # $2 - add to top-level Makefile
517dnl # $3 - additional build flags
b58986ee 518dnl #
608f8749
BB
519AC_DEFUN([ZFS_LINUX_CONFTEST_MAKEFILE], [
520 test -d build || mkdir -p build
521 test -d build/$1 || mkdir -p build/$1
522
523 file=build/$1/Makefile
524
525 dnl # Example command line to manually build source.
526 cat - <<_ACEOF >$file
527# Example command line to manually build source
528# make modules -C $LINUX_OBJ $ARCH_UM M=$PWD/build/$1
529
530ccflags-y := -Werror $FRAME_LARGER_THAN
531_ACEOF
532
533 dnl # Additional custom CFLAGS as requested.
534 m4_ifval($3, [echo "ccflags-y += $3" >>$file], [])
535
536 dnl # Test case source
537 echo "obj-m := $1.o" >>$file
538
539 AS_IF([test "x$2" = "xyes"], [echo "obj-m += $1/" >>build/Makefile], [])
b58986ee
BB
540])
541
e5b85622 542dnl #
608f8749 543dnl # ZFS_LINUX_TEST_PROGRAM(C)([PROLOGUE], [BODY])
e5b85622 544dnl #
608f8749 545m4_define([ZFS_LINUX_TEST_PROGRAM], [
c347fac5 546#include <linux/module.h>
608f8749 547$1
c347fac5 548
608f8749
BB
549int
550main (void)
551{
552$2
553 ;
554 return 0;
555}
c347fac5
BB
556
557MODULE_DESCRIPTION("conftest");
558MODULE_AUTHOR(ZFS_META_AUTHOR);
559MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE);
560MODULE_LICENSE($3);
608f8749
BB
561])
562
e5b85622 563dnl #
608f8749 564dnl # ZFS_LINUX_TEST_REMOVE
e5b85622 565dnl #
608f8749
BB
566dnl # Removes the specified test source and results.
567dnl #
568AC_DEFUN([ZFS_LINUX_TEST_REMOVE], [
569 test -d build/$1 && rm -Rf build/$1
570 test -f build/Makefile && sed '/$1/d' build/Makefile
571])
e5b85622 572
608f8749
BB
573dnl #
574dnl # ZFS_LINUX_COMPILE
575dnl #
576dnl # $1 - build dir
577dnl # $2 - test command
578dnl # $3 - pass command
579dnl # $4 - fail command
580dnl # $5 - set KBUILD_MODPOST_NOFINAL='yes'
581dnl # $6 - set KBUILD_MODPOST_WARN='yes'
582dnl #
583dnl # Used internally by ZFS_LINUX_TEST_{COMPILE,MODPOST}
584dnl #
585AC_DEFUN([ZFS_LINUX_COMPILE], [
586 AC_TRY_COMMAND([
587 KBUILD_MODPOST_NOFINAL="$5" KBUILD_MODPOST_WARN="$6"
588 make modules -k -j$TEST_JOBS -C $LINUX_OBJ $ARCH_UM
db0ad393 589 M=$PWD/$1 >$1/build.log 2>&1])
608f8749 590 AS_IF([AC_TRY_COMMAND([$2])], [$3], [$4])
c9c0d073
BB
591])
592
593dnl #
608f8749 594dnl # ZFS_LINUX_TEST_COMPILE
93ce2b4c 595dnl #
608f8749 596dnl # Perform a full compile excluding the final modpost phase.
93ce2b4c 597dnl #
608f8749
BB
598AC_DEFUN([ZFS_LINUX_TEST_COMPILE], [
599 ZFS_LINUX_COMPILE([$2], [test -f $2/build.log], [
600 mv $2/Makefile $2/Makefile.compile.$1
601 mv $2/build.log $2/build.log.$1
93ce2b4c 602 ],[
608f8749
BB
603 AC_MSG_ERROR([
604 *** Unable to compile test source to determine kernel interfaces.])
605 ], [yes], [])
93ce2b4c
BB
606])
607
608dnl #
608f8749 609dnl # ZFS_LINUX_TEST_MODPOST
c9c0d073 610dnl #
608f8749
BB
611dnl # Perform a full compile including the modpost phase. This may
612dnl # be an incremental build if the objects have already been built.
613dnl #
614AC_DEFUN([ZFS_LINUX_TEST_MODPOST], [
615 ZFS_LINUX_COMPILE([$2], [test -f $2/build.log], [
616 mv $2/Makefile $2/Makefile.modpost.$1
617 cat $2/build.log >>build/build.log.$1
618 ],[
619 AC_MSG_ERROR([
620 *** Unable to modpost test source to determine kernel interfaces.])
621 ], [], [yes])
0b39b9f9
PS
622])
623
624dnl #
608f8749 625dnl # Perform the compilation of the test cases in two phases.
0b39b9f9 626dnl #
608f8749
BB
627dnl # Phase 1) attempt to build the object files for all of the tests
628dnl # defined by the ZFS_LINUX_TEST_SRC macro. But do not
629dnl # perform the final modpost stage.
630dnl #
631dnl # Phase 2) disable all tests which failed the initial compilation,
632dnl # then invoke the final modpost step for the remaining tests.
633dnl #
634dnl # This allows us efficiently build the test cases in parallel while
635dnl # remaining resilient to build failures which are expected when
636dnl # detecting the available kernel interfaces.
637dnl #
638dnl # The maximum allowed parallelism can be controlled by setting the
639dnl # TEST_JOBS environment variable. Otherwise, it default to $(nproc).
640dnl #
641AC_DEFUN([ZFS_LINUX_TEST_COMPILE_ALL], [
642 dnl # Phase 1 - Compilation only, final linking is skipped.
643 ZFS_LINUX_TEST_COMPILE([$1], [build])
644
645 dnl #
646 dnl # Phase 2 - When building external modules disable test cases
647 dnl # which failed to compile and invoke modpost to verify the
648 dnl # final linking.
649 dnl #
650 dnl # Test names suffixed with '_license' call modpost independently
651 dnl # to ensure that a single incompatibility does not result in the
652 dnl # modpost phase exiting early. This check is not performed on
653 dnl # every symbol since the majority are compatible and doing so
654 dnl # would significantly slow down this phase.
655 dnl #
656 dnl # When configuring for builtin (--enable-linux-builtin)
657 dnl # fake the linking step artificially create the expected .ko
658 dnl # files for tests which did compile. This is required for
659 dnl # kernels which do not have loadable module support or have
660 dnl # not yet been built.
661 dnl #
662 AS_IF([test "x$enable_linux_builtin" = "xno"], [
663 for dir in $(awk '/^obj-m/ { print [$]3 }' \
664 build/Makefile.compile.$1); do
665 name=${dir%/}
666 AS_IF([test -f build/$name/$name.o], [
667 AS_IF([test "${name##*_}" = "license"], [
668 ZFS_LINUX_TEST_MODPOST([$1],
669 [build/$name])
670 echo "obj-n += $dir" >>build/Makefile
671 ], [
672 echo "obj-m += $dir" >>build/Makefile
673 ])
674 ], [
675 echo "obj-n += $dir" >>build/Makefile
676 ])
677 done
678
679 ZFS_LINUX_TEST_MODPOST([$1], [build])
680 ], [
681 for dir in $(awk '/^obj-m/ { print [$]3 }' \
682 build/Makefile.compile.$1); do
683 name=${dir%/}
684 AS_IF([test -f build/$name/$name.o], [
685 touch build/$name/$name.ko
686 ])
687 done
688 ])
c9c0d073
BB
689])
690
691dnl #
608f8749 692dnl # ZFS_LINUX_TEST_SRC
c9c0d073 693dnl #
608f8749
BB
694dnl # $1 - name
695dnl # $2 - global
696dnl # $3 - source
697dnl # $4 - extra cflags
698dnl # $5 - check license-compatibility
699dnl #
c347fac5
BB
700dnl # Check if the test source is buildable at all and then if it is
701dnl # license compatible.
702dnl #
608f8749
BB
703dnl # N.B because all of the test cases are compiled in parallel they
704dnl # must never depend on the results of previous tests. Each test
705dnl # needs to be entirely independent.
706dnl #
707AC_DEFUN([ZFS_LINUX_TEST_SRC], [
c347fac5
BB
708 ZFS_LINUX_CONFTEST_C([ZFS_LINUX_TEST_PROGRAM([[$2]], [[$3]],
709 [["Dual BSD/GPL"]])], [$1])
608f8749
BB
710 ZFS_LINUX_CONFTEST_MAKEFILE([$1], [yes], [$4])
711
712 AS_IF([ test -n "$5" ], [
c347fac5
BB
713 ZFS_LINUX_CONFTEST_C([ZFS_LINUX_TEST_PROGRAM(
714 [[$2]], [[$3]], [[$5]])], [$1_license])
608f8749
BB
715 ZFS_LINUX_CONFTEST_MAKEFILE([$1_license], [yes], [$4])
716 ])
c9c0d073
BB
717])
718
719dnl #
608f8749 720dnl # ZFS_LINUX_TEST_RESULT
c9c0d073 721dnl #
608f8749
BB
722dnl # $1 - name of a test source (ZFS_LINUX_TEST_SRC)
723dnl # $2 - run on success (valid .ko generated)
724dnl # $3 - run on failure (unable to compile)
725dnl #
726AC_DEFUN([ZFS_LINUX_TEST_RESULT], [
727 AS_IF([test -d build/$1], [
728 AS_IF([test -f build/$1/$1.ko], [$2], [$3])
729 ], [
730 AC_MSG_ERROR([
731 *** No matching source for the "$1" test, check that
732 *** both the test source and result macros refer to the same name.
733 ])
734 ])
c9c0d073
BB
735])
736
737dnl #
608f8749 738dnl # ZFS_LINUX_TEST_ERROR
c9c0d073 739dnl #
608f8749
BB
740dnl # Generic error message which can be used when none of the expected
741dnl # kernel interfaces were detected.
742dnl #
743AC_DEFUN([ZFS_LINUX_TEST_ERROR], [
744 AC_MSG_ERROR([
745 *** None of the expected "$1" interfaces were detected.
746 *** This may be because your kernel version is newer than what is
747 *** supported, or you are using a patched custom kernel with
748 *** incompatible modifications.
749 ***
750 *** ZFS Version: $ZFS_META_ALIAS
751 *** Compatible Kernels: $ZFS_META_KVER_MIN - $ZFS_META_KVER_MAX
752 ])
c9c0d073
BB
753])
754
755dnl #
608f8749 756dnl # ZFS_LINUX_TEST_RESULT_SYMBOL
c9c0d073 757dnl #
608f8749
BB
758dnl # Like ZFS_LINUX_TEST_RESULT except ZFS_CHECK_SYMBOL_EXPORT is called to
759dnl # verify symbol exports, unless --enable-linux-builtin was provided to
760dnl # configure.
761dnl #
762AC_DEFUN([ZFS_LINUX_TEST_RESULT_SYMBOL], [
763 AS_IF([ ! test -f build/$1/$1.ko], [
764 $5
765 ], [
766 AS_IF([test "x$enable_linux_builtin" != "xyes"], [
767 ZFS_CHECK_SYMBOL_EXPORT([$2], [$3], [$4], [$5])
768 ], [
769 $4
770 ])
c9c0d073
BB
771 ])
772])
773
608f8749
BB
774dnl #
775dnl # ZFS_LINUX_COMPILE_IFELSE
776dnl #
777AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [
778 ZFS_LINUX_TEST_REMOVE([conftest])
779
780 m4_ifvaln([$1], [ZFS_LINUX_CONFTEST_C([$1], [conftest])])
781 m4_ifvaln([$5], [ZFS_LINUX_CONFTEST_H([$5], [conftest])],
782 [ZFS_LINUX_CONFTEST_H([], [conftest])])
783
784 ZFS_LINUX_CONFTEST_MAKEFILE([conftest], [no],
785 [m4_ifvaln([$5], [-I$PWD/build/conftest], [])])
786 ZFS_LINUX_COMPILE([build/conftest], [$2], [$3], [$4], [], [])
787])
788
789dnl #
790dnl # ZFS_LINUX_TRY_COMPILE
791dnl #
792dnl # $1 - global
793dnl # $2 - source
794dnl # $3 - run on success (valid .ko generated)
795dnl # $4 - run on failure (unable to compile)
796dnl #
3f99a3ab
BB
797dnl # When configuring as builtin (--enable-linux-builtin) for kernels
798dnl # without loadable module support (CONFIG_MODULES=n) only the object
799dnl # file is created. See ZFS_LINUX_TEST_COMPILE_ALL for details.
800dnl #
608f8749 801AC_DEFUN([ZFS_LINUX_TRY_COMPILE], [
3f99a3ab
BB
802 AS_IF([test "x$enable_linux_builtin" = "xyes"], [
803 ZFS_LINUX_COMPILE_IFELSE(
c347fac5
BB
804 [ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]],
805 [[ZFS_META_LICENSE]])],
3f99a3ab
BB
806 [test -f build/conftest/conftest.o], [$3], [$4])
807 ], [
808 ZFS_LINUX_COMPILE_IFELSE(
c347fac5
BB
809 [ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]],
810 [[ZFS_META_LICENSE]])],
3f99a3ab
BB
811 [test -f build/conftest/conftest.ko], [$3], [$4])
812 ])
608f8749
BB
813])
814
c9c0d073
BB
815dnl #
816dnl # ZFS_CHECK_SYMBOL_EXPORT
608f8749
BB
817dnl #
818dnl # Check if a symbol is exported on not by consulting the symbols
819dnl # file, or optionally the source code.
c9c0d073 820dnl #
70574182 821AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT], [
c9c0d073
BB
822 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
823 $LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null
824 rc=$?
70574182 825 if test $rc -ne 0; then
c9c0d073
BB
826 export=0
827 for file in $2; do
70574182
ED
828 grep -q -E "EXPORT_SYMBOL.*($1)" \
829 "$LINUX/$file" 2>/dev/null
c9c0d073 830 rc=$?
70574182 831 if test $rc -eq 0; then
8366cd6a
PS
832 export=1
833 break;
70574182 834 fi
c9c0d073 835 done
70574182 836 if test $export -eq 0; then :
c9c0d073 837 $4
70574182 838 else :
c9c0d073 839 $3
70574182
ED
840 fi
841 else :
c9c0d073 842 $3
70574182
ED
843 fi
844])
845
846dnl #
847dnl # ZFS_LINUX_TRY_COMPILE_SYMBOL
608f8749
BB
848dnl #
849dnl # Like ZFS_LINUX_TRY_COMPILER except ZFS_CHECK_SYMBOL_EXPORT is called
850dnl # to verify symbol exports, unless --enable-linux-builtin was provided
851dnl # to configure.
70574182
ED
852dnl #
853AC_DEFUN([ZFS_LINUX_TRY_COMPILE_SYMBOL], [
854 ZFS_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
855 if test $rc -ne 0; then :
856 $6
857 else
858 if test "x$enable_linux_builtin" != xyes; then
859 ZFS_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
860 fi
861 if test $rc -ne 0; then :
862 $6
863 else :
864 $5
865 fi
866 fi
c9c0d073 867])
0b39b9f9
PS
868
869dnl #
870dnl # ZFS_LINUX_TRY_COMPILE_HEADER
871dnl # like ZFS_LINUX_TRY_COMPILE, except the contents conftest.h are
872dnl # provided via the fifth parameter
873dnl #
608f8749
BB
874AC_DEFUN([ZFS_LINUX_TRY_COMPILE_HEADER], [
875 ZFS_LINUX_COMPILE_IFELSE(
c347fac5 876 [ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]], [[ZFS_META_LICENSE]])],
608f8749
BB
877 [test -f build/conftest/conftest.ko],
878 [$3], [$4], [$5])
0b39b9f9 879])