git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #94377 from rtreffer/make-zfs-linux-58-compatible

zfs: backport linux 5.8 compatibility patch to 0.8.4 release

commitdebea4b65bf69ac7d463eb6783d5b93186c084ad authorMaximilian Bosch <maximilian@mbosch.me> dateSat 1 Aug 2020, 23:16 (6 years ago) parent1e55e220856652
2 files changed+155−1
pkgs/os-specific/linux/zfs/BACKPORT-Linux-5.8-compat-__vmalloc.patch+154 pkgs/os-specific/linux/zfs/default.nix+1−1
pkgs/os-specific/linux/zfs/BACKPORT-Linux-5.8-compat-__vmalloc.patchnew file+154
@@ -0,0 +1,154 @@
1+From 6cc95288ccea12ad7b67b2b5b3997dfad8e5b5c9 Mon Sep 17 00:00:00 2001
2+From: =?UTF-8?q?Michael=20Niew=C3=B6hner?=
3+ <c0d3z3r0@users.noreply.github.com>
4+Date: Tue, 9 Jun 2020 01:32:02 +0200
5+Subject: [PATCH] BACKPORT: Linux 5.8 compat: __vmalloc()
6+MIME-Version: 1.0
7+Content-Type: text/plain; charset=UTF-8
8+Content-Transfer-Encoding: 8bit
9+
10+The `pgprot` argument has been removed from `__vmalloc` in Linux 5.8,
11+being `PAGE_KERNEL` always now [1].
12+
13+Detect this during configure and define a wrapper for older kernels.
14+
15+[1] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/mm/vmalloc.c?h=next-20200605&id=88dca4ca5a93d2c09e5bbc6a62fbfc3af83c4fca
16+
17+Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
18+Co-authored-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
19+Co-authored-by: Michael Niewöhner <foss@mniewoehner.de>
20+Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
21+Signed-off-by: Michael Niewöhner <foss@mniewoehner.de>
22+Closes #10422
23+---
24+ config/kernel-kmem.m4 | 26 ++++++++++++++++++++++++++
25+ config/kernel.m4 | 2 ++
26+ include/spl/sys/kmem.h | 9 +++++++++
27+ module/spl/spl-kmem-cache.c | 4 ++--
28+ module/spl/spl-kmem.c | 9 ++++-----
29+ 5 files changed, 43 insertions(+), 7 deletions(-)
30+
31+diff --git a/config/kernel-kmem.m4 b/config/kernel-kmem.m4
32+index cc055e530..f1c0d2412 100644
33+--- a/config/kernel-kmem.m4
34++++ b/config/kernel-kmem.m4
35+@@ -56,3 +56,29 @@ AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
36+ AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
37+ AC_MSG_RESULT([$enable_debug_kmem_tracking])
38+ ])
39++
40++dnl #
41++dnl # 5.8 API,
42++dnl # __vmalloc PAGE_KERNEL removal
43++dnl #
44++AC_DEFUN([ZFS_AC_KERNEL_SRC_VMALLOC_PAGE_KERNEL], [
45++ ZFS_LINUX_TEST_SRC([__vmalloc], [
46++ #include <linux/mm.h>
47++ #include <linux/vmalloc.h>
48++ ],[
49++ void *p __attribute__ ((unused));
50++
51++ p = __vmalloc(0, GFP_KERNEL, PAGE_KERNEL);
52++ ])
53++])
54++
55++AC_DEFUN([ZFS_AC_KERNEL_VMALLOC_PAGE_KERNEL], [
56++ AC_MSG_CHECKING([whether __vmalloc(ptr, flags, pageflags) is available])
57++ ZFS_LINUX_TEST_RESULT([__vmalloc], [
58++ AC_MSG_RESULT(yes)
59++ AC_DEFINE(HAVE_VMALLOC_PAGE_KERNEL, 1, [__vmalloc page flags exists])
60++ ],[
61++ AC_MSG_RESULT(no)
62++ ])
63++])
64++-
65+diff --git a/config/kernel.m4 b/config/kernel.m4
66+index b67fcef8c..23edfdcd8 100644
67+--- a/config/kernel.m4
68++++ b/config/kernel.m4
69+@@ -45,6 +45,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
70+ ZFS_AC_KERNEL_SRC_SCHED
71+ ZFS_AC_KERNEL_SRC_USLEEP_RANGE
72+ ZFS_AC_KERNEL_SRC_KMEM_CACHE
73++ ZFS_AC_KERNEL_SRC_VMALLOC_PAGE_KERNEL
74+ ZFS_AC_KERNEL_SRC_WAIT
75+ ZFS_AC_KERNEL_SRC_INODE_TIMES
76+ ZFS_AC_KERNEL_SRC_INODE_LOCK
77+@@ -163,6 +164,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
78+ ZFS_AC_KERNEL_SCHED
79+ ZFS_AC_KERNEL_USLEEP_RANGE
80+ ZFS_AC_KERNEL_KMEM_CACHE
81++ ZFS_AC_KERNEL_VMALLOC_PAGE_KERNEL
82+ ZFS_AC_KERNEL_WAIT
83+ ZFS_AC_KERNEL_INODE_TIMES
84+ ZFS_AC_KERNEL_INODE_LOCK
85+diff --git a/include/spl/sys/kmem.h b/include/spl/sys/kmem.h
86+index 72d3a7765..ca15bfe7f 100644
87+--- a/include/spl/sys/kmem.h
88++++ b/include/spl/sys/kmem.h
89+@@ -169,6 +169,15 @@ extern void *spl_kmem_alloc(size_t sz, int fl, const char *func, int line);
90+ extern void *spl_kmem_zalloc(size_t sz, int fl, const char *func, int line);
91+ extern void spl_kmem_free(const void *ptr, size_t sz);
92+
93++/*
94++ * 5.8 API change, pgprot_t argument removed.
95++ */
96++#ifdef HAVE_VMALLOC_PAGE_KERNEL
97++#define spl_vmalloc(size, flags) __vmalloc(size, flags, PAGE_KERNEL)
98++#else
99++#define spl_vmalloc(size, flags) __vmalloc(size, flags)
100++#endif
101++
102+ /*
103+ * The following functions are only available for internal use.
104+ */
105+diff --git a/module/spl/spl-kmem-cache.c b/module/spl/spl-kmem-cache.c
106+index d71b4b348..4866b2993 100644
107+--- a/module/spl/spl-kmem-cache.c
108++++ b/module/spl/spl-kmem-cache.c
109+@@ -203,7 +203,7 @@ kv_alloc(spl_kmem_cache_t *skc, int size, int flags)
110+ ASSERT(ISP2(size));
111+ ptr = (void *)__get_free_pages(lflags, get_order(size));
112+ } else {
113+- ptr = __vmalloc(size, lflags | __GFP_HIGHMEM, PAGE_KERNEL);
114++ ptr = spl_vmalloc(size, lflags | __GFP_HIGHMEM);
115+ }
116+
117+ /* Resulting allocated memory will be page aligned */
118+@@ -1242,7 +1242,7 @@ spl_cache_grow(spl_kmem_cache_t *skc, int flags, void **obj)
119+ * allocation.
120+ *
121+ * However, this can't be applied to KVM_VMEM due to a bug that
122+- * __vmalloc() doesn't honor gfp flags in page table allocation.
123++ * spl_vmalloc() doesn't honor gfp flags in page table allocation.
124+ */
125+ if (!(skc->skc_flags & KMC_VMEM)) {
126+ rc = __spl_cache_grow(skc, flags | KM_NOSLEEP);
127+diff --git a/module/spl/spl-kmem.c b/module/spl/spl-kmem.c
128+index cee69ad43..ca1fc145f 100644
129+--- a/module/spl/spl-kmem.c
130++++ b/module/spl/spl-kmem.c
131+@@ -172,16 +172,15 @@ spl_kmem_alloc_impl(size_t size, int flags, int node)
132+ * kmem_zalloc() callers.
133+ *
134+ * For vmem_alloc() and vmem_zalloc() callers it is permissible
135+- * to use __vmalloc(). However, in general use of __vmalloc()
136+- * is strongly discouraged because a global lock must be
137+- * acquired. Contention on this lock can significantly
138++ * to use spl_vmalloc(). However, in general use of
139++ * spl_vmalloc() is strongly discouraged because a global lock
140++ * must be acquired. Contention on this lock can significantly
141+ * impact performance so frequently manipulating the virtual
142+ * address space is strongly discouraged.
143+ */
144+ if ((size > spl_kmem_alloc_max) || use_vmem) {
145+ if (flags & KM_VMEM) {
146+- ptr = __vmalloc(size, lflags | __GFP_HIGHMEM,
147+- PAGE_KERNEL);
148++ ptr = spl_vmalloc(size, lflags | __GFP_HIGHMEM);
149+ } else {
150+ return (NULL);
151+ }
152+--
153+2.25.1
154+
pkgs/os-specific/linux/zfs/default.nix+1−1
@@ -42,7 +42,7 @@ let
4242 inherit rev sha256;
4343 };
4444
45− patches = [ ] ++ extraPatches;
45+ patches = [ ./BACKPORT-Linux-5.8-compat-__vmalloc.patch ] ++ extraPatches;
4646
4747 postPatch = optionalString buildKernel ''
4848 patchShebangs scripts