]> git.proxmox.com Git - mirror_zfs.git/commitdiff
linux 5.4 compat: page_size()
authorRob Norris <rob.norris@klarasystems.com>
Mon, 13 Nov 2023 06:55:29 +0000 (17:55 +1100)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 25 Mar 2024 23:48:15 +0000 (16:48 -0700)
Before 5.4 we have to do a little math.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Closes #15533
Closes #15588

config/kernel-mm-page-size.m4 [new file with mode: 0644]
config/kernel.m4
include/os/linux/Makefile.am
include/os/linux/kernel/linux/mm_compat.h [new file with mode: 0644]

diff --git a/config/kernel-mm-page-size.m4 b/config/kernel-mm-page-size.m4
new file mode 100644 (file)
index 0000000..d5ebd92
--- /dev/null
@@ -0,0 +1,17 @@
+AC_DEFUN([ZFS_AC_KERNEL_SRC_MM_PAGE_SIZE], [
+       ZFS_LINUX_TEST_SRC([page_size], [
+               #include <linux/mm.h>
+       ],[
+               unsigned long s;
+               s = page_size(NULL);
+       ])
+])
+AC_DEFUN([ZFS_AC_KERNEL_MM_PAGE_SIZE], [
+       AC_MSG_CHECKING([whether page_size() is available])
+       ZFS_LINUX_TEST_RESULT([page_size], [
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_MM_PAGE_SIZE, 1, [page_size() is available])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+])
index 1d0c5a27fc7f3a62d95b19351194c6cb01e090a1..548905ccd04d7a6d1d6d0fbf5999c68a7da4c8ce 100644 (file)
@@ -167,6 +167,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
        ZFS_AC_KERNEL_SRC_REGISTER_SYSCTL_TABLE
        ZFS_AC_KERNEL_SRC_COPY_SPLICE_READ
        ZFS_AC_KERNEL_SRC_SYNC_BDEV
+       ZFS_AC_KERNEL_SRC_MM_PAGE_SIZE
        case "$host_cpu" in
                powerpc*)
                        ZFS_AC_KERNEL_SRC_CPU_HAS_FEATURE
@@ -316,6 +317,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
        ZFS_AC_KERNEL_REGISTER_SYSCTL_TABLE
        ZFS_AC_KERNEL_COPY_SPLICE_READ
        ZFS_AC_KERNEL_SYNC_BDEV
+       ZFS_AC_KERNEL_MM_PAGE_SIZE
        case "$host_cpu" in
                powerpc*)
                        ZFS_AC_KERNEL_CPU_HAS_FEATURE
index 3830d198dfff513d7f2d832b61cba62118b32015..51c27132b4efe8e80f4fd87b0ba8ccb13784f5fa 100644 (file)
@@ -5,6 +5,7 @@ kernel_linux_HEADERS = \
        %D%/kernel/linux/compiler_compat.h \
        %D%/kernel/linux/dcache_compat.h \
        %D%/kernel/linux/kmap_compat.h \
+       %D%/kernel/linux/mm_compat.h \
        %D%/kernel/linux/mod_compat.h \
        %D%/kernel/linux/page_compat.h \
        %D%/kernel/linux/percpu_compat.h \
diff --git a/include/os/linux/kernel/linux/mm_compat.h b/include/os/linux/kernel/linux/mm_compat.h
new file mode 100644 (file)
index 0000000..40056c6
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or https://opensource.org/licenses/CDDL-1.0.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2023, 2024, Klara Inc.
+ */
+
+#ifndef _ZFS_MM_COMPAT_H
+#define        _ZFS_MM_COMPAT_H
+
+#include <linux/mm.h>
+
+/* 5.4 introduced page_size(). Older kernels can use a trivial macro instead */
+#ifndef HAVE_MM_PAGE_SIZE
+#define        page_size(p) ((unsigned long)(PAGE_SIZE << compound_order(p)))
+#endif
+
+#endif /* _ZFS_MM_COMPAT_H */