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