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