about summary refs log tree commit diff
path: root/pkgs/os-specific/linux/zfs
diff options
context:
space:
mode:
authorAndrew Marshall <andrew@johnandrewmarshall.com>2023-11-26 13:15:39 -0500
committerAndrew Marshall <andrew@johnandrewmarshall.com>2023-11-26 13:29:41 -0500
commit9670ddc54389828b70447860821ed6521124bdd1 (patch)
tree4f74e128da179964e678e63697550664d4d81108 /pkgs/os-specific/linux/zfs
parent5689f242a1532ee4281e64fa98170db18ce6d234 (diff)
zfs: default disable zfs_dmu_offset_next_sync to avoid data corruption
This helps mitigate a data corruption bug. This was previously defaulted
to zero prior to upstream commit
05b3eb6d232009db247882a39d518e7282630753, and it is already a tunable,
so doing this seems safe. Initially data corruption was thought to be
introduced with v2.2, but further upstream investigation currently
believes that changes in v2.2 only exacerbated the issue that already
existed.

A longer-term fix is likely to be
https://github.com/openzfs/zfs/pull/15571, though that is not yet
merged. The zfs_2_1 package has already backported that, so do not apply
the tunable default change there.

Positioning of `extraPatches` is to avoid merge conflicts with
https://github.com/NixOS/nixpkgs/pull/269097.

Patch is nearly identical to the [Gentoo][1] patch, but better patch
formatting.

See https://github.com/openzfs/zfs/issues/11900
See https://github.com/openzfs/zfs/issues/15526

[1]: https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-fs/zfs-kmod/files/zfs-kmod-2.2.1-Disable-zfs_dmu_offset_next_sync-tunable-by-default.patch
Diffstat (limited to 'pkgs/os-specific/linux/zfs')
-rw-r--r--pkgs/os-specific/linux/zfs/patches/disable-zfs-dmu-offset-next-sync-by-default-v2-2.patch44
-rw-r--r--pkgs/os-specific/linux/zfs/stable.nix4
-rw-r--r--pkgs/os-specific/linux/zfs/unstable.nix4
3 files changed, 52 insertions, 0 deletions
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 0000000000000..197aa6f223b74
--- /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 <andrew@johnandrewmarshall.com>
+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 ab71d2ecb8e16..1770f6e9f1972 100644
--- a/pkgs/os-specific/linux/zfs/stable.nix
+++ b/pkgs/os-specific/linux/zfs/stable.nix
@@ -28,6 +28,10 @@ callPackage ./generic.nix args {
   # this package should point to the latest release.
   version = "2.2.0";
 
+  extraPatches = [
+    ./patches/disable-zfs-dmu-offset-next-sync-by-default-v2-2.patch
+  ];
+
   tests = [
     nixosTests.zfs.installer
     nixosTests.zfs.stable
diff --git a/pkgs/os-specific/linux/zfs/unstable.nix b/pkgs/os-specific/linux/zfs/unstable.nix
index cce2d69efa3bb..b76a90dac48e9 100644
--- a/pkgs/os-specific/linux/zfs/unstable.nix
+++ b/pkgs/os-specific/linux/zfs/unstable.nix
@@ -36,4 +36,8 @@ callPackage ./generic.nix args {
   tests = [
     nixosTests.zfs.unstable
   ];
+
+  extraPatches = [
+    ./patches/disable-zfs-dmu-offset-next-sync-by-default-v2-2.patch
+  ];
 }