From 4450b8fbd962780c46ec40c8019a003404bb7a41 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 5 Jul 2025 08:47:50 +0100 Subject: [PATCH] server: Fix .zero fallback path resolves: RHEL-101635 --- 0044-server-Fix-.zero-fallback-path.patch | 39 +++++++++++++++++++++++ nbdkit.spec | 7 +++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 0044-server-Fix-.zero-fallback-path.patch diff --git a/0044-server-Fix-.zero-fallback-path.patch b/0044-server-Fix-.zero-fallback-path.patch new file mode 100644 index 0000000..50524c7 --- /dev/null +++ b/0044-server-Fix-.zero-fallback-path.patch @@ -0,0 +1,39 @@ +From e947a2a55cb018711b7f4ede5b5cec291ed5cf24 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Wed, 2 Jul 2025 16:18:19 +0100 +Subject: [PATCH] server: Fix .zero fallback path + +When no efficient zero method is supported, we fall back to writing a +buffer of actual zeroes. However because of an omitted update to +'offset' we would only zero out (up to) the first 64M of each range. +nbdcopy defaults to working on blocks of 128M, leaving the second 64M +unzeroed. + +This affects only backing filesystems which do not support fallocate +FALLOC_FL_PUNCH_HOLE or FALLOC_FL_ZERO_RANGE, which turns out to be +rare, but it does include some NFS-mounted filesystems which is where +I saw this problem. + +Fixes: commit 19184d3eb6356ae3b14da0fbaa9c9bdc7743a448 +Thanks: Alex Kalenyuk +(cherry picked from commit 20b23fc9838faeddfd42664a7f497a9b29dc5921) +(cherry picked from commit 3c8d0812e7a7b6a1f9e5cceab7bee6e25b9cd7cd) +--- + server/plugins.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/server/plugins.c b/server/plugins.c +index 3c7df0d2..db36ce42 100644 +--- a/server/plugins.c ++++ b/server/plugins.c +@@ -807,6 +807,7 @@ plugin_zero (struct context *c, + if (r == -1) + break; + count -= limit; ++ offset += limit; + } + + done: +-- +2.47.1 + diff --git a/nbdkit.spec b/nbdkit.spec index e6801fa..3d9cdcd 100644 --- a/nbdkit.spec +++ b/nbdkit.spec @@ -56,7 +56,7 @@ Name: nbdkit Version: 1.38.5 -Release: 11%{?dist} +Release: 12%{?dist} Summary: NBD server License: BSD-3-Clause @@ -124,6 +124,7 @@ Patch0040: 0040-vddk-stats-Collect-elapsed-time-for-ReadAsync-and-Wr.patch Patch0041: 0041-server-Fix-off-by-one-for-maximum-block_status-lengt.patch Patch0042: 0042-blocksize-Fix-32-bit-overflow-in-.extents-CVE-2025-4.patch Patch0043: 0043-vddk-Add-support-for-VDDK-9.0.0.0.patch +Patch0044: 0044-server-Fix-.zero-fallback-path.patch # For automatic RPM Provides generation. # See: https://rpm-software-management.github.io/rpm/manual/dependency_generators.html @@ -1542,6 +1543,10 @@ fi %changelog +* Sat Jul 05 2025 Richard W.M. Jones - 1.38.5-12 +- server: Fix .zero fallback path + resolves: RHEL-101635 + * Mon Jun 23 2025 Richard W.M. Jones - 1.38.5-11 - Add support for VDDK 9.0.0.0 resolves: RHEL-99466