From 1c7f2f6a5088126695e99e91f6873f34e512c242 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Tue, 24 Sep 2024 16:44:01 +1000 Subject: [PATCH] Linux 6.12: f_version removed from struct file linux/torvalds@11068e0b64cb removes it, suggesting this was a always there as a helper to handle concurrent seeks, which all filesystems now handle themselves if necessary. Without looking into the mechanism, I can imagine how it might have been used, but we have always set it to zero and never read from it, presumably because we've always tracked per-caller position through the znode anyway. So I don't see how there can be any functional change for us by removing it. I've stayed conservative though and left it in for older kernels, since its clearly not hurting anything there. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Signed-off-by: Rob Norris Closes #16582 --- config/kernel-file.m4 | 31 ++++++++++++++++++++++ config/kernel.m4 | 2 ++ include/os/linux/kernel/linux/vfs_compat.h | 2 ++ 3 files changed, 35 insertions(+) create mode 100644 config/kernel-file.m4 diff --git a/config/kernel-file.m4 b/config/kernel-file.m4 new file mode 100644 index 000000000..31252544c --- /dev/null +++ b/config/kernel-file.m4 @@ -0,0 +1,31 @@ +dnl # +dnl # 6.12 removed f_version from struct file +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_FILE_F_VERSION], [ + ZFS_LINUX_TEST_SRC([file_f_version], [ + #include + + static const struct f __attribute__((unused)) = { + .f_version = 0; + }; + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_FILE_F_VERSION], [ + AC_MSG_CHECKING([whether file->f_version exists]) + ZFS_LINUX_TEST_RESULT([file_f_version], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_FILE_F_VERSION, 1, + [file->f_version exists]) + ], [ + AC_MSG_RESULT(no) + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_FILE], [ + ZFS_AC_KERNEL_FILE_F_VERSION +]) + +AC_DEFUN([ZFS_AC_KERNEL_SRC_FILE], [ + ZFS_AC_KERNEL_SRC_FILE_F_VERSION +]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 628581c98..bfd8404cd 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -127,6 +127,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_SYNC_BDEV ZFS_AC_KERNEL_SRC_MM_PAGE_SIZE ZFS_AC_KERNEL_SRC_MM_PAGE_MAPPING + ZFS_AC_KERNEL_SRC_FILE case "$host_cpu" in powerpc*) ZFS_AC_KERNEL_SRC_CPU_HAS_FEATURE @@ -238,6 +239,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_MM_PAGE_SIZE ZFS_AC_KERNEL_MM_PAGE_MAPPING ZFS_AC_KERNEL_1ARG_ASSIGN_STR + ZFS_AC_KERNEL_FILE case "$host_cpu" in powerpc*) ZFS_AC_KERNEL_CPU_HAS_FEATURE diff --git a/include/os/linux/kernel/linux/vfs_compat.h b/include/os/linux/kernel/linux/vfs_compat.h index b4767d1ec..3ed456dbf 100644 --- a/include/os/linux/kernel/linux/vfs_compat.h +++ b/include/os/linux/kernel/linux/vfs_compat.h @@ -81,7 +81,9 @@ lseek_execute( if (offset != filp->f_pos) { spin_lock(&filp->f_lock); filp->f_pos = offset; +#ifdef HAVE_FILE_F_VERSION filp->f_version = 0; +#endif spin_unlock(&filp->f_lock); }