Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use simple folio migration function to avoid BUG in migrate_folio_extra #16723

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions config/kernel-vfs-invalidate_folio.m4

This file was deleted.

27 changes: 27 additions & 0 deletions config/kernel-vfs-migrate_folio.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
dnl #
dnl # Linux 6.0 uses migrate_folio in lieu of migrate_page
dnl #
AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_MIGRATE_FOLIO], [
ZFS_LINUX_TEST_SRC([vfs_has_migrate_folio], [
#include <linux/fs.h>
#include <linux/migrate.h>

static const struct address_space_operations
aops __attribute__ ((unused)) = {
.migrate_folio = migrate_folio,
};
],[])
])

AC_DEFUN([ZFS_AC_KERNEL_VFS_MIGRATE_FOLIO], [
dnl #
dnl # Linux 6.0 uses migrate_folio in lieu of migrate_page
dnl #
AC_MSG_CHECKING([whether migrate_folio exists])
ZFS_LINUX_TEST_RESULT([vfs_has_migrate_folio], [
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_VFS_MIGRATE_FOLIO, 1, [migrate_folio exists])
],[
AC_MSG_RESULT([no])
])
])
32 changes: 0 additions & 32 deletions config/kernel-vfs-release_folio.m4

This file was deleted.

6 changes: 2 additions & 4 deletions config/kernel.m4
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
ZFS_AC_KERNEL_SRC_SGET
ZFS_AC_KERNEL_SRC_VFS_FILEMAP_DIRTY_FOLIO
ZFS_AC_KERNEL_SRC_VFS_READ_FOLIO
ZFS_AC_KERNEL_SRC_VFS_RELEASE_FOLIO
ZFS_AC_KERNEL_SRC_VFS_INVALIDATE_FOLIO
ZFS_AC_KERNEL_SRC_VFS_MIGRATE_FOLIO
ZFS_AC_KERNEL_SRC_VFS_FSYNC_2ARGS
ZFS_AC_KERNEL_SRC_VFS_DIRECT_IO
ZFS_AC_KERNEL_SRC_VFS_READPAGES
Expand Down Expand Up @@ -189,8 +188,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
ZFS_AC_KERNEL_SGET
ZFS_AC_KERNEL_VFS_FILEMAP_DIRTY_FOLIO
ZFS_AC_KERNEL_VFS_READ_FOLIO
ZFS_AC_KERNEL_VFS_RELEASE_FOLIO
ZFS_AC_KERNEL_VFS_INVALIDATE_FOLIO
ZFS_AC_KERNEL_VFS_MIGRATE_FOLIO
ZFS_AC_KERNEL_VFS_FSYNC_2ARGS
ZFS_AC_KERNEL_VFS_DIRECT_IO
ZFS_AC_KERNEL_VFS_READPAGES
Expand Down
17 changes: 0 additions & 17 deletions module/os/linux/zfs/zfs_vnops_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,6 @@ update_pages(znode_t *zp, int64_t start, int len, objset_t *os)
} else {
ClearPageError(pp);
SetPageUptodate(pp);
if (!PagePrivate(pp)) {
/*
* Set private bit so page migration
* will wait for us to finish writeback
* before calling migrate_folio().
*/
SetPagePrivate(pp);
get_page(pp);
}

if (mapping_writably_mapped(mp))
flush_dcache_page(pp);
Expand Down Expand Up @@ -4090,14 +4081,6 @@ zfs_fillpage(struct inode *ip, struct page *pp)
} else {
ClearPageError(pp);
SetPageUptodate(pp);
if (!PagePrivate(pp)) {
/*
* Set private bit so page migration will wait for us to
* finish writeback before calling migrate_folio().
*/
SetPagePrivate(pp);
get_page(pp);
}
}

return (error);
Expand Down
8 changes: 0 additions & 8 deletions module/os/linux/zfs/zfs_znode_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -1577,14 +1577,6 @@ zfs_zero_partial_page(znode_t *zp, uint64_t start, uint64_t len)
mark_page_accessed(pp);
SetPageUptodate(pp);
ClearPageError(pp);
if (!PagePrivate(pp)) {
/*
* Set private bit so page migration will wait for us to
* finish writeback before calling migrate_folio().
*/
SetPagePrivate(pp);
get_page(pp);
}
unlock_page(pp);
put_page(pp);
}
Expand Down
48 changes: 4 additions & 44 deletions module/os/linux/zfs/zpl_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <linux/compat.h>
#endif
#include <linux/fs.h>
#include <linux/migrate.h>
#include <sys/file.h>
#include <sys/dmu_objset.h>
#include <sys/zfs_znode.h>
Expand Down Expand Up @@ -607,42 +608,6 @@ zpl_writepage(struct page *pp, struct writeback_control *wbc)
return (zpl_putpage(pp, wbc, &for_sync));
}

static int
zpl_releasepage(struct page *pp, gfp_t gfp)
{
if (PagePrivate(pp)) {
ClearPagePrivate(pp);
put_page(pp);
}
return (1);
}

#ifdef HAVE_VFS_RELEASE_FOLIO
static bool
zpl_release_folio(struct folio *folio, gfp_t gfp)
{
return (zpl_releasepage(&folio->page, gfp));
}
#endif

#ifdef HAVE_VFS_INVALIDATE_FOLIO
static void
zpl_invalidate_folio(struct folio *folio, size_t offset, size_t len)
{
if ((offset == 0) && (len == PAGE_SIZE)) {
zpl_releasepage(&folio->page, 0);
}
}
#else
static void
zpl_invalidatepage(struct page *pp, unsigned int offset, unsigned int len)
{
if ((offset == 0) && (len == PAGE_SIZE)) {
zpl_releasepage(pp, 0);
}
}
#endif

/*
* The flag combination which matches the behavior of zfs_space() is
* FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE. The FALLOC_FL_PUNCH_HOLE
Expand Down Expand Up @@ -1126,15 +1091,10 @@ const struct address_space_operations zpl_address_space_operations = {
#ifdef HAVE_VFS_FILEMAP_DIRTY_FOLIO
.dirty_folio = filemap_dirty_folio,
#endif
#ifdef HAVE_VFS_RELEASE_FOLIO
.release_folio = zpl_release_folio,
#else
.releasepage = zpl_releasepage,
#endif
#ifdef HAVE_VFS_INVALIDATE_FOLIO
.invalidate_folio = zpl_invalidate_folio,
#ifdef HAVE_VFS_MIGRATE_FOLIO
.migrate_folio = migrate_folio,
#else
.invalidatepage = zpl_invalidatepage,
.migratepage = migrate_page,
#endif
};

Expand Down