From ed2aca91ec6c853715d539dda23ccb157cc5d0b2 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Mon, 26 Feb 2024 23:48:18 +0100 Subject: [PATCH] [type/__openzfs] Auto-mitigate data corruption bug Set zfs_dmu_offset_next_sync=0 on OpenZFS < 2.1.14 or < 2.2.2. --- type/__openzfs/manifest | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/type/__openzfs/manifest b/type/__openzfs/manifest index d25e89e..b354e06 100755 --- a/type/__openzfs/manifest +++ b/type/__openzfs/manifest @@ -1,6 +1,6 @@ #!/bin/sh -e # -# 2020,2023 Dennis Camera (dennis.camera at riiengineering.ch) +# 2020,2023,2024 Dennis Camera (dennis.camera at riiengineering.ch) # # This file is part of skonfig-extra. # @@ -166,6 +166,31 @@ then EOF fi +# HACK: Workaround 2023 data corruption issue +# https://github.com/openzfs/zfs/releases/tag/zfs-2.1.5 +# https://github.com/openzfs/zfs/releases/tag/zfs-2.2.2 +# https://github.com/openzfs/zfs/issues/15526 +# https://github.com/openzfs/zfs/pull/15571 +if test -n "${kmod_version}" +then + if { version_ge "${kmod_version}" 2.2.0 && ! version_ge "${kmod_version}" 2.2.2; } \ + || { version_ge "${kmod_version}" 2.1.5 && ! version_ge "${kmod_version}" 2.1.14; } + then + # We only need to apply this hack on OpenZFS < 2.1.14 or < 2.2.2 + zfs_dmu_offset_next_sync=0 + fi + + require= \ + __block /etc/modprobe.d/zfs.conf:cdist-data-corruption-workaround \ + --state "$(test "${zfs_dmu_offset_next_sync-}" && echo present || echo absent)" \ + --file /etc/modprobe.d/zfs.conf \ + --prefix '# skonfig:zfs-corruption-mitigation' \ + --suffix '#/skonfig:zfs-corruption-mitigation' \ + -text - <<-EOF + options zfs zfs_dmu_offset_next_sync=$((zfs_dmu_offset_next_sync)) + EOF +fi + set_zed_rc() { require=__package_apt/zfs-zed \ __key_value /etc/zfs/zed.d/zed.rc:"$1" \