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