# Sparse-copy observations: bytes, seek maps and reservation

Companion to [Sparse files, preallocation and thin-pool capacity](https://hesela.com/analyses/sparse-files-preallocation-thin-capacity/#copy-observer).
These are controlled software observations, not device benchmarks or power-loss experiments.

## What the evidence says

On the recorded ext4 mount, reading a preallocated 1 MiB zero-filled file changed
SEEK_DATA/SEEK_HOLE classification while the source allocation, bytes and logical
FIEMAP descriptors stayed unchanged. Reopening retained the changed classification;
per-file DONTNEED advice reversed it, and rereading restored it.

The separate GNU cp matrix contains 336 copies: seven layouts, four option
combinations, two preread conditions, two filesystems and three repeats per cell.
A half-preallocated zero source produced a default-cp destination with 0 allocated
bytes without a preread, or 524288 after one. A fully preallocated source produced
1048576 in both conditions. Tmpfs did not show the half-preallocation interaction.
All destinations matched their constructed byte oracle and 1048576-byte length.

The practical inference is narrow: a byte-correct copy need not preserve source
preallocation. A matching checksum does not certify a destination space reservation.
No later ENOSPC outcome was tested. No-preread is not a measured cold-cache state.

## Method and scope

Preparation used native fallocate, fsync and writer close. Later source handles
were read-only. Independent fresh files were used for both preread conditions.
The preread condition read and hashed the entire source before cp; the other
condition deliberately postponed source-content validation until after cp.
Destination synchronization and allocation measurement preceded its byte check.
All relevant source metadata and logical FIEMAP descriptors remained unchanged.
Sequential stat, seek and mapping calls are not an atomic snapshot.

Seven layouts include sparse files, full/half preallocation, written zeros,
nonzero patterns and three nonzero data islands with/without full preallocation.
Four copy policies are default and sparse=auto/always/never paired with
reflink=never. These are combined policy interventions, not isolation of a single
flag. Four separate strace witnesses corroborate the selected decision paths;
they are not additional observations in the 336-copy denominator.

Environment: one host, Ubuntu Linux 6.8.0-146-generic, GNU cp 9.4-3ubuntu6.3,
Python 3.12.3 and glibc 2.39, on ext4 and tmpfs. Kernel/compiler/mount options,
binary hashes and exact operation records are retained in JSON.

Five repeats of the original four-layout/two-filesystem experiment are 40 files,
not 40 independent hosts. The two experiments are not pooled into a failure rate.
No latency, physical-write traffic, cache-residency percentage, capacity-exhaustion,
network-filesystem, hardware-failure or independent-host replication is claimed.
Per-file eviction advice is a request, not a guaranteed cache-state reset.

## Evidence and provenance

- [Original 40-fixture read-sequence observations](observation.json).
- [GNU cp 336-copy observations](gnu-cp/final-observation.json).
- [Complete grouped results](gnu-cp/results.json) and [table](gnu-cp/results-table.md).
- [Separate syscall witnesses](gnu-cp/syscall-witness.json).
- [Publication summary](publication-summary.json) and [immutable-file manifest](publication-manifest.json).
- [Original source receipts](sources.json) and [GNU cp source receipts](gnu-cp/sources.json).
- [Rechecked source identities and corrected symbol-based locators](source-locator-audit.json).

The manifest records evidence commit 5e771a23d924683ad0d022c4b91b1a83dd2d5a65 and
SHA-256 for every copied original file. Those files remain byte-identical.
Publication-summary.json is a derivative checked against the raw observations.
The source-locator audit corrects inaccurate handwritten line hints without
rewriting old receipts. External source bodies are not redistributed.
These are author verification checks, not independent scientific peer review.

## Reproduce

Keep the directory layout, including the gnu-cp subdirectory. Download all files
listed in publication-manifest.json. Requires Linux, Python 3, GNU cp with
--debug, cc, Linux headers, findmnt and dpkg-query. strace is needed only for
trace_witness.py. No installation, mount changes or raw-device access occurs.
Only new private temporary files are created; existing result paths are refused.

From this directory:

~~~sh
python3 -m unittest -v test_observe
python3 observe.py --root disk=/your/writable/directory --root ram=/dev/shm --output new-read-observation.json
cd gnu-cp
python3 -m unittest -v test_experiment
python3 -O -m unittest -v test_experiment
python3 experiment.py --root disk=/your/writable/directory --root ram=/dev/shm --output new-cp-observation.json
~~~

The parent validator intentionally rejects optimized Python rather than silently
disabling its assertions. The child validator uses explicit checks and is tested
under normal and optimized Python. Fresh-execution tests use sequential private
fixtures with about 2-3 MiB of payload at a time.

Retained-result tests verify this recorded environment. The generic runner permits
different allocation results on other supported filesystems. A new environment
must not overwrite or be represented as the old observation.

Next useful evidence is an independently provisioned kernel/filesystem/coreutils
replication and more boundary sizes. Do not prescribe production cache eviction
from this experiment.
