nbdkit/SOURCES/0018-server-Fix-.zero-fallback-path.patch

41 lines
1.3 KiB
Diff

From 37c234f30706958a63d45aeea0ffa8ffa8ba10d9 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
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)
(cherry picked from commit e947a2a55cb018711b7f4ede5b5cec291ed5cf24)
---
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