Skip to content

Commit 3abffc8

Browse files
robnbehlendorf
authored andcommitted
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. Reviewed-by: Tony Hutter <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Rob Norris <[email protected]> Sponsored-by: https://despairlabs.com/sponsor/ Closes #16400
1 parent f5236fe commit 3abffc8

File tree

5 files changed

+46
-17
lines changed

5 files changed

+46
-17
lines changed

config/kernel-mm-page-size.m4

Lines changed: 0 additions & 17 deletions
This file was deleted.

config/kernel-mm-pagemap.m4

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
AC_DEFUN([ZFS_AC_KERNEL_SRC_MM_PAGE_SIZE], [
2+
ZFS_LINUX_TEST_SRC([page_size], [
3+
#include <linux/mm.h>
4+
],[
5+
unsigned long s;
6+
s = page_size(NULL);
7+
])
8+
])
9+
AC_DEFUN([ZFS_AC_KERNEL_MM_PAGE_SIZE], [
10+
AC_MSG_CHECKING([whether page_size() is available])
11+
ZFS_LINUX_TEST_RESULT([page_size], [
12+
AC_MSG_RESULT(yes)
13+
AC_DEFINE(HAVE_MM_PAGE_SIZE, 1, [page_size() is available])
14+
],[
15+
AC_MSG_RESULT(no)
16+
])
17+
])
18+
19+
20+
AC_DEFUN([ZFS_AC_KERNEL_SRC_MM_PAGE_MAPPING], [
21+
ZFS_LINUX_TEST_SRC([page_mapping], [
22+
#include <linux/pagemap.h>
23+
],[
24+
struct page *p = NULL;
25+
struct address_space *m = page_mapping(NULL);
26+
])
27+
])
28+
AC_DEFUN([ZFS_AC_KERNEL_MM_PAGE_MAPPING], [
29+
AC_MSG_CHECKING([whether page_mapping() is available])
30+
ZFS_LINUX_TEST_RESULT([page_mapping], [
31+
AC_MSG_RESULT(yes)
32+
AC_DEFINE(HAVE_MM_PAGE_MAPPING, 1, [page_mapping() is available])
33+
],[
34+
AC_MSG_RESULT(no)
35+
])
36+
])

config/kernel.m4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
171171
ZFS_AC_KERNEL_SRC_COPY_SPLICE_READ
172172
ZFS_AC_KERNEL_SRC_SYNC_BDEV
173173
ZFS_AC_KERNEL_SRC_MM_PAGE_SIZE
174+
ZFS_AC_KERNEL_SRC_MM_PAGE_MAPPING
174175
case "$host_cpu" in
175176
powerpc*)
176177
ZFS_AC_KERNEL_SRC_CPU_HAS_FEATURE
@@ -324,6 +325,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
324325
ZFS_AC_KERNEL_COPY_SPLICE_READ
325326
ZFS_AC_KERNEL_SYNC_BDEV
326327
ZFS_AC_KERNEL_MM_PAGE_SIZE
328+
ZFS_AC_KERNEL_MM_PAGE_MAPPING
327329
case "$host_cpu" in
328330
powerpc*)
329331
ZFS_AC_KERNEL_CPU_HAS_FEATURE

include/os/linux/kernel/linux/mm_compat.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,23 @@
2121

2222
/*
2323
* Copyright (c) 2023, 2024, Klara Inc.
24+
* Copyright (c) 2024, Rob Norris <[email protected]>
2425
*/
2526

2627
#ifndef _ZFS_MM_COMPAT_H
2728
#define _ZFS_MM_COMPAT_H
2829

2930
#include <linux/mm.h>
31+
#include <linux/pagemap.h>
3032

3133
/* 5.4 introduced page_size(). Older kernels can use a trivial macro instead */
3234
#ifndef HAVE_MM_PAGE_SIZE
3335
#define page_size(p) ((unsigned long)(PAGE_SIZE << compound_order(p)))
3436
#endif
3537

38+
/* 6.11 removed page_mapping(). A simple wrapper around folio_mapping() works */
39+
#ifndef HAVE_MM_PAGE_MAPPING
40+
#define page_mapping(p) folio_mapping(page_folio(p))
41+
#endif
42+
3643
#endif /* _ZFS_MM_COMPAT_H */

module/os/linux/zfs/zfs_vnops_os.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#include <sys/zpl.h>
7070
#include <sys/zil.h>
7171
#include <sys/sa_impl.h>
72+
#include <linux/mm_compat.h>
7273

7374
/*
7475
* Programming rules.

0 commit comments

Comments
 (0)