diff --git a/pkgs/os-specific/linux/zfs/patches/disable-zfs-dmu-offset-next-sync-by-default-v2-2.patch b/pkgs/os-specific/linux/zfs/patches/disable-zfs-dmu-offset-next-sync-by-default-v2-2.patch new file mode 100644 index 000000000000000..197aa6f223b74b3 --- /dev/null +++ b/pkgs/os-specific/linux/zfs/patches/disable-zfs-dmu-offset-next-sync-by-default-v2-2.patch @@ -0,0 +1,44 @@ +From 3ba4ff328ab001d88d7714087d8a89687bc68312 Mon Sep 17 00:00:00 2001 +From: Andrew Marshall +Date: Sun, 26 Nov 2023 12:46:18 -0500 +Subject: [PATCH] Disable zfs_dmu_offset_next_sync tunable by default + +This helps mitigate a data corruption bug. This was previously defaulted +to zero, so doing so seems safe. + +See https://github.com/openzfs/zfs/issues/11900 +See https://github.com/openzfs/zfs/issues/15526 +--- + man/man4/zfs.4 | 2 +- + module/zfs/dmu.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/man/man4/zfs.4 b/man/man4/zfs.4 +index 4ec52a2fb..2a69a8f54 100644 +--- a/man/man4/zfs.4 ++++ b/man/man4/zfs.4 +@@ -1660,7 +1660,7 @@ Allow no-operation writes. + The occurrence of nopwrites will further depend on other pool properties + .Pq i.a. the checksumming and compression algorithms . + . +-.It Sy zfs_dmu_offset_next_sync Ns = Ns Sy 1 Ns | Ns 0 Pq int ++.It Sy zfs_dmu_offset_next_sync Ns = Ns Sy 0 Ns | Ns 1 Pq int + Enable forcing TXG sync to find holes. + When enabled forces ZFS to sync data when + .Sy SEEK_HOLE No or Sy SEEK_DATA +diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c +index ddb29020b..5d37b6f92 100644 +--- a/module/zfs/dmu.c ++++ b/module/zfs/dmu.c +@@ -82,7 +82,7 @@ static uint_t zfs_per_txg_dirty_frees_percent = 30; + * Disabling this option will result in holes never being reported in dirty + * files which is always safe. + */ +-static int zfs_dmu_offset_next_sync = 1; ++static int zfs_dmu_offset_next_sync = 0; + + /* + * Limit the amount we can prefetch with one call to this amount. This +-- +2.42.0 + diff --git a/pkgs/os-specific/linux/zfs/stable.nix b/pkgs/os-specific/linux/zfs/stable.nix index 76a2787c4c77aec..95007db4986eb4a 100644 --- a/pkgs/os-specific/linux/zfs/stable.nix +++ b/pkgs/os-specific/linux/zfs/stable.nix @@ -3,7 +3,7 @@ , stdenv , linuxKernel , removeLinuxDRM ? false -, fetchpatch +, nixosTests , ... } @ args: @@ -24,5 +24,14 @@ callPackage ./generic.nix args { # this package should point to the latest release. version = "2.2.1"; - sha256 = "sha256-2Q/Nhp3YKgMCLPNRNBq5r9U4GeuYlWMWAsjsQy3vFW4="; + extraPatches = [ + ./patches/disable-zfs-dmu-offset-next-sync-by-default-v2-2.patch + ]; + + tests = [ + nixosTests.zfs.installer + nixosTests.zfs.stable + ]; + + hash = "sha256-2Q/Nhp3YKgMCLPNRNBq5r9U4GeuYlWMWAsjsQy3vFW4="; } diff --git a/pkgs/os-specific/linux/zfs/unstable.nix b/pkgs/os-specific/linux/zfs/unstable.nix index 18d1ae7f9d17fe1..bc8e9924d054662 100644 --- a/pkgs/os-specific/linux/zfs/unstable.nix +++ b/pkgs/os-specific/linux/zfs/unstable.nix @@ -3,6 +3,7 @@ , stdenv , linuxKernel , removeLinuxDRM ? false +, nixosTests , ... } @ args: @@ -25,7 +26,14 @@ callPackage ./generic.nix args { # maintainers. version = "2.2.1"; - sha256 = "sha256-2Q/Nhp3YKgMCLPNRNBq5r9U4GeuYlWMWAsjsQy3vFW4="; + hash = "sha256-2Q/Nhp3YKgMCLPNRNBq5r9U4GeuYlWMWAsjsQy3vFW4="; isUnstable = true; + tests = [ + nixosTests.zfs.unstable + ]; + + extraPatches = [ + ./patches/disable-zfs-dmu-offset-next-sync-by-default-v2-2.patch + ]; }