Skip to content

[2.3] Linux 6.18 compat#18038

Merged
behlendorf merged 10 commits intoopenzfs:zfs-2.3.6-stagingfrom
robn:linux-6.18-compat-2.3
Dec 17, 2025
Merged

[2.3] Linux 6.18 compat#18038
behlendorf merged 10 commits intoopenzfs:zfs-2.3.6-stagingfrom
robn:linux-6.18-compat-2.3

Conversation

@robn
Copy link
Copy Markdown
Member

@robn robn commented Dec 10, 2025

Motivation and Context

Adding 6.18.x kernel support to 2.3.x. This is the LTS kernel for next year, so we should try to work with it.

Closes #18026.

Description

Cherry-picks commits from #17842 with appropriate adjustments.

Changes to module/os/linux/zvol_os.c are a little different because #17625 etc not backported.

Did not pick fe8b50f because we do not use generic_drop_inode()/generic_delete_inode() (#17746 not backported).

Also including commits from #17954 to allow compilation with recent Clang.

How Has This Been Tested?

Compile checked only against kernels: 6.18.0 6.15.9 6.12.41 6.8.12 6.1.147 5.10.240 4.19.325

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)
  • Quality assurance (non-breaking change which makes the code more robust against bugs)
  • 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 added 9 commits December 10, 2025 12:09
Sponsored-by: https://despairlabs.com/sponsor/
Signed-off-by: Rob Norris <robn@despairlabs.com>
ida_simple_get() and ida_simple_remove() are removed in 6.18. However,
since 4.19 they have been simple wrappers around ida_alloc() and
ida_free(), so we can just use those directly.

Sponsored-by: https://despairlabs.com/sponsor/
Signed-off-by: Rob Norris <robn@despairlabs.com>
Sponsored-by: https://despairlabs.com/sponsor/
Signed-off-by: Rob Norris <robn@despairlabs.com>
Linux 6.18 removed write_cache_pages() without a usable replacement.
Here we implement a minimal zpl_write_cache_pages() that find the dirty
pages within the mapping, gets them into the expected state and hands
them off to zfs_putpage(), which handles the rest.

Sponsored-by: https://despairlabs.com/sponsor/
Signed-off-by: Rob Norris <robn@despairlabs.com>
The namespace type has moved from the namespace ops struct to the
"common" base namespace struct. Detect this and define a macro that does
the right thing for both versions.

Sponsored-by: https://despairlabs.com/sponsor/
Signed-off-by: Rob Norris <robn@despairlabs.com>
Linux 6.18 has conflicting prototypes for various sha256_* and sha512_*
functions, which we get through a very long include chain. That's tough
to fix right now; easier is just to rename our internal functions.

Sponsored-by: https://despairlabs.com/sponsor/
Signed-off-by: Rob Norris <robn@despairlabs.com>
Linux switched from -std=gnu89 to -std=gnu11 in 5.18
(torvalds/linux@e8c07082a810f). We've always overridden that with gnu99
because we use some newer features.

More recent kernels are using C11 features in headers that we include.
GCC generally doesn't seem to care, but more recent versions of Clang
seem to be enforcing our gnu99 override more strictly, which breaks the
build in some configurations.

Just bumping our "override" to match the kernel seems to be the easiest
workaround. It's an effective no-op since 5.18, while still allowing us
to build on older kernels.

Sponsored-by: https://despairlabs.com/sponsor/
Signed-off-by: Rob Norris <robn@despairlabs.com>
Using strlen() in an static array declaration is a GCC extension. Clang
calls it "gnu-folding-constant" and warns about it, which breaks the
build. If it were widespread we could just turn off the warning, but
since there's only one case, lets just change the array to an explicit
size.

Sponsored-by: https://despairlabs.com/sponsor/
Signed-off-by: Rob Norris <robn@despairlabs.com>
6.18 changes kmap_atomic() to take a const pointer. This is no problem
for the places we use it, but Clang fails the test due to a warning
about being unable to guarantee that uninitialised data will definitely
not change. Easily solved by forcibly initialising it.

Sponsored-by: https://despairlabs.com/sponsor/
Signed-off-by: Rob Norris <robn@despairlabs.com>
@behlendorf behlendorf self-requested a review December 11, 2025 02:00
@mabod
Copy link
Copy Markdown

mabod commented Dec 11, 2025

I get an error when applying this patch with the zfs-dkms PKGBUILD:

==> 18038.patch
patching file module/os/linux/zfs/abd_os.c
patching file module/os/linux/zfs/zvol_os.c
patching file config/kernel-block-device-operations.m4
patching file module/os/linux/zfs/zvol_os.c
patching file config/kernel-writeback.m4
patching file config/kernel-writepage_t.m4
patching file config/kernel.m4
patching file module/os/linux/zfs/zpl_file.c
patching file config/kernel-namespace.m4
The next patch would delete the file config/kernel-userns-capabilities.m4,
which does not exist!  Assume -R? [n]
Apply anyway? [n]
Skipping patch.
1 out of 1 hunk ignored
patching file config/kernel.m4
patching file module/os/linux/spl/spl-zone.c
patching file module/icp/algs/sha2/sha2_generic.c
patching file module/Kbuild.in
patching file udev/zvol_id.c
patching file config/kernel-kmap-atomic-args.m4
==> ERROR: A failure occurred in prepare().
    Aborting...

This PR works if I remove the part related to config/kernel-userns-capabilities.m4

@behlendorf
Copy link
Copy Markdown
Contributor

@robn thanks for pulling this together. Can you add META update from #18039 then this should be complete for 6.18 support.

@mabod I'm not seeing that conflict. Are you sure you're applying this patch stack to a clean 2.3.5 checkout?

@behlendorf behlendorf added the Status: Accepted Ready to integrate (reviewed, tested) label Dec 15, 2025
@tonyhutter
Copy link
Copy Markdown
Contributor

Please leave the commit messages unaltered when backporting. I see:

[master] bfd137d92 config/kmap_atomic: initialise test data
[linux-6.18-compat-2.3] 77da44de6 config/kmap_atomic: initialise test data
--- /tmp/diff-master	2025-12-15 17:31:01.043026912 -0800
+++ /tmp/diff-linux-6.18-compat-2.3	2025-12-15 17:31:01.043026912 -0800
@@ -10,10 +10,7 @@
     not change. Easily solved by forcibly initialising it.
     
     Sponsored-by: https://despairlabs.com/sponsor/
-    Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com>
-    Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
     Signed-off-by: Rob Norris <robn@despairlabs.com>
-    Closes #17954
 
 diff --git a/config/kernel-kmap-atomic-args.m4 b/config/kernel-kmap-atomic-args.m4
[master] b7e00c739 zvol_id: make array length properly known at compile time
[linux-6.18-compat-2.3] 86200a21f zvol_id: make array length properly known at compile time
--- /tmp/diff-master	2025-12-15 17:31:01.184026906 -0800
+++ /tmp/diff-linux-6.18-compat-2.3	2025-12-15 17:31:01.184026906 -0800
@@ -11,10 +11,7 @@
    size.
    
    Sponsored-by: https://despairlabs.com/sponsor/
-    Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com>
-    Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
    Signed-off-by: Rob Norris <robn@despairlabs.com>
-    Closes #17954

diff --git a/udev/zvol_id.c b/udev/zvol_id.c
[master] c631f5e6c Linux: bump -std to gnu11
[linux-6.18-compat-2.3] 9888d8a24 Linux: bump -std to gnu11
--- /tmp/diff-master	2025-12-15 17:31:01.325026899 -0800
+++ /tmp/diff-linux-6.18-compat-2.3	2025-12-15 17:31:01.326026899 -0800
@@ -18,10 +18,7 @@
     to build on older kernels.
     
     Sponsored-by: https://despairlabs.com/sponsor/
-    Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com>
-    Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
     Signed-off-by: Rob Norris <robn@despairlabs.com>
-    Closes #17954

I also see authors being changed, Co-authored lines being changed, and added Signed-off-by lines:

[master] ccf5a8a6f linux: use sys/stat.h instead of linux/stat.h
[linux-6.18-compat-2.3] bbbf438d6 linux: use sys/stat.h instead of linux/stat.h
--- /tmp/diff-master	2025-12-15 17:31:02.335026850 -0800
+++ /tmp/diff-linux-6.18-compat-2.3	2025-12-15 17:31:02.335026850 -0800
@@ -1,6 +1,6 @@
 
-Author: classabbyamp <5366828+classabbyamp@users.noreply.github.com>
-Date:   Wed Aug 27 17:42:32 2025 -0400
+Author: Alexander Moch <github@alexanderjulian.de>
+Date:   Tue Dec 9 19:58:45 2025 +0000
 
     linux: use sys/stat.h instead of linux/stat.h
     
@@ -15,8 +15,12 @@
     
     Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
     Tested-By: Achill Gilgenast <achill@achill.org>
-    Signed-off-by: classabbyamp <dev@placeviolette.net>
+    
     Closes #17675
+    
+    Signed-off-by: classabbyamp <dev@placeviolette.net>
+    Signed-off-by: Alexander Moch <mail@alexmoch.com>
+    Co-authored-by: classabbyamp <5366828+classabbyamp@users.noreply.github.com>
[master] 9acedbace config: Fix LLVM-21 -Wuninitialized-const-pointer warning
[linux-6.18-compat-2.3] 2d9ba1e3c config: Fix LLVM-21 -Wuninitialized-const-pointer warning (#17997)
--- /tmp/diff-master	2025-12-15 17:31:02.477026844 -0800
+++ /tmp/diff-linux-6.18-compat-2.3	2025-12-15 17:31:02.477026844 -0800
@@ -1,8 +1,8 @@
 
-Author: Brian Behlendorf <behlendorf1@llnl.gov>
-Date:   Tue Sep 2 09:34:08 2025 -0700
+Author: Alexander Moch <github@alexanderjulian.de>
+Date:   Wed Dec 3 19:30:55 2025 +0000
 
-    config: Fix LLVM-21 -Wuninitialized-const-pointer warning
+    config: Fix LLVM-21 -Wuninitialized-const-pointer warning (#17997)
     
     LLVM-21 enables -Wuninitialized-const-pointer which results in the
     following compiler warning and the bdev_file_open_by_path() interface
@@ -15,9 +15,13 @@
         argument here [-Werror,-Wuninitialized-const-pointer]
     
     Reviewed-by: Rob Norris <robn@despairlabs.com>
-    Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
+    
     Closes #17682
     Closes #17684
+    
+    Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
+    Signed-off-by: Alexander Moch <mail@alexmoch.com>
+    Co-authored-by: Brian Behlendorf <behlendorf1@llnl.gov>

Sponsored-by: https://despairlabs.com/sponsor/
Signed-off-by: Rob Norris <robn@despairlabs.com>
@github-actions github-actions Bot removed the Status: Accepted Ready to integrate (reviewed, tested) label Dec 16, 2025
@robn
Copy link
Copy Markdown
Member Author

robn commented Dec 16, 2025

@behlendorf META bumped.

@tonyhutter I usually treat them as brand-new commits, because some are actually different in small ways because the code they're patching is different, but more importantly, the listed reviewers have not signed off on them in this context, and I do not wish to speak for them. I can do something different, but please do let me know what the goal is because it's different to what I've done before and I want to make sure I'm bringing over the bits that are important to you.

(The change in authors and co-authors is nothing to do with me; those came from #17997).

@mabod
Copy link
Copy Markdown

mabod commented Dec 16, 2025

@mabod I'm not seeing that conflict. Are you sure you're applying this patch stack to a clean 2.3.5 checkout?

@behlendorf : you are right. I was using the standard PKGBUILD with

pkgver=2.3.5
"https://github.com/zfsonlinux/zfs/releases/download/zfs-${pkgver}/zfs-${pkgver}.tar.gz"{,.asc}

If I do a git clone instead with git checkout zfs-2.3.5 I do not see any error during patching. All good.

@tonyhutter
Copy link
Copy Markdown
Contributor

@robn you actually bring up a good point, in that we have no documentation how we want backports to be done! I just opened a PR here to update the docs with backport instructions: openzfs/openzfs-docs#592. Please commit in that PR with what you think of the policy.

@behlendorf behlendorf added the Status: Accepted Ready to integrate (reviewed, tested) label Dec 17, 2025
@behlendorf behlendorf merged commit 2fec0e3 into openzfs:zfs-2.3.6-staging Dec 17, 2025
49 of 57 checks passed
@hoopty-hoop
Copy link
Copy Markdown

@tonyhutter : Sorry for the silly question but I can't find the tracker for 2.3.6 release. Upstream has EOL'ed 6.17.xx and its that time of the upgrade cycle again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Accepted Ready to integrate (reviewed, tested)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants