config/kernel: enforce maximum kernel version, with escape hatch

META lists the maximum kernel version we consider to be fully supported.
However, we don't enforce this.

Sometimes we ship experimental patches for a newer kernel than we're
ready to support or, less often, we compile just fine against a newer
kernel. Invariably, something doesn't quite work properly, and it's
difficult for users to understand that they're actually running against
a kernel that we're not yet ready to support.

This commit tries to improve this situation. First, it simply enforces
Linux-Maximum, by having configure bail out if you try to compile
against a newer version that.

Then, it adds the --enable-linux-experimental switch to configure. When
supplied, this disables enforcing the maximum version, allowing the user
to attempt to build against a kernel with version higher than
Linux-Maximum.

Finally, if the switch is supplied _and_ configure is run against a
higher kernel version, it shows a big warning message when configure
finishes, and defines HAVE_LINUX_EXPERIMENTAL for the build. This allows
us to add code to modify runtime behaviour as well.

Reviewed-by: Robert Evans <evansr@google.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Sponsored-by: https://despairlabs.com/sponsor/
Closes #15986
This commit is contained in:
Rob Norris
2024-03-12 20:38:12 +11:00
committed by Brian Behlendorf
parent e419a63bf4
commit 410287f7f8
3 changed files with 231 additions and 2 deletions
+52 -2
View File
@@ -417,13 +417,39 @@ AC_DEFUN([ZFS_AC_KERNEL], [
AC_MSG_RESULT([$kernsrcver])
AS_VERSION_COMPARE([$kernsrcver], [$ZFS_META_KVER_MIN], [
AC_MSG_ERROR([
AX_COMPARE_VERSION([$kernsrcver], [ge], [$ZFS_META_KVER_MIN], [], [
AC_MSG_ERROR([
*** Cannot build against kernel version $kernsrcver.
*** The minimum supported kernel version is $ZFS_META_KVER_MIN.
])
])
AC_ARG_ENABLE([linux-experimental],
AS_HELP_STRING([--enable-linux-experimental],
[Allow building against some unsupported kernel versions]))
AX_COMPARE_VERSION([$kernsrcver], [ge], [$ZFS_META_KVER_MAX], [
AX_COMPARE_VERSION([$kernsrcver], [eq2], [$ZFS_META_KVER_MAX], [
kern_max_version_ok=yes
], [
kern_max_version_ok=no
])
], [
kern_max_version_ok=yes
])
AS_IF([test "x$kern_max_version_ok" != "xyes"], [
AS_IF([test "x$enable_linux_experimental" == "xyes"], [
AC_DEFINE(HAVE_LINUX_EXPERIMENTAL, 1,
[building against unsupported kernel version])
], [
AC_MSG_ERROR([
*** Cannot build against kernel version $kernsrcver.
*** The maximum supported kernel version is $ZFS_META_KVER_MAX.
])
])
])
LINUX=${kernelsrc}
LINUX_OBJ=${kernelbuild}
LINUX_VERSION=${kernsrcver}
@@ -433,6 +459,30 @@ AC_DEFUN([ZFS_AC_KERNEL], [
AC_SUBST(LINUX_VERSION)
])
AC_DEFUN([ZFS_AC_KERNEL_VERSION_WARNING], [
AS_IF([test "x$enable_linux_experimental" = "xyes" && \
test "x$kern_max_version_ok" != "xyes"], [
AC_MSG_WARN([
You are building OpenZFS against Linux version $kernsrcver.
This combination is considered EXPERIMENTAL by the OpenZFS project.
Even if it appears to build and run correctly, there may be bugs that
can cause SERIOUS DATA LOSS.
YOU HAVE BEEN WARNED!
If you choose to continue, we'd appreciate if you could report your
results on the OpenZFS issue tracker at:
https://github.com/openzfs/zfs/issues/new
Your feedback will help us prepare a new OpenZFS release that supports
this version of Linux.
])
])
])
dnl #
dnl # Detect the QAT module to be built against, QAT provides hardware
dnl # acceleration for data compression: