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_CONFIG_DEFINED 12 ZFS_AC_MODULE_SYMVERS 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_MISC_MINOR 18 ZFS_AC_KERNEL_DECLARE_EVENT_CLASS 19 20 dnl # Parallel ZFS_LINUX_TEST_SRC / ZFS_LINUX_TEST_RESULT tests 21 ZFS_AC_KERNEL_TEST_SRC 22 ZFS_AC_KERNEL_TEST_RESULT 23 24 AS_IF([test "$LINUX_OBJ" != "$LINUX"], [ 25 KERNEL_MAKE="$KERNEL_MAKE O=$LINUX_OBJ" 26 ]) 27 28 AC_SUBST(KERNEL_MAKE) 29 ]) 30]) 31 32dnl # 33dnl # Generate and compile all of the kernel API test cases to determine 34dnl # which interfaces are available. By invoking the kernel build system 35dnl # only once the compilation can be done in parallel significantly 36dnl # speeding up the process. 37dnl # 38AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ 39 ZFS_AC_KERNEL_SRC_TYPES 40 ZFS_AC_KERNEL_SRC_OBJTOOL 41 ZFS_AC_KERNEL_SRC_ACCESS_OK_TYPE 42 ZFS_AC_KERNEL_SRC_PDE_DATA 43 ZFS_AC_KERNEL_SRC_GENERIC_FADVISE 44 ZFS_AC_KERNEL_SRC_SCHED 45 ZFS_AC_KERNEL_SRC_USLEEP_RANGE 46 ZFS_AC_KERNEL_SRC_VMALLOC_PAGE_KERNEL 47 ZFS_AC_KERNEL_SRC_INODE_TIMES 48 ZFS_AC_KERNEL_SRC_PROC_OPERATIONS 49 ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS 50 ZFS_AC_KERNEL_SRC_BIO 51 ZFS_AC_KERNEL_SRC_BLKDEV 52 ZFS_AC_KERNEL_SRC_BLK_QUEUE 53 ZFS_AC_KERNEL_SRC_GENHD_FLAGS 54 ZFS_AC_KERNEL_SRC_REVALIDATE_DISK 55 ZFS_AC_KERNEL_SRC_GET_DISK_RO 56 ZFS_AC_KERNEL_SRC_DISCARD_GRANULARITY 57 ZFS_AC_KERNEL_SRC_INODE_OWNER_OR_CAPABLE 58 ZFS_AC_KERNEL_SRC_XATTR 59 ZFS_AC_KERNEL_SRC_ACL 60 ZFS_AC_KERNEL_SRC_INODE_SETATTR 61 ZFS_AC_KERNEL_SRC_INODE_GETATTR 62 ZFS_AC_KERNEL_SRC_SHOW_OPTIONS 63 ZFS_AC_KERNEL_SRC_SHRINKER 64 ZFS_AC_KERNEL_SRC_MKDIR 65 ZFS_AC_KERNEL_SRC_LOOKUP_FLAGS 66 ZFS_AC_KERNEL_SRC_CREATE 67 ZFS_AC_KERNEL_SRC_PERMISSION 68 ZFS_AC_KERNEL_SRC_TMPFILE 69 ZFS_AC_KERNEL_SRC_AUTOMOUNT 70 ZFS_AC_KERNEL_SRC_COMMIT_METADATA 71 ZFS_AC_KERNEL_SRC_SETATTR_PREPARE 72 ZFS_AC_KERNEL_SRC_INSERT_INODE_LOCKED 73 ZFS_AC_KERNEL_SRC_TRUNCATE_SETSIZE 74 ZFS_AC_KERNEL_SRC_SECURITY_INODE 75 ZFS_AC_KERNEL_SRC_FST_MOUNT 76 ZFS_AC_KERNEL_SRC_SET_NLINK 77 ZFS_AC_KERNEL_SRC_SGET 78 ZFS_AC_KERNEL_SRC_VFS_FILEMAP_DIRTY_FOLIO 79 ZFS_AC_KERNEL_SRC_VFS_READ_FOLIO 80 ZFS_AC_KERNEL_SRC_VFS_FSYNC_2ARGS 81 ZFS_AC_KERNEL_SRC_VFS_DIRECT_IO 82 ZFS_AC_KERNEL_SRC_VFS_READPAGES 83 ZFS_AC_KERNEL_SRC_VFS_SET_PAGE_DIRTY_NOBUFFERS 84 ZFS_AC_KERNEL_SRC_VFS_IOV_ITER 85 ZFS_AC_KERNEL_SRC_VFS_GENERIC_COPY_FILE_RANGE 86 ZFS_AC_KERNEL_SRC_VFS_SPLICE_COPY_FILE_RANGE 87 ZFS_AC_KERNEL_SRC_VFS_REMAP_FILE_RANGE 88 ZFS_AC_KERNEL_SRC_VFS_CLONE_FILE_RANGE 89 ZFS_AC_KERNEL_SRC_VFS_DEDUPE_FILE_RANGE 90 ZFS_AC_KERNEL_SRC_KMAP_ATOMIC_ARGS 91 ZFS_AC_KERNEL_SRC_KMAP_LOCAL_PAGE 92 ZFS_AC_KERNEL_SRC_FOLLOW_DOWN_ONE 93 ZFS_AC_KERNEL_SRC_MAKE_REQUEST_FN 94 ZFS_AC_KERNEL_SRC_GENERIC_IO_ACCT 95 ZFS_AC_KERNEL_SRC_FPU 96 ZFS_AC_KERNEL_SRC_FMODE_T 97 ZFS_AC_KERNEL_SRC_KUIDGID_T 98 ZFS_AC_KERNEL_SRC_KUID_HELPERS 99 ZFS_AC_KERNEL_SRC_RENAME 100 ZFS_AC_KERNEL_SRC_TOTALRAM_PAGES_FUNC 101 ZFS_AC_KERNEL_SRC_TOTALHIGH_PAGES 102 ZFS_AC_KERNEL_SRC_PERCPU 103 ZFS_AC_KERNEL_SRC_GENERIC_FILLATTR 104 ZFS_AC_KERNEL_SRC_MKNOD 105 ZFS_AC_KERNEL_SRC_SYMLINK 106 ZFS_AC_KERNEL_SRC_BIO_MAX_SEGS 107 ZFS_AC_KERNEL_SRC_SIGINFO 108 ZFS_AC_KERNEL_SRC_SYSFS 109 ZFS_AC_KERNEL_SRC_STANDALONE_LINUX_STDARG 110 ZFS_AC_KERNEL_SRC_STRLCPY 111 ZFS_AC_KERNEL_SRC_PAGEMAP_FOLIO_WAIT_BIT 112 ZFS_AC_KERNEL_SRC_ADD_DISK 113 ZFS_AC_KERNEL_SRC_KTHREAD 114 ZFS_AC_KERNEL_SRC_ZERO_PAGE 115 ZFS_AC_KERNEL_SRC___COPY_FROM_USER_INATOMIC 116 ZFS_AC_KERNEL_SRC_IDMAP_MNT_API 117 ZFS_AC_KERNEL_SRC_IDMAP_NO_USERNS 118 ZFS_AC_KERNEL_SRC_IATTR_VFSID 119 ZFS_AC_KERNEL_SRC_WRITEPAGE_T 120 ZFS_AC_KERNEL_SRC_RECLAIMED 121 ZFS_AC_KERNEL_SRC_REGISTER_SYSCTL_TABLE 122 ZFS_AC_KERNEL_SRC_REGISTER_SYSCTL_SZ 123 ZFS_AC_KERNEL_SRC_PROC_HANDLER_CTL_TABLE_CONST 124 ZFS_AC_KERNEL_SRC_COPY_SPLICE_READ 125 ZFS_AC_KERNEL_SRC_SYNC_BDEV 126 ZFS_AC_KERNEL_SRC_MM_PAGE_FLAGS 127 ZFS_AC_KERNEL_SRC_MM_PAGE_SIZE 128 ZFS_AC_KERNEL_SRC_MM_PAGE_MAPPING 129 ZFS_AC_KERNEL_SRC_FILE 130 case "$host_cpu" in 131 powerpc*) 132 ZFS_AC_KERNEL_SRC_CPU_HAS_FEATURE 133 ZFS_AC_KERNEL_SRC_FLUSH_DCACHE_PAGE 134 ;; 135 riscv*) 136 ZFS_AC_KERNEL_SRC_FLUSH_DCACHE_PAGE 137 ;; 138 esac 139 140 AC_MSG_CHECKING([for available kernel interfaces]) 141 ZFS_LINUX_TEST_COMPILE_ALL([kabi]) 142 AC_MSG_RESULT([done]) 143]) 144 145dnl # 146dnl # Check results of kernel interface tests. 147dnl # 148AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ 149 ZFS_AC_KERNEL_TYPES 150 ZFS_AC_KERNEL_ACCESS_OK_TYPE 151 ZFS_AC_KERNEL_OBJTOOL 152 ZFS_AC_KERNEL_PDE_DATA 153 ZFS_AC_KERNEL_GENERIC_FADVISE 154 ZFS_AC_KERNEL_SCHED 155 ZFS_AC_KERNEL_USLEEP_RANGE 156 ZFS_AC_KERNEL_VMALLOC_PAGE_KERNEL 157 ZFS_AC_KERNEL_INODE_TIMES 158 ZFS_AC_KERNEL_PROC_OPERATIONS 159 ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS 160 ZFS_AC_KERNEL_BIO 161 ZFS_AC_KERNEL_BLKDEV 162 ZFS_AC_KERNEL_BLK_QUEUE 163 ZFS_AC_KERNEL_GENHD_FLAGS 164 ZFS_AC_KERNEL_REVALIDATE_DISK 165 ZFS_AC_KERNEL_GET_DISK_RO 166 ZFS_AC_KERNEL_DISCARD_GRANULARITY 167 ZFS_AC_KERNEL_INODE_OWNER_OR_CAPABLE 168 ZFS_AC_KERNEL_XATTR 169 ZFS_AC_KERNEL_ACL 170 ZFS_AC_KERNEL_INODE_SETATTR 171 ZFS_AC_KERNEL_INODE_GETATTR 172 ZFS_AC_KERNEL_SHOW_OPTIONS 173 ZFS_AC_KERNEL_SHRINKER 174 ZFS_AC_KERNEL_MKDIR 175 ZFS_AC_KERNEL_LOOKUP_FLAGS 176 ZFS_AC_KERNEL_CREATE 177 ZFS_AC_KERNEL_PERMISSION 178 ZFS_AC_KERNEL_TMPFILE 179 ZFS_AC_KERNEL_AUTOMOUNT 180 ZFS_AC_KERNEL_COMMIT_METADATA 181 ZFS_AC_KERNEL_SETATTR_PREPARE 182 ZFS_AC_KERNEL_INSERT_INODE_LOCKED 183 ZFS_AC_KERNEL_TRUNCATE_SETSIZE 184 ZFS_AC_KERNEL_SECURITY_INODE 185 ZFS_AC_KERNEL_FST_MOUNT 186 ZFS_AC_KERNEL_SET_NLINK 187 ZFS_AC_KERNEL_SGET 188 ZFS_AC_KERNEL_VFS_FILEMAP_DIRTY_FOLIO 189 ZFS_AC_KERNEL_VFS_READ_FOLIO 190 ZFS_AC_KERNEL_VFS_FSYNC_2ARGS 191 ZFS_AC_KERNEL_VFS_DIRECT_IO 192 ZFS_AC_KERNEL_VFS_READPAGES 193 ZFS_AC_KERNEL_VFS_SET_PAGE_DIRTY_NOBUFFERS 194 ZFS_AC_KERNEL_VFS_IOV_ITER 195 ZFS_AC_KERNEL_VFS_GENERIC_COPY_FILE_RANGE 196 ZFS_AC_KERNEL_VFS_SPLICE_COPY_FILE_RANGE 197 ZFS_AC_KERNEL_VFS_REMAP_FILE_RANGE 198 ZFS_AC_KERNEL_VFS_CLONE_FILE_RANGE 199 ZFS_AC_KERNEL_VFS_DEDUPE_FILE_RANGE 200 ZFS_AC_KERNEL_KMAP_ATOMIC_ARGS 201 ZFS_AC_KERNEL_KMAP_LOCAL_PAGE 202 ZFS_AC_KERNEL_FOLLOW_DOWN_ONE 203 ZFS_AC_KERNEL_MAKE_REQUEST_FN 204 ZFS_AC_KERNEL_GENERIC_IO_ACCT 205 ZFS_AC_KERNEL_FPU 206 ZFS_AC_KERNEL_FMODE_T 207 ZFS_AC_KERNEL_KUIDGID_T 208 ZFS_AC_KERNEL_KUID_HELPERS 209 ZFS_AC_KERNEL_RENAME 210 ZFS_AC_KERNEL_TOTALRAM_PAGES_FUNC 211 ZFS_AC_KERNEL_TOTALHIGH_PAGES 212 ZFS_AC_KERNEL_PERCPU 213 ZFS_AC_KERNEL_GENERIC_FILLATTR 214 ZFS_AC_KERNEL_MKNOD 215 ZFS_AC_KERNEL_SYMLINK 216 ZFS_AC_KERNEL_BIO_MAX_SEGS 217 ZFS_AC_KERNEL_SIGINFO 218 ZFS_AC_KERNEL_SYSFS 219 ZFS_AC_KERNEL_STANDALONE_LINUX_STDARG 220 ZFS_AC_KERNEL_STRLCPY 221 ZFS_AC_KERNEL_PAGEMAP_FOLIO_WAIT_BIT 222 ZFS_AC_KERNEL_ADD_DISK 223 ZFS_AC_KERNEL_KTHREAD 224 ZFS_AC_KERNEL_ZERO_PAGE 225 ZFS_AC_KERNEL___COPY_FROM_USER_INATOMIC 226 ZFS_AC_KERNEL_IDMAP_MNT_API 227 ZFS_AC_KERNEL_IDMAP_NO_USERNS 228 ZFS_AC_KERNEL_IATTR_VFSID 229 ZFS_AC_KERNEL_WRITEPAGE_T 230 ZFS_AC_KERNEL_RECLAIMED 231 ZFS_AC_KERNEL_REGISTER_SYSCTL_TABLE 232 ZFS_AC_KERNEL_REGISTER_SYSCTL_SZ 233 ZFS_AC_KERNEL_PROC_HANDLER_CTL_TABLE_CONST 234 ZFS_AC_KERNEL_COPY_SPLICE_READ 235 ZFS_AC_KERNEL_SYNC_BDEV 236 ZFS_AC_KERNEL_MM_PAGE_FLAGS 237 ZFS_AC_KERNEL_MM_PAGE_SIZE 238 ZFS_AC_KERNEL_MM_PAGE_MAPPING 239 ZFS_AC_KERNEL_1ARG_ASSIGN_STR 240 ZFS_AC_KERNEL_FILE 241 case "$host_cpu" in 242 powerpc*) 243 ZFS_AC_KERNEL_CPU_HAS_FEATURE 244 ZFS_AC_KERNEL_FLUSH_DCACHE_PAGE 245 ;; 246 riscv*) 247 ZFS_AC_KERNEL_FLUSH_DCACHE_PAGE 248 ;; 249 esac 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 && grep -qF UTS_RELEASE $utsrelease1], [ 394 utsrelease=$utsrelease1 395 ], [test -r $utsrelease2 && grep -qF UTS_RELEASE $utsrelease2], [ 396 utsrelease=$utsrelease2 397 ], [test -r $utsrelease3 && grep -qF 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 440dnl # 441dnl # Detect the QAT module to be built against, QAT provides hardware 442dnl # acceleration for data compression: 443dnl # 444dnl # https://01.org/intel-quickassist-technology 445dnl # 446dnl # 1) Download and install QAT driver from the above link 447dnl # 2) Start QAT driver in your system: 448dnl # service qat_service start 449dnl # 3) Enable QAT in ZFS, e.g.: 450dnl # ./configure --with-qat=<qat-driver-path>/QAT1.6 451dnl # make 452dnl # 4) Set GZIP compression in ZFS dataset: 453dnl # zfs set compression = gzip <dataset> 454dnl # 455dnl # Then the data written to this ZFS pool is compressed by QAT accelerator 456dnl # automatically, and de-compressed by QAT when read from the pool. 457dnl # 458dnl # 1) Get QAT hardware statistics with: 459dnl # cat /proc/icp_dh895xcc_dev/qat 460dnl # 2) To disable QAT: 461dnl # insmod zfs.ko zfs_qat_disable=1 462dnl # 463AC_DEFUN([ZFS_AC_QAT], [ 464 AC_ARG_WITH([qat], 465 AS_HELP_STRING([--with-qat=PATH], 466 [Path to qat source]), 467 AS_IF([test "$withval" = "yes"], 468 AC_MSG_ERROR([--with-qat=PATH requires a PATH]), 469 [qatsrc="$withval"])) 470 471 AC_ARG_WITH([qat-obj], 472 AS_HELP_STRING([--with-qat-obj=PATH], 473 [Path to qat build objects]), 474 [qatbuild="$withval"]) 475 476 AS_IF([test ! -z "${qatsrc}"], [ 477 AC_MSG_CHECKING([qat source directory]) 478 AC_MSG_RESULT([$qatsrc]) 479 QAT_SRC="${qatsrc}/quickassist" 480 AS_IF([ test ! -e "$QAT_SRC/include/cpa.h"], [ 481 AC_MSG_ERROR([ 482 *** Please make sure the qat driver package is installed 483 *** and specify the location of the qat source with the 484 *** '--with-qat=PATH' option then try again. Failed to 485 *** find cpa.h in: 486 ${QAT_SRC}/include]) 487 ]) 488 ]) 489 490 AS_IF([test ! -z "${qatsrc}"], [ 491 AC_MSG_CHECKING([qat build directory]) 492 AS_IF([test -z "$qatbuild"], [ 493 qatbuild="${qatsrc}/build" 494 ]) 495 496 AC_MSG_RESULT([$qatbuild]) 497 QAT_OBJ=${qatbuild} 498 AS_IF([ ! test -e "$QAT_OBJ/icp_qa_al.ko" && ! test -e "$QAT_OBJ/qat_api.ko"], [ 499 AC_MSG_ERROR([ 500 *** Please make sure the qat driver is installed then try again. 501 *** Failed to find icp_qa_al.ko or qat_api.ko in: 502 $QAT_OBJ]) 503 ]) 504 505 AC_SUBST(QAT_SRC) 506 AC_SUBST(QAT_OBJ) 507 508 AC_DEFINE(HAVE_QAT, 1, 509 [qat is enabled and existed]) 510 ]) 511 512 dnl # 513 dnl # Detect the name used for the QAT Module.symvers file. 514 dnl # 515 AS_IF([test ! -z "${qatsrc}"], [ 516 AC_MSG_CHECKING([qat file for module symbols]) 517 QAT_SYMBOLS=$QAT_SRC/lookaside/access_layer/src/Module.symvers 518 519 AS_IF([test -r $QAT_SYMBOLS], [ 520 AC_MSG_RESULT([$QAT_SYMBOLS]) 521 AC_SUBST(QAT_SYMBOLS) 522 ],[ 523 AC_MSG_ERROR([ 524 *** Please make sure the qat driver is installed then try again. 525 *** Failed to find Module.symvers in: 526 $QAT_SYMBOLS 527 ]) 528 ]) 529 ]) 530]) 531 532dnl # 533dnl # ZFS_LINUX_CONFTEST_H 534dnl # 535AC_DEFUN([ZFS_LINUX_CONFTEST_H], [ 536test -d build/$2 || mkdir -p build/$2 537cat - <<_ACEOF >build/$2/$2.h 538$1 539_ACEOF 540]) 541 542dnl # 543dnl # ZFS_LINUX_CONFTEST_C 544dnl # 545AC_DEFUN([ZFS_LINUX_CONFTEST_C], [ 546test -d build/$2 || mkdir -p build/$2 547cat confdefs.h - <<_ACEOF >build/$2/$2.c 548$1 549_ACEOF 550]) 551 552dnl # 553dnl # ZFS_LINUX_CONFTEST_MAKEFILE 554dnl # 555dnl # $1 - test case name 556dnl # $2 - add to top-level Makefile 557dnl # $3 - additional build flags 558dnl # 559AC_DEFUN([ZFS_LINUX_CONFTEST_MAKEFILE], [ 560 test -d build || mkdir -p build 561 test -d build/$1 || mkdir -p build/$1 562 563 file=build/$1/Makefile 564 565 dnl # Example command line to manually build source. 566 cat - <<_ACEOF >$file 567# Example command line to manually build source 568# make modules -C $LINUX_OBJ $ARCH_UM M=$PWD/build/$1 569 570ccflags-y := -Werror $FRAME_LARGER_THAN 571_ACEOF 572 573 dnl # Additional custom CFLAGS as requested. 574 m4_ifval($3, [echo "ccflags-y += $3" >>$file], []) 575 576 dnl # Test case source 577 echo "obj-m := $1.o" >>$file 578 579 AS_IF([test "x$2" = "xyes"], [echo "obj-m += $1/" >>build/Makefile], []) 580]) 581 582dnl # 583dnl # ZFS_LINUX_TEST_PROGRAM(C)([PROLOGUE], [BODY]) 584dnl # 585m4_define([ZFS_LINUX_TEST_PROGRAM], [ 586#include <linux/module.h> 587$1 588 589int 590main (void) 591{ 592$2 593 ; 594 return 0; 595} 596 597MODULE_DESCRIPTION("conftest"); 598MODULE_AUTHOR(ZFS_META_AUTHOR); 599MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); 600MODULE_LICENSE($3); 601]) 602 603dnl # 604dnl # ZFS_LINUX_TEST_REMOVE 605dnl # 606dnl # Removes the specified test source and results. 607dnl # 608AC_DEFUN([ZFS_LINUX_TEST_REMOVE], [ 609 test -d build/$1 && rm -Rf build/$1 610 test -f build/Makefile && sed '/$1/d' build/Makefile 611]) 612 613dnl # 614dnl # ZFS_LINUX_COMPILE 615dnl # 616dnl # $1 - build dir 617dnl # $2 - test command 618dnl # $3 - pass command 619dnl # $4 - fail command 620dnl # $5 - set KBUILD_MODPOST_NOFINAL='yes' 621dnl # $6 - set KBUILD_MODPOST_WARN='yes' 622dnl # 623dnl # Used internally by ZFS_LINUX_TEST_{COMPILE,MODPOST} 624dnl # 625AC_DEFUN([ZFS_LINUX_COMPILE], [ 626 AC_ARG_VAR([KERNEL_CC], [C compiler for 627 building kernel modules]) 628 AC_ARG_VAR([KERNEL_LD], [Linker for 629 building kernel modules]) 630 AC_ARG_VAR([KERNEL_LLVM], [Binary option to 631 build kernel modules with LLVM/CLANG toolchain]) 632 AC_TRY_COMMAND([ 633 KBUILD_MODPOST_NOFINAL="$5" KBUILD_MODPOST_WARN="$6" 634 make modules -k -j$TEST_JOBS ${KERNEL_CC:+CC=$KERNEL_CC} 635 ${KERNEL_LD:+LD=$KERNEL_LD} ${KERNEL_LLVM:+LLVM=$KERNEL_LLVM} 636 CONFIG_MODULES=y CFLAGS_MODULE=-DCONFIG_MODULES 637 -C $LINUX_OBJ $ARCH_UM M=$PWD/$1 >$1/build.log 2>&1]) 638 AS_IF([AC_TRY_COMMAND([$2])], [$3], [$4]) 639]) 640 641dnl # 642dnl # ZFS_LINUX_TEST_COMPILE 643dnl # 644dnl # Perform a full compile excluding the final modpost phase. 645dnl # 646AC_DEFUN([ZFS_LINUX_TEST_COMPILE], [ 647 ZFS_LINUX_COMPILE([$2], [test -f $2/build.log], [ 648 mv $2/Makefile $2/Makefile.compile.$1 649 mv $2/build.log $2/build.log.$1 650 ],[ 651 AC_MSG_ERROR([ 652 *** Unable to compile test source to determine kernel interfaces.]) 653 ], [yes], []) 654]) 655 656dnl # 657dnl # ZFS_LINUX_TEST_MODPOST 658dnl # 659dnl # Perform a full compile including the modpost phase. This may 660dnl # be an incremental build if the objects have already been built. 661dnl # 662AC_DEFUN([ZFS_LINUX_TEST_MODPOST], [ 663 ZFS_LINUX_COMPILE([$2], [test -f $2/build.log], [ 664 mv $2/Makefile $2/Makefile.modpost.$1 665 cat $2/build.log >>build/build.log.$1 666 ],[ 667 AC_MSG_ERROR([ 668 *** Unable to modpost test source to determine kernel interfaces.]) 669 ], [], [yes]) 670]) 671 672dnl # 673dnl # Perform the compilation of the test cases in two phases. 674dnl # 675dnl # Phase 1) attempt to build the object files for all of the tests 676dnl # defined by the ZFS_LINUX_TEST_SRC macro. But do not 677dnl # perform the final modpost stage. 678dnl # 679dnl # Phase 2) disable all tests which failed the initial compilation, 680dnl # then invoke the final modpost step for the remaining tests. 681dnl # 682dnl # This allows us efficiently build the test cases in parallel while 683dnl # remaining resilient to build failures which are expected when 684dnl # detecting the available kernel interfaces. 685dnl # 686dnl # The maximum allowed parallelism can be controlled by setting the 687dnl # TEST_JOBS environment variable. Otherwise, it default to $(nproc). 688dnl # 689AC_DEFUN([ZFS_LINUX_TEST_COMPILE_ALL], [ 690 dnl # Phase 1 - Compilation only, final linking is skipped. 691 ZFS_LINUX_TEST_COMPILE([$1], [build]) 692 693 dnl # 694 dnl # Phase 2 - When building external modules disable test cases 695 dnl # which failed to compile and invoke modpost to verify the 696 dnl # final linking. 697 dnl # 698 dnl # Test names suffixed with '_license' call modpost independently 699 dnl # to ensure that a single incompatibility does not result in the 700 dnl # modpost phase exiting early. This check is not performed on 701 dnl # every symbol since the majority are compatible and doing so 702 dnl # would significantly slow down this phase. 703 dnl # 704 dnl # When configuring for builtin (--enable-linux-builtin) 705 dnl # fake the linking step artificially create the expected .ko 706 dnl # files for tests which did compile. This is required for 707 dnl # kernels which do not have loadable module support or have 708 dnl # not yet been built. 709 dnl # 710 AS_IF([test "x$enable_linux_builtin" = "xno"], [ 711 for dir in $(awk '/^obj-m/ { print [$]3 }' \ 712 build/Makefile.compile.$1); do 713 name=${dir%/} 714 AS_IF([test -f build/$name/$name.o], [ 715 AS_IF([test "${name##*_}" = "license"], [ 716 ZFS_LINUX_TEST_MODPOST([$1], 717 [build/$name]) 718 echo "obj-n += $dir" >>build/Makefile 719 ], [ 720 echo "obj-m += $dir" >>build/Makefile 721 ]) 722 ], [ 723 echo "obj-n += $dir" >>build/Makefile 724 ]) 725 done 726 727 ZFS_LINUX_TEST_MODPOST([$1], [build]) 728 ], [ 729 for dir in $(awk '/^obj-m/ { print [$]3 }' \ 730 build/Makefile.compile.$1); do 731 name=${dir%/} 732 AS_IF([test -f build/$name/$name.o], [ 733 touch build/$name/$name.ko 734 ]) 735 done 736 ]) 737]) 738 739dnl # 740dnl # ZFS_LINUX_TEST_SRC 741dnl # 742dnl # $1 - name 743dnl # $2 - global 744dnl # $3 - source 745dnl # $4 - extra cflags 746dnl # $5 - check license-compatibility 747dnl # 748dnl # Check if the test source is buildable at all and then if it is 749dnl # license compatible. 750dnl # 751dnl # N.B because all of the test cases are compiled in parallel they 752dnl # must never depend on the results of previous tests. Each test 753dnl # needs to be entirely independent. 754dnl # 755AC_DEFUN([ZFS_LINUX_TEST_SRC], [ 756 ZFS_LINUX_CONFTEST_C([ZFS_LINUX_TEST_PROGRAM([[$2]], [[$3]], 757 [["Dual BSD/GPL"]])], [$1]) 758 ZFS_LINUX_CONFTEST_MAKEFILE([$1], [yes], [$4]) 759 760 AS_IF([ test -n "$5" ], [ 761 ZFS_LINUX_CONFTEST_C([ZFS_LINUX_TEST_PROGRAM( 762 [[$2]], [[$3]], [[$5]])], [$1_license]) 763 ZFS_LINUX_CONFTEST_MAKEFILE([$1_license], [yes], [$4]) 764 ]) 765]) 766 767dnl # 768dnl # ZFS_LINUX_TEST_RESULT 769dnl # 770dnl # $1 - name of a test source (ZFS_LINUX_TEST_SRC) 771dnl # $2 - run on success (valid .ko generated) 772dnl # $3 - run on failure (unable to compile) 773dnl # 774AC_DEFUN([ZFS_LINUX_TEST_RESULT], [ 775 AS_IF([test -d build/$1], [ 776 AS_IF([test -f build/$1/$1.ko], [$2], [$3]) 777 ], [ 778 AC_MSG_ERROR([ 779 *** No matching source for the "$1" test, check that 780 *** both the test source and result macros refer to the same name. 781 ]) 782 ]) 783]) 784 785dnl # 786dnl # ZFS_LINUX_TEST_ERROR 787dnl # 788dnl # Generic error message which can be used when none of the expected 789dnl # kernel interfaces were detected. 790dnl # 791AC_DEFUN([ZFS_LINUX_TEST_ERROR], [ 792 AC_MSG_ERROR([ 793 *** None of the expected "$1" interfaces were detected. 794 *** This may be because your kernel version is newer than what is 795 *** supported, or you are using a patched custom kernel with 796 *** incompatible modifications. 797 *** 798 *** ZFS Version: $ZFS_META_ALIAS 799 *** Compatible Kernels: $ZFS_META_KVER_MIN - $ZFS_META_KVER_MAX 800 ]) 801]) 802 803dnl # 804dnl # ZFS_LINUX_TEST_RESULT_SYMBOL 805dnl # 806dnl # Like ZFS_LINUX_TEST_RESULT except ZFS_CHECK_SYMBOL_EXPORT is called to 807dnl # verify symbol exports, unless --enable-linux-builtin was provided to 808dnl # configure. 809dnl # 810AC_DEFUN([ZFS_LINUX_TEST_RESULT_SYMBOL], [ 811 AS_IF([ ! test -f build/$1/$1.ko], [ 812 $5 813 ], [ 814 AS_IF([test "x$enable_linux_builtin" != "xyes"], [ 815 ZFS_CHECK_SYMBOL_EXPORT([$2], [$3], [$4], [$5]) 816 ], [ 817 $4 818 ]) 819 ]) 820]) 821 822dnl # 823dnl # ZFS_LINUX_COMPILE_IFELSE 824dnl # 825AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [ 826 ZFS_LINUX_TEST_REMOVE([conftest]) 827 828 m4_ifvaln([$1], [ZFS_LINUX_CONFTEST_C([$1], [conftest])]) 829 m4_ifvaln([$5], [ZFS_LINUX_CONFTEST_H([$5], [conftest])], 830 [ZFS_LINUX_CONFTEST_H([], [conftest])]) 831 832 ZFS_LINUX_CONFTEST_MAKEFILE([conftest], [no], 833 [m4_ifvaln([$5], [-I$PWD/build/conftest], [])]) 834 ZFS_LINUX_COMPILE([build/conftest], [$2], [$3], [$4], [], []) 835]) 836 837dnl # 838dnl # ZFS_LINUX_TRY_COMPILE 839dnl # 840dnl # $1 - global 841dnl # $2 - source 842dnl # $3 - run on success (valid .ko generated) 843dnl # $4 - run on failure (unable to compile) 844dnl # 845dnl # When configuring as builtin (--enable-linux-builtin) for kernels 846dnl # without loadable module support (CONFIG_MODULES=n) only the object 847dnl # file is created. See ZFS_LINUX_TEST_COMPILE_ALL for details. 848dnl # 849AC_DEFUN([ZFS_LINUX_TRY_COMPILE], [ 850 AS_IF([test "x$enable_linux_builtin" = "xyes"], [ 851 ZFS_LINUX_COMPILE_IFELSE( 852 [ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]], 853 [[ZFS_META_LICENSE]])], 854 [test -f build/conftest/conftest.o], [$3], [$4]) 855 ], [ 856 ZFS_LINUX_COMPILE_IFELSE( 857 [ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]], 858 [[ZFS_META_LICENSE]])], 859 [test -f build/conftest/conftest.ko], [$3], [$4]) 860 ]) 861]) 862 863dnl # 864dnl # ZFS_CHECK_SYMBOL_EXPORT 865dnl # 866dnl # Check if a symbol is exported on not by consulting the symbols 867dnl # file, or optionally the source code. 868dnl # 869AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT], [ 870 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \ 871 $LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null 872 rc=$? 873 if test $rc -ne 0; then 874 export=0 875 for file in $2; do 876 grep -q -E "EXPORT_SYMBOL.*($1)" \ 877 "$LINUX/$file" 2>/dev/null 878 rc=$? 879 if test $rc -eq 0; then 880 export=1 881 break; 882 fi 883 done 884 if test $export -eq 0; then : 885 $4 886 else : 887 $3 888 fi 889 else : 890 $3 891 fi 892]) 893 894dnl # 895dnl # ZFS_LINUX_TRY_COMPILE_SYMBOL 896dnl # 897dnl # Like ZFS_LINUX_TRY_COMPILER except ZFS_CHECK_SYMBOL_EXPORT is called 898dnl # to verify symbol exports, unless --enable-linux-builtin was provided 899dnl # to configure. 900dnl # 901AC_DEFUN([ZFS_LINUX_TRY_COMPILE_SYMBOL], [ 902 ZFS_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1]) 903 if test $rc -ne 0; then : 904 $6 905 else 906 if test "x$enable_linux_builtin" != xyes; then 907 ZFS_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1]) 908 fi 909 if test $rc -ne 0; then : 910 $6 911 else : 912 $5 913 fi 914 fi 915]) 916 917dnl # 918dnl # ZFS_LINUX_TRY_COMPILE_HEADER 919dnl # like ZFS_LINUX_TRY_COMPILE, except the contents conftest.h are 920dnl # provided via the fifth parameter 921dnl # 922AC_DEFUN([ZFS_LINUX_TRY_COMPILE_HEADER], [ 923 AS_IF([test "x$enable_linux_builtin" = "xyes"], [ 924 ZFS_LINUX_COMPILE_IFELSE( 925 [ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]], 926 [[ZFS_META_LICENSE]])], 927 [test -f build/conftest/conftest.o], [$3], [$4], [$5]) 928 ], [ 929 ZFS_LINUX_COMPILE_IFELSE( 930 [ZFS_LINUX_TEST_PROGRAM([[$1]], [[$2]], 931 [[ZFS_META_LICENSE]])], 932 [test -f build/conftest/conftest.ko], [$3], [$4], [$5]) 933 ]) 934]) 935 936dnl # 937dnl # AS_VERSION_COMPARE_LE 938dnl # like AS_VERSION_COMPARE_LE, but runs $3 if (and only if) $1 <= $2 939dnl # AS_VERSION_COMPARE_LE (version-1, version-2, [action-if-less-or-equal], [action-if-greater]) 940dnl # 941AC_DEFUN([AS_VERSION_COMPARE_LE], [ 942 AS_VERSION_COMPARE([$1], [$2], [$3], [$3], [$4]) 943]) 944 945dnl # 946dnl # ZFS_LINUX_REQUIRE_API 947dnl # like ZFS_LINUX_TEST_ERROR, except only fails if the kernel is 948dnl # at least some specified version. 949dnl # 950AC_DEFUN([ZFS_LINUX_REQUIRE_API], [ 951 AS_VERSION_COMPARE_LE([$2], [$kernsrcver], [ 952 AC_MSG_ERROR([ 953 *** None of the expected "$1" interfaces were detected. This 954 *** interface is expected for kernels version "$2" and above. 955 *** This may be because your kernel version is newer than what is 956 *** supported, or you are using a patched custom kernel with 957 *** incompatible modifications. Newer kernels may have incompatible 958 *** APIs. 959 *** 960 *** ZFS Version: $ZFS_META_ALIAS 961 *** Compatible Kernels: $ZFS_META_KVER_MIN - $ZFS_META_KVER_MAX 962 ]) 963 ], [ 964 AC_MSG_RESULT(no) 965 ]) 966]) 967