Skip to content
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

Linux 6.12 compatibility #16582

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions config/kernel-file.m4
Original file line number Diff line number Diff line change
@@ -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 <linux/fs.h>

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
])
37 changes: 30 additions & 7 deletions config/kernel-kthread.m4
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,32 @@ AC_DEFUN([ZFS_AC_KERNEL_KTHREAD_COMPLETE_AND_EXIT], [
])
])

AC_DEFUN([ZFS_AC_KERNEL_KTHREAD_DEQUEUE_SIGNAL_4ARG], [
AC_DEFUN([ZFS_AC_KERNEL_KTHREAD_DEQUEUE_SIGNAL], [
dnl #
dnl # 5.17 API: enum pid_type * as new 4th dequeue_signal() argument,
dnl # 5768d8906bc23d512b1a736c1e198aa833a6daa4 ("signal: Requeue signals in the appropriate queue")
dnl #
dnl # int dequeue_signal(struct task_struct *task, sigset_t *mask, kernel_siginfo_t *info);
dnl # int dequeue_signal(struct task_struct *task, sigset_t *mask, kernel_siginfo_t *info, enum pid_type *type);
dnl #
dnl # 6.12 API: first arg struct_task* removed
dnl # int dequeue_signal(sigset_t *mask, kernel_siginfo_t *info, enum pid_type *type);
dnl #
AC_MSG_CHECKING([whether dequeue_signal() takes 4 arguments])
ZFS_LINUX_TEST_RESULT([kthread_dequeue_signal], [
ZFS_LINUX_TEST_RESULT([kthread_dequeue_signal_4arg], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_DEQUEUE_SIGNAL_4ARG, 1, [dequeue_signal() takes 4 arguments])
AC_DEFINE(HAVE_DEQUEUE_SIGNAL_4ARG, 1,
[dequeue_signal() takes 4 arguments])
], [
AC_MSG_RESULT(no)
AC_MSG_CHECKING([whether dequeue_signal() a task argument])
ZFS_LINUX_TEST_RESULT([kthread_dequeue_signal_3arg_task], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_DEQUEUE_SIGNAL_3ARG_TASK, 1,
[dequeue_signal() takes a task argument])
], [
AC_MSG_RESULT(no)
])
])
])

Expand All @@ -43,8 +55,19 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD_COMPLETE_AND_EXIT], [
])
])

AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD_DEQUEUE_SIGNAL_4ARG], [
ZFS_LINUX_TEST_SRC([kthread_dequeue_signal], [
AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD_DEQUEUE_SIGNAL], [
ZFS_LINUX_TEST_SRC([kthread_dequeue_signal_3arg_task], [
#include <linux/sched/signal.h>
], [
struct task_struct *task = NULL;
sigset_t *mask = NULL;
kernel_siginfo_t *info = NULL;
int error __attribute__ ((unused));

error = dequeue_signal(task, mask, info);
])

ZFS_LINUX_TEST_SRC([kthread_dequeue_signal_4arg], [
#include <linux/sched/signal.h>
], [
struct task_struct *task = NULL;
Expand All @@ -59,10 +82,10 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD_DEQUEUE_SIGNAL_4ARG], [

AC_DEFUN([ZFS_AC_KERNEL_KTHREAD], [
ZFS_AC_KERNEL_KTHREAD_COMPLETE_AND_EXIT
ZFS_AC_KERNEL_KTHREAD_DEQUEUE_SIGNAL_4ARG
ZFS_AC_KERNEL_KTHREAD_DEQUEUE_SIGNAL
])

AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD], [
ZFS_AC_KERNEL_SRC_KTHREAD_COMPLETE_AND_EXIT
ZFS_AC_KERNEL_SRC_KTHREAD_DEQUEUE_SIGNAL_4ARG
ZFS_AC_KERNEL_SRC_KTHREAD_DEQUEUE_SIGNAL
])
24 changes: 24 additions & 0 deletions config/kernel-mm-page-flags.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
AC_DEFUN([ZFS_AC_KERNEL_SRC_MM_PAGE_FLAG_ERROR], [
ZFS_LINUX_TEST_SRC([mm_page_flag_error], [
#include <linux/page-flags.h>

static enum pageflags
test_flag __attribute__((unused)) = PG_error;
])
])
AC_DEFUN([ZFS_AC_KERNEL_MM_PAGE_FLAG_ERROR], [
AC_MSG_CHECKING([whether PG_error flag is available])
ZFS_LINUX_TEST_RESULT([mm_page_flag_error], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_MM_PAGE_FLAG_ERROR, 1, [PG_error flag is available])
],[
AC_MSG_RESULT(no)
])
])

AC_DEFUN([ZFS_AC_KERNEL_SRC_MM_PAGE_FLAGS], [
ZFS_AC_KERNEL_SRC_MM_PAGE_FLAG_ERROR
])
AC_DEFUN([ZFS_AC_KERNEL_MM_PAGE_FLAGS], [
ZFS_AC_KERNEL_MM_PAGE_FLAG_ERROR
])
4 changes: 4 additions & 0 deletions config/kernel.m4
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
ZFS_AC_KERNEL_SRC_PROC_HANDLER_CTL_TABLE_CONST
ZFS_AC_KERNEL_SRC_COPY_SPLICE_READ
ZFS_AC_KERNEL_SRC_SYNC_BDEV
ZFS_AC_KERNEL_SRC_MM_PAGE_FLAGS
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
Expand Down Expand Up @@ -235,9 +237,11 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
ZFS_AC_KERNEL_PROC_HANDLER_CTL_TABLE_CONST
ZFS_AC_KERNEL_COPY_SPLICE_READ
ZFS_AC_KERNEL_SYNC_BDEV
ZFS_AC_KERNEL_MM_PAGE_FLAGS
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
Expand Down
14 changes: 14 additions & 0 deletions include/os/linux/kernel/linux/mm_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,18 @@
#define page_mapping(p) folio_mapping(page_folio(p))
#endif

/*
* 6.12 removed PG_error, SetPageError and ClearPageError, with no direct
* replacement, because page writeback errors are recorded elsewhere. Since we
* only use the page cache to assist with mmap(), never directly backing it
* with IO, it shouldn't be possible for this condition to occur on our pages
* anyway, even if this is the right way to report it. So it should be safe
* to remove, but for avoidance of doubt, we make it a no-op on 6.12 and leave
* it for everything else.
*/
#ifndef HAVE_MM_PAGE_FLAG_ERROR
#define SetPageError(p) do {} while (0)
#define ClearPageError(p) do {} while (0)
#endif

#endif /* _ZFS_MM_COMPAT_H */
6 changes: 6 additions & 0 deletions include/os/linux/kernel/linux/vfs_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ lseek_execute(
loff_t offset,
loff_t maxsize)
{
#ifdef FMODE_UNSIGNED_OFFSET
if (offset < 0 && !(filp->f_mode & FMODE_UNSIGNED_OFFSET))
#else
if (offset < 0 && !(filp->f_op->fop_flags & FOP_UNSIGNED_OFFSET))
#endif
return (-EINVAL);

if (offset > maxsize)
Expand All @@ -77,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);
}

Expand Down
1 change: 1 addition & 0 deletions include/os/linux/spl/sys/kmem_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ extern uint64_t spl_kmem_cache_entry_size(kmem_cache_t *cache);

/* Avoid conflicts with kernel names that might be implemented as macros. */
#undef kmem_cache_alloc
#undef kmem_cache_create

#define kmem_cache_create(name, size, align, ctor, dtor, rclm, priv, vmp, fl) \
spl_kmem_cache_create(name, size, align, ctor, dtor, rclm, priv, vmp, fl)
Expand Down
18 changes: 10 additions & 8 deletions module/os/linux/spl/spl-thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,22 @@ issig(void)
if (!signal_pending(current))
return (0);

struct task_struct *task = current;
spl_kernel_siginfo_t __info;
sigset_t set;
siginitsetinv(&set, 1ULL << (SIGSTOP - 1) | 1ULL << (SIGTSTP - 1));
sigorsets(&set, &task->blocked, &set);
sigorsets(&set, &current->blocked, &set);

spin_lock_irq(&task->sighand->siglock);
#ifdef HAVE_DEQUEUE_SIGNAL_4ARG
spin_lock_irq(&current->sighand->siglock);
#if defined(HAVE_DEQUEUE_SIGNAL_4ARG)
enum pid_type __type;
if (dequeue_signal(task, &set, &__info, &__type) != 0) {
if (dequeue_signal(current, &set, &__info, &__type) != 0) {
#elif defined(HAVE_DEQUEUE_SIGNAL_3ARG_TASK)
if (dequeue_signal(current, &set, &__info) != 0) {
#else
if (dequeue_signal(task, &set, &__info) != 0) {
enum pid_type __type;
if (dequeue_signal(&set, &__info, &__type) != 0) {
#endif
spin_unlock_irq(&task->sighand->siglock);
spin_unlock_irq(&current->sighand->siglock);
kernel_signal_stop();

/*
Expand All @@ -188,7 +190,7 @@ issig(void)
return (0);
}

spin_unlock_irq(&task->sighand->siglock);
spin_unlock_irq(&current->sighand->siglock);

return (1);
}
Expand Down
1 change: 1 addition & 0 deletions module/os/linux/zfs/zfs_znode_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#include <sys/sa.h>
#include <sys/zfs_sa.h>
#include <sys/zfs_stat.h>
#include <linux/mm_compat.h>

#include "zfs_prop.h"
#include "zfs_comutil.h"
Expand Down