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.

Change-Id: Idd38aa3a9871e188580aae86f5b22621a5511bb2
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>
This commit is contained in:
Cheyenne Wills 2024-11-08 21:16:21 -07:00 committed by Andrew Deason
parent 2f96f95229
commit 1ccc87bbdc
2 changed files with 34 additions and 3 deletions

View File

@ -3589,13 +3589,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);
@ -3604,7 +3614,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,
@ -3630,7 +3645,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) {

View File

@ -307,6 +307,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"],