Skip to content

Linux 6.14 compat: Check for migratepage VFS #17217

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

Merged
merged 1 commit into from
Apr 11, 2025

Conversation

tonyhutter
Copy link
Contributor

Motivation and Context

Support 6.14 kernel.

Description

The 6.14 kernel doesn't expect a 'migratepage' VFS op. Check for migratepage.

I'm not sure how this slipped though the cracks when we bumped META to 6.14. Maybe because I was testing against the Fedora 6.14 kernel and that's different from kernel.org one?

How Has This Been Tested?

Built against kernel.org source with ./configure --with-linux=<path to source>.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@robn
Copy link
Member

robn commented Apr 5, 2025

The kernel.org 6.14.0 has indeed removed migratepage, but has migrate_folio, so never gets into the #else. I've just built against 6.14.0 again and it worked fine (HAVE_VFS_MIGRATE_FOLIO is set), so I wonder if you've got something else weird going on?

I don't mind this PR as such, because I rather prefer tests that ask for the thing they need, rather than rely on the absence of some other thing, so I'll go test it on some older kernels too. But I'd still like to know what's happening so you needed it?

(FWIW, I tend to hold Fedora kernels at arms length when thinking specific kernel versions. They're not as weird as full Redhat kernels can be, but they're still a bit weird. Another reason to test for the specific things we want!)


static const struct address_space_operations
aops __attribute__ ((unused)) = {
.migrate_page = migrate_page,
Copy link
Member

@robn robn Apr 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be .migratepage: no one has .migrate_page :)

@@ -1059,8 +1059,10 @@ const struct address_space_operations zpl_address_space_operations = {
#ifdef HAVE_VFS_MIGRATE_FOLIO
.migrate_folio = migrate_folio,
#else
#ifdef HAVE_VFS_MIGRATEPAGE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer #elif defined(HAVE_VFS_MIGRATEPAGE) etc but it hardly matters.

@robn
Copy link
Member

robn commented Apr 5, 2025

FYI, with the test changed to .migratepage it compiles with the correct results for migrate_folio vs migratepage on kernels: 4.19.325 5.4.291 5.10.235 5.15.179 6.1.131 6.2.16 6.3.13 6.4.16 6.5.13 6.6.84 6.7.12 6.8.12 6.9.12 6.10.14 6.11.11 6.12.20 6.13.8 6.14.0

(I did not try using it though)

@amotin amotin added the Status: Code Review Needed Ready for review and testing label Apr 8, 2025
@tonyhutter
Copy link
Contributor Author

tonyhutter commented Apr 8, 2025

I've just built against 6.14.0 again and it worked fine (HAVE_VFS_MIGRATE_FOLIO is set), so I wonder if you've got something else weird going on?

Here's the specific failure I'm seeing:

  CC [M]  os/linux/zfs/zvol_os.o
  CC [M]  icp/algs/aes/aes_impl_aesni.o
  CC [M]  icp/algs/aes/aes_impl_x86-64.o
os/linux/zfs/zpl_file.c:1062:10: error: ‘const struct address_space_operations’ has no member named ‘migratepage’; did you mean ‘writepage’?
 1062 |         .migratepage    = migrate_page,
      |          ^~~~~~~~~~~
      |          writepage
os/linux/zfs/zpl_file.c:1062:27: error: ‘migrate_page’ undeclared here (not in a function); did you mean ‘migrate_pages’?
 1062 |         .migratepage    = migrate_page,
      |                           ^~~~~~~~~~~~
      |                           migrate_pages
make[6]: *** [/mnt/kernel/linux-6.14.1/scripts/Makefile.build:207: os/linux/zfs/zpl_file.o] Error 1
make[6]: *** Waiting for unfinished jobs....
make[5]: *** [/mnt/kernel/linux-6.14.1/Makefile:1994: .] Error 2

I'm building against the kernel.org 6.14.1 kernel (https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.14.1.tar.xz) which I built using a make tinyconfig configuration.

Now I'm thinking we can just get rid of .migratepage entirely since we don't use it:

diff --git a/module/os/linux/zfs/zpl_file.c b/module/os/linux/zfs/zpl_file.c
index 787d3cb31..e6ed55157 100644
--- a/module/os/linux/zfs/zpl_file.c
+++ b/module/os/linux/zfs/zpl_file.c
@@ -1058,8 +1058,6 @@ const struct address_space_operations zpl_address_space_operations = {
 #endif
 #ifdef HAVE_VFS_MIGRATE_FOLIO
        .migrate_folio  = migrate_folio,
-#else
-       .migratepage    = migrate_page,
 #endif
 };
 

@robn
Copy link
Member

robn commented Apr 9, 2025

Ahh, I think I see what's happening. The test doesn't just test that .migrate_folio exists, but also that the default function can be assigned to (rather than one we provide). But, the default migrate_folio function doesn't exist when CONFIG_MIGRATION is not set, which it is not for tinyconfig (and same for migrate_page pre-6.0). So the assignment fails in the test and we don't set HAVE_VFS_MIGRATE_FOLIO.

I wrote 74ae760 and was just about to offer it, but then realised that's basically what you'd already done! So if you fix up your migratepage test to set .migratepage, we'll have basically the same thing, and I'll be happy to +1 it.

Glad to understand it :)

@@ -0,0 +1,27 @@
dnl #
dnl # Linux 6.14 gets rid of address_space_operations.migratepage
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6.0.

@robn
Copy link
Member

robn commented Apr 9, 2025

Re getting rid of it, I think we have to keep it - kernel looks like it it doesn't always check for it to be non-NULL when calling it, so we at least have to set it to the fallback.

The couple of filesystems that do set it put it behind a #ifdef CONFIG_MIGRATION gate, but we don't need to because the autoconf test wont set our define anyways.

The 6.0 kernel removes the 'migratepage' VFS op. Check for
migratepage.

Signed-off-by: Tony Hutter <[email protected]>
@tonyhutter
Copy link
Contributor Author

@robn thanks for detective work on what was going on. My latest push should include all the changes you were looking for.

@tonyhutter tonyhutter mentioned this pull request Apr 9, 2025
13 tasks
Copy link
Member

@robn robn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 👍

@tonyhutter tonyhutter merged commit ab9bb19 into openzfs:master Apr 11, 2025
18 of 23 checks passed
fuporovvStack pushed a commit to fuporovvStack/zfs that referenced this pull request Apr 11, 2025
The 6.0 kernel removes the 'migratepage' VFS op. Check for
migratepage.

Signed-off-by: Tony Hutter <[email protected]>
Reviewed-by: Rob Norris <[email protected]>
Reviewed-by: Alexander Motin <[email protected]
fuporovvStack pushed a commit to fuporovvStack/zfs that referenced this pull request Apr 11, 2025
The 6.0 kernel removes the 'migratepage' VFS op. Check for
migratepage.

Signed-off-by: Tony Hutter <[email protected]>
Reviewed-by: Rob Norris <[email protected]>
Reviewed-by: Alexander Motin <[email protected]
tonyhutter added a commit to tonyhutter/zfs that referenced this pull request Apr 15, 2025
The 6.0 kernel removes the 'migratepage' VFS op. Check for
migratepage.

Signed-off-by: Tony Hutter <[email protected]>
Reviewed-by: Rob Norris <[email protected]>
Reviewed-by: Alexander Motin <[email protected]
tonyhutter added a commit to tonyhutter/zfs that referenced this pull request Apr 16, 2025
The 6.0 kernel removes the 'migratepage' VFS op. Check for
migratepage.

Signed-off-by: Tony Hutter <[email protected]>
Reviewed-by: Rob Norris <[email protected]>
Reviewed-by: Alexander Motin <[email protected]
snajpa pushed a commit to vpsfreecz/zfs that referenced this pull request May 2, 2025
The 6.0 kernel removes the 'migratepage' VFS op. Check for
migratepage.

Signed-off-by: Tony Hutter <[email protected]>
Reviewed-by: Rob Norris <[email protected]>
Reviewed-by: Alexander Motin <[email protected]
robn pushed a commit to robn/zfs that referenced this pull request May 12, 2025
The 6.0 kernel removes the 'migratepage' VFS op. Check for
migratepage.

Signed-off-by: Tony Hutter <[email protected]>
Reviewed-by: Rob Norris <[email protected]>
Reviewed-by: Alexander Motin <[email protected]
(cherry picked from commit ab9bb19)
robn pushed a commit to robn/zfs that referenced this pull request May 12, 2025
The 6.0 kernel removes the 'migratepage' VFS op. Check for
migratepage.

Signed-off-by: Tony Hutter <[email protected]>
Reviewed-by: Rob Norris <[email protected]>
Reviewed-by: Alexander Motin <[email protected]
Closes openzfs#17217
(cherry picked from commit ab9bb19)
@robn robn mentioned this pull request May 12, 2025
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Code Review Needed Ready for review and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants