commit bf636acc1e71cd78273831c01b7a5138b668ce56 Author: Jan Rękorajski <bagg...@pld-linux.org> Date: Fri Nov 17 00:35:19 2023 +0100
- up to 2.2.0 final, needs fix to build with kernel 6.6 blkdev.patch | 222 ------------- kernel-6.5.patch | 934 ------------------------------------------------------- zfs.spec | 12 +- 3 files changed, 5 insertions(+), 1163 deletions(-) --- diff --git a/zfs.spec b/zfs.spec index a415511..508db3d 100644 --- a/zfs.spec +++ b/zfs.spec @@ -24,8 +24,8 @@ exit 1 %define _duplicate_files_terminate_build 0 -%define pre rc3 -%define rel 0.%{pre}.1 +#define pre rc3 +%define rel 0.1 %define pname zfs Summary: Native Linux port of the ZFS filesystem Summary(pl.UTF-8): Natywny linuksowy port systemu plików ZFS @@ -34,10 +34,9 @@ Version: 2.2.0 Release: %{rel}%{?_pld_builder:%{?with_kernel:@%{_kernel_ver_str}}} License: CDDL Group: Applications/System -Source0: https://github.com/openzfs/zfs/releases/download/zfs-%{version}-%{pre}/%{pname}-%{version}-%{pre}.tar.gz -# Source0-md5: 75fd8dc40d9601db40029b357c824f3f +Source0: https://github.com/openzfs/zfs/releases/download/zfs-%{version}/%{pname}-%{version}.tar.gz +# Source0-md5: d7e2ec4c52d6a48653ce4a5b96c24a01 Patch0: initdir.patch -Patch3: kernel-6.5.patch URL: https://zfsonlinux.org/ BuildRequires: autoconf >= 2.50 BuildRequires: automake @@ -267,9 +266,8 @@ p=`pwd`\ %{?with_kernel:%{expand:%create_kernel_packages}} %prep -%setup -q -n %{pname}-%{version}-%{pre} +%setup -q -n %{pname}-%{version} %patch0 -p1 -%patch3 -p1 %{__sed} -E -i -e '1s,#!\s*/usr/bin/env\s+python3(\s|$),#!%{__python3}\1,' \ cmd/arc_summary diff --git a/blkdev.patch b/blkdev.patch deleted file mode 100644 index e8a00db..0000000 --- a/blkdev.patch +++ /dev/null @@ -1,222 +0,0 @@ -From ae0b1f66c707cff09bfde54aade784a016559a34 Mon Sep 17 00:00:00 2001 -From: Rich Ercolani <214141+rincebr...@users.noreply.github.com> -Date: Mon, 27 Mar 2023 14:29:19 -0400 -Subject: [PATCH] linux 6.3 compat: add another bdev_io_acct case - -Linux 6.3+, and backports from it (6.2.8+), changed the -signatures on bdev_io_{start,end}_acct. Add a case for it. - -Reviewed-by: Brian Behlendorf <behlendo...@llnl.gov> -Signed-off-by: Rich Ercolani <rincebr...@gmail.com> -Closes #14658 -Closes #14668 ---- - config/kernel-generic_io_acct.m4 | 98 ++++++++++++------- - include/os/linux/kernel/linux/blkdev_compat.h | 10 +- - 2 files changed, 69 insertions(+), 39 deletions(-) - -diff --git a/config/kernel-generic_io_acct.m4 b/config/kernel-generic_io_acct.m4 -index a8a448c6fe9..a6a10900429 100644 ---- a/config/kernel-generic_io_acct.m4 -+++ b/config/kernel-generic_io_acct.m4 -@@ -2,7 +2,20 @@ dnl # - dnl # Check for generic io accounting interface. - dnl # - AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_IO_ACCT], [ -- ZFS_LINUX_TEST_SRC([bdev_io_acct], [ -+ ZFS_LINUX_TEST_SRC([bdev_io_acct_63], [ -+ #include <linux/blkdev.h> -+ ], [ -+ struct block_device *bdev = NULL; -+ struct bio *bio = NULL; -+ unsigned long passed_time = 0; -+ unsigned long start_time; -+ -+ start_time = bdev_start_io_acct(bdev, bio_op(bio), -+ passed_time); -+ bdev_end_io_acct(bdev, bio_op(bio), bio_sectors(bio), start_time); -+ ]) -+ -+ ZFS_LINUX_TEST_SRC([bdev_io_acct_old], [ - #include <linux/blkdev.h> - ], [ - struct block_device *bdev = NULL; -@@ -63,74 +76,85 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_IO_ACCT], [ - - AC_DEFUN([ZFS_AC_KERNEL_GENERIC_IO_ACCT], [ - dnl # -- dnl # 5.19 API, -+ dnl # Linux 6.3, and then backports thereof, changed -+ dnl # the signatures on bdev_start_io_acct/bdev_end_io_acct - dnl # -- dnl # disk_start_io_acct() and disk_end_io_acct() have been replaced by -- dnl # bdev_start_io_acct() and bdev_end_io_acct(). -- dnl # -- AC_MSG_CHECKING([whether generic bdev_*_io_acct() are available]) -- ZFS_LINUX_TEST_RESULT([bdev_io_acct], [ -+ AC_MSG_CHECKING([whether 6.3+ bdev_*_io_acct() are available]) -+ ZFS_LINUX_TEST_RESULT([bdev_io_acct_63], [ - AC_MSG_RESULT(yes) -- AC_DEFINE(HAVE_BDEV_IO_ACCT, 1, [bdev_*_io_acct() available]) -+ AC_DEFINE(HAVE_BDEV_IO_ACCT_63, 1, [bdev_*_io_acct() available]) - ], [ - AC_MSG_RESULT(no) - - dnl # -- dnl # 5.12 API, -+ dnl # 5.19 API, - dnl # -- dnl # bio_start_io_acct() and bio_end_io_acct() became GPL-exported -- dnl # so use disk_start_io_acct() and disk_end_io_acct() instead -+ dnl # disk_start_io_acct() and disk_end_io_acct() have been replaced by -+ dnl # bdev_start_io_acct() and bdev_end_io_acct(). - dnl # -- AC_MSG_CHECKING([whether generic disk_*_io_acct() are available]) -- ZFS_LINUX_TEST_RESULT([disk_io_acct], [ -+ AC_MSG_CHECKING([whether pre-6.3 bdev_*_io_acct() are available]) -+ ZFS_LINUX_TEST_RESULT([bdev_io_acct_old], [ - AC_MSG_RESULT(yes) -- AC_DEFINE(HAVE_DISK_IO_ACCT, 1, [disk_*_io_acct() available]) -+ AC_DEFINE(HAVE_BDEV_IO_ACCT_OLD, 1, [bdev_*_io_acct() available]) - ], [ - AC_MSG_RESULT(no) -- - dnl # -- dnl # 5.7 API, -+ dnl # 5.12 API, - dnl # -- dnl # Added bio_start_io_acct() and bio_end_io_acct() helpers. -+ dnl # bio_start_io_acct() and bio_end_io_acct() became GPL-exported -+ dnl # so use disk_start_io_acct() and disk_end_io_acct() instead - dnl # -- AC_MSG_CHECKING([whether generic bio_*_io_acct() are available]) -- ZFS_LINUX_TEST_RESULT([bio_io_acct], [ -+ AC_MSG_CHECKING([whether generic disk_*_io_acct() are available]) -+ ZFS_LINUX_TEST_RESULT([disk_io_acct], [ - AC_MSG_RESULT(yes) -- AC_DEFINE(HAVE_BIO_IO_ACCT, 1, [bio_*_io_acct() available]) -+ AC_DEFINE(HAVE_DISK_IO_ACCT, 1, [disk_*_io_acct() available]) - ], [ - AC_MSG_RESULT(no) - - dnl # -- dnl # 4.14 API, -+ dnl # 5.7 API, - dnl # -- dnl # generic_start_io_acct/generic_end_io_acct now require -- dnl # request_queue to be provided. No functional changes, -- dnl # but preparation for inflight accounting. -+ dnl # Added bio_start_io_acct() and bio_end_io_acct() helpers. - dnl # -- AC_MSG_CHECKING([whether generic_*_io_acct wants 4 args]) -- ZFS_LINUX_TEST_RESULT_SYMBOL([generic_acct_4args], -- [generic_start_io_acct], [block/bio.c], [ -+ AC_MSG_CHECKING([whether generic bio_*_io_acct() are available]) -+ ZFS_LINUX_TEST_RESULT([bio_io_acct], [ - AC_MSG_RESULT(yes) -- AC_DEFINE(HAVE_GENERIC_IO_ACCT_4ARG, 1, -- [generic_*_io_acct() 4 arg available]) -+ AC_DEFINE(HAVE_BIO_IO_ACCT, 1, [bio_*_io_acct() available]) - ], [ - AC_MSG_RESULT(no) - - dnl # -- dnl # 3.19 API addition -+ dnl # 4.14 API, - dnl # -- dnl # torvalds/linux@394ffa50 allows us to increment -- dnl # iostat counters without generic_make_request(). -+ dnl # generic_start_io_acct/generic_end_io_acct now require -+ dnl # request_queue to be provided. No functional changes, -+ dnl # but preparation for inflight accounting. - dnl # -- AC_MSG_CHECKING( -- [whether generic_*_io_acct wants 3 args]) -- ZFS_LINUX_TEST_RESULT_SYMBOL([generic_acct_3args], -+ AC_MSG_CHECKING([whether generic_*_io_acct wants 4 args]) -+ ZFS_LINUX_TEST_RESULT_SYMBOL([generic_acct_4args], - [generic_start_io_acct], [block/bio.c], [ - AC_MSG_RESULT(yes) -- AC_DEFINE(HAVE_GENERIC_IO_ACCT_3ARG, 1, -- [generic_*_io_acct() 3 arg available]) -+ AC_DEFINE(HAVE_GENERIC_IO_ACCT_4ARG, 1, -+ [generic_*_io_acct() 4 arg available]) - ], [ - AC_MSG_RESULT(no) -+ -+ dnl # -+ dnl # 3.19 API addition -+ dnl # -+ dnl # torvalds/linux@394ffa50 allows us to increment -+ dnl # iostat counters without generic_make_request(). -+ dnl # -+ AC_MSG_CHECKING( -+ [whether generic_*_io_acct wants 3 args]) -+ ZFS_LINUX_TEST_RESULT_SYMBOL([generic_acct_3args], -+ [generic_start_io_acct], [block/bio.c], [ -+ AC_MSG_RESULT(yes) -+ AC_DEFINE(HAVE_GENERIC_IO_ACCT_3ARG, 1, -+ [generic_*_io_acct() 3 arg available]) -+ ], [ -+ AC_MSG_RESULT(no) -+ ]) - ]) - ]) - ]) -diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h -index f04eb5b2593..c7405ffab8b 100644 ---- a/include/os/linux/kernel/linux/blkdev_compat.h -+++ b/include/os/linux/kernel/linux/blkdev_compat.h -@@ -592,7 +592,10 @@ blk_generic_start_io_acct(struct request_queue *q __attribute__((unused)), - struct gendisk *disk __attribute__((unused)), - int rw __attribute__((unused)), struct bio *bio) - { --#if defined(HAVE_BDEV_IO_ACCT) -+#if defined(HAVE_BDEV_IO_ACCT_63) -+ return (bdev_start_io_acct(bio->bi_bdev, bio_op(bio), -+ jiffies)); -+#elif defined(HAVE_BDEV_IO_ACCT_OLD) - return (bdev_start_io_acct(bio->bi_bdev, bio_sectors(bio), - bio_op(bio), jiffies)); - #elif defined(HAVE_DISK_IO_ACCT) -@@ -618,7 +621,10 @@ blk_generic_end_io_acct(struct request_queue *q __attribute__((unused)), - struct gendisk *disk __attribute__((unused)), - int rw __attribute__((unused)), struct bio *bio, unsigned long start_time) - { --#if defined(HAVE_BDEV_IO_ACCT) -+#if defined(HAVE_BDEV_IO_ACCT_63) -+ bdev_end_io_acct(bio->bi_bdev, bio_op(bio), bio_sectors(bio), -+ start_time); -+#elif defined(HAVE_BDEV_IO_ACCT_OLD) - bdev_end_io_acct(bio->bi_bdev, bio_op(bio), start_time); - #elif defined(HAVE_DISK_IO_ACCT) - disk_end_io_acct(disk, bio_op(bio), start_time); -From c5431f14655ce05d1ea99cb012806f0e5873d257 Mon Sep 17 00:00:00 2001 -From: youzhongyang <youzh...@gmail.com> -Date: Fri, 31 Mar 2023 12:46:22 -0400 -Subject: [PATCH] linux 6.3 compat: needs REQ_PREFLUSH | REQ_OP_WRITE - -Modify bio_set_flush() so if kernel version is >= 4.10, flags -REQ_PREFLUSH and REQ_OP_WRITE are set together. - -Reviewed-by: Tony Hutter <hutt...@llnl.gov> -Reviewed-by: Brian Behlendorf <behlendo...@llnl.gov> -Signed-off-by: Youzhong Yang <yy...@mathworks.com> -Closes #14695 ---- - include/os/linux/kernel/linux/blkdev_compat.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h -index c7405ffab8b..c5c6385be6f 100644 ---- a/include/os/linux/kernel/linux/blkdev_compat.h -+++ b/include/os/linux/kernel/linux/blkdev_compat.h -@@ -426,7 +426,7 @@ static inline void - bio_set_flush(struct bio *bio) - { - #if defined(HAVE_REQ_PREFLUSH) /* >= 4.10 */ -- bio_set_op_attrs(bio, 0, REQ_PREFLUSH); -+ bio_set_op_attrs(bio, 0, REQ_PREFLUSH | REQ_OP_WRITE); - #elif defined(WRITE_FLUSH_FUA) /* >= 2.6.37 and <= 4.9 */ - bio_set_op_attrs(bio, 0, WRITE_FLUSH_FUA); - #else diff --git a/kernel-6.5.patch b/kernel-6.5.patch deleted file mode 100644 index 6c4a55f..0000000 --- a/kernel-6.5.patch +++ /dev/null @@ -1,934 +0,0 @@ -From 3b8e318b7737fa40daf6abbc06ba31cd6ae8d572 Mon Sep 17 00:00:00 2001 -From: Coleman Kane <ck...@colemankane.org> -Date: Tue, 1 Aug 2023 11:32:38 -0400 -Subject: [PATCH] Linux 6.5 compat: use disk_check_media_change when it exists - -When disk_check_media_change() exists, then define -zfs_check_media_change() to simply call disk_check_media_change() on -the bd_disk member of its argument. Since disk_check_media_change() -is newer than when revalidate_disk was present in bops, we should -be able to safely do this via a macro, instead of recreating a new -implementation of the inline function that forces revalidation. - -Reviewed-by: Brian Behlendorf <behlendo...@llnl.gov> -Reviewed-by: Brian Atkinson <batkin...@lanl.gov> -Signed-off-by: Coleman Kane <ck...@colemankane.org> -Closes #15101 ---- - include/os/linux/kernel/linux/blkdev_compat.h | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h -index e0f20ba32008..1641dd92a918 100644 ---- a/include/os/linux/kernel/linux/blkdev_compat.h -+++ b/include/os/linux/kernel/linux/blkdev_compat.h -@@ -347,6 +347,7 @@ zfs_check_media_change(struct block_device *bdev) - #define vdev_bdev_reread_part(bdev) zfs_check_media_change(bdev) - #elif defined(HAVE_DISK_CHECK_MEDIA_CHANGE) - #define vdev_bdev_reread_part(bdev) disk_check_media_change(bdev->bd_disk) -+#define zfs_check_media_change(bdev) disk_check_media_change(bdev->bd_disk) - #else - /* - * This is encountered if check_disk_change() and bdev_check_media_change() -From 43e8f6e37fddc31f23301cb70d466687bd205cd9 Mon Sep 17 00:00:00 2001 -From: Coleman Kane <ck...@colemankane.org> -Date: Tue, 1 Aug 2023 11:37:20 -0400 -Subject: [PATCH] Linux 6.5 compat: blkdev changes - -Multiple changes to the blkdev API were introduced in Linux 6.5. This -includes passing (void* holder) to blkdev_put, adding a new -blk_holder_ops* arg to blkdev_get_by_path, adding a new blk_mode_t type -that replaces uses of fmode_t, and removing an argument from the release -handler on block_device_operations that we weren't using. The open -function definition has also changed to take gendisk* and blk_mode_t, so -update it accordingly, too. - -Implement local wrappers for blkdev_get_by_path() and -vdev_blkdev_put() so that the in-line calls are cleaner, and place the -conditionally-compiled implementation details inside of both of these -local wrappers. Both calls are exclusively used within vdev_disk.c, at -this time. - -Add blk_mode_is_open_write() to test FMODE_WRITE / BLK_OPEN_WRITE -The wrapper function is now used for testing using the appropriate -method for the kernel, whether the open mode is writable or not. - -Emphasize fmode_t arg in zvol_release is not used - -Reviewed-by: Brian Behlendorf <behlendo...@llnl.gov> -Signed-off-by: Coleman Kane <ck...@colemankane.org> -Closes #15099 ---- - config/kernel-blkdev.m4 | 84 ++++++++++++++++++- - config/kernel-block-device-operations.m4 | 35 +++++++- - include/os/linux/kernel/linux/blkdev_compat.h | 6 ++ - module/os/linux/zfs/vdev_disk.c | 65 ++++++++++++-- - module/os/linux/zfs/zfs_vnops_os.c | 2 +- - module/os/linux/zfs/zpl_ctldir.c | 2 +- - module/os/linux/zfs/zvol_os.c | 28 ++++++- - 7 files changed, 203 insertions(+), 19 deletions(-) - -diff --git a/config/kernel-blkdev.m4 b/config/kernel-blkdev.m4 -index 887acee670ba..e04a2bd2c3b6 100644 ---- a/config/kernel-blkdev.m4 -+++ b/config/kernel-blkdev.m4 -@@ -16,12 +16,63 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH], [ - ]) - ]) - -+dnl # -+dnl # 6.5.x API change, -+dnl # blkdev_get_by_path() takes 4 args -+dnl # -+AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH_4ARG], [ -+ ZFS_LINUX_TEST_SRC([blkdev_get_by_path_4arg], [ -+ #include <linux/fs.h> -+ #include <linux/blkdev.h> -+ ], [ -+ struct block_device *bdev __attribute__ ((unused)) = NULL; -+ const char *path = "path"; -+ fmode_t mode = 0; -+ void *holder = NULL; -+ struct blk_holder_ops h; -+ -+ bdev = blkdev_get_by_path(path, mode, holder, &h); -+ ]) -+]) -+ - AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH], [ -- AC_MSG_CHECKING([whether blkdev_get_by_path() exists]) -+ AC_MSG_CHECKING([whether blkdev_get_by_path() exists and takes 3 args]) - ZFS_LINUX_TEST_RESULT([blkdev_get_by_path], [ - AC_MSG_RESULT(yes) - ], [ -- ZFS_LINUX_TEST_ERROR([blkdev_get_by_path()]) -+ AC_MSG_RESULT(no) -+ AC_MSG_CHECKING([whether blkdev_get_by_path() exists and takes 4 args]) -+ ZFS_LINUX_TEST_RESULT([blkdev_get_by_path_4arg], [ -+ AC_DEFINE(HAVE_BLKDEV_GET_BY_PATH_4ARG, 1, -+ [blkdev_get_by_path() exists and takes 4 args]) -+ AC_MSG_RESULT(yes) -+ ], [ -+ ZFS_LINUX_TEST_ERROR([blkdev_get_by_path()]) -+ ]) -+ ]) -+]) -+ -+dnl # -+dnl # 6.5.x API change -+dnl # blk_mode_t was added as a type to supercede some places where fmode_t -+dnl # is used -+dnl # -+AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_BLK_MODE_T], [ -+ ZFS_LINUX_TEST_SRC([blk_mode_t], [ -+ #include <linux/fs.h> -+ #include <linux/blkdev.h> -+ ], [ -+ blk_mode_t m __attribute((unused)) = (blk_mode_t)0; -+ ]) -+]) -+ -+AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BLK_MODE_T], [ -+ AC_MSG_CHECKING([whether blk_mode_t is defined]) -+ ZFS_LINUX_TEST_RESULT([blk_mode_t], [ -+ AC_MSG_RESULT(yes) -+ AC_DEFINE(HAVE_BLK_MODE_T, 1, [blk_mode_t is defined]) -+ ], [ -+ AC_MSG_RESULT(no) - ]) - ]) - -@@ -41,12 +92,35 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_PUT], [ - ]) - ]) - -+dnl # -+dnl # 6.5.x API change. -+dnl # blkdev_put() takes (void* holder) as arg 2 -+dnl # -+AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV_PUT_HOLDER], [ -+ ZFS_LINUX_TEST_SRC([blkdev_put_holder], [ -+ #include <linux/fs.h> -+ #include <linux/blkdev.h> -+ ], [ -+ struct block_device *bdev = NULL; -+ void *holder = NULL; -+ -+ blkdev_put(bdev, holder); -+ ]) -+]) -+ - AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_PUT], [ - AC_MSG_CHECKING([whether blkdev_put() exists]) - ZFS_LINUX_TEST_RESULT([blkdev_put], [ - AC_MSG_RESULT(yes) - ], [ -- ZFS_LINUX_TEST_ERROR([blkdev_put()]) -+ AC_MSG_CHECKING([whether blkdev_put() accepts void* as arg 2]) -+ ZFS_LINUX_TEST_RESULT([blkdev_put_holder], [ -+ AC_MSG_RESULT(yes) -+ AC_DEFINE(HAVE_BLKDEV_PUT_HOLDER, 1, -+ [blkdev_put() accepts void* as arg 2]) -+ ], [ -+ ZFS_LINUX_TEST_ERROR([blkdev_put()]) -+ ]) - ]) - ]) - -@@ -495,7 +569,9 @@ AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BLK_STS_RESV_CONFLICT], [ - - AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV], [ - ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH -+ ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH_4ARG - ZFS_AC_KERNEL_SRC_BLKDEV_PUT -+ ZFS_AC_KERNEL_SRC_BLKDEV_PUT_HOLDER - ZFS_AC_KERNEL_SRC_BLKDEV_REREAD_PART - ZFS_AC_KERNEL_SRC_BLKDEV_INVALIDATE_BDEV - ZFS_AC_KERNEL_SRC_BLKDEV_LOOKUP_BDEV -@@ -510,6 +586,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV], [ - ZFS_AC_KERNEL_SRC_BLKDEV_PART_TO_DEV - ZFS_AC_KERNEL_SRC_BLKDEV_DISK_CHECK_MEDIA_CHANGE - ZFS_AC_KERNEL_SRC_BLKDEV_BLK_STS_RESV_CONFLICT -+ ZFS_AC_KERNEL_SRC_BLKDEV_BLK_MODE_T - ]) - - AC_DEFUN([ZFS_AC_KERNEL_BLKDEV], [ -@@ -530,4 +607,5 @@ AC_DEFUN([ZFS_AC_KERNEL_BLKDEV], [ - ZFS_AC_KERNEL_BLKDEV_PART_TO_DEV - ZFS_AC_KERNEL_BLKDEV_DISK_CHECK_MEDIA_CHANGE - ZFS_AC_KERNEL_BLKDEV_BLK_STS_RESV_CONFLICT -+ ZFS_AC_KERNEL_BLKDEV_BLK_MODE_T - ]) -diff --git a/config/kernel-block-device-operations.m4 b/config/kernel-block-device-operations.m4 -index 84e39dc8a2f6..d13c1337b1fb 100644 ---- a/config/kernel-block-device-operations.m4 -+++ b/config/kernel-block-device-operations.m4 -@@ -49,12 +49,42 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_RELEASE_VOID], [ - ], [], []) - ]) - -+dnl # -+dnl # 5.9.x API change -+dnl # -+AC_DEFUN([ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_RELEASE_1ARG], [ -+ ZFS_LINUX_TEST_SRC([block_device_operations_release_void_1arg], [ -+ #include <linux/blkdev.h> -+ -+ void blk_release(struct gendisk *g) { -+ (void) g; -+ return; -+ } -+ -+ static const struct block_device_operations -+ bops __attribute__ ((unused)) = { -+ .open = NULL, -+ .release = blk_release, -+ .ioctl = NULL, -+ .compat_ioctl = NULL, -+ }; -+ ], [], []) -+]) -+ - AC_DEFUN([ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_RELEASE_VOID], [ -- AC_MSG_CHECKING([whether bops->release() is void]) -+ AC_MSG_CHECKING([whether bops->release() is void and takes 2 args]) - ZFS_LINUX_TEST_RESULT([block_device_operations_release_void], [ - AC_MSG_RESULT(yes) - ],[ -- ZFS_LINUX_TEST_ERROR([bops->release()]) -+ AC_MSG_RESULT(no) -+ AC_MSG_CHECKING([whether bops->release() is void and takes 1 arg]) -+ ZFS_LINUX_TEST_RESULT([block_device_operations_release_void_1arg], [ -+ AC_MSG_RESULT(yes) -+ AC_DEFINE([HAVE_BLOCK_DEVICE_OPERATIONS_RELEASE_1ARG], [1], -+ [Define if release() in block_device_operations takes 1 arg]) -+ ],[ -+ ZFS_LINUX_TEST_ERROR([bops->release()]) -+ ]) - ]) - ]) - -@@ -92,6 +122,7 @@ AC_DEFUN([ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS_REVALIDATE_DISK], [ - AC_DEFUN([ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS], [ - ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_CHECK_EVENTS - ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_RELEASE_VOID -+ ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_RELEASE_1ARG - ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS_REVALIDATE_DISK - ]) - -diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h -index 1641dd92a918..f111e648ccf7 100644 ---- a/include/os/linux/kernel/linux/blkdev_compat.h -+++ b/include/os/linux/kernel/linux/blkdev_compat.h -@@ -398,6 +398,12 @@ vdev_lookup_bdev(const char *path, dev_t *dev) - #endif - } - -+#if defined(HAVE_BLK_MODE_T) -+#define blk_mode_is_open_write(flag) ((flag) & BLK_OPEN_WRITE) -+#else -+#define blk_mode_is_open_write(flag) ((flag) & FMODE_WRITE) -+#endif -+ - /* - * Kernels without bio_set_op_attrs use bi_rw for the bio flags. - */ -diff --git a/module/os/linux/zfs/vdev_disk.c b/module/os/linux/zfs/vdev_disk.c -index 925ee9d9fe9c..48ac55f07034 100644 ---- a/module/os/linux/zfs/vdev_disk.c -+++ b/module/os/linux/zfs/vdev_disk.c -@@ -80,9 +80,22 @@ typedef struct dio_request { - - static unsigned int zfs_vdev_failfast_mask = 1; - -+#ifdef HAVE_BLK_MODE_T -+static blk_mode_t -+#else - static fmode_t -+#endif - vdev_bdev_mode(spa_mode_t spa_mode) - { -+#ifdef HAVE_BLK_MODE_T -+ blk_mode_t mode = 0; -+ -+ if (spa_mode & SPA_MODE_READ) -+ mode |= BLK_OPEN_READ; -+ -+ if (spa_mode & SPA_MODE_WRITE) -+ mode |= BLK_OPEN_WRITE; -+#else - fmode_t mode = 0; - - if (spa_mode & SPA_MODE_READ) -@@ -90,6 +103,7 @@ vdev_bdev_mode(spa_mode_t spa_mode) - - if (spa_mode & SPA_MODE_WRITE) - mode |= FMODE_WRITE; -+#endif - - return (mode); - } -@@ -197,12 +211,47 @@ vdev_disk_kobj_evt_post(vdev_t *v) - } - } - -+#if !defined(HAVE_BLKDEV_GET_BY_PATH_4ARG) -+/* -+ * Define a dummy struct blk_holder_ops for kernel versions -+ * prior to 6.5. -+ */ -+struct blk_holder_ops {}; -+#endif -+ -+static struct block_device * -+vdev_blkdev_get_by_path(const char *path, spa_mode_t mode, void *holder, -+ const struct blk_holder_ops *hops) -+{ -+#ifdef HAVE_BLKDEV_GET_BY_PATH_4ARG -+ return (blkdev_get_by_path(path, -+ vdev_bdev_mode(mode) | BLK_OPEN_EXCL, holder, hops)); -+#else -+ return (blkdev_get_by_path(path, -+ vdev_bdev_mode(mode) | FMODE_EXCL, holder)); -+#endif -+} -+ -+static void -+vdev_blkdev_put(struct block_device *bdev, spa_mode_t mode, void *holder) -+{ -+#ifdef HAVE_BLKDEV_PUT_HOLDER -+ return (blkdev_put(bdev, holder)); -+#else -+ return (blkdev_put(bdev, vdev_bdev_mode(mode) | FMODE_EXCL)); -+#endif -+} -+ - static int - vdev_disk_open(vdev_t *v, uint64_t *psize, uint64_t *max_psize, - uint64_t *logical_ashift, uint64_t *physical_ashift) - { - struct block_device *bdev; -+#ifdef HAVE_BLK_MODE_T -+ blk_mode_t mode = vdev_bdev_mode(spa_mode(v->vdev_spa)); -+#else - fmode_t mode = vdev_bdev_mode(spa_mode(v->vdev_spa)); -+#endif - hrtime_t timeout = MSEC2NSEC(zfs_vdev_open_timeout_ms); - vdev_disk_t *vd; - -@@ -252,15 +301,15 @@ vdev_disk_open(vdev_t *v, uint64_t *psize, uint64_t *max_psize, - reread_part = B_TRUE; - } - -- blkdev_put(bdev, mode | FMODE_EXCL); -+ vdev_blkdev_put(bdev, mode, zfs_vdev_holder); - } - - if (reread_part) { -- bdev = blkdev_get_by_path(disk_name, mode | FMODE_EXCL, -- zfs_vdev_holder); -+ bdev = vdev_blkdev_get_by_path(disk_name, mode, -+ zfs_vdev_holder, NULL); - if (!IS_ERR(bdev)) { - int error = vdev_bdev_reread_part(bdev); -- blkdev_put(bdev, mode | FMODE_EXCL); -+ vdev_blkdev_put(bdev, mode, zfs_vdev_holder); - if (error == 0) { - timeout = MSEC2NSEC( - zfs_vdev_open_timeout_ms * 2); -@@ -305,8 +354,8 @@ vdev_disk_open(vdev_t *v, uint64_t *psize, uint64_t *max_psize, - hrtime_t start = gethrtime(); - bdev = ERR_PTR(-ENXIO); - while (IS_ERR(bdev) && ((gethrtime() - start) < timeout)) { -- bdev = blkdev_get_by_path(v->vdev_path, mode | FMODE_EXCL, -- zfs_vdev_holder); -+ bdev = vdev_blkdev_get_by_path(v->vdev_path, mode, -+ zfs_vdev_holder, NULL); - if (unlikely(PTR_ERR(bdev) == -ENOENT)) { - /* - * There is no point of waiting since device is removed -@@ -382,8 +431,8 @@ vdev_disk_close(vdev_t *v) - return; - - if (vd->vd_bdev != NULL) { -- blkdev_put(vd->vd_bdev, -- vdev_bdev_mode(spa_mode(v->vdev_spa)) | FMODE_EXCL); -+ vdev_blkdev_put(vd->vd_bdev, spa_mode(v->vdev_spa), -+ zfs_vdev_holder); - } - - rw_destroy(&vd->vd_lock); -diff --git a/module/os/linux/zfs/zfs_vnops_os.c b/module/os/linux/zfs/zfs_vnops_os.c -index 234c4d5ef0e0..33baac9db06b 100644 ---- a/module/os/linux/zfs/zfs_vnops_os.c -+++ b/module/os/linux/zfs/zfs_vnops_os.c -@@ -186,7 +186,7 @@ zfs_open(struct inode *ip, int mode, int flag, cred_t *cr) - return (error); - - /* Honor ZFS_APPENDONLY file attribute */ -- if ((mode & FMODE_WRITE) && (zp->z_pflags & ZFS_APPENDONLY) && -+ if (blk_mode_is_open_write(mode) && (zp->z_pflags & ZFS_APPENDONLY) && - ((flag & O_APPEND) == 0)) { - zfs_exit(zfsvfs, FTAG); - return (SET_ERROR(EPERM)); -diff --git a/module/os/linux/zfs/zpl_ctldir.c b/module/os/linux/zfs/zpl_ctldir.c -index 68a7de78f471..7786444fea35 100644 ---- a/module/os/linux/zfs/zpl_ctldir.c -+++ b/module/os/linux/zfs/zpl_ctldir.c -@@ -42,7 +42,7 @@ - static int - zpl_common_open(struct inode *ip, struct file *filp) - { -- if (filp->f_mode & FMODE_WRITE) -+ if (blk_mode_is_open_write(filp->f_mode)) - return (-EACCES); - - return (generic_file_open(ip, filp)); -diff --git a/module/os/linux/zfs/zvol_os.c b/module/os/linux/zfs/zvol_os.c -index 38bc8e2c4eeb..7a95b54bdf0d 100644 ---- a/module/os/linux/zfs/zvol_os.c -+++ b/module/os/linux/zfs/zvol_os.c -@@ -671,7 +671,11 @@ zvol_request(struct request_queue *q, struct bio *bio) - } - - static int -+#ifdef HAVE_BLK_MODE_T -+zvol_open(struct gendisk *disk, blk_mode_t flag) -+#else - zvol_open(struct block_device *bdev, fmode_t flag) -+#endif - { - zvol_state_t *zv; - int error = 0; -@@ -686,10 +690,14 @@ zvol_open(struct block_device *bdev, fmode_t flag) - /* - * Obtain a copy of private_data under the zvol_state_lock to make - * sure that either the result of zvol free code path setting -- * bdev->bd_disk->private_data to NULL is observed, or zvol_os_free() -+ * disk->private_data to NULL is observed, or zvol_os_free() - * is not called on this zv because of the positive zv_open_count. - */ -+#ifdef HAVE_BLK_MODE_T -+ zv = disk->private_data; -+#else - zv = bdev->bd_disk->private_data; -+#endif - if (zv == NULL) { - rw_exit(&zvol_state_lock); - return (SET_ERROR(-ENXIO)); -@@ -769,14 +777,15 @@ zvol_open(struct block_device *bdev, fmode_t flag) - } - } - -- error = -zvol_first_open(zv, !(flag & FMODE_WRITE)); -+ error = -zvol_first_open(zv, !(blk_mode_is_open_write(flag))); - - if (drop_namespace) - mutex_exit(&spa_namespace_lock); - } - - if (error == 0) { -- if ((flag & FMODE_WRITE) && (zv->zv_flags & ZVOL_RDONLY)) { -+ if ((blk_mode_is_open_write(flag)) && -+ (zv->zv_flags & ZVOL_RDONLY)) { - if (zv->zv_open_count == 0) - zvol_last_close(zv); - -@@ -791,14 +800,25 @@ zvol_open(struct block_device *bdev, fmode_t flag) - rw_exit(&zv->zv_suspend_lock); - - if (error == 0) -+#ifdef HAVE_BLK_MODE_T -+ disk_check_media_change(disk); -+#else - zfs_check_media_change(bdev); -+#endif - - return (error); - } - - static void --zvol_release(struct gendisk *disk, fmode_t mode) -+#ifdef HAVE_BLOCK_DEVICE_OPERATIONS_RELEASE_1ARG -+zvol_release(struct gendisk *disk) -+#else -+zvol_release(struct gendisk *disk, fmode_t unused) -+#endif - { -+#if !defined(HAVE_BLOCK_DEVICE_OPERATIONS_RELEASE_1ARG) -+ (void) unused; -+#endif - zvol_state_t *zv; - boolean_t drop_suspend = B_TRUE; - -From e47e9bbe86f2e8fe5da0fc7c3a9014e1f8c132a9 Mon Sep 17 00:00:00 2001 -From: Coleman Kane <ck...@colemankane.org> -Date: Wed, 2 Aug 2023 17:05:46 -0400 -Subject: [PATCH] Linux 6.5 compat: register_sysctl_table removed - -Additionally, the .child element of ctl_table has been removed in 6.5. -This change adds a new test for the pre-6.5 register_sysctl_table() -function, and uses the old code in that case. If it isn't found, then -the parentage entries in the tables are removed, and the register_sysctl -call is provided the paths of "kernel/spl", "kernel/spl/kmem", and -"kernel/spl/kstat" directly, to populate each subdirectory over three -calls, as is the new API. - -Reviewed-by: Brian Atkinson <batkin...@lanl.gov> -Reviewed-by: Brian Behlendorf <behlendo...@llnl.gov> -Signed-off-by: Coleman Kane <ck...@colemankane.org> -Closes #15138 ---- - config/kernel-register_sysctl_table.m4 | 27 ++++++++++++++++++++++++++ - config/kernel.m4 | 2 ++ - module/os/linux/spl/spl-proc.c | 26 ++++++++++++++++++++++--- - 3 files changed, 52 insertions(+), 3 deletions(-) - create mode 100644 config/kernel-register_sysctl_table.m4 - -diff --git a/config/kernel-register_sysctl_table.m4 b/config/kernel-register_sysctl_table.m4 -new file mode 100644 -index 000000000000..a5e934f56d29 ---- /dev/null -+++ b/config/kernel-register_sysctl_table.m4 -@@ -0,0 +1,27 @@ -+dnl # -+dnl # Linux 6.5 removes register_sysctl_table -+dnl # -+AC_DEFUN([ZFS_AC_KERNEL_SRC_REGISTER_SYSCTL_TABLE], [ -+ ZFS_LINUX_TEST_SRC([has_register_sysctl_table], [ -+ #include <linux/sysctl.h> -+ -+ static struct ctl_table dummy_table[] = { -+ {} -+ }; -+ -+ ],[ -+ struct ctl_table_header *h -+ __attribute((unused)) = register_sysctl_table(dummy_table); -+ ]) -+]) -+ -+AC_DEFUN([ZFS_AC_KERNEL_REGISTER_SYSCTL_TABLE], [ -+ AC_MSG_CHECKING([whether register_sysctl_table exists]) -+ ZFS_LINUX_TEST_RESULT([has_register_sysctl_table], [ -+ AC_MSG_RESULT([yes]) -+ AC_DEFINE(HAVE_REGISTER_SYSCTL_TABLE, 1, -+ [register_sysctl_table exists]) -+ ],[ -+ AC_MSG_RESULT([no]) -+ ]) -+]) -diff --git a/config/kernel.m4 b/config/kernel.m4 -index 1487fa2e7793..28bd361d33ff 100644 ---- a/config/kernel.m4 -+++ b/config/kernel.m4 -@@ -160,6 +160,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ - ZFS_AC_KERNEL_SRC_FILEMAP - ZFS_AC_KERNEL_SRC_WRITEPAGE_T - ZFS_AC_KERNEL_SRC_RECLAIMED -+ ZFS_AC_KERNEL_SRC_REGISTER_SYSCTL_TABLE - case "$host_cpu" in - powerpc*) - ZFS_AC_KERNEL_SRC_CPU_HAS_FEATURE -@@ -299,6 +300,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ - ZFS_AC_KERNEL_FILEMAP - ZFS_AC_KERNEL_WRITEPAGE_T - ZFS_AC_KERNEL_RECLAIMED -+ ZFS_AC_KERNEL_REGISTER_SYSCTL_TABLE - case "$host_cpu" in - powerpc*) - ZFS_AC_KERNEL_CPU_HAS_FEATURE -diff --git a/module/os/linux/spl/spl-proc.c b/module/os/linux/spl/spl-proc.c -index 01f5619e1893..bcc356ae55b6 100644 ---- a/module/os/linux/spl/spl-proc.c -+++ b/module/os/linux/spl/spl-proc.c -@@ -624,6 +624,7 @@ static struct ctl_table spl_table[] = { - .mode = 0644, - .proc_handler = &proc_dohostid, - }, -+#ifdef HAVE_REGISTER_SYSCTL_TABLE - { - .procname = "kmem", - .mode = 0555, -@@ -634,9 +635,11 @@ static struct ctl_table spl_table[] = { - .mode = 0555, - .child = spl_kstat_table, - }, -+#endif - {}, - }; - -+#ifdef HAVE_REGISTER_SYSCTL_TABLE - static struct ctl_table spl_dir[] = { - { - .procname = "spl", -@@ -648,21 +651,38 @@ static struct ctl_table spl_dir[] = { - - static struct ctl_table spl_root[] = { - { -- .procname = "kernel", -- .mode = 0555, -- .child = spl_dir, -+ .procname = "kernel", -+ .mode = 0555, -+ .child = spl_dir, - }, - {} - }; -+#endif - - int - spl_proc_init(void) - { - int rc = 0; - -+#ifdef HAVE_REGISTER_SYSCTL_TABLE - spl_header = register_sysctl_table(spl_root); - if (spl_header == NULL) - return (-EUNATCH); -+#else -+ spl_header = register_sysctl("kernel/spl", spl_table); -+ if (spl_header == NULL) -+ return (-EUNATCH); -+ -+ if (register_sysctl("kernel/spl/kmem", spl_kmem_table) == NULL) { -+ rc = -EUNATCH; -+ goto out; -+ } -+ -+ if (register_sysctl("kernel/spl/kstat", spl_kstat_table) == NULL) { -+ rc = -EUNATCH; -+ goto out; -+ } -+#endif - - proc_spl = proc_mkdir("spl", NULL); - if (proc_spl == NULL) { -From 36261c8238df462b214854ccea1df4f060cf0995 Mon Sep 17 00:00:00 2001 -From: Coleman Kane <ck...@colemankane.org> -Date: Mon, 7 Aug 2023 18:47:46 -0400 -Subject: [PATCH] Linux 6.5 compat: replace generic_file_splice_read with - filemap_splice_read - -The generic_file_splice_read function was removed in Linux 6.5 in favor -of filemap_splice_read. Add an autoconf test for filemap_splice_read and -use it if it is found as the handler for .splice_read in the -file_operations struct. Additionally, ITER_PIPE was removed in 6.5. This -change removes the ITER_* macros that OpenZFS doesn't use from being -tested in config/kernel-vfs-iov_iter.m4. The removal of ITER_PIPE was -causing the test to fail, which also affected the code responsible for -setting the .splice_read handler, above. That behavior caused run-time -panics on Linux 6.5. - -Reviewed-by: Brian Atkinson <batkin...@lanl.gov> -Reviewed-by: Brian Behlendorf <behlendo...@llnl.gov> -Signed-off-by: Coleman Kane <ck...@colemankane.org> -Closes #15155 ---- - config/kernel-filemap-splice-read.m4 | 25 +++++++++++++++++++++++++ - config/kernel-vfs-iov_iter.m4 | 3 +-- - config/kernel.m4 | 2 ++ - module/os/linux/zfs/zpl_file.c | 4 ++++ - 4 files changed, 32 insertions(+), 2 deletions(-) - create mode 100644 config/kernel-filemap-splice-read.m4 - -diff --git a/config/kernel-filemap-splice-read.m4 b/config/kernel-filemap-splice-read.m4 -new file mode 100644 -index 000000000000..5199b7373e4d ---- /dev/null -+++ b/config/kernel-filemap-splice-read.m4 -@@ -0,0 +1,25 @@ -+AC_DEFUN([ZFS_AC_KERNEL_SRC_FILEMAP_SPLICE_READ], [ -+ dnl # -+ dnl # Kernel 6.5 - generic_file_splice_read was removed in favor -+ dnl # of filemap_splice_read for the .splice_read member of the -+ dnl # file_operations struct. -+ dnl # -+ ZFS_LINUX_TEST_SRC([has_filemap_splice_read], [ -+ #include <linux/fs.h> -+ -+ struct file_operations fops __attribute__((unused)) = { -+ .splice_read = filemap_splice_read, -+ }; -+ ],[]) -+]) -+ -+AC_DEFUN([ZFS_AC_KERNEL_FILEMAP_SPLICE_READ], [ -+ AC_MSG_CHECKING([whether filemap_splice_read() exists]) -+ ZFS_LINUX_TEST_RESULT([has_filemap_splice_read], [ -+ AC_MSG_RESULT(yes) -+ AC_DEFINE(HAVE_FILEMAP_SPLICE_READ, 1, -+ [filemap_splice_read exists]) -+ ],[ -+ AC_MSG_RESULT(no) -+ ]) -+]) -diff --git a/config/kernel-vfs-iov_iter.m4 b/config/kernel-vfs-iov_iter.m4 -index cc5a7ab0c237..ff560ff3eef0 100644 ---- a/config/kernel-vfs-iov_iter.m4 -+++ b/config/kernel-vfs-iov_iter.m4 -@@ -6,8 +6,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_IOV_ITER], [ - #include <linux/fs.h> - #include <linux/uio.h> - ],[ -- int type __attribute__ ((unused)) = -- ITER_IOVEC | ITER_KVEC | ITER_BVEC | ITER_PIPE; -+ int type __attribute__ ((unused)) = ITER_KVEC; - ]) - - ZFS_LINUX_TEST_SRC([iov_iter_advance], [ -diff --git a/config/kernel.m4 b/config/kernel.m4 -index 28bd361d33ff..309f1819be48 100644 ---- a/config/kernel.m4 -+++ b/config/kernel.m4 -@@ -161,6 +161,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ - ZFS_AC_KERNEL_SRC_WRITEPAGE_T - ZFS_AC_KERNEL_SRC_RECLAIMED - ZFS_AC_KERNEL_SRC_REGISTER_SYSCTL_TABLE -+ ZFS_AC_KERNEL_SRC_FILEMAP_SPLICE_READ - case "$host_cpu" in - powerpc*) - ZFS_AC_KERNEL_SRC_CPU_HAS_FEATURE -@@ -301,6 +302,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ - ZFS_AC_KERNEL_WRITEPAGE_T - ZFS_AC_KERNEL_RECLAIMED - ZFS_AC_KERNEL_REGISTER_SYSCTL_TABLE -+ ZFS_AC_KERNEL_FILEMAP_SPLICE_READ - case "$host_cpu" in - powerpc*) - ZFS_AC_KERNEL_CPU_HAS_FEATURE -diff --git a/module/os/linux/zfs/zpl_file.c b/module/os/linux/zfs/zpl_file.c -index f6af2ebd1163..24cc1064a8fc 100644 ---- a/module/os/linux/zfs/zpl_file.c -+++ b/module/os/linux/zfs/zpl_file.c -@@ -1323,7 +1323,11 @@ const struct file_operations zpl_file_operations = { - .read_iter = zpl_iter_read, - .write_iter = zpl_iter_write, - #ifdef HAVE_VFS_IOV_ITER -+#ifdef HAVE_FILEMAP_SPLICE_READ -+ .splice_read = filemap_splice_read, -+#else - .splice_read = generic_file_splice_read, -+#endif - .splice_write = iter_file_splice_write, - #endif - #else -From 8ce2eba9e6a384feef93d77c397f37d17dc588ce Mon Sep 17 00:00:00 2001 -From: Coleman Kane <ck...@colemankane.org> -Date: Tue, 8 Aug 2023 18:42:32 -0400 -Subject: [PATCH] Linux 6.5 compat: Use copy_splice_read instead of - filemap_splice_read - -Using the filemap_splice_read function for the splice_read handler was -leading to occasional data corruption under certain circumstances. Favor -using copy_splice_read instead, which does not demonstrate the same -erroneous behavior under the tested failure cases. - -Reviewed-by: Brian Atkinson <batkin...@lanl.gov> -Reviewed-by: Brian Behlendorf <behlendo...@llnl.gov> -Signed-off-by: Coleman Kane <ck...@colemankane.org> -Closes #15164 ---- - config/kernel-filemap-splice-read.m4 | 18 +++++++++--------- - config/kernel.m4 | 4 ++-- - module/os/linux/zfs/zpl_file.c | 4 ++-- - 3 files changed, 13 insertions(+), 13 deletions(-) - -diff --git a/config/kernel-filemap-splice-read.m4 b/config/kernel-filemap-splice-read.m4 -index 5199b7373e4d..4c83b31d738a 100644 ---- a/config/kernel-filemap-splice-read.m4 -+++ b/config/kernel-filemap-splice-read.m4 -@@ -1,24 +1,24 @@ --AC_DEFUN([ZFS_AC_KERNEL_SRC_FILEMAP_SPLICE_READ], [ -+AC_DEFUN([ZFS_AC_KERNEL_SRC_COPY_SPLICE_READ], [ - dnl # - dnl # Kernel 6.5 - generic_file_splice_read was removed in favor -- dnl # of filemap_splice_read for the .splice_read member of the -+ dnl # of copy_splice_read for the .splice_read member of the - dnl # file_operations struct. - dnl # -- ZFS_LINUX_TEST_SRC([has_filemap_splice_read], [ -+ ZFS_LINUX_TEST_SRC([has_copy_splice_read], [ - #include <linux/fs.h> - - struct file_operations fops __attribute__((unused)) = { -- .splice_read = filemap_splice_read, -+ .splice_read = copy_splice_read, - }; - ],[]) - ]) - --AC_DEFUN([ZFS_AC_KERNEL_FILEMAP_SPLICE_READ], [ -- AC_MSG_CHECKING([whether filemap_splice_read() exists]) -- ZFS_LINUX_TEST_RESULT([has_filemap_splice_read], [ -+AC_DEFUN([ZFS_AC_KERNEL_COPY_SPLICE_READ], [ -+ AC_MSG_CHECKING([whether copy_splice_read() exists]) -+ ZFS_LINUX_TEST_RESULT([has_copy_splice_read], [ - AC_MSG_RESULT(yes) -- AC_DEFINE(HAVE_FILEMAP_SPLICE_READ, 1, -- [filemap_splice_read exists]) -+ AC_DEFINE(HAVE_COPY_SPLICE_READ, 1, -+ [copy_splice_read exists]) - ],[ - AC_MSG_RESULT(no) - ]) -diff --git a/config/kernel.m4 b/config/kernel.m4 -index 309f1819be48..df194ec72207 100644 ---- a/config/kernel.m4 -+++ b/config/kernel.m4 -@@ -161,7 +161,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ - ZFS_AC_KERNEL_SRC_WRITEPAGE_T - ZFS_AC_KERNEL_SRC_RECLAIMED - ZFS_AC_KERNEL_SRC_REGISTER_SYSCTL_TABLE -- ZFS_AC_KERNEL_SRC_FILEMAP_SPLICE_READ -+ ZFS_AC_KERNEL_SRC_COPY_SPLICE_READ - case "$host_cpu" in - powerpc*) - ZFS_AC_KERNEL_SRC_CPU_HAS_FEATURE -@@ -302,7 +302,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ - ZFS_AC_KERNEL_WRITEPAGE_T - ZFS_AC_KERNEL_RECLAIMED - ZFS_AC_KERNEL_REGISTER_SYSCTL_TABLE -- ZFS_AC_KERNEL_FILEMAP_SPLICE_READ -+ ZFS_AC_KERNEL_COPY_SPLICE_READ - case "$host_cpu" in - powerpc*) - ZFS_AC_KERNEL_CPU_HAS_FEATURE -diff --git a/module/os/linux/zfs/zpl_file.c b/module/os/linux/zfs/zpl_file.c -index 24cc1064a8fc..3caa0fc6c214 100644 ---- a/module/os/linux/zfs/zpl_file.c -+++ b/module/os/linux/zfs/zpl_file.c -@@ -1323,8 +1323,8 @@ const struct file_operations zpl_file_operations = { - .read_iter = zpl_iter_read, - .write_iter = zpl_iter_write, - #ifdef HAVE_VFS_IOV_ITER --#ifdef HAVE_FILEMAP_SPLICE_READ -- .splice_read = filemap_splice_read, -+#ifdef HAVE_COPY_SPLICE_READ -+ .splice_read = copy_splice_read, - #else - .splice_read = generic_file_splice_read, - #endif -From bcb1159c095f57564914b59f5e7e82170261afb0 Mon Sep 17 00:00:00 2001 -From: Andrea Righi <andrea.ri...@canonical.com> -Date: Sat, 2 Sep 2023 02:21:40 +0200 -Subject: [PATCH] Linux 6.5 compat: safe cleanup in spl_proc_fini() - -If we fail to create a proc entry in spl_proc_init() we may end up -calling unregister_sysctl_table() twice: one in the failure path of -spl_proc_init() and another time during spl_proc_fini(). - -Avoid the double call to unregister_sysctl_table() and while at it -refactor the code a bit to reduce code duplication. - -This was accidentally introduced when the spl code was -updated for Linux 6.5 compatibility. - -Reviewed-by: Brian Behlendorf <behlendo...@llnl.gov> -Reviewed-by: Ameer Hamza <aha...@ixsystems.com> -Signed-off-by: Andrea Righi <andrea.ri...@canonical.com> -Closes #15234 -Closes #15235 ---- - module/os/linux/spl/spl-proc.c | 36 +++++++++++++++++----------------- - 1 file changed, 18 insertions(+), 18 deletions(-) - -diff --git a/module/os/linux/spl/spl-proc.c b/module/os/linux/spl/spl-proc.c -index bcc356ae55b6..5cb5a6dadb05 100644 ---- a/module/os/linux/spl/spl-proc.c -+++ b/module/os/linux/spl/spl-proc.c -@@ -659,6 +659,21 @@ static struct ctl_table spl_root[] = { - }; - #endif - -+static void spl_proc_cleanup(void) -+{ -+ remove_proc_entry("kstat", proc_spl); -+ remove_proc_entry("slab", proc_spl_kmem); -+ remove_proc_entry("kmem", proc_spl); -+ remove_proc_entry("taskq-all", proc_spl); -+ remove_proc_entry("taskq", proc_spl); -+ remove_proc_entry("spl", NULL); -+ -+ if (spl_header) { -+ unregister_sysctl_table(spl_header); -+ spl_header = NULL; -+ } -+} -+ - int - spl_proc_init(void) - { -@@ -723,15 +738,8 @@ spl_proc_init(void) - goto out; - } - out: -- if (rc) { -- remove_proc_entry("kstat", proc_spl); -- remove_proc_entry("slab", proc_spl_kmem); -- remove_proc_entry("kmem", proc_spl); -- remove_proc_entry("taskq-all", proc_spl); -- remove_proc_entry("taskq", proc_spl); -- remove_proc_entry("spl", NULL); -- unregister_sysctl_table(spl_header); -- } -+ if (rc) -+ spl_proc_cleanup(); - - return (rc); - } -@@ -739,13 +747,5 @@ spl_proc_init(void) - void - spl_proc_fini(void) - { -- remove_proc_entry("kstat", proc_spl); -- remove_proc_entry("slab", proc_spl_kmem); -- remove_proc_entry("kmem", proc_spl); -- remove_proc_entry("taskq-all", proc_spl); -- remove_proc_entry("taskq", proc_spl); -- remove_proc_entry("spl", NULL); -- -- ASSERT(spl_header != NULL); -- unregister_sysctl_table(spl_header); -+ spl_proc_cleanup(); - } ================================================================ ---- gitweb: http://git.pld-linux.org/gitweb.cgi/packages/zfs.git/commitdiff/bf636acc1e71cd78273831c01b7a5138b668ce56 _______________________________________________ pld-cvs-commit mailing list pld-cvs-commit@lists.pld-linux.org http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit