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