Fix build for Linux 6.18 with PowerPC/RISC-V kernels. (#18145)
Some checks failed
checkstyle / checkstyle (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
smatch / smatch (push) Has been cancelled
zfs-qemu / Setup (push) Has been cancelled
zfs-qemu / qemu-x86 (push) Has been cancelled
zfs-qemu / Cleanup (push) Has been cancelled
zloop / zloop (push) Has been cancelled

The macro 'flush_dcache_page(...)' modifies the page flags, but in Linux
6.18 the type of the page flags changed from 'unsigned long' to the
struct type 'memdesc_flags_t' with a single member 'f' which is the page
flags field.

Signed-off-by: Erik Larsson <catacombae@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
This commit is contained in:
Erik Larsson
2026-02-03 00:16:10 +02:00
committed by GitHub
parent 13601e2d24
commit 7e33476a7c
2 changed files with 42 additions and 4 deletions

View File

@@ -17,9 +17,36 @@ AC_DEFUN([ZFS_AC_KERNEL_MM_PAGE_FLAG_ERROR], [
])
])
dnl #
dnl # Linux 6.18+ uses a struct typedef (memdesc_flags_t) instead of an
dnl # 'unsigned long' for the 'flags' field in 'struct page'.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_SRC_MM_PAGE_FLAGS_STRUCT], [
ZFS_LINUX_TEST_SRC([mm_page_flags_struct], [
#include <linux/mm.h>
static const struct page p __attribute__ ((unused)) = {
.flags = { .f = 0 }
};
],[])
])
AC_DEFUN([ZFS_AC_KERNEL_MM_PAGE_FLAGS_STRUCT], [
AC_MSG_CHECKING([whether 'flags' in 'struct page' is a struct])
ZFS_LINUX_TEST_RESULT([mm_page_flags_struct], [
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_MM_PAGE_FLAGS_STRUCT, 1,
['flags' in 'struct page' is a struct])
],[
AC_MSG_RESULT([no])
])
])
AC_DEFUN([ZFS_AC_KERNEL_SRC_MM_PAGE_FLAGS], [
ZFS_AC_KERNEL_SRC_MM_PAGE_FLAG_ERROR
ZFS_AC_KERNEL_SRC_MM_PAGE_FLAGS_STRUCT
])
AC_DEFUN([ZFS_AC_KERNEL_MM_PAGE_FLAGS], [
ZFS_AC_KERNEL_MM_PAGE_FLAG_ERROR
ZFS_AC_KERNEL_MM_PAGE_FLAGS_STRUCT
])

View File

@@ -34,6 +34,17 @@
#define d_alias d_u.d_alias
#ifdef HAVE_MM_PAGE_FLAGS_STRUCT
/*
* Starting from Linux 6.18, the 'flags' field in 'struct page' is defined
* to a struct ('memdesc_flags_t' typedef) instead of an unsigned long for
* improved typesafety.
*/
#define page_flags flags.f
#else
#define page_flags flags
#endif
/*
* Starting from Linux 5.13, flush_dcache_page() becomes an inline function
* and under some configurations, may indirectly referencing GPL-only
@@ -44,8 +55,8 @@
#include <linux/simd_powerpc.h>
#define flush_dcache_page(page) do { \
if (!cpu_has_feature(CPU_FTR_COHERENT_ICACHE) && \
test_bit(PG_dcache_clean, &(page)->flags)) \
clear_bit(PG_dcache_clean, &(page)->flags); \
test_bit(PG_dcache_clean, &(page)->page_flags)) \
clear_bit(PG_dcache_clean, &(page)->page_flags);\
} while (0)
#endif
/*
@@ -55,8 +66,8 @@
*/
#if defined __riscv && defined HAVE_FLUSH_DCACHE_PAGE_GPL_ONLY
#define flush_dcache_page(page) do { \
if (test_bit(PG_dcache_clean, &(page)->flags)) \
clear_bit(PG_dcache_clean, &(page)->flags); \
if (test_bit(PG_dcache_clean, &(page)->page_flags)) \
clear_bit(PG_dcache_clean, &(page)->page_flags);\
} while (0)
#endif