diff --git a/src/afs/LINUX/osi_compat.h b/src/afs/LINUX/osi_compat.h index 53a079b676..9a080da31c 100644 --- a/src/afs/LINUX/osi_compat.h +++ b/src/afs/LINUX/osi_compat.h @@ -138,7 +138,9 @@ hlist_unhashed(const struct hlist_node *h) { #define AOP_WRITEPAGE_ACTIVATE WRITEPAGE_ACTIVATE #endif -#if defined(STRUCT_ADDRESS_SPACE_OPERATIONS_HAS_WRITE_BEGIN) && !defined(HAVE_LINUX_GRAB_CACHE_PAGE_WRITE_BEGIN) +#if defined(STRUCT_ADDRESS_SPACE_OPERATIONS_HAS_WRITE_BEGIN) && \ + !defined(HAVE_LINUX_GRAB_CACHE_PAGE_WRITE_BEGIN_WITHFLAGS) && \ + !defined(HAVE_LINUX_GRAB_CACHE_PAGE_WRITE_BEGIN_NOFLAGS) static inline struct page * grab_cache_page_write_begin(struct address_space *mapping, pgoff_t index, unsigned int flags) { diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index e6fa64f0d1..ed88bc5b1a 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -3476,6 +3476,33 @@ afs_linux_write_end(struct file *file, struct address_space *mapping, return code; } +# if 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, + struct page **pagep, void **fsdata) +{ + struct page *page; + pgoff_t index = pos >> PAGE_SHIFT; + unsigned int from = pos & (PAGE_SIZE - 1); + int code; + + page = grab_cache_page_write_begin(mapping, index); + if (!page) { + return -ENOMEM; + } + + *pagep = page; + + code = afs_linux_prepare_write(file, page, from, from + len); + if (code) { + unlock_page(page); + put_page(page); + } + + return code; +} +# else static int afs_linux_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, @@ -3501,7 +3528,8 @@ afs_linux_write_begin(struct file *file, struct address_space *mapping, return code; } -#endif +# endif /* HAVE_LINUX_GRAB_CACHE_PAGE_WRITE_BEGIN_NOFLAGS */ +#endif /* STRUCT_ADDRESS_SPACE_OPERATIONS_HAS_WRITE_BEGIN */ #ifndef STRUCT_DENTRY_OPERATIONS_HAS_D_AUTOMOUNT static void * diff --git a/src/cf/linux-kernel-func.m4 b/src/cf/linux-kernel-func.m4 index cd4afe9143..27a1d4141c 100644 --- a/src/cf/linux-kernel-func.m4 +++ b/src/cf/linux-kernel-func.m4 @@ -59,9 +59,14 @@ AC_CHECK_LINUX_FUNC([find_task_by_pid], AC_CHECK_LINUX_FUNC([generic_file_aio_read], [#include ], [generic_file_aio_read(NULL,NULL,0,0);]) -AC_CHECK_LINUX_FUNC([grab_cache_page_write_begin], +dnl - linux 5.19 removed the flags parameter, need to test +dnl - with and without the flags parameter +AC_CHECK_LINUX_FUNC([grab_cache_page_write_begin_withflags], [#include ], [grab_cache_page_write_begin(NULL, 0, 0);]) +AC_CHECK_LINUX_FUNC([grab_cache_page_write_begin_noflags], + [#include ], + [grab_cache_page_write_begin(NULL, 0);]) AC_CHECK_LINUX_FUNC([hlist_unhashed], [#include ], [hlist_unhashed(0);])