diff -pruN 0.7.12-1/debian/changelog 0.7.12-1ubuntu4/debian/changelog
--- 0.7.12-1/debian/changelog	2018-11-19 11:25:53.000000000 +0000
+++ 0.7.12-1ubuntu4/debian/changelog	2019-05-28 09:14:11.000000000 +0000
@@ -1,3 +1,48 @@
+spl-linux (0.7.12-1ubuntu4) eoan; urgency=medium
+
+  * Remove 0002-Add-check-for-totalram-pages.patch, replace with
+    backported upstream fix
+    - 0002-Linux-5.0-compat-Use-totalram_pages.patch 
+  * Add 5.0, 5.1, 5.2 zfs upstream compat fixes
+    - 0006-Linux-5.0-compat-Fix-SUBDIRs.patch
+    - 0007-Linux-4.20-compat-Fix-VERIFY-RW_READ_HELD-hash-mh_co.patch
+    - 0008-Linux-5.1-compat-get_ds-removed.patch
+    - 0009-Linux-5.0-compat-Use-totalhigh_pages.patch
+    - 0010-Linux-5.1-compat-Drop-ULLONG_MAX-and-LLONG_MAX-defin.patch
+    - 0011-Linux-5.2-compat-rw_tryupgrade.patch
+    - 0012-Linux-5.2-compat-Remove-config-kernel-set-fs-pwd.m4.patch
+  * Workaround modpost defaults changes in 5.2, fix this to throws a warning
+    instead of an error.
+    - Add KBUILD_MODPOST_WARN=1 to debian/dkms configure
+
+ -- Colin Ian King <colin.king@canonical.com>  Tue, 28 May 2019 10:14:11 +0100
+
+spl-linux (0.7.12-1ubuntu3) disco; urgency=medium
+
+  * Fix test depends, we really need to include @ too
+  * Just run the splat tests for now as these are the
+    critical interface tests and the will fail if spl
+    modules are broken.
+
+ -- Colin Ian King <colin.king@canonical.com>  Mon, 28 Jan 2019 18:39:53 +0000
+
+spl-linux (0.7.12-1ubuntu2) disco; urgency=medium
+
+  * Various Linux compat 5.0 changes
+    - check for ktime_get_coarse_real_ts64
+    - check for ktime_get_ts64
+    - check for timespec64
+    - check for totalram-pages now being a function
+    - and use the above fixes in spl
+   
+ -- Colin Ian King <colin.king@canonical.com>  Fri, 18 Jan 2019 14:53:11 +0000
+
+spl-linux (0.7.12-1ubuntu1) disco; urgency=medium
+
+  * Sync with Debian 0.7.12-1
+
+ -- Colin Ian King <colin.king@canonical.com>  Wed, 21 Nov 2018 10:54:15 +0000
+
 spl-linux (0.7.12-1) unstable; urgency=medium
 
   * New upstream version 0.7.12
diff -pruN 0.7.12-1/debian/control 0.7.12-1ubuntu4/debian/control
--- 0.7.12-1/debian/control	2018-11-19 11:25:53.000000000 +0000
+++ 0.7.12-1ubuntu4/debian/control	2019-05-28 09:14:11.000000000 +0000
@@ -1,7 +1,8 @@
 Source: spl-linux
 Section: kernel
 Priority: optional
-Maintainer: Debian ZFS on Linux maintainers <pkg-zfsonlinux-devel@alioth-lists.debian.net>
+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
+XSBC-Original-Maintainer: Debian ZFS on Linux maintainers <pkg-zfsonlinux-devel@alioth-lists.debian.net>
 Uploaders: Aron Xu <aron@debian.org>,
            Carlos Alberto Lopez Perez <clopez@igalia.com>,
            Mo Zhou <cdluminate@gmail.com>,
diff -pruN 0.7.12-1/debian/control.in 0.7.12-1ubuntu4/debian/control.in
--- 0.7.12-1/debian/control.in	2018-11-19 11:25:53.000000000 +0000
+++ 0.7.12-1ubuntu4/debian/control.in	2018-11-21 10:54:15.000000000 +0000
@@ -1,7 +1,8 @@
 Source: spl-linux
 Section: kernel
 Priority: optional
-Maintainer: Debian ZFS on Linux maintainers <pkg-zfsonlinux-devel@alioth-lists.debian.net>
+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
+XSBC-Original-Maintainer: Debian ZFS on Linux maintainers <pkg-zfsonlinux-devel@alioth-lists.debian.net>
 Uploaders: Aron Xu <aron@debian.org>,
            Carlos Alberto Lopez Perez <clopez@igalia.com>,
            Mo Zhou <cdluminate@gmail.com>,
diff -pruN 0.7.12-1/debian/dkms 0.7.12-1ubuntu4/debian/dkms
--- 0.7.12-1/debian/dkms	2018-11-19 11:25:53.000000000 +0000
+++ 0.7.12-1ubuntu4/debian/dkms	2019-05-28 09:14:11.000000000 +0000
@@ -2,6 +2,7 @@ AUTOINSTALL="yes"
 PACKAGE_NAME="spl"
 PACKAGE_VERSION="#MODULE_VERSION#"
 PRE_BUILD="configure
+  KBUILD_MODPOST_WARN=1
   --prefix=/usr
   --with-config=kernel
   --with-linux=$(case `lsb_release -is` in
diff -pruN 0.7.12-1/debian/patches/0001-Add-check-for-ktime_get_coarse_real_ts64-for-V5.0-ke.patch 0.7.12-1ubuntu4/debian/patches/0001-Add-check-for-ktime_get_coarse_real_ts64-for-V5.0-ke.patch
--- 0.7.12-1/debian/patches/0001-Add-check-for-ktime_get_coarse_real_ts64-for-V5.0-ke.patch	1970-01-01 00:00:00.000000000 +0000
+++ 0.7.12-1ubuntu4/debian/patches/0001-Add-check-for-ktime_get_coarse_real_ts64-for-V5.0-ke.patch	2019-05-28 09:00:42.000000000 +0000
@@ -0,0 +1,80 @@
+Add support for ktime_get_coarse_real_ts64 for 5.0
+
+Signed-off-by; Colin Ian King <colin.king@canonical.com>
+---
+
+Index: spl-linux-0.7.12/config/kernel-ktime.m4
+===================================================================
+--- /dev/null
++++ spl-linux-0.7.12/config/kernel-ktime-get-coarse-real-ts64.m4
+@@ -0,0 +1,20 @@
++dnl #
++dnl # 5.0 API change
++dnl # current_kernel_time64 to ktime_get_coarse_real_ts64 timespec64
++dnl #
++AC_DEFUN([SPL_AC_KERNEL_KTIME_GET_COARSE_REAL_TS64], [
++	AC_MSG_CHECKING([whether ktime_get_coarse_real_ts64 exists])
++	SPL_LINUX_TRY_COMPILE([
++		#include <linux/ktime.h>
++	],[
++		struct timespec64 ts;
++
++		ktime_get_coarse_real_ts64(&ts);
++	],[
++		AC_MSG_RESULT(yes)
++		AC_DEFINE(HAVE_KTIME_GET_COARSE_REAL_TS64, 1,
++		    [ktime_get_coarse_real_ts64 is provided])
++	],[
++		AC_MSG_RESULT(no)
++	])
++])
+Index: spl-linux-0.7.12/include/sys/time.h
+===================================================================
+--- spl-linux-0.7.12.orig/include/sys/time.h
++++ spl-linux-0.7.12/include/sys/time.h
+@@ -71,22 +71,32 @@ typedef struct timespec		inode_timespec_
+ 
+ static inline void
+ gethrestime(inode_timespec_t *ts)
+- {
++{
++#if defined(HAVE_KTIME_GET_COARSE_REAL_TS64)
++	ktime_get_coarse_real_ts64(ts);
++#else
+ #if defined(HAVE_INODE_TIMESPEC64_TIMES)
+ 	*ts = current_kernel_time64();
+ #else
+ 	*ts = current_kernel_time();
+ #endif
++#endif
+ }
+ 
+ static inline time_t
+ gethrestime_sec(void)
+ {
++#if defined(HAVE_KTIME_GET_COARSE_REAL_TS64)
++	inode_timespec_t ts;
++
++	ktime_get_coarse_real_ts64(&ts);
++#else
+ #if defined(HAVE_INODE_TIMESPEC64_TIMES)
+ 	inode_timespec_t ts = current_kernel_time64();
+ #else
+ 	inode_timespec_t ts = current_kernel_time();
+ #endif
++#endif
+ 	return (ts.tv_sec);
+ }
+ 
+Index: spl-linux-0.7.12/config/spl-build.m4
+===================================================================
+--- spl-linux-0.7.12.orig/config/spl-build.m4
++++ spl-linux-0.7.12/config/spl-build.m4
+@@ -54,6 +54,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
+ 	SPL_AC_KERNEL_WRITE
+ 	SPL_AC_KERNEL_READ
+ 	SPL_AC_KERNEL_TIMER_FUNCTION_TIMER_LIST
++	SPL_AC_KERNEL_KTIME_GET_COARSE_REAL_TS64
+ ])
+ 
+ AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
diff -pruN 0.7.12-1/debian/patches/0002-Linux-5.0-compat-Use-totalram_pages.patch 0.7.12-1ubuntu4/debian/patches/0002-Linux-5.0-compat-Use-totalram_pages.patch
--- 0.7.12-1/debian/patches/0002-Linux-5.0-compat-Use-totalram_pages.patch	1970-01-01 00:00:00.000000000 +0000
+++ 0.7.12-1ubuntu4/debian/patches/0002-Linux-5.0-compat-Use-totalram_pages.patch	2019-05-28 09:14:11.000000000 +0000
@@ -0,0 +1,78 @@
+From 031cea17a3db1dae3b6968a8c71bcfb678a03235 Mon Sep 17 00:00:00 2001
+From: Tony Hutter <hutter2@llnl.gov>
+Date: Thu, 10 Jan 2019 14:28:10 -0800
+Subject: [PATCH] Linux 5.0 compat: Use totalram_pages()
+
+totalram_pages() was converted to an atomic variable in 5.0:
+
+https://patchwork.kernel.org/patch/10652795/
+
+Its value should now be read though the totalram_pages() helper
+function.
+
+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Signed-off-by: Tony Hutter <hutter2@llnl.gov>
+(backported from upstream commit 031cea17a3db1dae3b6968a8c71bcfb678a03235)
+Signed-off-by: Colin Ian King <colin.king@canonical.com>
+Closes #8263
+---
+ config/kernel-totalram-pages-func.m4 | 18 ++++++++++++++++++
+ include/sys/vmsystm.h                |  8 +++++++-
+ 4 files changed, 28 insertions(+), 3 deletions(-)
+ create mode 100644 config/kernel-totalram-pages-func.m4
+
+Index: spl-linux-0.7.12/config/kernel-totalram-pages-func.m4
+===================================================================
+--- /dev/null
++++ spl-linux-0.7.12/config/kernel-totalram-pages-func.m4
+@@ -0,0 +1,18 @@
++dnl #
++dnl # Linux 5.0: totalram_pages is no longer a global variable, and must be
++dnl # read via the totalram_pages() helper function.
++dnl #
++AC_DEFUN([SPL_AC_KERNEL_TOTALRAM_PAGES_FUNC], [
++	AC_MSG_CHECKING([whether totalram_pages() exists])
++	SPL_LINUX_TRY_COMPILE([
++		#include <linux/mm.h>
++	],[
++		unsigned long pages __attribute__ ((unused));
++		pages = totalram_pages();
++	],[
++		AC_MSG_RESULT(yes)
++		AC_DEFINE(HAVE_TOTALRAM_PAGES_FUNC, 1, [kernel has totalram_pages()])
++	],[
++		AC_MSG_RESULT(no)
++	])
++])
+Index: spl-linux-0.7.12/include/sys/vmsystm.h
+===================================================================
+--- spl-linux-0.7.12.orig/include/sys/vmsystm.h
++++ spl-linux-0.7.12/include/sys/vmsystm.h
+@@ -33,8 +33,14 @@
+ #include <sys/types.h>
+ #include <asm/uaccess.h>
+ 
++#ifdef HAVE_TOTALRAM_PAGES_FUNC
++#define	zfs_totalram_pages	totalram_pages()
++#else
++#define	zfs_totalram_pages	totalram_pages
++#endif
++
+ #define	membar_producer()		smp_wmb()
+-#define	physmem				totalram_pages
++#define	physmem				zfs_totalram_pages
+ #define	freemem			(nr_free_pages() + \
+ 				global_page_state(NR_INACTIVE_FILE) + \
+ 				global_page_state(NR_INACTIVE_ANON) + \
+Index: spl-linux-0.7.12/config/spl-build.m4
+===================================================================
+--- spl-linux-0.7.12.orig/config/spl-build.m4
++++ spl-linux-0.7.12/config/spl-build.m4
+@@ -55,6 +55,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
+ 	SPL_AC_KERNEL_READ
+ 	SPL_AC_KERNEL_TIMER_FUNCTION_TIMER_LIST
+ 	SPL_AC_KERNEL_KTIME_GET_COARSE_REAL_TS64
++	SPL_AC_KERNEL_TOTALRAM_PAGES_FUNC
+ ])
+ 
+ AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
diff -pruN 0.7.12-1/debian/patches/0003-Add-check-for-ktime_get_ts64-for-V5.0-ke.patch 0.7.12-1ubuntu4/debian/patches/0003-Add-check-for-ktime_get_ts64-for-V5.0-ke.patch
--- 0.7.12-1/debian/patches/0003-Add-check-for-ktime_get_ts64-for-V5.0-ke.patch	1970-01-01 00:00:00.000000000 +0000
+++ 0.7.12-1ubuntu4/debian/patches/0003-Add-check-for-ktime_get_ts64-for-V5.0-ke.patch	2019-05-28 09:00:42.000000000 +0000
@@ -0,0 +1,42 @@
+Add support for ktime_get_ts64 for 5.0
+
+Signed-off-by; Colin Ian King <colin.king@canonical.com>
+---
+
+Index: spl-linux-0.7.12/config/kernel-ktime-get-ts64.m4
+===================================================================
+--- /dev/null
++++ spl-linux-0.7.12/config/kernel-ktime-get-ts64.m4
+@@ -0,0 +1,20 @@
++dnl #
++dnl # 4.20 API change
++dnl # check if ktime_get_ts64 exists
++dnl #
++AC_DEFUN([SPL_AC_KERNEL_KTIME_GET_TS64], [
++	AC_MSG_CHECKING([whether ktime_get_ts64 exists])
++	SPL_LINUX_TRY_COMPILE([
++		#include <linux/ktime.h>
++	],[
++		struct timespec64 ts;
++
++		ktime_get_ts64(&ts);
++	],[
++		AC_MSG_RESULT(yes)
++		AC_DEFINE(HAVE_KTIME_GET_TS64, 1,
++		    [ktime_get_ts64 is provided])
++	],[
++		AC_MSG_RESULT(no)
++	])
++])
+Index: spl-linux-0.7.12/config/spl-build.m4
+===================================================================
+--- spl-linux-0.7.12.orig/config/spl-build.m4
++++ spl-linux-0.7.12/config/spl-build.m4
+@@ -55,6 +55,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
+ 	SPL_AC_KERNEL_READ
+ 	SPL_AC_KERNEL_TIMER_FUNCTION_TIMER_LIST
+ 	SPL_AC_KERNEL_KTIME_GET_COARSE_REAL_TS64
++	SPL_AC_KERNEL_KTIME_GET_TS64
+ 	SPL_AC_KERNEL_TOTALRAM_PAGES_FUNC
+ ])
+ 
diff -pruN 0.7.12-1/debian/patches/0004-Add-check-for-timespec64-sub.patch 0.7.12-1ubuntu4/debian/patches/0004-Add-check-for-timespec64-sub.patch
--- 0.7.12-1/debian/patches/0004-Add-check-for-timespec64-sub.patch	1970-01-01 00:00:00.000000000 +0000
+++ 0.7.12-1ubuntu4/debian/patches/0004-Add-check-for-timespec64-sub.patch	2019-05-28 09:00:42.000000000 +0000
@@ -0,0 +1,42 @@
+Add support for timespec64 for 5.0
+
+Signed-off-by; Colin Ian King <colin.king@canonical.com>
+---
+
+Index: spl-linux-0.7.12/config/kernel-timespec64.m4
+===================================================================
+--- /dev/null
++++ spl-linux-0.7.12/config/kernel-timespec64.m4
+@@ -0,0 +1,20 @@
++dnl #
++dnl # 4.20 API change
++dnl # timespec64_sub replacing timespec_sub
++dnl #
++AC_DEFUN([SPL_AC_KERNEL_TIMESPEC64_SUB], [
++	AC_MSG_CHECKING([whether timespec64_sub exists])
++	SPL_LINUX_TRY_COMPILE([
++		#include <linux/ktime.h>
++	],[
++		struct timespec64 ts1 = { 0 }, ts2 = { 0 }, delta;
++
++		delta = timespec64_sub(ts1, ts2);
++	],[
++		AC_MSG_RESULT(yes)
++		AC_DEFINE(HAVE_TIMESPEC64_SUB, 1,
++		    [timespec64_sub is provided])
++	],[
++		AC_MSG_RESULT(no)
++	])
++])
+Index: spl-linux-0.7.12/config/spl-build.m4
+===================================================================
+--- spl-linux-0.7.12.orig/config/spl-build.m4
++++ spl-linux-0.7.12/config/spl-build.m4
+@@ -56,6 +56,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
+ 	SPL_AC_KERNEL_TIMER_FUNCTION_TIMER_LIST
+ 	SPL_AC_KERNEL_KTIME_GET_COARSE_REAL_TS64
+ 	SPL_AC_KERNEL_KTIME_GET_TS64
++	SPL_AC_KERNEL_TIMESPEC64_SUB
+ 	SPL_AC_KERNEL_TOTALRAM_PAGES_FUNC
+ ])
+ 
diff -pruN 0.7.12-1/debian/patches/0005-Use-64-bit-timespec-fixes.patch 0.7.12-1ubuntu4/debian/patches/0005-Use-64-bit-timespec-fixes.patch
--- 0.7.12-1/debian/patches/0005-Use-64-bit-timespec-fixes.patch	1970-01-01 00:00:00.000000000 +0000
+++ 0.7.12-1ubuntu4/debian/patches/0005-Use-64-bit-timespec-fixes.patch	2019-05-28 09:00:42.000000000 +0000
@@ -0,0 +1,180 @@
+Add 64 bit timespec support for 5.0
+
+Signed-off-by; Colin Ian King <colin.king@canonical.com>
+---
+
+Index: spl-linux-0.7.12/module/splat/splat-kmem.c
+===================================================================
+--- spl-linux-0.7.12.orig/module/splat/splat-kmem.c
++++ spl-linux-0.7.12/module/splat/splat-kmem.c
+@@ -713,7 +713,11 @@ splat_kmem_cache_thread_test(struct file
+ {
+ 	kmem_cache_priv_t *kcp;
+ 	kthread_t *thr;
++#if defined(HAVE_TIMESPEC64_SUB)
++	struct timespec64 start, stop, delta;
++#else
+ 	struct timespec start, stop, delta;
++#endif
+ 	char cache_name[32];
+ 	int i, rc = 0;
+ 
+@@ -737,7 +741,11 @@ splat_kmem_cache_thread_test(struct file
+ 		goto out_kcp;
+ 	}
+ 
++#if defined(HAVE_KTIME_GET_TS64)
++	ktime_get_ts64(&start);
++#else
+ 	getnstimeofday(&start);
++#endif
+ 
+ 	for (i = 0; i < SPLAT_KMEM_THREADS; i++) {
+ 		thr = thread_create(NULL, 0,
+@@ -762,14 +770,22 @@ splat_kmem_cache_thread_test(struct file
+ 	/* Sleep until all thread have finished */
+ 	wait_event(kcp->kcp_ctl_waitq, splat_kmem_cache_test_threads(kcp, 0));
+ 
++#if defined(HAVE_KTIME_GET_TS64)
++	ktime_get_ts64(&stop);
++#else
+ 	getnstimeofday(&stop);
++#endif
++#if defined(HAVE_TIMESPEC64_SUB)
++	delta = timespec64_sub(stop, start);
++#else
+ 	delta = timespec_sub(stop, start);
++#endif
+ 
+ 	splat_vprint(file, name,
+-		     "%-22s %2ld.%09ld\t"
++		     "%-22s %2lld.%09ld\t"
+ 		     "%lu/%lu/%lu\t%lu/%lu/%lu\n",
+ 		     kcp->kcp_cache->skc_name,
+-		     delta.tv_sec, delta.tv_nsec,
++		     (long long)delta.tv_sec, delta.tv_nsec,
+ 		     (unsigned long)kcp->kcp_cache->skc_slab_total,
+ 		     (unsigned long)kcp->kcp_cache->skc_slab_max,
+ 		     (unsigned long)(kcp->kcp_alloc *
+@@ -1226,7 +1242,11 @@ splat_kmem_test13(struct file *file, voi
+ 	kmem_cache_thread_t *kct;
+ 	dummy_page_t *dp;
+ 	struct list_head list;
++#if defined(HAVE_TIMESPEC64_SUB)
++	struct timespec64 start, stop, delta = { 0, 0 };
++#else
+ 	struct timespec start, stop, delta = { 0, 0 };
++#endif
+ 	int size, count, slabs, fails = 0;
+ 	int i, rc = 0, max_time = 10;
+ 
+@@ -1274,7 +1294,11 @@ splat_kmem_test13(struct file *file, voi
+ 	i = 0;
+ 	slabs = kcp->kcp_cache->skc_slab_total;
+ 	INIT_LIST_HEAD(&list);
++#if defined(HAVE_KTIME_GET_TS64)
++	ktime_get_ts64(&start);
++#else
+ 	getnstimeofday(&start);
++#endif
+ 
+ 	/* Apply memory pressure */
+ 	while (kcp->kcp_cache->skc_slab_total > (slabs >> 2)) {
+@@ -1283,8 +1307,16 @@ splat_kmem_test13(struct file *file, voi
+ 			splat_kmem_cache_test_debug(
+ 			    file, SPLAT_KMEM_TEST13_NAME, kcp);
+ 
++#if defined(HAVE_KTIME_GET_TS64)
++		ktime_get_ts64(&stop);
++#else
+ 		getnstimeofday(&stop);
++#endif
++#if defined(HAVE_TIMESPEC64_SUB)
++		delta = timespec64_sub(stop, start);
++#else
+ 		delta = timespec_sub(stop, start);
++#endif
+ 		if (delta.tv_sec >= max_time) {
+ 			splat_vprint(file, SPLAT_KMEM_TEST13_NAME,
+ 				     "Failed to reclaim 3/4 of cache in %ds, "
+Index: spl-linux-0.7.12/module/splat/splat-taskq.c
+===================================================================
+--- spl-linux-0.7.12.orig/module/splat/splat-taskq.c
++++ spl-linux-0.7.12/module/splat/splat-taskq.c
+@@ -1077,14 +1077,22 @@ splat_taskq_throughput_func(void *arg)
+ static int
+ splat_taskq_throughput(struct file *file, void *arg, const char *name,
+     int nthreads, int minalloc, int maxalloc, int flags, int tasks,
++#if defined(HAVE_TIMESPEC64_SUB)
++    struct timespec64 *delta)
++#else
+     struct timespec *delta)
++#endif
+ {
+ 	taskq_t *tq;
+ 	taskqid_t id;
+ 	splat_taskq_arg_t tq_arg;
+ 	taskq_ent_t **tqes;
+ 	atomic_t count;
++#if defined(HAVE_TIMESPEC64_SUB)
++	struct timespec64 start, stop;
++#else
+ 	struct timespec start, stop;
++#endif
+ 	int i, j, rc = 0;
+ 
+ 	tqes = vmalloc(sizeof (*tqes) * tasks);
+@@ -1107,7 +1115,11 @@ splat_taskq_throughput(struct file *file
+ 	tq_arg.count = &count;
+ 	atomic_set(tq_arg.count, 0);
+ 
++#if defined(HAVE_KTIME_GET_TS64)
++	ktime_get_ts64(&start);
++#else
+ 	getnstimeofday(&start);
++#endif
+ 
+ 	for (i = 0; i < tasks; i++) {
+ 		tqes[i] = kmalloc(sizeof (taskq_ent_t), GFP_KERNEL);
+@@ -1136,8 +1148,16 @@ splat_taskq_throughput(struct file *file
+ 	taskq_wait(tq);
+ 
+ 	if (delta != NULL) {
++#if defined(HAVE_KTIME_GET_TS64)
++		ktime_get_ts64(&stop);
++#else
+ 		getnstimeofday(&stop);
++#endif
++#if defined(HAVE_TIMESPEC64_SUB)
++		*delta = timespec64_sub(stop, start);
++#else
+ 		*delta = timespec_sub(stop, start);
++#endif
+ 	}
+ 
+ 	splat_vprint(file, name, "Taskq '%s' %d/%d dispatches finished\n",
+@@ -1452,7 +1472,11 @@ out_free:
+ static int
+ splat_taskq_test11(struct file *file, void *arg)
+ {
++#if defined(HAVE_TIMESPEC64_SUB)
++	struct timespec64 normal, dynamic;
++#else
+ 	struct timespec normal, dynamic;
++#endif
+ 	int error;
+ 
+ 	error = splat_taskq_throughput(file, arg, SPLAT_TASKQ_TEST11_NAME,
+@@ -1468,9 +1492,9 @@ splat_taskq_test11(struct file *file, vo
+ 		return (error);
+ 
+ 	splat_vprint(file, SPLAT_TASKQ_TEST11_NAME,
+-	    "Timing taskq_wait(): normal=%ld.%09lds, dynamic=%ld.%09lds\n",
+-	    normal.tv_sec, normal.tv_nsec,
+-	    dynamic.tv_sec, dynamic.tv_nsec);
++	    "Timing taskq_wait(): normal=%lld.%09lds, dynamic=%lld.%09lds\n",
++	    (unsigned long long)normal.tv_sec, normal.tv_nsec,
++	    (unsigned long long)dynamic.tv_sec, dynamic.tv_nsec);
+ 
+ 	/* A 10x increase in runtime is used to indicate a core problem. */
+ 	if (((int64_t)dynamic.tv_sec * NANOSEC + (int64_t)dynamic.tv_nsec) >
diff -pruN 0.7.12-1/debian/patches/0006-Linux-5.0-compat-Fix-SUBDIRs.patch 0.7.12-1ubuntu4/debian/patches/0006-Linux-5.0-compat-Fix-SUBDIRs.patch
--- 0.7.12-1/debian/patches/0006-Linux-5.0-compat-Fix-SUBDIRs.patch	1970-01-01 00:00:00.000000000 +0000
+++ 0.7.12-1ubuntu4/debian/patches/0006-Linux-5.0-compat-Fix-SUBDIRs.patch	2019-05-28 09:14:11.000000000 +0000
@@ -0,0 +1,41 @@
+From ed158b19b1dddf26f2bbebb4d0fd21f04fdd5d38 Mon Sep 17 00:00:00 2001
+From: Tony Hutter <hutter2@llnl.gov>
+Date: Thu, 10 Jan 2019 17:07:05 -0800
+Subject: [PATCH] Linux 5.0 compat: Fix SUBDIRs
+
+SUBDIRs has been deprecated for a long time, and was finally removed in
+the 5.0 kernel.  Use "M=" instead.
+
+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Signed-off-by: Tony Hutter <hutter2@llnl.gov>
+(backported from upstream fix ed158b19b1dddf26f2bbebb4d0fd21f04fdd5d38)
+Signed-off-by: Colin Ian King <colin.king@canonical.com>
+Closes #8257 
+
+Index: spl-linux-0.7.12/module/Makefile.in
+===================================================================
+--- spl-linux-0.7.12.orig/module/Makefile.in
++++ spl-linux-0.7.12/module/Makefile.in
+@@ -8,19 +8,19 @@ SPL_MODULE_CFLAGS += -include @abs_top_b
+ export SPL_MODULE_CFLAGS
+ 
+ modules:
+-	$(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ CONFIG_SPL=m $@
++	$(MAKE) -C @LINUX_OBJ@ M=`pwd` @KERNELMAKE_PARAMS@ CONFIG_SPL=m $@
+ 
+ clean:
+ 	@# Only cleanup the kernel build directories when CONFIG_KERNEL
+ 	@# is defined.  This indicates that kernel modules should be built.
+-@CONFIG_KERNEL_TRUE@	$(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ $@
++@CONFIG_KERNEL_TRUE@	$(MAKE) -C @LINUX_OBJ@ M=`pwd` @KERNELMAKE_PARAMS@ $@
+ 
+ 	if [ -f @LINUX_SYMBOLS@ ]; then $(RM) @LINUX_SYMBOLS@; fi
+ 	if [ -f Module.markers ]; then $(RM) Module.markers; fi
+ 
+ modules_install:
+ 	@# Install the kernel modules
+-	$(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` $@ \
++	$(MAKE) -C @LINUX_OBJ@ M=`pwd` $@ \
+ 		INSTALL_MOD_PATH=$(DESTDIR)$(INSTALL_MOD_PATH) \
+ 		INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) \
+ 		KERNELRELEASE=@LINUX_VERSION@
diff -pruN 0.7.12-1/debian/patches/0007-Linux-4.20-compat-Fix-VERIFY-RW_READ_HELD-hash-mh_co.patch 0.7.12-1ubuntu4/debian/patches/0007-Linux-4.20-compat-Fix-VERIFY-RW_READ_HELD-hash-mh_co.patch
--- 0.7.12-1/debian/patches/0007-Linux-4.20-compat-Fix-VERIFY-RW_READ_HELD-hash-mh_co.patch	1970-01-01 00:00:00.000000000 +0000
+++ 0.7.12-1ubuntu4/debian/patches/0007-Linux-4.20-compat-Fix-VERIFY-RW_READ_HELD-hash-mh_co.patch	2019-05-28 09:14:11.000000000 +0000
@@ -0,0 +1,94 @@
+From e73ab1b38cd099f3416eed0ab5576639383bbdcc Mon Sep 17 00:00:00 2001
+From: Tony Hutter <hutter2@llnl.gov>
+Date: Fri, 15 Feb 2019 12:37:20 -0800
+Subject: [PATCH] Linux 4.20 compat: Fix
+ VERIFY(RW_READ_HELD(&hash->mh_contents))
+
+The 4.20 kernel changed the meaning of the rw_semaphore.owner bits,
+causing an assertion when loading the module under the 4.20 kernel.
+This patch fixes the issue.
+
+Reviewed-by: Chunwei Chen <tuxoko@gmail.com>
+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Signed-off-by: Tony Hutter <hutter2@llnl.gov>
+(backported from upsteam commit e73ab1b38cd099f3416eed0ab5576639383bbdcc)
+Signed-off-by: Colin Ian King <colin.king@canonical.com>
+Closes #8360
+Closes #8389
+---
+ include/sys/rwlock.h | 55 ++++++++++++++++++++++++++++++++--------
+ 1 file changed, 45 insertions(+), 10 deletions(-)
+
+Index: spl-linux-0.7.12/include/sys/rwlock.h
+===================================================================
+--- spl-linux-0.7.12.orig/include/sys/rwlock.h
++++ spl-linux-0.7.12/include/sys/rwlock.h
+@@ -111,16 +111,6 @@ spl_rw_lockdep_on_maybe(krwlock_t *rwp)
+ #define	spl_rw_lockdep_on_maybe(rwp)
+ #endif /* CONFIG_LOCKDEP */
+ 
+-static inline int
+-RW_READ_HELD(krwlock_t *rwp)
+-{
+-	/*
+-	 * Linux 4.8 will set owner to 1 when read held instead of leave it
+-	 * NULL. So we check whether owner <= 1.
+-	 */
+-	return (spl_rwsem_is_locked(SEM(rwp)) &&
+-	    (unsigned long)rw_owner(rwp) <= 1);
+-}
+ 
+ static inline int
+ RW_WRITE_HELD(krwlock_t *rwp)
+@@ -134,6 +124,51 @@ RW_LOCK_HELD(krwlock_t *rwp)
+ 	return (spl_rwsem_is_locked(SEM(rwp)));
+ }
+ 
++static inline int
++RW_READ_HELD(krwlock_t *rwp)
++{
++	if (!RW_LOCK_HELD(rwp))
++		return (0);
++
++	/*
++	 * rw_semaphore cheat sheet:
++	 *
++	 * < 3.16:
++	 * There's no rw_semaphore.owner, so use rwp.owner instead.
++	 * If rwp.owner == NULL then it's a reader
++	 *
++	 * 3.16 - 4.7:
++	 * rw_semaphore.owner added (https://lwn.net/Articles/596656/)
++	 * and CONFIG_RWSEM_SPIN_ON_OWNER introduced.
++	 * If rw_semaphore.owner == NULL then it's a reader
++	 *
++	 * 4.8 - 4.16.16:
++	 * RWSEM_READER_OWNED added as an internal #define.
++	 * (https://lore.kernel.org/patchwork/patch/678590/)
++	 * If rw_semaphore.owner == 1 then it's a reader
++	 *
++	 * 4.16.17 - 4.19:
++	 * RWSEM_OWNER_UNKNOWN introduced as ((struct task_struct *)-1L)
++	 * (https://do-db2.lkml.org/lkml/2018/5/15/985)
++	 * If rw_semaphore.owner == 1 then it's a reader.
++	 *
++	 * 4.20+:
++	 * RWSEM_OWNER_UNKNOWN changed to ((struct task_struct *)-2L)
++	 * (https://lkml.org/lkml/2018/9/6/986)
++	 * If rw_semaphore.owner & 1 then it's a reader, and also the reader's
++	 * task_struct may be embedded in rw_semaphore->owner.
++	 */
++#if	defined(CONFIG_RWSEM_SPIN_ON_OWNER) && defined(RWSEM_OWNER_UNKNOWN)
++	if (RWSEM_OWNER_UNKNOWN == (struct task_struct *)-2L) {
++		/* 4.20+ kernels with CONFIG_RWSEM_SPIN_ON_OWNER */
++		return ((unsigned long) SEM(rwp)->owner & 1);
++	}
++#endif
++
++	/* < 4.20 kernel or !CONFIG_RWSEM_SPIN_ON_OWNER */
++	return (rw_owner(rwp) == NULL || (unsigned long) rw_owner(rwp) == 1);
++}
++
+ /*
+  * The following functions must be a #define and not static inline.
+  * This ensures that the native linux semaphore functions (down/up)
diff -pruN 0.7.12-1/debian/patches/0008-Linux-5.1-compat-get_ds-removed.patch 0.7.12-1ubuntu4/debian/patches/0008-Linux-5.1-compat-get_ds-removed.patch
--- 0.7.12-1/debian/patches/0008-Linux-5.1-compat-get_ds-removed.patch	1970-01-01 00:00:00.000000000 +0000
+++ 0.7.12-1ubuntu4/debian/patches/0008-Linux-5.1-compat-get_ds-removed.patch	2019-05-28 09:00:42.000000000 +0000
@@ -0,0 +1,33 @@
+From b46fd243d57d0af4b4b568d8c0c4b30b79059ecc Mon Sep 17 00:00:00 2001
+From: Brian Behlendorf <behlendorf1@llnl.gov>
+Date: Thu, 7 Mar 2019 14:44:23 -0800
+Subject: [PATCH] Linux 5.1 compat: get_ds() removed
+
+Commit torvalds/linux@736706bee has removed the get_fs() function
+as a bit of cleanup.  It has been defined as KERNEL_DS on all
+architectures for all supported kernels.  Replace get_fs() with
+KERNEL_DS as was done in the kernel.
+
+Reviewed-by: Tom Caputi <tcaputi@datto.com>
+Reviewed-by: Tony Hutter <hutter2@llnl.gov>
+Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
+(backported form upstream commit b46fd243d57d0af4b4b568d8c0c4b30b79059ecc)
+Signed-off-by: Colin Ian King <colin.king@canonical.com>
+Closes #8479
+---
+ module/spl/spl-vnode.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+Index: spl-linux-0.7.12/module/spl/spl-vnode.c
+===================================================================
+--- spl-linux-0.7.12.orig/module/spl/spl-vnode.c
++++ spl-linux-0.7.12/module/spl/spl-vnode.c
+@@ -608,7 +608,7 @@ vn_set_pwd(const char *filename)
+ 	 * size to ensure strncpy_from_user() does not fail with -EFAULT.
+ 	 */
+ 	saved_fs = get_fs();
+-	set_fs(get_ds());
++	set_fs(KERNEL_DS);
+ 
+ 	rc = user_path_dir(filename, &path);
+ 	if (rc)
diff -pruN 0.7.12-1/debian/patches/0009-Linux-5.0-compat-Use-totalhigh_pages.patch 0.7.12-1ubuntu4/debian/patches/0009-Linux-5.0-compat-Use-totalhigh_pages.patch
--- 0.7.12-1/debian/patches/0009-Linux-5.0-compat-Use-totalhigh_pages.patch	1970-01-01 00:00:00.000000000 +0000
+++ 0.7.12-1ubuntu4/debian/patches/0009-Linux-5.0-compat-Use-totalhigh_pages.patch	2019-05-28 09:14:11.000000000 +0000
@@ -0,0 +1,79 @@
+From de3e0b914b28deaf9034656d8f6e0bdf9ccd7c7f Mon Sep 17 00:00:00 2001
+From: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
+Date: Sun, 5 May 2019 08:40:48 +0900
+Subject: [PATCH] Linux 5.0 compat: Use totalhigh_pages()
+
+Linux kernel commit ca79b0c211af63fa3276f0e3fd7dd9ada2439839
+"mm: convert totalram_pages and totalhigh_pages variables to atomic"
+
+replaced `totalhigh_pages` with an inline function `totalhigh_pages()`.
+This broke compilation on IA32, etc, as ZoL uses `totalhigh_pages`
+on archs with highmem. Confirmed on Fedora 30 (5.0.9-301.fc30.i686).
+
+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
+(backported from upstream commit de3e0b914b28deaf9034656d8f6e0bdf9ccd7c7f)
+Signed-off-by: Colin Ian King <colin.king@canonical.com>
+Closes #8677
+Closes #8701
+---
+ config/kernel-totalhigh_pages.m4 | 19 +++++++++++++++++++
+ config/kernel.m4                 |  1 +
+ include/spl/sys/vmsystm.h        |  6 ++++++
+ module/zfs/arc.c                 |  2 +-
+ 4 files changed, 27 insertions(+), 1 deletion(-)
+ create mode 100644 config/kernel-totalhigh_pages.m4
+
+Index: spl-linux-0.7.12/config/kernel-totalhigh_pages.m4
+===================================================================
+--- /dev/null
++++ spl-linux-0.7.12/config/kernel-totalhigh_pages.m4
+@@ -0,0 +1,19 @@
++dnl #
++dnl # 5.0 API change
++dnl #
++dnl # ca79b0c211af mm: convert totalram_pages and totalhigh_pages variables to atomic
++dnl #
++AC_DEFUN([SPL_AC_KERNEL_TOTALHIGH_PAGES], [
++	AC_MSG_CHECKING([whether totalhigh_pages() exists])
++	SPL_LINUX_TRY_COMPILE([
++		#include <linux/highmem.h>
++	],[
++		unsigned long pages __attribute__ ((unused));
++		pages = totalhigh_pages();
++	],[
++		AC_MSG_RESULT(yes)
++		AC_DEFINE(HAVE_TOTALHIGH_PAGES, 1, [totalhigh_pages() exists])
++	],[
++		AC_MSG_RESULT(no)
++	])
++])
+Index: spl-linux-0.7.12/include/sys/vmsystm.h
+===================================================================
+--- spl-linux-0.7.12.orig/include/sys/vmsystm.h
++++ spl-linux-0.7.12/include/sys/vmsystm.h
+@@ -39,6 +39,12 @@
+ #define	zfs_totalram_pages	totalram_pages
+ #endif
+ 
++#ifdef HAVE_TOTALHIGH_PAGES
++#define	zfs_totalhigh_pages	totalhigh_pages()
++#else
++#define	zfs_totalhigh_pages	totalhigh_pages
++#endif
++
+ #define	membar_producer()		smp_wmb()
+ #define	physmem				zfs_totalram_pages
+ #define	freemem			(nr_free_pages() + \
+Index: spl-linux-0.7.12/config/spl-build.m4
+===================================================================
+--- spl-linux-0.7.12.orig/config/spl-build.m4
++++ spl-linux-0.7.12/config/spl-build.m4
+@@ -58,6 +58,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
+ 	SPL_AC_KERNEL_KTIME_GET_TS64
+ 	SPL_AC_KERNEL_TIMESPEC64_SUB
+ 	SPL_AC_KERNEL_TOTALRAM_PAGES_FUNC
++	SPL_AC_KERNEL_TOTALHIGH_PAGES
+ ])
+ 
+ AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
diff -pruN 0.7.12-1/debian/patches/0010-Linux-5.1-compat-Drop-ULLONG_MAX-and-LLONG_MAX-defin.patch 0.7.12-1ubuntu4/debian/patches/0010-Linux-5.1-compat-Drop-ULLONG_MAX-and-LLONG_MAX-defin.patch
--- 0.7.12-1/debian/patches/0010-Linux-5.1-compat-Drop-ULLONG_MAX-and-LLONG_MAX-defin.patch	1970-01-01 00:00:00.000000000 +0000
+++ 0.7.12-1ubuntu4/debian/patches/0010-Linux-5.1-compat-Drop-ULLONG_MAX-and-LLONG_MAX-defin.patch	2019-05-28 09:14:11.000000000 +0000
@@ -0,0 +1,50 @@
+From 75346937de39f059722eedd29468ac9b86bea67c Mon Sep 17 00:00:00 2001
+From: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
+Date: Wed, 8 May 2019 01:55:40 +0900
+Subject: [PATCH] Linux 5.1 compat: Drop ULLONG_MAX and LLONG_MAX definitions
+
+Linux kernel commit 54d50897d544c874562253e2a8f70dfcad22afe8
+"linux/kernel.h: split *_MAX and *_MIN macros into <linux/limits.h>"
+
+which first appeared in 5.1 has moved several macros from
+<linux/kernel.h> to <linux/limits.h>. This broke compilation due to
+header inclusion order against the local header include/spl/sys/types.h
+which also defines ULLONG_MAX and LLONG_MAX if undefined.
+
+It looks like local ULLONG_MAX and LLONG_MAX were never needed
+(or after spl integration ?) as <linux/kernel.h> has had the same
+definitions since an upstream commit
+111ebb6e6f7bd7de6d722c5848e95621f43700d9 in 2.6.18, so drop them.
+
+--
+linux/include/linux/limits.h:17: error: "LLONG_MAX" redefined [-Werror]
+ #define LLONG_MAX ((long long)(~0ULL >> 1))
+zfs/include/spl/sys/types.h:35: note: this is the location of the previous definition
+ #define LLONG_MAX  ((long long)(~0ULL>>1))
+
+Reviewed-by: Richard Laager <rlaager@wiktel.com>
+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
+(backported from upstream commit 75346937de39f059722eedd29468ac9b86bea67c)
+Signed-off-by: Colin Ian King <colin.king@canonical.com>
+Closes #8714
+
+Index: spl-linux-0.7.12/include/sys/types.h
+===================================================================
+--- spl-linux-0.7.12.orig/include/sys/types.h
++++ spl-linux-0.7.12/include/sys/types.h
+@@ -28,14 +28,6 @@
+ #include <linux/types.h>
+ #include <sys/sysmacros.h>
+ 
+-#ifndef ULLONG_MAX
+-#define	ULLONG_MAX			(~0ULL)
+-#endif
+-
+-#ifndef LLONG_MAX
+-#define	LLONG_MAX			((long long)(~0ULL>>1))
+-#endif
+-
+ typedef enum { B_FALSE = 0, B_TRUE = 1 }	boolean_t;
+ typedef unsigned long			intptr_t;
+ typedef unsigned long			ulong_t;
diff -pruN 0.7.12-1/debian/patches/0011-Linux-5.2-compat-rw_tryupgrade.patch 0.7.12-1ubuntu4/debian/patches/0011-Linux-5.2-compat-rw_tryupgrade.patch
--- 0.7.12-1/debian/patches/0011-Linux-5.2-compat-rw_tryupgrade.patch	1970-01-01 00:00:00.000000000 +0000
+++ 0.7.12-1ubuntu4/debian/patches/0011-Linux-5.2-compat-rw_tryupgrade.patch	2019-05-28 09:14:11.000000000 +0000
@@ -0,0 +1,98 @@
+From bff2361aeb32a83c26e2992733864ca99cced257 Mon Sep 17 00:00:00 2001
+From: Brian Behlendorf <behlendorf1@llnl.gov>
+Date: Thu, 23 May 2019 13:46:33 -0700
+Subject: [PATCH] Linux 5.2 compat: rw_tryupgrade()
+
+Commit torvalds/linux@46ad0840b has removed the architecture specific
+rwsem source and headers leaving only the generic version.  As part
+of this change the RWSEM_ACTIVE_READ_BIAS and RWSEM_ACTIVE_WRITE_BIAS
+macros were moved to the private kernel/locking/rwsem.h header.
+This results in a build failure because these macros were required
+to implement the rw_tryupgrade() compatibility function.
+
+In practice, this isn't a major problem because there are only a
+few consumers of rw_tryupgrade() and because consumers of rw_tryupgrade
+should be written to retry using rw_enter(RW_WRITER).
+
+After auditing all of the callers only dmu_zfetch() was determined
+not to perform a retry.  It has been updated in this commit to
+resolve this issue.
+
+That said, the rw_tryupgrade() functionality should be considered
+for possible removal in a future release due to the difficultly
+in supporting the interface.
+
+Reviewed-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
+Reviewed-by: Chunwei Chen <tuxoko@gmail.com>
+Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
+(backported from upstream commit bff2361aeb32a83c26e2992733864ca99cced257)
+Signed-off-by: Colin Ian King <colin.king@canonical.com>
+Closes #8730
+
+Index: spl-linux-0.7.12/include/linux/rwsem_compat.h
+===================================================================
+--- spl-linux-0.7.12.orig/include/linux/rwsem_compat.h
++++ spl-linux-0.7.12/include/linux/rwsem_compat.h
+@@ -33,7 +33,7 @@
+ #elif defined(CONFIG_RWSEM_GENERIC_SPINLOCK)
+ #define	SPL_RWSEM_SINGLE_READER_VALUE	(1)
+ #define	SPL_RWSEM_SINGLE_WRITER_VALUE	(-1)
+-#else
++#elif defined(RWSEM_ACTIVE_MASK)
+ #define	SPL_RWSEM_SINGLE_READER_VALUE	(RWSEM_ACTIVE_READ_BIAS)
+ #define	SPL_RWSEM_SINGLE_WRITER_VALUE	(RWSEM_ACTIVE_WRITE_BIAS)
+ #endif
+Index: spl-linux-0.7.12/module/spl/spl-rwlock.c
+===================================================================
+--- spl-linux-0.7.12.orig/module/spl/spl-rwlock.c
++++ spl-linux-0.7.12/module/spl/spl-rwlock.c
+@@ -84,7 +84,8 @@ __rwsem_tryupgrade(struct rw_semaphore *
+ 	spl_rwsem_unlock_irqrestore(&rwsem->wait_lock, flags);
+ 	return (ret);
+ }
+-#elif defined(HAVE_RWSEM_ATOMIC_LONG_COUNT)
++#elif defined(RWSEM_ACTIVE_MASK)
++#if defined(HAVE_RWSEM_ATOMIC_LONG_COUNT)
+ static int
+ __rwsem_tryupgrade(struct rw_semaphore *rwsem)
+ {
+@@ -103,6 +104,13 @@ __rwsem_tryupgrade(struct rw_semaphore *
+ 	return (val == SPL_RWSEM_SINGLE_READER_VALUE);
+ }
+ #endif
++#else
++static int
++__rwsem_tryupgrade(struct rw_semaphore *rwsem)
++{
++	return (0);
++}
++#endif
+ 
+ int
+ rwsem_tryupgrade(struct rw_semaphore *rwsem)
+Index: spl-linux-0.7.12/module/splat/splat-rwlock.c
+===================================================================
+--- spl-linux-0.7.12.orig/module/splat/splat-rwlock.c
++++ spl-linux-0.7.12/module/splat/splat-rwlock.c
+@@ -595,6 +595,7 @@ out:
+ 	return rc;
+ }
+ 
++#if defined(RWSEM_ACTIVE_MASK)
+ static int
+ splat_rwlock_test6(struct file *file, void *arg)
+ {
+@@ -641,6 +642,13 @@ out:
+ 
+ 	return rc;
+ }
++#else
++static int
++splat_rwlock_test6(struct file *file, void *arg)
++{
++	return 0;
++}
++#endif
+ 
+ static int
+ splat_rwlock_test7(struct file *file, void *arg)
diff -pruN 0.7.12-1/debian/patches/0012-Linux-5.2-compat-Remove-config-kernel-set-fs-pwd.m4.patch 0.7.12-1ubuntu4/debian/patches/0012-Linux-5.2-compat-Remove-config-kernel-set-fs-pwd.m4.patch
--- 0.7.12-1/debian/patches/0012-Linux-5.2-compat-Remove-config-kernel-set-fs-pwd.m4.patch	1970-01-01 00:00:00.000000000 +0000
+++ 0.7.12-1ubuntu4/debian/patches/0012-Linux-5.2-compat-Remove-config-kernel-set-fs-pwd.m4.patch	2019-05-28 09:14:11.000000000 +0000
@@ -0,0 +1,94 @@
+From 4bb17ebfe20754078d15e14a3231e25be1d5ca9f Mon Sep 17 00:00:00 2001
+From: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
+Date: Sun, 26 May 2019 05:28:56 +0900
+Subject: [PATCH] Linux 5.2 compat: Remove config/kernel-set-fs-pwd.m4
+
+This failed on 5.2-rc1 with "error: unknown" message, for set_fs_pwd()
+not being visible in both const and non-const tests.
+
+This is caused by torvalds/linux@83da1bed86. It's configurable,
+but we would want to be able to compile with default kbuild setting.
+
+set_fs_pwd() has never been exported with exception of some distro
+kernels, and set_fs_pwd() wasn't used in ZoL to begin with. The test
+result was used for a spl function vn_set_fs_pwd().
+
+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Reviewed-by: loli10K <ezomori.nozomu@gmail.com>
+Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@osnexus.com>
+(backported from upstream commit 4bb17ebfe20754078d15e14a3231e25be1d5ca9f)
+Signed-off-by: Colin Ian King <colin.king@canonical.com>
+Closes #8777
+
+Index: spl-linux-0.7.12/config/kernel-set-fs-pwd.m4
+===================================================================
+--- spl-linux-0.7.12.orig/config/kernel-set-fs-pwd.m4
++++ /dev/null
+@@ -1,39 +0,0 @@
+-dnl #
+-dnl # 3.9 API change
+-dnl # set_fs_pwd takes const struct path *
+-dnl #
+-AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
+-	tmp_flags="$EXTRA_KCFLAGS"
+-	EXTRA_KCFLAGS="-Werror"
+-	[AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
+-	SPL_LINUX_TRY_COMPILE([
+-		#include <linux/spinlock.h>
+-		#include <linux/fs_struct.h>
+-		#include <linux/path.h>
+-		void (*const set_fs_pwd_func)
+-			(struct fs_struct *, const struct path *)
+-			= set_fs_pwd;
+-	],[
+-		return 0;
+-	],[
+-		AC_MSG_RESULT(yes)
+-		AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
+-			[set_fs_pwd() needs const path *])
+-	],[
+-		SPL_LINUX_TRY_COMPILE([
+-			#include <linux/spinlock.h>
+-			#include <linux/fs_struct.h>
+-			#include <linux/path.h>
+-			void (*const set_fs_pwd_func)
+-				(struct fs_struct *, struct path *)
+-				= set_fs_pwd;
+-		],[
+-			return 0;
+-		],[
+-			AC_MSG_RESULT(no)
+-		],[
+-			AC_MSG_ERROR(unknown)
+-		])
+-	])
+-	EXTRA_KCFLAGS="$tmp_flags"
+-])
+Index: spl-linux-0.7.12/module/spl/spl-vnode.c
+===================================================================
+--- spl-linux-0.7.12.orig/module/spl/spl-vnode.c
++++ spl-linux-0.7.12/module/spl/spl-vnode.c
+@@ -569,11 +569,7 @@ EXPORT_SYMBOL(areleasef);
+ 
+ 
+ static void
+-#ifdef HAVE_SET_FS_PWD_WITH_CONST
+-vn_set_fs_pwd(struct fs_struct *fs, const struct path *path)
+-#else
+ vn_set_fs_pwd(struct fs_struct *fs, struct path *path)
+-#endif /* HAVE_SET_FS_PWD_WITH_CONST */
+ {
+ 	struct path old_pwd;
+ 
+Index: spl-linux-0.7.12/config/spl-build.m4
+===================================================================
+--- spl-linux-0.7.12.orig/config/spl-build.m4
++++ spl-linux-0.7.12/config/spl-build.m4
+@@ -23,7 +23,6 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
+ 	SPL_AC_CTL_NAME
+ 	SPL_AC_CONFIG_TRIM_UNUSED_KSYMS
+ 	SPL_AC_PDE_DATA
+-	SPL_AC_SET_FS_PWD_WITH_CONST
+ 	SPL_AC_2ARGS_VFS_FSYNC
+ 	SPL_AC_INODE_TRUNCATE_RANGE
+ 	SPL_AC_FS_STRUCT_SPINLOCK
diff -pruN 0.7.12-1/debian/patches/series 0.7.12-1ubuntu4/debian/patches/series
--- 0.7.12-1/debian/patches/series	1970-01-01 00:00:00.000000000 +0000
+++ 0.7.12-1ubuntu4/debian/patches/series	2019-05-28 09:14:11.000000000 +0000
@@ -0,0 +1,12 @@
+0001-Add-check-for-ktime_get_coarse_real_ts64-for-V5.0-ke.patch
+0002-Linux-5.0-compat-Use-totalram_pages.patch
+0003-Add-check-for-ktime_get_ts64-for-V5.0-ke.patch
+0004-Add-check-for-timespec64-sub.patch
+0005-Use-64-bit-timespec-fixes.patch
+0006-Linux-5.0-compat-Fix-SUBDIRs.patch
+0007-Linux-4.20-compat-Fix-VERIFY-RW_READ_HELD-hash-mh_co.patch
+0008-Linux-5.1-compat-get_ds-removed.patch
+0009-Linux-5.0-compat-Use-totalhigh_pages.patch
+0010-Linux-5.1-compat-Drop-ULLONG_MAX-and-LLONG_MAX-defin.patch
+0011-Linux-5.2-compat-rw_tryupgrade.patch
+0012-Linux-5.2-compat-Remove-config-kernel-set-fs-pwd.m4.patch
diff -pruN 0.7.12-1/debian/rules 0.7.12-1ubuntu4/debian/rules
--- 0.7.12-1/debian/rules	2018-11-19 11:25:53.000000000 +0000
+++ 0.7.12-1ubuntu4/debian/rules	2019-05-28 09:14:11.000000000 +0000
@@ -74,7 +74,7 @@ override_dh_prep-deb-files:
 
 override_dh_configure_modules: override_dh_configure_modules_stamp
 override_dh_configure_modules_stamp:
-	./configure --with-config=kernel --with-linux=$(KSRC) \
+	KBUILD_MODPOST_WARN=1 ./configure --with-config=kernel --with-linux=$(KSRC) \
 		--with-linux-obj=$(KOBJ) \
 		--disable-debug-kmem
 	touch override_dh_configure_modules_stamp
diff -pruN 0.7.12-1/debian/tests/control 0.7.12-1ubuntu4/debian/tests/control
--- 0.7.12-1/debian/tests/control	2018-11-19 11:25:53.000000000 +0000
+++ 0.7.12-1ubuntu4/debian/tests/control	2019-01-28 18:37:41.000000000 +0000
@@ -1,3 +1,3 @@
-Tests: dkms-test check.sh
+Tests: check.sh
 Restrictions: needs-root, allow-stderr, isolation-machine
-Depends: dkms
+Depends: dkms, @
