summary refs log tree commit diff
path: root/pkgs/os-specific/linux/zfs
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/os-specific/linux/zfs')
-rw-r--r--pkgs/os-specific/linux/zfs/BACKPORT-Linux-5.8-compat-__vmalloc.patch154
-rw-r--r--pkgs/os-specific/linux/zfs/default.nix114
2 files changed, 63 insertions, 205 deletions
diff --git a/pkgs/os-specific/linux/zfs/BACKPORT-Linux-5.8-compat-__vmalloc.patch b/pkgs/os-specific/linux/zfs/BACKPORT-Linux-5.8-compat-__vmalloc.patch
deleted file mode 100644
index 780ce83d84f..00000000000
--- a/pkgs/os-specific/linux/zfs/BACKPORT-Linux-5.8-compat-__vmalloc.patch
+++ /dev/null
@@ -1,154 +0,0 @@
-From 6cc95288ccea12ad7b67b2b5b3997dfad8e5b5c9 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Michael=20Niew=C3=B6hner?=
- <c0d3z3r0@users.noreply.github.com>
-Date: Tue, 9 Jun 2020 01:32:02 +0200
-Subject: [PATCH] BACKPORT: Linux 5.8 compat: __vmalloc()
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-The `pgprot` argument has been removed from `__vmalloc` in Linux 5.8,
-being `PAGE_KERNEL` always now [1].
-
-Detect this during configure and define a wrapper for older kernels.
-
-[1] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/mm/vmalloc.c?h=next-20200605&id=88dca4ca5a93d2c09e5bbc6a62fbfc3af83c4fca
-
-Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
-Co-authored-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
-Co-authored-by: Michael Niewöhner <foss@mniewoehner.de>
-Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
-Signed-off-by: Michael Niewöhner <foss@mniewoehner.de>
-Closes #10422
----
- config/kernel-kmem.m4       | 26 ++++++++++++++++++++++++++
- config/kernel.m4            |  2 ++
- include/spl/sys/kmem.h      |  9 +++++++++
- module/spl/spl-kmem-cache.c |  4 ++--
- module/spl/spl-kmem.c       |  9 ++++-----
- 5 files changed, 43 insertions(+), 7 deletions(-)
-
-diff --git a/config/kernel-kmem.m4 b/config/kernel-kmem.m4
-index cc055e530..f1c0d2412 100644
---- a/config/kernel-kmem.m4
-+++ b/config/kernel-kmem.m4
-@@ -56,3 +56,29 @@ AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
- 	AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
- 	AC_MSG_RESULT([$enable_debug_kmem_tracking])
- ])
-+
-+dnl #
-+dnl # 5.8 API,
-+dnl # __vmalloc PAGE_KERNEL removal
-+dnl #
-+AC_DEFUN([ZFS_AC_KERNEL_SRC_VMALLOC_PAGE_KERNEL], [
-+	ZFS_LINUX_TEST_SRC([__vmalloc], [
-+		#include <linux/mm.h>
-+		#include <linux/vmalloc.h>
-+	],[
-+		void *p __attribute__ ((unused));
-+
-+		p = __vmalloc(0, GFP_KERNEL, PAGE_KERNEL);
-+	])
-+])
-+
-+AC_DEFUN([ZFS_AC_KERNEL_VMALLOC_PAGE_KERNEL], [
-+	AC_MSG_CHECKING([whether __vmalloc(ptr, flags, pageflags) is available])
-+	ZFS_LINUX_TEST_RESULT([__vmalloc], [
-+		AC_MSG_RESULT(yes)
-+		AC_DEFINE(HAVE_VMALLOC_PAGE_KERNEL, 1, [__vmalloc page flags exists])
-+	],[
-+		AC_MSG_RESULT(no)
-+	])
-+])
-+-
-diff --git a/config/kernel.m4 b/config/kernel.m4
-index b67fcef8c..23edfdcd8 100644
---- a/config/kernel.m4
-+++ b/config/kernel.m4
-@@ -45,6 +45,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
- 	ZFS_AC_KERNEL_SRC_SCHED
- 	ZFS_AC_KERNEL_SRC_USLEEP_RANGE
- 	ZFS_AC_KERNEL_SRC_KMEM_CACHE
-+	ZFS_AC_KERNEL_SRC_VMALLOC_PAGE_KERNEL
- 	ZFS_AC_KERNEL_SRC_WAIT
- 	ZFS_AC_KERNEL_SRC_INODE_TIMES
- 	ZFS_AC_KERNEL_SRC_INODE_LOCK
-@@ -163,6 +164,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
- 	ZFS_AC_KERNEL_SCHED
- 	ZFS_AC_KERNEL_USLEEP_RANGE
- 	ZFS_AC_KERNEL_KMEM_CACHE
-+	ZFS_AC_KERNEL_VMALLOC_PAGE_KERNEL
- 	ZFS_AC_KERNEL_WAIT
- 	ZFS_AC_KERNEL_INODE_TIMES
- 	ZFS_AC_KERNEL_INODE_LOCK
-diff --git a/include/spl/sys/kmem.h b/include/spl/sys/kmem.h
-index 72d3a7765..ca15bfe7f 100644
---- a/include/spl/sys/kmem.h
-+++ b/include/spl/sys/kmem.h
-@@ -169,6 +169,15 @@ extern void *spl_kmem_alloc(size_t sz, int fl, const char *func, int line);
- extern void *spl_kmem_zalloc(size_t sz, int fl, const char *func, int line);
- extern void spl_kmem_free(const void *ptr, size_t sz);
- 
-+/*
-+ * 5.8 API change, pgprot_t argument removed.
-+ */
-+#ifdef HAVE_VMALLOC_PAGE_KERNEL
-+#define	spl_vmalloc(size, flags)	__vmalloc(size, flags, PAGE_KERNEL)
-+#else
-+#define	spl_vmalloc(size, flags)	__vmalloc(size, flags)
-+#endif
-+
- /*
-  * The following functions are only available for internal use.
-  */
-diff --git a/module/spl/spl-kmem-cache.c b/module/spl/spl-kmem-cache.c
-index d71b4b348..4866b2993 100644
---- a/module/spl/spl-kmem-cache.c
-+++ b/module/spl/spl-kmem-cache.c
-@@ -203,7 +203,7 @@ kv_alloc(spl_kmem_cache_t *skc, int size, int flags)
- 		ASSERT(ISP2(size));
- 		ptr = (void *)__get_free_pages(lflags, get_order(size));
- 	} else {
--		ptr = __vmalloc(size, lflags | __GFP_HIGHMEM, PAGE_KERNEL);
-+		ptr = spl_vmalloc(size, lflags | __GFP_HIGHMEM);
- 	}
- 
- 	/* Resulting allocated memory will be page aligned */
-@@ -1242,7 +1242,7 @@ spl_cache_grow(spl_kmem_cache_t *skc, int flags, void **obj)
- 	 * allocation.
- 	 *
- 	 * However, this can't be applied to KVM_VMEM due to a bug that
--	 * __vmalloc() doesn't honor gfp flags in page table allocation.
-+	 * spl_vmalloc() doesn't honor gfp flags in page table allocation.
- 	 */
- 	if (!(skc->skc_flags & KMC_VMEM)) {
- 		rc = __spl_cache_grow(skc, flags | KM_NOSLEEP);
-diff --git a/module/spl/spl-kmem.c b/module/spl/spl-kmem.c
-index cee69ad43..ca1fc145f 100644
---- a/module/spl/spl-kmem.c
-+++ b/module/spl/spl-kmem.c
-@@ -172,16 +172,15 @@ spl_kmem_alloc_impl(size_t size, int flags, int node)
- 		 * kmem_zalloc() callers.
- 		 *
- 		 * For vmem_alloc() and vmem_zalloc() callers it is permissible
--		 * to use __vmalloc().  However, in general use of __vmalloc()
--		 * is strongly discouraged because a global lock must be
--		 * acquired.  Contention on this lock can significantly
-+		 * to use spl_vmalloc().  However, in general use of
-+		 * spl_vmalloc() is strongly discouraged because a global lock
-+		 * must be acquired.  Contention on this lock can significantly
- 		 * impact performance so frequently manipulating the virtual
- 		 * address space is strongly discouraged.
- 		 */
- 		if ((size > spl_kmem_alloc_max) || use_vmem) {
- 			if (flags & KM_VMEM) {
--				ptr = __vmalloc(size, lflags | __GFP_HIGHMEM,
--				    PAGE_KERNEL);
-+				ptr = spl_vmalloc(size, lflags | __GFP_HIGHMEM);
- 			} else {
- 				return (NULL);
- 			}
--- 
-2.25.1
-
diff --git a/pkgs/os-specific/linux/zfs/default.nix b/pkgs/os-specific/linux/zfs/default.nix
index 56b36d4f368..7784aa8e03f 100644
--- a/pkgs/os-specific/linux/zfs/default.nix
+++ b/pkgs/os-specific/linux/zfs/default.nix
@@ -1,22 +1,25 @@
-{ stdenv, fetchFromGitHub, fetchpatch
-, autoreconfHook, utillinux, nukeReferences, coreutils
-, perl, buildPackages
+{ lib, stdenv, fetchFromGitHub
+, autoreconfHook269, util-linux, nukeReferences, coreutils
+, perl, nixosTests
 , configFile ? "all"
 
 # Userspace dependencies
 , zlib, libuuid, python3, attr, openssl
 , libtirpc
-, nfs-utils
+, nfs-utils, samba
 , gawk, gnugrep, gnused, systemd
-, smartmontools, sysstat, sudo
+, smartmontools, enableMail ? false
+, sysstat, pkg-config
 
 # Kernel dependencies
 , kernel ? null
 , enablePython ? true
 }:
 
-with stdenv.lib;
+with lib;
 let
+  smartmon = smartmontools.override { inherit enableMail; };
+
   buildKernel = any (n: n == configFile) [ "kernel" "all" ];
   buildUser = any (n: n == configFile) [ "user" "all" ];
 
@@ -25,15 +28,9 @@ let
     , extraPatches ? []
     , rev ? "zfs-${version}"
     , isUnstable ? false
-    , incompatibleKernelVersion ? null }:
-    if buildKernel &&
-      (incompatibleKernelVersion != null) &&
-        versionAtLeast kernel.version incompatibleKernelVersion then
-       throw ''
-         Linux v${kernel.version} is not yet supported by zfsonlinux v${version}.
-         ${stdenv.lib.optionalString (!isUnstable) "Try zfsUnstable or set the NixOS option boot.zfs.enableUnstable."}
-       ''
-    else stdenv.mkDerivation {
+    , kernelCompatible ? null }:
+
+    stdenv.mkDerivation {
       name = "zfs-${configFile}-${version}${optionalString buildKernel "-${kernel.version}"}";
 
       src = fetchFromGitHub {
@@ -42,27 +39,27 @@ let
         inherit rev sha256;
       };
 
-      patches = [ ./BACKPORT-Linux-5.8-compat-__vmalloc.patch ] ++ extraPatches;
+      patches = extraPatches;
 
       postPatch = optionalString buildKernel ''
         patchShebangs scripts
         # The arrays must remain the same length, so we repeat a flag that is
         # already part of the command and therefore has no effect.
-        substituteInPlace ./module/zfs/zfs_ctldir.c --replace '"/usr/bin/env", "umount"' '"${utillinux}/bin/umount", "-n"' \
-                                                    --replace '"/usr/bin/env", "mount"'  '"${utillinux}/bin/mount", "-n"'
+        substituteInPlace ./module/os/linux/zfs/zfs_ctldir.c \
+          --replace '"/usr/bin/env", "umount"' '"${util-linux}/bin/umount", "-n"' \
+          --replace '"/usr/bin/env", "mount"'  '"${util-linux}/bin/mount", "-n"'
       '' + optionalString buildUser ''
-        substituteInPlace ./lib/libzfs/libzfs_mount.c --replace "/bin/umount"             "${utillinux}/bin/umount" \
-                                                      --replace "/bin/mount"              "${utillinux}/bin/mount"
-        substituteInPlace ./lib/libshare/nfs.c        --replace "/usr/sbin/exportfs"      "${
+        substituteInPlace ./lib/libshare/os/linux/nfs.c --replace "/usr/sbin/exportfs" "${
           # We don't *need* python support, but we set it like this to minimize closure size:
           # If it's disabled by default, no need to enable it, even if we have python enabled
           # And if it's enabled by default, only change that if we explicitly disable python to remove python from the closure
           nfs-utils.override (old: { enablePython = old.enablePython or true && enablePython; })
         }/bin/exportfs"
+        substituteInPlace ./lib/libshare/smb.h        --replace "/usr/bin/net"            "${samba}/bin/net"
         substituteInPlace ./config/user-systemd.m4    --replace "/usr/lib/modules-load.d" "$out/etc/modules-load.d"
-        substituteInPlace ./config/zfs-build.m4       --replace "\$sysconfdir/init.d"     "$out/etc/init.d"
+        substituteInPlace ./config/zfs-build.m4       --replace "\$sysconfdir/init.d"     "$out/etc/init.d" \
+                                                      --replace "/etc/default"            "$out/etc/default"
         substituteInPlace ./etc/zfs/Makefile.am       --replace "\$(sysconfdir)"          "$out/etc"
-        substituteInPlace ./cmd/zed/Makefile.am       --replace "\$(sysconfdir)"          "$out/etc"
 
         substituteInPlace ./contrib/initramfs/hooks/Makefile.am \
           --replace "/usr/share/initramfs-tools/hooks" "$out/usr/share/initramfs-tools/hooks"
@@ -79,23 +76,22 @@ let
         substituteInPlace ./etc/systemd/system/Makefile.am \
           --replace '$(DESTDIR)$(systemdunitdir)' "$out"'$(DESTDIR)$(systemdunitdir)'
 
-        substituteInPlace ./etc/systemd/system/zfs-share.service.in \
-          --replace "/bin/rm " "${coreutils}/bin/rm "
+        substituteInPlace ./contrib/initramfs/conf.d/Makefile.am \
+          --replace "/usr/share/initramfs-tools/conf.d" "$out/usr/share/initramfs-tools/conf.d"
+        substituteInPlace ./contrib/initramfs/conf-hooks.d/Makefile.am \
+          --replace "/usr/share/initramfs-tools/conf-hooks.d" "$out/usr/share/initramfs-tools/conf-hooks.d"
 
         substituteInPlace ./cmd/vdev_id/vdev_id \
           --replace "PATH=/bin:/sbin:/usr/bin:/usr/sbin" \
           "PATH=${makeBinPath [ coreutils gawk gnused gnugrep systemd ]}"
-      '' + optionalString stdenv.hostPlatform.isMusl ''
-        substituteInPlace config/user-libtirpc.m4 \
-          --replace /usr/include/tirpc ${libtirpc}/include/tirpc
       '';
 
-      nativeBuildInputs = [ autoreconfHook nukeReferences ]
-        ++ optionals buildKernel (kernel.moduleBuildDependencies ++ [ perl ]);
-      buildInputs = optionals buildUser [ zlib libuuid attr ]
+      nativeBuildInputs = [ autoreconfHook269 nukeReferences ]
+        ++ optionals buildKernel (kernel.moduleBuildDependencies ++ [ perl ])
+        ++ optional buildUser pkg-config;
+      buildInputs = optionals buildUser [ zlib libuuid attr libtirpc ]
         ++ optional buildUser openssl
-        ++ optional (buildUser && enablePython) python3
-        ++ optional stdenv.hostPlatform.isMusl libtirpc;
+        ++ optional (buildUser && enablePython) python3;
 
       # for zdb to get the rpath to libgcc_s, needed for pthread_cancel to work
       NIX_CFLAGS_LINK = "-lgcc_s";
@@ -104,6 +100,7 @@ let
 
       configureFlags = [
         "--with-config=${configFile}"
+        "--with-tirpc=1"
         (withFeatureAs (buildUser && enablePython) "python" python3.interpreter)
       ] ++ optionals buildUser [
         "--with-dracutdir=$(out)/lib/dracut"
@@ -134,7 +131,7 @@ let
       postInstall = optionalString buildKernel ''
         # Add reference that cannot be detected due to compressed kernel module
         mkdir -p "$out/nix-support"
-        echo "${utillinux}" >> "$out/nix-support/extra-refs"
+        echo "${util-linux}" >> "$out/nix-support/extra-refs"
       '' + optionalString buildUser ''
         # Remove provided services as they are buggy
         rm $out/etc/systemd/system/zfs-import-*.service
@@ -145,9 +142,6 @@ let
         substituteInPlace $i --replace "zfs-import-cache.service" "zfs-import.target"
         done
 
-        # Fix pkgconfig.
-        ln -s ../share/pkgconfig $out/lib/pkgconfig
-
         # Remove tests because they add a runtime dependency on gcc
         rm -rf $out/share/zfs/zfs-tests
 
@@ -156,14 +150,27 @@ let
         (cd $out/share/bash-completion/completions; ln -s zfs zpool)
       '';
 
-      postFixup = ''
-        path="PATH=${makeBinPath [ coreutils gawk gnused gnugrep utillinux smartmontools sysstat sudo ]}"
+      postFixup = let
+        path = "PATH=${makeBinPath [ coreutils gawk gnused gnugrep util-linux smartmon sysstat ]}:$PATH";
+      in ''
         for i in $out/libexec/zfs/zpool.d/*; do
-          sed -i "2i$path" $i
+          sed -i '2i${path}' $i
         done
       '';
 
-      outputs = [ "out" ] ++ optionals buildUser [ "lib" "dev" ];
+      outputs = [ "out" ] ++ optionals buildUser [ "dev" ];
+
+      passthru = {
+        inherit enableMail;
+
+        tests =
+          if isUnstable then [
+            nixosTests.zfs.unstable
+          ] else [
+            nixosTests.zfs.installer
+            nixosTests.zfs.stable
+          ];
+      };
 
       meta = {
         description = "ZFS Filesystem Linux Kernel module";
@@ -172,10 +179,14 @@ let
           Copy-On-Write filesystem with data integrity detection and repair,
           snapshotting, cloning, block devices, deduplication, and more.
         '';
-        homepage = "https://zfsonlinux.org/";
+        homepage = "https://github.com/openzfs/zfs";
+        changelog = "https://github.com/openzfs/zfs/releases/tag/zfs-${version}";
         license = licenses.cddl;
         platforms = platforms.linux;
-        maintainers = with maintainers; [ jcumming wizeman fpletz globin ];
+        maintainers = with maintainers; [ hmenke jcumming jonringer wizeman fpletz globin mic92 ];
+        # If your Linux kernel version is not yet supported by zfs, try zfsUnstable.
+        # On NixOS set the option boot.zfs.enableUnstable.
+        broken = buildKernel && (kernelCompatible != null) && !kernelCompatible;
       };
     };
 in {
@@ -183,23 +194,24 @@ in {
   # ./nixos/modules/tasks/filesystems/zfs.nix needs
   # to be adapted
   zfsStable = common {
-    # comment/uncomment if breaking kernel versions are known
-    # incompatibleKernelVersion = "4.20";
+    # check the release notes for compatible kernels
+    kernelCompatible = kernel.kernelAtLeast "3.10" && kernel.kernelOlder "5.14";
 
     # this package should point to the latest release.
-    version = "0.8.4";
+    version = "2.1.0";
 
-    sha256 = "1hl4n900d24gl4vd65qdzq4m62b7bpvckldazcbd1xqcn8xhi6wp";
+    sha256 = "sha256-YdY4SStXZGBBdAHdM3R/unco7ztxI3s0/buPSNSeh5o=";
   };
 
   zfsUnstable = common {
-    # comment/uncomment if breaking kernel versions are known
-    # incompatibleKernelVersion = "4.19";
+    # check the release notes for compatible kernels
+    kernelCompatible = kernel.kernelAtLeast "3.10" && kernel.kernelOlder "5.14";
 
     # this package should point to a version / git revision compatible with the latest kernel release
-    version = "0.8.4";
+    version = "2.1.0";
+
+    sha256 = "sha256-YdY4SStXZGBBdAHdM3R/unco7ztxI3s0/buPSNSeh5o=";
 
-    sha256 = "1hl4n900d24gl4vd65qdzq4m62b7bpvckldazcbd1xqcn8xhi6wp";
     isUnstable = true;
   };
 }