From f31dcf0ab0d260b981b4b8087b58d6e02e90c30e Mon Sep 17 00:00:00 2001
From: Kiyoshi Aman <kiyoshi.aman+adelie@gmail.com>
Date: Sun, 8 Dec 2019 07:46:14 -0500
Subject: [PATCH 1/5] user/zfs: new package

---
 user/zfs/APKBUILD | 59 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 user/zfs/APKBUILD

diff --git a/user/zfs/APKBUILD b/user/zfs/APKBUILD
new file mode 100644
index 0000000000..ef11bf22d1
--- /dev/null
+++ b/user/zfs/APKBUILD
@@ -0,0 +1,59 @@
+# Contributor: Kiyoshi Aman <kiyoshi.aman+adelie@gmail.com>
+# Maintainer: Kiyoshi Aman <kiyoshi.aman+adelie@gmail.com>
+# keep these in sync with kernel version
+_kflavour=""
+_kver="4.14.138-mc15"
+_kver2="$_kver-easy"
+pkgname="zfs-$_kver"
+pkgver=0.8.2
+pkgrel=0
+pkgdesc="Linux support for the ZFS filesystem"
+url="https://open-zfs.org"
+arch="all"
+license="CDDL"
+depends="easy-kernel$_kflavour-modules-$_kver"
+makedepends="eudev-dev libtirpc-dev linux-headers openssl-dev zlib-dev
+	easy-kernel$_kflavour-src-$_kver"
+install=""
+subpackages="$pkgname-dev"
+source="https://github.com/zfsonlinux/zfs/releases/download/zfs-$pkgver/zfs-$pkgver.tar.gz"
+builddir="$srcdir/zfs-$pkgver"
+
+prepare() {
+	default_prepare
+	update_config_sub
+}
+
+build() {
+	./configure \
+		--build=$CBUILD \
+		--host=$CHOST \
+		--prefix=/usr \
+		--sysconfdir=/etc \
+		--mandir=/usr/share/man \
+		--localstatedir=/var \
+		--with-linux=/usr/src/linux-$_kver \
+		--with-spec=generic \
+		--with-config=kernel
+	make
+}
+
+check() {
+	make check
+}
+
+package() {
+	make DESTDIR="$pkgdir" install
+}
+
+dev() {
+	default_dev
+	mv "$pkgdir/usr/src/spl-$pkgver" "$subpkgdir/usr/src"
+	cd "$pkgdir/usr/src/zfs-$pkgver"
+	mv zfs.release.in zfs_config.h.in "$subpkgdir/usr/src/zfs-$pkgver"
+	cd "$pkgdir/usr/src/zfs-$pkgver/$_kver2"
+	mv Module.symvers zfs.release spl.release "$subpkgdir/usr/src/zfs-$pkgver/$_kver2"
+	rm -r "$pkgdir/usr/src"
+}
+
+sha512sums="1424b1a030b814f812b5da422100669db5b8c3ccae14c2fdd62a5e0df28e7255247fe5ca99c95a14f08c92cc1574c22dd132093e4a1dd81e38c95b10cc5e2496  zfs-0.8.2.tar.gz"
-- 
GitLab


From d17ba1dc84f98beefc871befd65fc555d36174e9 Mon Sep 17 00:00:00 2001
From: Kiyoshi Aman <kiyoshi.aman+adelie@gmail.com>
Date: Sun, 8 Dec 2019 08:35:49 -0500
Subject: [PATCH 2/5] user/zfs-utils: new package

---
 user/zfs-utils/APKBUILD | 49 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 user/zfs-utils/APKBUILD

diff --git a/user/zfs-utils/APKBUILD b/user/zfs-utils/APKBUILD
new file mode 100644
index 0000000000..1d424b5005
--- /dev/null
+++ b/user/zfs-utils/APKBUILD
@@ -0,0 +1,49 @@
+# Contributor: Kiyoshi Aman <kiyoshi.aman+adelie@gmail.com>
+# Maintainer: Kiyoshi Aman <kiyoshi.aman+adelie@gmail.com>
+# keep these in sync with kernel version
+_kflavour=""
+_kver="4.14.138-mc15"
+_kver2="$_kver-easy"
+pkgname=zfs-utils
+pkgver=0.8.2
+pkgrel=0
+pkgdesc="User utilities for the ZFS filesystem"
+url="https://open-zfs.org"
+arch="all"
+license="CDDL"
+depends=""
+makedepends="eudev-dev libtirpc-dev linux-headers openssl-dev zlib-dev"
+install=""
+subpackages="$pkgname-dev $pkgname-doc zfs-openrc"
+source="https://github.com/zfsonlinux/zfs/releases/download/zfs-$pkgver/zfs-$pkgver.tar.gz"
+builddir="$srcdir/zfs-$pkgver"
+
+prepare() {
+	default_prepare
+	update_config_sub
+}
+
+build() {
+	./configure \
+		--build=$CBUILD \
+		--host=$CHOST \
+		--prefix=/usr \
+		--sysconfdir=/etc \
+		--mandir=/usr/share/man \
+		--localstatedir=/var \
+		--with-linux=/usr/src/linux-$_kver \
+		--with-spec=generic \
+		--with-config=user
+	make
+}
+
+check() {
+	make check
+}
+
+package() {
+	make DESTDIR="$pkgdir" install
+	rm -r "$pkgdir/usr/share/zfs/zfs-tests"
+}
+
+sha512sums="1424b1a030b814f812b5da422100669db5b8c3ccae14c2fdd62a5e0df28e7255247fe5ca99c95a14f08c92cc1574c22dd132093e4a1dd81e38c95b10cc5e2496  zfs-0.8.2.tar.gz"
-- 
GitLab


From a63cc05c53a6f4c22422dc8c69808b14d87a6f6e Mon Sep 17 00:00:00 2001
From: Kiyoshi Aman <kiyoshi.aman+adelie@gmail.com>
Date: Sun, 8 Dec 2019 08:52:14 -0500
Subject: [PATCH 3/5] user/zfs: depend on zfs-utils

---
 user/zfs/APKBUILD | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/user/zfs/APKBUILD b/user/zfs/APKBUILD
index ef11bf22d1..8dd9119b8e 100644
--- a/user/zfs/APKBUILD
+++ b/user/zfs/APKBUILD
@@ -11,7 +11,7 @@ pkgdesc="Linux support for the ZFS filesystem"
 url="https://open-zfs.org"
 arch="all"
 license="CDDL"
-depends="easy-kernel$_kflavour-modules-$_kver"
+depends="easy-kernel$_kflavour-modules-$_kver zfs-utils"
 makedepends="eudev-dev libtirpc-dev linux-headers openssl-dev zlib-dev
 	easy-kernel$_kflavour-src-$_kver"
 install=""
-- 
GitLab


From 2bcfdd65af6623d67e1865abc9636d7958ec4190 Mon Sep 17 00:00:00 2001
From: CyberLeo <cyberleo@cyberleo.net>
Date: Sat, 28 Mar 2020 05:06:25 -0500
Subject: [PATCH 4/5] user/zfs, user/zfs-utils: update to 0.8.3 and make it
 build

Update autoconf to remove nonstandard '&>' redirection that causes
module build test to inadvertently background in dash and then fail due
to a race.

Also backport patches to support removal of time_t; commit hashes
courtesy of https://bugs.launchpad.net/bugs/1863136 .
---
 user/zfs-utils/APKBUILD                       |   6 +-
 user/zfs/APKBUILD                             |  19 ++-
 ...mpat-ktime_get_raw_ts64-ff5587d65137.patch | 145 ++++++++++++++++++
 ...Linux-5.6-compat-time_t-2c3a83701dd1.patch | 110 +++++++++++++
 ...mpat-timestamp_truncate-795699a6cc28.patch | 131 ++++++++++++++++
 .../fix-autoconf-redirection-for-dash.patch   |  11 ++
 6 files changed, 414 insertions(+), 8 deletions(-)
 create mode 100644 user/zfs/Linux-5.6-compat-ktime_get_raw_ts64-ff5587d65137.patch
 create mode 100644 user/zfs/Linux-5.6-compat-time_t-2c3a83701dd1.patch
 create mode 100644 user/zfs/Linux-5.6-compat-timestamp_truncate-795699a6cc28.patch
 create mode 100644 user/zfs/fix-autoconf-redirection-for-dash.patch

diff --git a/user/zfs-utils/APKBUILD b/user/zfs-utils/APKBUILD
index 1d424b5005..dc985302ec 100644
--- a/user/zfs-utils/APKBUILD
+++ b/user/zfs-utils/APKBUILD
@@ -2,10 +2,10 @@
 # Maintainer: Kiyoshi Aman <kiyoshi.aman+adelie@gmail.com>
 # keep these in sync with kernel version
 _kflavour=""
-_kver="4.14.138-mc15"
+_kver="5.4.5-mc0"
 _kver2="$_kver-easy"
 pkgname=zfs-utils
-pkgver=0.8.2
+pkgver=0.8.3
 pkgrel=0
 pkgdesc="User utilities for the ZFS filesystem"
 url="https://open-zfs.org"
@@ -46,4 +46,4 @@ package() {
 	rm -r "$pkgdir/usr/share/zfs/zfs-tests"
 }
 
-sha512sums="1424b1a030b814f812b5da422100669db5b8c3ccae14c2fdd62a5e0df28e7255247fe5ca99c95a14f08c92cc1574c22dd132093e4a1dd81e38c95b10cc5e2496  zfs-0.8.2.tar.gz"
+sha512sums="aded632e6b04180560d4f2ff283260016e883dadae4e7fda9070b7113dee948099cb7a7b183f1c8139654389a2610fb9cc6f997acdc846040e605125cf016010 zfs-0.8.3.tar.gz"
diff --git a/user/zfs/APKBUILD b/user/zfs/APKBUILD
index 8dd9119b8e..31991c44d8 100644
--- a/user/zfs/APKBUILD
+++ b/user/zfs/APKBUILD
@@ -2,10 +2,10 @@
 # Maintainer: Kiyoshi Aman <kiyoshi.aman+adelie@gmail.com>
 # keep these in sync with kernel version
 _kflavour=""
-_kver="4.14.138-mc15"
+_kver="5.4.5-mc0"
 _kver2="$_kver-easy"
 pkgname="zfs-$_kver"
-pkgver=0.8.2
+pkgver=0.8.3
 pkgrel=0
 pkgdesc="Linux support for the ZFS filesystem"
 url="https://open-zfs.org"
@@ -13,15 +13,20 @@ arch="all"
 license="CDDL"
 depends="easy-kernel$_kflavour-modules-$_kver zfs-utils"
 makedepends="eudev-dev libtirpc-dev linux-headers openssl-dev zlib-dev
-	easy-kernel$_kflavour-src-$_kver"
+	easy-kernel$_kflavour-src-$_kver autoconf automake libtool"
 install=""
 subpackages="$pkgname-dev"
-source="https://github.com/zfsonlinux/zfs/releases/download/zfs-$pkgver/zfs-$pkgver.tar.gz"
+source="https://github.com/zfsonlinux/zfs/releases/download/zfs-$pkgver/zfs-$pkgver.tar.gz
+	fix-autoconf-redirection-for-dash.patch
+	Linux-5.6-compat-time_t-2c3a83701dd1.patch
+	Linux-5.6-compat-timestamp_truncate-795699a6cc28.patch
+	Linux-5.6-compat-ktime_get_raw_ts64-ff5587d65137.patch"
 builddir="$srcdir/zfs-$pkgver"
 
 prepare() {
 	default_prepare
 	update_config_sub
+	./autogen.sh
 }
 
 build() {
@@ -56,4 +61,8 @@ dev() {
 	rm -r "$pkgdir/usr/src"
 }
 
-sha512sums="1424b1a030b814f812b5da422100669db5b8c3ccae14c2fdd62a5e0df28e7255247fe5ca99c95a14f08c92cc1574c22dd132093e4a1dd81e38c95b10cc5e2496  zfs-0.8.2.tar.gz"
+sha512sums="aded632e6b04180560d4f2ff283260016e883dadae4e7fda9070b7113dee948099cb7a7b183f1c8139654389a2610fb9cc6f997acdc846040e605125cf016010 zfs-0.8.3.tar.gz
+47dc563fc1daa4c67096d2316ed2cea6aeaf4ca9e0daa41f2036a4ff3dcb542c88534ac25033a23e8fa97a9b82e56a8933f9fa56bae8a1fa07c1b15eb18f68f8  fix-autoconf-redirection-for-dash.patch
+a74bb30ef2e5f28fdc7b0cfe915f2841762ec8f6cd2368d2e4ba8627443e8e0754011a88b743e27519d191464e35e6c923510451f2a86d7e1a4ad3c5b737015f  Linux-5.6-compat-time_t-2c3a83701dd1.patch
+a791406265a6e1501e743b6f13764736439a14a9dfc1feaabc5fc82e27de1b2adf56b566c162fc42313f311fbf76c3213f7c2c05a518de36f96887e3d462e94a  Linux-5.6-compat-timestamp_truncate-795699a6cc28.patch
+9c78793a5840bc5fb5bb44a210124c1c8f09ce0ddfe88b91be8dbde5465763912308b89cd87300fd05b898076366528612c34a9c2f834d3b6573aa68eb442ec3  Linux-5.6-compat-ktime_get_raw_ts64-ff5587d65137.patch"
\ No newline at end of file
diff --git a/user/zfs/Linux-5.6-compat-ktime_get_raw_ts64-ff5587d65137.patch b/user/zfs/Linux-5.6-compat-ktime_get_raw_ts64-ff5587d65137.patch
new file mode 100644
index 0000000000..1b0402d298
--- /dev/null
+++ b/user/zfs/Linux-5.6-compat-ktime_get_raw_ts64-ff5587d65137.patch
@@ -0,0 +1,145 @@
+commit ff5587d651371ab496f7962e85fe2c337fdb8a59
+Author: Brian Behlendorf <behlendorf1@llnl.gov>
+Date:   Wed Feb 26 12:42:33 2020 -0800
+
+    Linux 5.6 compat: ktime_get_raw_ts64()
+    
+    The getrawmonotonic() and getrawmonotonic64() interfaces have been
+    fully retired.  Update gethrtime() to use the replacement interface
+    ktime_get_raw_ts64() which was introduced in the 4.18 kernel.
+    
+    Reviewed-by: Tony Hutter <hutter2@llnl.gov>
+    Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
+    Closes #10052
+    Closes #10064
+
+diff --git a/config/kernel-ktime.m4 b/config/kernel-ktime.m4
+new file mode 100644
+index 000000000..64c3b5f90
+--- /dev/null
++++ b/config/kernel-ktime.m4
+@@ -0,0 +1,55 @@
++dnl #
++dnl # 4.18: ktime_get_coarse_real_ts64() replaces current_kernel_time64().
++dnl #
++AC_DEFUN([ZFS_AC_KERNEL_SRC_KTIME_GET_COARSE_REAL_TS64], [
++	ZFS_LINUX_TEST_SRC([ktime_get_coarse_real_ts64], [
++		#include <linux/mm.h>
++	], [
++		struct timespec64 ts;
++		ktime_get_coarse_real_ts64(&ts);
++	])
++])
++
++AC_DEFUN([ZFS_AC_KERNEL_KTIME_GET_COARSE_REAL_TS64], [
++	AC_MSG_CHECKING([whether ktime_get_coarse_real_ts64() exists])
++	ZFS_LINUX_TEST_RESULT([ktime_get_coarse_real_ts64], [
++		AC_MSG_RESULT(yes)
++		AC_DEFINE(HAVE_KTIME_GET_COARSE_REAL_TS64, 1,
++		    [ktime_get_coarse_real_ts64() exists])
++	], [
++		AC_MSG_RESULT(no)
++	])
++])
++
++dnl #
++dnl # 4.18: ktime_get_raw_ts64() replaces getrawmonotonic64().
++dnl #
++AC_DEFUN([ZFS_AC_KERNEL_SRC_KTIME_GET_RAW_TS64], [
++	ZFS_LINUX_TEST_SRC([ktime_get_raw_ts64], [
++		#include <linux/mm.h>
++	], [
++		struct timespec64 ts;
++		ktime_get_raw_ts64(&ts);
++	])
++])
++
++AC_DEFUN([ZFS_AC_KERNEL_KTIME_GET_RAW_TS64], [
++	AC_MSG_CHECKING([whether ktime_get_raw_ts64() exists])
++	ZFS_LINUX_TEST_RESULT([ktime_get_raw_ts64], [
++		AC_MSG_RESULT(yes)
++		AC_DEFINE(HAVE_KTIME_GET_RAW_TS64, 1,
++		    [ktime_get_raw_ts64() exists])
++	], [
++		AC_MSG_RESULT(no)
++	])
++])
++
++AC_DEFUN([ZFS_AC_KERNEL_SRC_KTIME], [
++	ZFS_AC_KERNEL_SRC_KTIME_GET_COARSE_REAL_TS64
++	ZFS_AC_KERNEL_SRC_KTIME_GET_RAW_TS64
++])
++
++AC_DEFUN([ZFS_AC_KERNEL_KTIME], [
++	ZFS_AC_KERNEL_KTIME_GET_COARSE_REAL_TS64
++	ZFS_AC_KERNEL_KTIME_GET_RAW_TS64
++])
+diff --git a/config/kernel-ktime_get_coarse_real_ts64.m4 b/config/kernel-ktime_get_coarse_real_ts64.m4
+deleted file mode 100644
+index 28492bf04..000000000
+--- a/config/kernel-ktime_get_coarse_real_ts64.m4
++++ /dev/null
+@@ -1,23 +0,0 @@
+-dnl #
+-dnl # 4.18: ktime_get_coarse_real_ts64() added.  Use it in place of
+-dnl # current_kernel_time64().
+-dnl #
+-AC_DEFUN([ZFS_AC_KERNEL_SRC_KTIME_GET_COARSE_REAL_TS64], [
+-	ZFS_LINUX_TEST_SRC([ktime_get_coarse_real_ts64], [
+-		#include <linux/mm.h>
+-	], [
+-		struct timespec64 ts;
+-		ktime_get_coarse_real_ts64(&ts);
+-	])
+-])
+-
+-AC_DEFUN([ZFS_AC_KERNEL_KTIME_GET_COARSE_REAL_TS64], [
+-	AC_MSG_CHECKING([whether ktime_get_coarse_real_ts64() exists])
+-	ZFS_LINUX_TEST_RESULT([ktime_get_coarse_real_ts64], [
+-		AC_MSG_RESULT(yes)
+-		AC_DEFINE(HAVE_KTIME_GET_COARSE_REAL_TS64, 1,
+-		    [ktime_get_coarse_real_ts64() exists])
+-	], [
+-		AC_MSG_RESULT(no)
+-	])
+-])
+diff --git a/config/kernel.m4 b/config/kernel.m4
+index 6bb37937c..a0fa2514e 100644
+--- a/config/kernel.m4
++++ b/config/kernel.m4
+@@ -114,7 +114,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
+ 	ZFS_AC_KERNEL_SRC_CURRENT_TIME
+ 	ZFS_AC_KERNEL_SRC_USERNS_CAPABILITIES
+ 	ZFS_AC_KERNEL_SRC_IN_COMPAT_SYSCALL
+-	ZFS_AC_KERNEL_SRC_KTIME_GET_COARSE_REAL_TS64
++	ZFS_AC_KERNEL_SRC_KTIME
+ 	ZFS_AC_KERNEL_SRC_TOTALRAM_PAGES_FUNC
+ 	ZFS_AC_KERNEL_SRC_TOTALHIGH_PAGES
+ 	ZFS_AC_KERNEL_SRC_KSTRTOUL
+@@ -208,7 +208,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
+ 	ZFS_AC_KERNEL_CURRENT_TIME
+ 	ZFS_AC_KERNEL_USERNS_CAPABILITIES
+ 	ZFS_AC_KERNEL_IN_COMPAT_SYSCALL
+-	ZFS_AC_KERNEL_KTIME_GET_COARSE_REAL_TS64
++	ZFS_AC_KERNEL_KTIME
+ 	ZFS_AC_KERNEL_TOTALRAM_PAGES_FUNC
+ 	ZFS_AC_KERNEL_TOTALHIGH_PAGES
+ 	ZFS_AC_KERNEL_KSTRTOUL
+diff --git a/include/spl/sys/time.h b/include/spl/sys/time.h
+index 312415b7b..56fd725c0 100644
+--- a/include/spl/sys/time.h
++++ b/include/spl/sys/time.h
+@@ -105,8 +105,13 @@ gethrestime_sec(void)
+ static inline hrtime_t
+ gethrtime(void)
+ {
++#if defined(HAVE_KTIME_GET_RAW_TS64)
++	struct timespec64 ts;
++	ktime_get_raw_ts64(&ts);
++#else
+ 	struct timespec ts;
+ 	getrawmonotonic(&ts);
++#endif
+ 	return (((hrtime_t)ts.tv_sec * NSEC_PER_SEC) + ts.tv_nsec);
+ }
+ 
diff --git a/user/zfs/Linux-5.6-compat-time_t-2c3a83701dd1.patch b/user/zfs/Linux-5.6-compat-time_t-2c3a83701dd1.patch
new file mode 100644
index 0000000000..7a97d968fd
--- /dev/null
+++ b/user/zfs/Linux-5.6-compat-time_t-2c3a83701dd1.patch
@@ -0,0 +1,110 @@
+commit 2c3a83701dd185cadb30db4556256534e2930c7d
+Author: Brian Behlendorf <behlendorf1@llnl.gov>
+Date:   Wed Feb 26 13:18:07 2020 -0800
+
+    Linux 5.6 compat: time_t
+    
+    As part of the Linux kernel's y2038 changes the time_t type has been
+    fully retired.  Callers are now required to use the time64_t type.
+    
+    Rather than move to the new type, I've removed the few remaining
+    places where a time_t is used in the kernel code.  They've been
+    replaced with a uint64_t which is already how ZFS internally
+    handled these values.
+    
+    Going forward we should work towards updating the remaining user
+    space time_t consumers to the 64-bit interfaces.
+    
+    Reviewed-by: Matthew Macy <mmacy@freebsd.org>
+    Reviewed-by: Tony Hutter <hutter2@llnl.gov>
+    Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
+    Closes #10052
+    Closes #10064
+
+diff --git a/include/spl/sys/time.h b/include/spl/sys/time.h
+index 56fd725c0..4309c300b 100644
+--- a/include/spl/sys/time.h
++++ b/include/spl/sys/time.h
+@@ -85,7 +85,7 @@ gethrestime(inode_timespec_t *ts)
+ #endif
+ }
+ 
+-static inline time_t
++static inline uint64_t
+ gethrestime_sec(void)
+ {
+ #if defined(HAVE_INODE_TIMESPEC64_TIMES)
+diff --git a/include/sys/vdev_impl.h b/include/sys/vdev_impl.h
+index 4f63e1ae5..b55871a5d 100644
+--- a/include/sys/vdev_impl.h
++++ b/include/sys/vdev_impl.h
+@@ -272,7 +272,7 @@ struct vdev {
+ 	range_tree_t	*vdev_initialize_tree;	/* valid while initializing */
+ 	uint64_t	vdev_initialize_bytes_est;
+ 	uint64_t	vdev_initialize_bytes_done;
+-	time_t		vdev_initialize_action_time;	/* start and end time */
++	uint64_t	vdev_initialize_action_time;	/* start and end time */
+ 
+ 	/* TRIM related */
+ 	boolean_t	vdev_trim_exit_wanted;
+@@ -293,7 +293,7 @@ struct vdev {
+ 	uint64_t	vdev_trim_rate;		/* requested rate (bytes/sec) */
+ 	uint64_t	vdev_trim_partial;	/* requested partial TRIM */
+ 	uint64_t	vdev_trim_secure;	/* requested secure TRIM */
+-	time_t		vdev_trim_action_time;	/* start and end time */
++	uint64_t	vdev_trim_action_time;	/* start and end time */
+ 
+ 	/* for limiting outstanding I/Os (initialize and TRIM) */
+ 	kmutex_t	vdev_initialize_io_lock;
+diff --git a/lib/libspl/include/sys/time.h b/lib/libspl/include/sys/time.h
+index 291f2190a..c9f616504 100644
+--- a/lib/libspl/include/sys/time.h
++++ b/lib/libspl/include/sys/time.h
+@@ -88,7 +88,7 @@ gethrestime(inode_timespec_t *ts)
+ 	ts->tv_nsec = tv.tv_usec * NSEC_PER_USEC;
+ }
+ 
+-static inline time_t
++static inline uint64_t
+ gethrestime_sec(void)
+ {
+ 	struct timeval tv;
+diff --git a/module/zfs/zfs_debug.c b/module/zfs/zfs_debug.c
+index a64971d0a..d98463f1b 100644
+--- a/module/zfs/zfs_debug.c
++++ b/module/zfs/zfs_debug.c
+@@ -28,7 +28,7 @@
+ 
+ typedef struct zfs_dbgmsg {
+ 	procfs_list_node_t	zdm_node;
+-	time_t			zdm_timestamp;
++	uint64_t		zdm_timestamp;
+ 	int			zdm_size;
+ 	char			zdm_msg[1]; /* variable length allocation */
+ } zfs_dbgmsg_t;
+diff --git a/module/zfs/vdev_initialize.c b/module/zfs/vdev_initialize.c
+index 3e691c7f5..5899af9fc 100644
+--- a/module/zfs/vdev_initialize.c
++++ b/module/zfs/vdev_initialize.c
+@@ -713,7 +713,7 @@ vdev_initialize_restart(vdev_t *vd)
+ 		    vd->vdev_leaf_zap, VDEV_LEAF_ZAP_INITIALIZE_ACTION_TIME,
+ 		    sizeof (timestamp), 1, &timestamp);
+ 		ASSERT(err == 0 || err == ENOENT);
+-		vd->vdev_initialize_action_time = (time_t)timestamp;
++		vd->vdev_initialize_action_time = timestamp;
+ 
+ 		if (vd->vdev_initialize_state == VDEV_INITIALIZE_SUSPENDED ||
+ 		    vd->vdev_offline) {
+diff --git a/module/zfs/vdev_trim.c b/module/zfs/vdev_trim.c
+index c7c429cbd..7dec07e3c 100644
+--- a/module/zfs/vdev_trim.c
++++ b/module/zfs/vdev_trim.c
+@@ -1051,7 +1051,7 @@ vdev_trim_restart(vdev_t *vd)
+ 		    vd->vdev_leaf_zap, VDEV_LEAF_ZAP_TRIM_ACTION_TIME,
+ 		    sizeof (timestamp), 1, &timestamp);
+ 		ASSERT(err == 0 || err == ENOENT);
+-		vd->vdev_trim_action_time = (time_t)timestamp;
++		vd->vdev_trim_action_time = timestamp;
+ 
+ 		if (vd->vdev_trim_state == VDEV_TRIM_SUSPENDED ||
+ 		    vd->vdev_offline) {
diff --git a/user/zfs/Linux-5.6-compat-timestamp_truncate-795699a6cc28.patch b/user/zfs/Linux-5.6-compat-timestamp_truncate-795699a6cc28.patch
new file mode 100644
index 0000000000..deb81347b3
--- /dev/null
+++ b/user/zfs/Linux-5.6-compat-timestamp_truncate-795699a6cc28.patch
@@ -0,0 +1,131 @@
+commit 795699a6cc28b8f1059397e03d1a86d576bfc7dc
+Author: Brian Behlendorf <behlendorf1@llnl.gov>
+Date:   Thu Feb 6 12:37:25 2020 -0800
+
+    Linux 5.6 compat: timestamp_truncate()
+    
+    The timestamp_truncate() function was added, it replaces the existing
+    timespec64_trunc() function.  This change renames our wrapper function
+    to be consistent with the upstream name and updates the compatibility
+    code for older kernels accordingly.
+    
+    Reviewed-by: Tony Hutter <hutter2@llnl.gov>
+    Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
+    Closes #9956
+    Closes #9961
+
+diff --git a/config/kernel-inode-times.m4 b/config/kernel-inode-times.m4
+index 57e7f31fd..8a79c299e 100644
+--- a/config/kernel-inode-times.m4
++++ b/config/kernel-inode-times.m4
+@@ -1,8 +1,22 @@
+-dnl #
+-dnl # 4.18 API change
+-dnl # i_atime, i_mtime, and i_ctime changed from timespec to timespec64.
+-dnl #
+ AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_TIMES], [
++
++	dnl #
++	dnl # 5.6 API change
++	dnl # timespec64_trunc() replaced by timestamp_truncate() interface.
++	dnl #
++	ZFS_LINUX_TEST_SRC([timestamp_truncate], [
++		#include <linux/fs.h>
++	],[
++		struct timespec64 ts;
++		struct inode ip;
++
++		ts = timestamp_truncate(ts, &ip);
++	])
++
++	dnl #
++	dnl # 4.18 API change
++	dnl # i_atime, i_mtime, and i_ctime changed from timespec to timespec64.
++	dnl #
+ 	ZFS_LINUX_TEST_SRC([inode_times], [
+ 		#include <linux/fs.h>
+ 	],[
+@@ -15,6 +29,15 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_TIMES], [
+ ])
+ 
+ AC_DEFUN([ZFS_AC_KERNEL_INODE_TIMES], [
++	AC_MSG_CHECKING([whether timestamp_truncate() exists])
++	ZFS_LINUX_TEST_RESULT([timestamp_truncate], [
++		AC_MSG_RESULT(yes)
++		AC_DEFINE(HAVE_INODE_TIMESTAMP_TRUNCATE, 1,
++		    [timestamp_truncate() exists])
++	],[
++		AC_MSG_RESULT(no)
++	])
++
+ 	AC_MSG_CHECKING([whether inode->i_*time's are timespec64])
+ 	ZFS_LINUX_TEST_RESULT([inode_times], [
+ 		AC_MSG_RESULT(no)
+diff --git a/include/sys/zpl.h b/include/sys/zpl.h
+index 20a3dc674..ef5a0b842 100644
+--- a/include/sys/zpl.h
++++ b/include/sys/zpl.h
+@@ -170,13 +170,14 @@ zpl_dir_emit_dots(struct file *file, zpl_dir_context_t *ctx)
+ }
+ #endif /* HAVE_VFS_ITERATE */
+ 
+-/*
+- * Linux 4.18, inode times converted from timespec to timespec64.
+- */
+-#if defined(HAVE_INODE_TIMESPEC64_TIMES)
+-#define	zpl_inode_timespec_trunc(ts, gran)	timespec64_trunc(ts, gran)
++#if defined(HAVE_INODE_TIMESTAMP_TRUNCATE)
++#define	zpl_inode_timestamp_truncate(ts, ip)	timestamp_truncate(ts, ip)
++#elif defined(HAVE_INODE_TIMESPEC64_TIMES)
++#define	zpl_inode_timestamp_truncate(ts, ip)	\
++	timespec64_trunc(ts, (ip)->i_sb->s_time_gran)
+ #else
+-#define	zpl_inode_timespec_trunc(ts, gran)	timespec_trunc(ts, gran)
++#define	zpl_inode_timestamp_truncate(ts, ip)	\
++	timespec_trunc(ts, (ip)->i_sb->s_time_gran)
+ #endif
+ 
+ #endif	/* _SYS_ZPL_H */
+diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c
+index ec63dbdeb..406cd7ef2 100644
+--- a/module/zfs/zfs_vnops.c
++++ b/module/zfs/zfs_vnops.c
+@@ -3444,8 +3444,8 @@ top:
+ 
+ 	if (mask & (ATTR_MTIME | ATTR_SIZE)) {
+ 		ZFS_TIME_ENCODE(&vap->va_mtime, mtime);
+-		ZTOI(zp)->i_mtime = zpl_inode_timespec_trunc(vap->va_mtime,
+-		    ZTOI(zp)->i_sb->s_time_gran);
++		ZTOI(zp)->i_mtime = zpl_inode_timestamp_truncate(
++		    vap->va_mtime, ZTOI(zp));
+ 
+ 		SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MTIME(zfsvfs), NULL,
+ 		    mtime, sizeof (mtime));
+@@ -3453,8 +3453,8 @@ top:
+ 
+ 	if (mask & (ATTR_CTIME | ATTR_SIZE)) {
+ 		ZFS_TIME_ENCODE(&vap->va_ctime, ctime);
+-		ZTOI(zp)->i_ctime = zpl_inode_timespec_trunc(vap->va_ctime,
+-		    ZTOI(zp)->i_sb->s_time_gran);
++		ZTOI(zp)->i_ctime = zpl_inode_timestamp_truncate(vap->va_ctime,
++		    ZTOI(zp));
+ 		SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zfsvfs), NULL,
+ 		    ctime, sizeof (ctime));
+ 	}
+diff --git a/module/zfs/zpl_inode.c b/module/zfs/zpl_inode.c
+index e1c6ce7b7..c1b582574 100644
+--- a/module/zfs/zpl_inode.c
++++ b/module/zfs/zpl_inode.c
+@@ -382,10 +382,8 @@ zpl_setattr(struct dentry *dentry, struct iattr *ia)
+ 	vap->va_mtime = ia->ia_mtime;
+ 	vap->va_ctime = ia->ia_ctime;
+ 
+-	if (vap->va_mask & ATTR_ATIME) {
+-		ip->i_atime = zpl_inode_timespec_trunc(ia->ia_atime,
+-		    ip->i_sb->s_time_gran);
+-	}
++	if (vap->va_mask & ATTR_ATIME)
++		ip->i_atime = zpl_inode_timestamp_truncate(ia->ia_atime, ip);
+ 
+ 	cookie = spl_fstrans_mark();
+ 	error = -zfs_setattr(ITOZ(ip), vap, 0, cr);
diff --git a/user/zfs/fix-autoconf-redirection-for-dash.patch b/user/zfs/fix-autoconf-redirection-for-dash.patch
new file mode 100644
index 0000000000..aa6e3becc4
--- /dev/null
+++ b/user/zfs/fix-autoconf-redirection-for-dash.patch
@@ -0,0 +1,11 @@
+--- a/config/kernel.m4	2020-03-28 09:54:37.851263408 +0000
++++ b/config/kernel.m4	2020-03-28 09:54:47.004155429 +0000
+@@ -603,7 +603,7 @@
+ 	AC_TRY_COMMAND([
+ 	    KBUILD_MODPOST_NOFINAL="$5" KBUILD_MODPOST_WARN="$6"
+ 	    make modules -k -j$TEST_JOBS -C $LINUX_OBJ $ARCH_UM
+-	    M=$PWD/$1 &>$1/build.log])
++	    M=$PWD/$1 >$1/build.log 2>&1])
+ 	AS_IF([AC_TRY_COMMAND([$2])], [$3], [$4])
+ ])
+ 
-- 
GitLab


From a77ab5fb063c6210aaa76775ec200499e6295cbc Mon Sep 17 00:00:00 2001
From: CyberLeo <cyberleo@cyberleo.net>
Date: Sat, 28 Mar 2020 23:09:51 -0500
Subject: [PATCH 5/5] user/zfs*: move to experimental per #418

---
 {user => experimental}/zfs-utils/APKBUILD                         | 0
 {user => experimental}/zfs/APKBUILD                               | 0
 .../zfs/Linux-5.6-compat-ktime_get_raw_ts64-ff5587d65137.patch    | 0
 .../zfs/Linux-5.6-compat-time_t-2c3a83701dd1.patch                | 0
 .../zfs/Linux-5.6-compat-timestamp_truncate-795699a6cc28.patch    | 0
 .../zfs/fix-autoconf-redirection-for-dash.patch                   | 0
 6 files changed, 0 insertions(+), 0 deletions(-)
 rename {user => experimental}/zfs-utils/APKBUILD (100%)
 rename {user => experimental}/zfs/APKBUILD (100%)
 rename {user => experimental}/zfs/Linux-5.6-compat-ktime_get_raw_ts64-ff5587d65137.patch (100%)
 rename {user => experimental}/zfs/Linux-5.6-compat-time_t-2c3a83701dd1.patch (100%)
 rename {user => experimental}/zfs/Linux-5.6-compat-timestamp_truncate-795699a6cc28.patch (100%)
 rename {user => experimental}/zfs/fix-autoconf-redirection-for-dash.patch (100%)

diff --git a/user/zfs-utils/APKBUILD b/experimental/zfs-utils/APKBUILD
similarity index 100%
rename from user/zfs-utils/APKBUILD
rename to experimental/zfs-utils/APKBUILD
diff --git a/user/zfs/APKBUILD b/experimental/zfs/APKBUILD
similarity index 100%
rename from user/zfs/APKBUILD
rename to experimental/zfs/APKBUILD
diff --git a/user/zfs/Linux-5.6-compat-ktime_get_raw_ts64-ff5587d65137.patch b/experimental/zfs/Linux-5.6-compat-ktime_get_raw_ts64-ff5587d65137.patch
similarity index 100%
rename from user/zfs/Linux-5.6-compat-ktime_get_raw_ts64-ff5587d65137.patch
rename to experimental/zfs/Linux-5.6-compat-ktime_get_raw_ts64-ff5587d65137.patch
diff --git a/user/zfs/Linux-5.6-compat-time_t-2c3a83701dd1.patch b/experimental/zfs/Linux-5.6-compat-time_t-2c3a83701dd1.patch
similarity index 100%
rename from user/zfs/Linux-5.6-compat-time_t-2c3a83701dd1.patch
rename to experimental/zfs/Linux-5.6-compat-time_t-2c3a83701dd1.patch
diff --git a/user/zfs/Linux-5.6-compat-timestamp_truncate-795699a6cc28.patch b/experimental/zfs/Linux-5.6-compat-timestamp_truncate-795699a6cc28.patch
similarity index 100%
rename from user/zfs/Linux-5.6-compat-timestamp_truncate-795699a6cc28.patch
rename to experimental/zfs/Linux-5.6-compat-timestamp_truncate-795699a6cc28.patch
diff --git a/user/zfs/fix-autoconf-redirection-for-dash.patch b/experimental/zfs/fix-autoconf-redirection-for-dash.patch
similarity index 100%
rename from user/zfs/fix-autoconf-redirection-for-dash.patch
rename to experimental/zfs/fix-autoconf-redirection-for-dash.patch
-- 
GitLab