the data in holes is actually not zeros as there might be a parent image having
other data. Properly reporting (non-)zero hole extents allows clients to have
information about whether the data in the image is unallocated, but the read
will return zero blocks (HOLE+ZERO) or whether the data is just not in this
later of the image (only HOLE).
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
plugins/vddk/vddk.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/plugins/vddk/vddk.c b/plugins/vddk/vddk.c
index 8cf54f6e2b96..cda670325b85 100644
--- a/plugins/vddk/vddk.c
+++ b/plugins/vddk/vddk.c
@@ -773,9 +773,17 @@ static int
add_extent (struct nbdkit_extents *extents,
uint64_t *position, uint64_t next_position, bool is_hole)
{
- const uint32_t type = is_hole ? NBDKIT_EXTENT_HOLE|NBDKIT_EXTENT_ZERO : 0;
+ uint32_t type = 0;
const uint64_t length = next_position - *position;
+ if (is_hole) {
+ type = NBDKIT_EXTENT_HOLE;
+ /* Images opened as single link might be backed by another file in the
+ chain, so the holes are not guaranteed to be zeros. */
+ if (!single_link)
+ type |= NBDKIT_EXTENT_ZERO;
+ }
+
assert (*position <= next_position);
if (*position == next_position)
return 0;
--
2.21.0