Linux 6.19: replace i_state access with inode_state_read_once()

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Closes #18053
This commit is contained in:
Rob Norris 2025-12-01 16:05:27 +11:00 committed by Brian Behlendorf
parent 3c4193333b
commit 3c8665cb5d
4 changed files with 35 additions and 1 deletions

View File

@ -0,0 +1,23 @@
dnl #
dnl # 6.19 API change. inode->i_state no longer accessible directly; helper
dnl # functions exist.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_STATE_READ_ONCE], [
ZFS_LINUX_TEST_SRC([inode_state_read_once], [
#include <linux/fs.h>
], [
struct inode i = {};
inode_state_read_once(&i);
],[])
])
AC_DEFUN([ZFS_AC_KERNEL_INODE_STATE_READ_ONCE], [
AC_MSG_CHECKING([whether inode_state_read_once() exists])
ZFS_LINUX_TEST_RESULT([inode_state_read_once], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_INODE_STATE_READ_ONCE, 1,
[inode_state_read_once() exists])
],[
AC_MSG_RESULT(no)
])
])

View File

@ -59,6 +59,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
ZFS_AC_KERNEL_SRC_ACL
ZFS_AC_KERNEL_SRC_INODE_SETATTR
ZFS_AC_KERNEL_SRC_INODE_GETATTR
ZFS_AC_KERNEL_SRC_INODE_STATE_READ_ONCE
ZFS_AC_KERNEL_SRC_SHOW_OPTIONS
ZFS_AC_KERNEL_SRC_SHRINKER
ZFS_AC_KERNEL_SRC_MKDIR
@ -181,6 +182,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
ZFS_AC_KERNEL_ACL
ZFS_AC_KERNEL_INODE_SETATTR
ZFS_AC_KERNEL_INODE_GETATTR
ZFS_AC_KERNEL_INODE_STATE_READ_ONCE
ZFS_AC_KERNEL_SHOW_OPTIONS
ZFS_AC_KERNEL_SHRINKER
ZFS_AC_KERNEL_MKDIR

View File

@ -269,4 +269,12 @@ zpl_is_32bit_api(void)
#define generic_drop_inode(ip) inode_generic_drop(ip)
#endif
#ifndef HAVE_INODE_STATE_READ_ONCE
/*
* 6.19 API change. We should no longer access i_state directly. If the new
* helper function doesn't exist, define our own.
*/
#define inode_state_read_once(ip) READ_ONCE(ip->i_state)
#endif
#endif /* _ZFS_VFS_H */

View File

@ -3513,7 +3513,8 @@ zfs_link(znode_t *tdzp, znode_t *szp, char *name, cred_t *cr,
boolean_t is_tmpfile = 0;
uint64_t txg;
is_tmpfile = (sip->i_nlink == 0 && (sip->i_state & I_LINKABLE));
is_tmpfile = (sip->i_nlink == 0 &&
(inode_state_read_once(sip) & I_LINKABLE));
ASSERT(S_ISDIR(ZTOI(tdzp)->i_mode));