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