From 556ed0953712bd94b49363c7c596d3d8000ff874 Mon Sep 17 00:00:00 2001 From: Antonio Russo Date: Wed, 4 Jan 2023 21:41:16 -0700 Subject: Introduce ZFS_LINUX_REQUIRE_API autoconf macro Currently, if API tests fail, we either ignore the failures, or unconditionally halt the kernel build. This leads to situations where incompatibilities with existing APIs may develop, but not trip the configure compatibility checks. This introduces a new mechanism to require APIs for kernels above a particular version. While not perfect, this at least guarantees mainline kernels do not break existing APIs without at least providing some warning. Reviewed-by: Richard Yao Reviewed-by: Brian Behlendorf Signed-off-by: Antonio Russo Closes #14343 --- config/kernel-tmpfile.m4 | 2 +- config/kernel.m4 | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/config/kernel-tmpfile.m4 b/config/kernel-tmpfile.m4 index acb7ea1e8..0e1deb361 100644 --- a/config/kernel-tmpfile.m4 +++ b/config/kernel-tmpfile.m4 @@ -60,7 +60,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TMPFILE], [ AC_DEFINE(HAVE_TMPFILE, 1, [i_op->tmpfile() exists]) AC_DEFINE(HAVE_TMPFILE_DENTRY, 1, [i_op->tmpfile() uses old dentry signature]) ],[ - AC_MSG_RESULT(no) + ZFS_LINUX_REQUIRE_API([i_op->tmpfile()], [3.11]) ]) ]) ]) diff --git a/config/kernel.m4 b/config/kernel.m4 index c71d576f4..353988e9c 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -958,3 +958,35 @@ AC_DEFUN([ZFS_LINUX_TRY_COMPILE_HEADER], [ [test -f build/conftest/conftest.ko], [$3], [$4], [$5]) ]) ]) + +dnl # +dnl # AS_VERSION_COMPARE_LE +dnl # like AS_VERSION_COMPARE_LE, but runs $3 if (and only if) $1 <= $2 +dnl # AS_VERSION_COMPARE_LE (version-1, version-2, [action-if-less-or-equal], [action-if-greater]) +dnl # +AC_DEFUN([AS_VERSION_COMPARE_LE], [ + AS_VERSION_COMPARE([$1], [$2], [$3], [$3], [$4]) +]) + +dnl # +dnl # ZFS_LINUX_REQUIRE_API +dnl # like ZFS_LINUX_TEST_ERROR, except only fails if the kernel is +dnl # at least some specified version. +dnl # +AC_DEFUN([ZFS_LINUX_REQUIRE_API], [ + AS_VERSION_COMPARE_LE([$2], [$kernsrcver], [ + AC_MSG_ERROR([ + *** None of the expected "$1" interfaces were detected. This + *** interface is expected for kernels version "$2" and above. + *** This may be because your kernel version is newer than what is + *** supported, or you are using a patched custom kernel with + *** incompatible modifications. Newer kernels may have incompatible + *** APIs. + *** + *** ZFS Version: $ZFS_META_ALIAS + *** Compatible Kernels: $ZFS_META_KVER_MIN - $ZFS_META_KVER_MAX + ]) + ], [ + AC_MSG_RESULT(no) + ]) +]) -- cgit v1.2.3