[packages/zfs] - rel 2, upstream fix for kernel 6.17

baggins baggins at pld-linux.org
Sun Oct 5 10:03:40 CEST 2025


commit a64971898bdc342028e651e7723e3cc06eb90cb8
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sun Oct 5 12:03:20 2025 +0200

    - rel 2, upstream fix for kernel 6.17

 kernel-6.17.patch | 239 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 zfs.spec          |   4 +-
 2 files changed, 242 insertions(+), 1 deletion(-)
---
diff --git a/zfs.spec b/zfs.spec
index c84853a..1df5b40 100644
--- a/zfs.spec
+++ b/zfs.spec
@@ -24,7 +24,7 @@ exit 1
 
 %define		_duplicate_files_terminate_build	0
 
-%define	rel	1
+%define	rel	2
 %define	pname	zfs
 Summary:	Native Linux port of the ZFS filesystem
 Summary(pl.UTF-8):	Natywny linuksowy port systemu plików ZFS
@@ -37,6 +37,7 @@ Source0:	https://github.com/openzfs/zfs/releases/download/zfs-%{version}/%{pname
 # Source0-md5:	33be66d78e53ad63fcd7ed4ed7703cb7
 Patch0:		initdir.patch
 Patch1:		pld.patch
+Patch2:		kernel-6.17.patch
 URL:		https://zfsonlinux.org/
 BuildRequires:	autoconf >= 2.50
 BuildRequires:	automake
@@ -264,6 +265,7 @@ p=`pwd`\
 %setup -q -n %{pname}-%{version}
 %patch -P 0 -p1
 %patch -P 1 -p1
+%patch -P 2 -p1
 
 %{__sed} -E -i -e '1s,#!\s*/usr/bin/env\s+python3(\s|$),#!%{__python3}\1,' \
 	cmd/arc_summary
diff --git a/kernel-6.17.patch b/kernel-6.17.patch
new file mode 100644
index 0000000..c516ce3
--- /dev/null
+++ b/kernel-6.17.patch
@@ -0,0 +1,239 @@
+From 0df91abe821e52bc63c59f4fd0548835081dc3ad Mon Sep 17 00:00:00 2001
+From: Rob Norris <robn at despairlabs.com>
+Date: Thu, 31 Jul 2025 13:12:43 +1000
+Subject: [PATCH] Linux 6.17: d_set_d_op() is no longer available
+
+We only have extremely narrow uses, so move it all into a single
+function that does only what we need, with and without d_set_d_op().
+
+Sponsored-by: https://despairlabs.com/sponsor/
+Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
+Reviewed-by: Tony Hutter <hutter2 at llnl.gov>
+Signed-off-by: Rob Norris <robn at despairlabs.com>
+Closes #17621
+---
+ config/kernel-dentry-operations.m4            | 10 +++-
+ include/os/linux/kernel/linux/dcache_compat.h | 26 ---------
+ module/os/linux/zfs/zpl_ctldir.c              | 55 ++++++++++++++++---
+ 3 files changed, 55 insertions(+), 36 deletions(-)
+
+diff --git a/config/kernel-dentry-operations.m4 b/config/kernel-dentry-operations.m4
+index 5a5c93b1eee9..6d87ad0e0710 100644
+--- a/config/kernel-dentry-operations.m4
++++ b/config/kernel-dentry-operations.m4
+@@ -0,0 +1,82 @@
++dnl #
++dnl # 2.6.28 API change
++dnl # Added d_obtain_alias() helper function.
++dnl #
++AC_DEFUN([ZFS_AC_KERNEL_SRC_D_OBTAIN_ALIAS], [
++	ZFS_LINUX_TEST_SRC([d_obtain_alias], [
++		#include <linux/dcache.h>
++	], [
++		d_obtain_alias(NULL);
++	])
++])
++
++AC_DEFUN([ZFS_AC_KERNEL_D_OBTAIN_ALIAS], [
++	AC_MSG_CHECKING([whether d_obtain_alias() is available])
++	ZFS_LINUX_TEST_RESULT_SYMBOL([d_obtain_alias],
++	    [d_obtain_alias], [fs/dcache.c], [
++		AC_MSG_RESULT(yes)
++	], [
++		ZFS_LINUX_TEST_ERROR([d_obtain_alias()])
++	])
++])
++
++dnl #
++dnl # 2.6.38 API change
++dnl # Added d_set_d_op() helper function.
++dnl #
++dnl # 6.17 API change
++dnl # d_set_d_op() removed. No direct replacement.
++dnl #
++AC_DEFUN([ZFS_AC_KERNEL_SRC_D_SET_D_OP], [
++	ZFS_LINUX_TEST_SRC([d_set_d_op], [
++		#include <linux/dcache.h>
++	], [
++		d_set_d_op(NULL, NULL);
++	])
++])
++
++AC_DEFUN([ZFS_AC_KERNEL_D_SET_D_OP], [
++	AC_MSG_CHECKING([whether d_set_d_op() is available])
++	ZFS_LINUX_TEST_RESULT([d_set_d_op], [
++		AC_MSG_RESULT(yes)
++		AC_DEFINE(HAVE_D_SET_D_OP, 1,
++		    [Define if d_set_d_op() is available])
++	], [
++		AC_MSG_RESULT(no)
++	])
++])
++
++dnl #
++dnl # 6.17 API change
++dnl # sb->s_d_op removed; set_default_d_op(sb, dop) added
++dnl #
++AC_DEFUN([ZFS_AC_KERNEL_SRC_SET_DEFAULT_D_OP], [
++	ZFS_LINUX_TEST_SRC([set_default_d_op], [
++		#include <linux/dcache.h>
++	], [
++		set_default_d_op(NULL, NULL);
++	])
++])
++
++AC_DEFUN([ZFS_AC_KERNEL_SET_DEFAULT_D_OP], [
++	AC_MSG_CHECKING([whether set_default_d_op() is available])
++	ZFS_LINUX_TEST_RESULT([set_default_d_op], [
++		AC_MSG_RESULT(yes)
++		AC_DEFINE(HAVE_SET_DEFAULT_D_OP, 1,
++		    [Define if set_default_d_op() is available])
++	], [
++		AC_MSG_RESULT(no)
++	])
++])
++
++AC_DEFUN([ZFS_AC_KERNEL_SRC_DENTRY], [
++        ZFS_AC_KERNEL_SRC_D_OBTAIN_ALIAS
++        ZFS_AC_KERNEL_SRC_D_SET_D_OP
++        ZFS_AC_KERNEL_SRC_SET_DEFAULT_D_OP
++])
++
++AC_DEFUN([ZFS_AC_KERNEL_DENTRY], [
++        ZFS_AC_KERNEL_D_OBTAIN_ALIAS
++        ZFS_AC_KERNEL_D_SET_D_OP
++        ZFS_AC_KERNEL_SET_DEFAULT_D_OP
++])
+diff --git a/include/os/linux/kernel/linux/dcache_compat.h b/include/os/linux/kernel/linux/dcache_compat.h
+index 16e8a319a5f8..152e5a606f0e 100644
+--- a/include/os/linux/kernel/linux/dcache_compat.h
++++ b/include/os/linux/kernel/linux/dcache_compat.h
+@@ -60,32 +60,6 @@
+ 	} while (0)
+ #endif
+ 
+-/*
+- * 2.6.30 API change,
+- * The const keyword was added to the 'struct dentry_operations' in
+- * the dentry structure.  To handle this we define an appropriate
+- * dentry_operations_t typedef which can be used.
+- */
+-typedef const struct dentry_operations	dentry_operations_t;
+-
+-/*
+- * 2.6.38 API addition,
+- * Added d_clear_d_op() helper function which clears some flags and the
+- * registered dentry->d_op table.  This is required because d_set_d_op()
+- * issues a warning when the dentry operations table is already set.
+- * For the .zfs control directory to work properly we must be able to
+- * override the default operations table and register custom .d_automount
+- * and .d_revalidate callbacks.
+- */
+-static inline void
+-d_clear_d_op(struct dentry *dentry)
+-{
+-	dentry->d_op = NULL;
+-	dentry->d_flags &= ~(
+-	    DCACHE_OP_HASH | DCACHE_OP_COMPARE |
+-	    DCACHE_OP_REVALIDATE | DCACHE_OP_DELETE);
+-}
+-
+ /*
+  * Walk and invalidate all dentry aliases of an inode
+  * unless it's a mountpoint
+diff --git a/module/os/linux/zfs/zpl_ctldir.c b/module/os/linux/zfs/zpl_ctldir.c
+index 48dae79a2373..81ac26cb0c93 100644
+--- a/module/os/linux/zfs/zpl_ctldir.c
++++ b/module/os/linux/zfs/zpl_ctldir.c
+@@ -202,7 +202,7 @@ zpl_snapdir_revalidate(struct dentry *dentry, unsigned int flags)
+ 	return (!!dentry->d_inode);
+ }
+ 
+-static dentry_operations_t zpl_dops_snapdirs = {
++static const struct dentry_operations zpl_dops_snapdirs = {
+ /*
+  * Auto mounting of snapshots is only supported for 2.6.37 and
+  * newer kernels.  Prior to this kernel the ops->follow_link()
+@@ -215,6 +215,51 @@ static dentry_operations_t zpl_dops_snapdirs = {
+ 	.d_revalidate	= zpl_snapdir_revalidate,
+ };
+ 
++/*
++ * For the .zfs control directory to work properly we must be able to override
++ * the default operations table and register custom .d_automount and
++ * .d_revalidate callbacks.
++ */
++static void
++set_snapdir_dentry_ops(struct dentry *dentry, unsigned int extraflags) {
++	static const unsigned int op_flags =
++	    DCACHE_OP_HASH | DCACHE_OP_COMPARE |
++	    DCACHE_OP_REVALIDATE | DCACHE_OP_DELETE |
++	    DCACHE_OP_PRUNE | DCACHE_OP_WEAK_REVALIDATE | DCACHE_OP_REAL;
++
++#ifdef HAVE_D_SET_D_OP
++	/*
++	 * d_set_d_op() will set the DCACHE_OP_ flags according to what it
++	 * finds in the passed dentry_operations, so we don't have to.
++	 *
++	 * We clear the flags and the old op table before calling d_set_d_op()
++	 * because issues a warning when the dentry operations table is already
++	 * set.
++	 */
++	dentry->d_op = NULL;
++	dentry->d_flags &= ~op_flags;
++	d_set_d_op(dentry, &zpl_dops_snapdirs);
++	dentry->d_flags |= extraflags;
++#else
++	/*
++	 * Since 6.17 there's no exported way to modify dentry ops, so we have
++	 * to reach in and do it ourselves. This should be safe for our very
++	 * narrow use case, which is to create or splice in an entry to give
++	 * access to a snapshot.
++	 *
++	 * We need to set the op flags directly. We hardcode
++	 * DCACHE_OP_REVALIDATE because that's the only operation we have; if
++	 * we ever extend zpl_dops_snapdirs we will need to update the op flags
++	 * to match.
++	 */
++	spin_lock(&dentry->d_lock);
++	dentry->d_op = &zpl_dops_snapdirs;
++	dentry->d_flags &= ~op_flags;
++	dentry->d_flags |= DCACHE_OP_REVALIDATE | extraflags;
++	spin_unlock(&dentry->d_lock);
++#endif
++}
++
+ static struct dentry *
+ zpl_snapdir_lookup(struct inode *dip, struct dentry *dentry,
+     unsigned int flags)
+@@ -236,10 +281,7 @@ zpl_snapdir_lookup(struct inode *dip, struct dentry *dentry,
+ 		return (ERR_PTR(error));
+ 
+ 	ASSERT(error == 0 || ip == NULL);
+-	d_clear_d_op(dentry);
+-	d_set_d_op(dentry, &zpl_dops_snapdirs);
+-	dentry->d_flags |= DCACHE_NEED_AUTOMOUNT;
+-
++	set_snapdir_dentry_ops(dentry, DCACHE_NEED_AUTOMOUNT);
+ 	return (d_splice_alias(ip, dentry));
+ }
+ 
+@@ -373,8 +415,7 @@ zpl_snapdir_mkdir(struct inode *dip, struct dentry *dentry, umode_t mode)
+ 
+ 	error = -zfsctl_snapdir_mkdir(dip, dname(dentry), vap, &ip, cr, 0);
+ 	if (error == 0) {
+-		d_clear_d_op(dentry);
+-		d_set_d_op(dentry, &zpl_dops_snapdirs);
++		set_snapdir_dentry_ops(dentry, 0);
+ 		d_instantiate(dentry, ip);
+ 	}
+ 
+--- zfs-2.3.4/META~	2025-08-25 22:57:18.000000000 +0200
++++ zfs-2.3.4/META	2025-10-05 00:32:44.599997606 +0200
+@@ -6,5 +6,5 @@
+ Release-Tags:  relext
+ License:       CDDL
+ Author:        OpenZFS
+-Linux-Maximum: 6.16
++Linux-Maximum: 6.17
+ Linux-Minimum: 4.18
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/zfs.git/commitdiff/a64971898bdc342028e651e7723e3cc06eb90cb8



More information about the pld-cvs-commit mailing list