From 679be593dd2c0092225f64c7ed2730b6202fb5ac Mon Sep 17 00:00:00 2001 From: Coleman Kane Date: Tue, 16 Nov 2021 00:10:35 -0500 Subject: [PATCH] Linux 5.16: wait_on_page_bit() no longer available to modules Instead, linux/pagemap.h offers a number of folio-specific functions to be called instead. In this case, module/os/linux/zfs/zfs_vnops_os.c wants to call wait_on_page_bit(pp, PG_writeback). This gets replaced with folio_wait_bit(folio_page(pp), PG_writeback). This change modifies the code to conditionally compile that if configure identifies th presence of the folio_wait_bit() function. Reviewed-by: Brian Behlendorf Signed-off-by: Coleman Kane Closes #12800 --- config/kernel-pagemap-folio_wait_bit.m4 | 26 +++++++++++++++++++++++++ config/kernel.m4 | 2 ++ module/os/linux/zfs/zfs_vnops_os.c | 4 ++++ 3 files changed, 32 insertions(+) create mode 100644 config/kernel-pagemap-folio_wait_bit.m4 diff --git a/config/kernel-pagemap-folio_wait_bit.m4 b/config/kernel-pagemap-folio_wait_bit.m4 new file mode 100644 index 0000000000..e0aaa4a574 --- /dev/null +++ b/config/kernel-pagemap-folio_wait_bit.m4 @@ -0,0 +1,26 @@ +dnl # +dnl # Linux 5.16 no longer allows directly calling wait_on_page_bit, and +dnl # instead requires you to call folio-specific functions. In this case, +dnl # wait_on_page_bit(pg, PG_writeback) becomes +dnl # folio_wait_bit(pg, PG_writeback) +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_PAGEMAP_FOLIO_WAIT_BIT], [ + ZFS_LINUX_TEST_SRC([pagemap_has_folio_wait_bit], [ + #include + ],[ + static struct folio *f = NULL; + + folio_wait_bit(f, PG_writeback); + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_PAGEMAP_FOLIO_WAIT_BIT], [ + AC_MSG_CHECKING([folio_wait_bit() exists]) + ZFS_LINUX_TEST_RESULT([pagemap_has_folio_wait_bit], [ + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_PAGEMAP_FOLIO_WAIT_BIT, 1, + [folio_wait_bit() exists]) + ],[ + AC_MSG_RESULT([no]) + ]) +]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 908c331ce8..93faf0c778 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -133,6 +133,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_SET_SPECIAL_STATE ZFS_AC_KERNEL_SRC_VFS_SET_PAGE_DIRTY_NOBUFFERS ZFS_AC_KERNEL_SRC_STANDALONE_LINUX_STDARG + ZFS_AC_KERNEL_SRC_PAGEMAP_FOLIO_WAIT_BIT AC_MSG_CHECKING([for available kernel interfaces]) ZFS_LINUX_TEST_COMPILE_ALL([kabi]) @@ -239,6 +240,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_SET_SPECIAL_STATE ZFS_AC_KERNEL_VFS_SET_PAGE_DIRTY_NOBUFFERS ZFS_AC_KERNEL_STANDALONE_LINUX_STDARG + ZFS_AC_KERNEL_PAGEMAP_FOLIO_WAIT_BIT ]) dnl # diff --git a/module/os/linux/zfs/zfs_vnops_os.c b/module/os/linux/zfs/zfs_vnops_os.c index fc9018381e..49117218d6 100644 --- a/module/os/linux/zfs/zfs_vnops_os.c +++ b/module/os/linux/zfs/zfs_vnops_os.c @@ -3549,7 +3549,11 @@ zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc) if (wbc->sync_mode != WB_SYNC_NONE) { if (PageWriteback(pp)) +#ifdef HAVE_PAGEMAP_FOLIO_WAIT_BIT + folio_wait_bit(page_folio(pp), PG_writeback); +#else wait_on_page_bit(pp, PG_writeback); +#endif } ZFS_EXIT(zfsvfs);