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