From dad353a427ed4ba6541b5f6d3286ff5ed5054a2e Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Wed, 31 Jul 2024 18:43:39 +1000 Subject: [PATCH] Linux 6.11: add compat macro for page_mapping() Since the change to folios it has just been a wrapper anyway. Linux has removed their wrapper, so we add one. Signed-off-by: Rob Norris Sponsored-by: https://despairlabs.com/sponsor/ --- config/kernel-mm-page-size.m4 | 17 ----------- config/kernel-mm-pagemap.m4 | 36 +++++++++++++++++++++++ config/kernel.m4 | 2 ++ include/os/linux/kernel/linux/mm_compat.h | 7 +++++ module/os/linux/zfs/zfs_vnops_os.c | 1 + 5 files changed, 46 insertions(+), 17 deletions(-) delete mode 100644 config/kernel-mm-page-size.m4 create mode 100644 config/kernel-mm-pagemap.m4 diff --git a/config/kernel-mm-page-size.m4 b/config/kernel-mm-page-size.m4 deleted file mode 100644 index d5ebd926986a..000000000000 --- a/config/kernel-mm-page-size.m4 +++ /dev/null @@ -1,17 +0,0 @@ -AC_DEFUN([ZFS_AC_KERNEL_SRC_MM_PAGE_SIZE], [ - ZFS_LINUX_TEST_SRC([page_size], [ - #include - ],[ - 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) - ]) -]) diff --git a/config/kernel-mm-pagemap.m4 b/config/kernel-mm-pagemap.m4 new file mode 100644 index 000000000000..466b6fa07d9a --- /dev/null +++ b/config/kernel-mm-pagemap.m4 @@ -0,0 +1,36 @@ +AC_DEFUN([ZFS_AC_KERNEL_SRC_MM_PAGE_SIZE], [ + ZFS_LINUX_TEST_SRC([page_size], [ + #include + ],[ + 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) + ]) +]) + + +AC_DEFUN([ZFS_AC_KERNEL_SRC_MM_PAGE_MAPPING], [ + ZFS_LINUX_TEST_SRC([page_mapping], [ + #include + ],[ + struct page *p = NULL; + struct address_space *m = page_mapping(NULL); + ]) +]) +AC_DEFUN([ZFS_AC_KERNEL_MM_PAGE_MAPPING], [ + AC_MSG_CHECKING([whether page_mapping() is available]) + ZFS_LINUX_TEST_RESULT([page_mapping], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_MM_PAGE_MAPPING, 1, [page_mapping() is available]) + ],[ + AC_MSG_RESULT(no) + ]) +]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 6194c119cca6..d6ea3453292a 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -171,6 +171,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_COPY_SPLICE_READ ZFS_AC_KERNEL_SRC_SYNC_BDEV ZFS_AC_KERNEL_SRC_MM_PAGE_SIZE + ZFS_AC_KERNEL_SRC_MM_PAGE_MAPPING case "$host_cpu" in powerpc*) ZFS_AC_KERNEL_SRC_CPU_HAS_FEATURE @@ -324,6 +325,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_COPY_SPLICE_READ ZFS_AC_KERNEL_SYNC_BDEV ZFS_AC_KERNEL_MM_PAGE_SIZE + ZFS_AC_KERNEL_MM_PAGE_MAPPING case "$host_cpu" in powerpc*) ZFS_AC_KERNEL_CPU_HAS_FEATURE diff --git a/include/os/linux/kernel/linux/mm_compat.h b/include/os/linux/kernel/linux/mm_compat.h index 40056c68d6dd..817f6df422de 100644 --- a/include/os/linux/kernel/linux/mm_compat.h +++ b/include/os/linux/kernel/linux/mm_compat.h @@ -21,16 +21,23 @@ /* * Copyright (c) 2023, 2024, Klara Inc. + * Copyright (c) 2024, Rob Norris */ #ifndef _ZFS_MM_COMPAT_H #define _ZFS_MM_COMPAT_H #include +#include /* 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 +/* 6.11 removed page_mapping(). A simple wrapper around folio_mapping() works */ +#ifndef HAVE_MM_PAGE_MAPPING +#define page_mapping(p) folio_mapping(page_folio(p)) +#endif + #endif /* _ZFS_MM_COMPAT_H */ diff --git a/module/os/linux/zfs/zfs_vnops_os.c b/module/os/linux/zfs/zfs_vnops_os.c index 1cecad9f7755..8061169c3293 100644 --- a/module/os/linux/zfs/zfs_vnops_os.c +++ b/module/os/linux/zfs/zfs_vnops_os.c @@ -69,6 +69,7 @@ #include #include #include +#include /* * Programming rules.