1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
From 6f1c1a5b90b1753252952d68f001b6d1a66e79eb Mon Sep 17 00:00:00 2001
From: Cheyenne Wills <cwills@sinenomine.net>
Date: Fri, 8 Nov 2024 21:16:21 -0700
Subject: [PATCH 3/3] Linux: Use folios for aops->write_begin/end
Linux-6.12 commit 'fs: Convert aops->write_begin to take a folio'
(1da86618bdce3) changed the address_space_operations's members
write_begin and write_end to use a folio instead of a page.
Add configure check to test the signature for aop's write_begin and
write_end members to see if they take a folio parameter.
Update the afs_linux_write_begin and afs_linux_write_end functions to
use a folio instead of a page.
Reviewed-on: https://gerrit.openafs.org/15898
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
(cherry picked from commit 1ccc87bbdca3a616ecef9eb25b6555f5fd2b579f)
Change-Id: Id0fd216e2a27ef3fe157b5d453ae21455148a1e4
---
src/afs/LINUX/osi_vnodeops.c | 25 ++++++++++++++++++++++---
src/cf/linux-kernel-func.m4 | 12 ++++++++++++
2 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c
index c7f20aae1..519c5da15 100644
--- a/src/afs/LINUX/osi_vnodeops.c
+++ b/src/afs/LINUX/osi_vnodeops.c
@@ -3598,13 +3598,23 @@ afs_linux_prepare_write(struct file *file, struct page *page, unsigned from,
}
#if defined(STRUCT_ADDRESS_SPACE_OPERATIONS_HAS_WRITE_BEGIN)
+# if defined(HAVE_LINUX_WRITE_BEGIN_END_FOLIO)
static int
afs_linux_write_end(struct file *file, struct address_space *mapping,
- loff_t pos, unsigned len, unsigned copied,
- struct page *page, void *fsdata)
+ loff_t pos, unsigned len, unsigned copied,
+ struct folio *folio, void *fsdata)
+# else
+static int
+afs_linux_write_end(struct file *file, struct address_space *mapping,
+ loff_t pos, unsigned len, unsigned copied,
+ struct page *page, void *fsdata)
+# endif
{
int code;
unsigned int from = pos & (PAGE_SIZE - 1);
+# if defined(HAVE_LINUX_WRITE_BEGIN_END_FOLIO)
+ struct page *page = &folio->page;
+# endif
code = afs_linux_commit_write(file, page, from, from + copied);
@@ -3613,7 +3623,12 @@ afs_linux_write_end(struct file *file, struct address_space *mapping,
return code;
}
-# if defined(HAVE_LINUX_GRAB_CACHE_PAGE_WRITE_BEGIN_NOFLAGS)
+# if defined(HAVE_LINUX_WRITE_BEGIN_END_FOLIO)
+static int
+afs_linux_write_begin(struct file *file, struct address_space *mapping,
+ loff_t pos, unsigned len,
+ struct folio **foliop, void **fsdata)
+# elif defined(HAVE_LINUX_GRAB_CACHE_PAGE_WRITE_BEGIN_NOFLAGS)
static int
afs_linux_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len,
@@ -3639,7 +3654,11 @@ afs_linux_write_begin(struct file *file, struct address_space *mapping,
return -ENOMEM;
}
+# if defined(HAVE_LINUX_WRITE_BEGIN_END_FOLIO)
+ *foliop = page_folio(page);
+# else
*pagep = page;
+# endif
code = afs_linux_prepare_write(file, page, from, from + len);
if (code) {
diff --git a/src/cf/linux-kernel-func.m4 b/src/cf/linux-kernel-func.m4
index 71a0c2c39..598114671 100644
--- a/src/cf/linux-kernel-func.m4
+++ b/src/cf/linux-kernel-func.m4
@@ -316,6 +316,18 @@ AC_CHECK_LINUX_FUNC([no_setpageerror],
r = ClearPageError('x');
r = SetPageError('x');]])
+dnl Linux 6.12 changed the signatgure for the address_space_operations members
+dnl write_begin and write_end to use a folio instead of a page.
+AC_CHECK_LINUX_FUNC([write_begin_end_folio],
+ [[#include <linux/fs.h>
+ static struct file *file;
+ static struct address_space *mapping;
+ static struct folio *foliop;
+ static void *fsdata;
+ static struct address_space_operations *aops;]],
+ [[aops->write_begin(file, mapping, 0, 0, &foliop, fsdata);
+ aops->write_end(file, mapping, 0, 0, 0, foliop, fsdata);]])
+
dnl Consequences - things which get set as a result of the
dnl above tests
AS_IF([test "x$ac_cv_linux_func_d_alloc_anon" = "xno"],
--
2.47.0
|