# e2undo replay: a zero status can accompany incomplete restoration

Seven controlled cases on e2fsprogs 1.47.0 and a locally compiled 1.47.4
show why a repair acceptance check needs diagnostics and independent content
validation. These are regular-file experiments, not measurements of drive
reliability or power-loss recovery.

## Observed result

A write-size limit allowed the first superblock restoration but rejected a
later write to backup-superblock block 8193. Both versions reported an I/O
error, returned status 0, and left an image different from both the before
and after states. The primary label reverted to BEFORE. This is a controlled
EFBIG error, not a real device failure.

In a separate case, one byte of a file outside the undo log was changed.
Replay restored the label and returned 0; a subsequent forced read-only
e2fsck also returned 0, but the payload remained different. The log restores
what it recorded, not the intended content of every file.

| Case | Status in both versions | Observation |
| --- | --- | --- |
| Normal replay | 0 | Whole image matched the before-operation SHA256 |
| Dry run | 0 | Target unchanged, label remained AFTER |
| Unlogged payload change | 0 | Label restored, payload still changed, e2fsck status 0 |
| Target-superblock mismatch | 1 | Replay refused; target unchanged |
| Corrupt undo-header padding | 1 | Header checksum failure; target unchanged |
| Forced dry run with that header | 0 | Header checksum safeguard bypassed; target unchanged |
| Write limited to 2048 bytes | 0 | I/O error reported; only partial restoration |

## Method

The observer makes a new 16 MiB ext4 image with 1024-byte blocks and a
known payload. The image is never mounted. tune2fs changes its label from
BEFORE to AFTER while recording an undo log. Every control gets its own
copy of the resulting image. Raw SHA256 hashes, versions, binary hashes,
commands, stdout and stderr are retained in each result.

For the error control, only the e2undo child receives RLIMIT_FSIZE=2048 and
an ignored SIGXFSZ. Existing writes at larger offsets then return EFBIG.
The limit does not apply to the observer or other processes. The harness
accepts no image/device argument and creates all images in a fresh
temporary directory.

The malformed-header case flips one padding byte at offset 128. Force
mode is exercised only with -n. This is not advice to force a replay on
valuable storage. A valid normal replay and two unchanged rejection controls
bound the interpretation of the error case.

## Scope and research context

Gatla et al., *Towards Robust File System Checkers*, FAST 2018, pp. 105-122,
examined interrupted repair with a different protocol: prefixes of recorded
atomic-block writes, including log writes, were replayed on selected images
(sections 3.2-3.4). Their ext4 input set comprised 175 e2fsprogs 1.43.1 test
images. The ordering diagnosis and rfsck design are in sections 4-5.
These seven controls do not reproduce that study, its fault model or its
performance claims.

The tagged 1.47.4 replay loop sets io_error after a failed write and emits
a diagnostic, but its final return expression uses csum_error. The source
therefore explains the zero exit status observed here. This is a narrow
versioned result, not a claim that every I/O error returns zero.

An undo log is not a complete backup. Successful replay, metadata
consistency, expected payload contents and survival of a power loss are
separate properties. Preserve an independent copy and review diagnostics
before accepting a recovery.

## Reproduction

Requirements: Linux, Python 3 standard library and the five e2fsprogs tools.
No root, mount, loop device, external data or new package is needed for the
installed-tool run. Peak logical temporary image size is below 200 MiB.

```sh
python3 -B probe.py --output local-result.json
python3 -B probe.py --tool-root /path/to/e2fsprogs-1.47.4 --output built-result.json
python3 -B -m unittest discover -s . -p test_evidence.py
python3 -B -O -m unittest discover -s . -p test_evidence.py
```

Version 1.47.4 was built without installation using:
`./configure --disable-nls --disable-fuse2fs --enable-libuuid --enable-libblkid --disable-uuidd`
and `make -j4`. The initially attempted external-UUID configuration failed
because development files were unavailable; it was not used for results.

The upstream archive SHA256 is
`fd5bf388cbdbe006a3d3b318d983b2948382440acc85a87f1e7d108653e8db0b`.
The reviewed misc/e2undo.c SHA256 is
`8ee3859a5b3da726955031bdf7a6cc7f8ee06a612b1a370ac3703a6f82e06a97`.
These identify retrieved bytes; no signature verification is claimed.
e2fsprogs is GPL/LGPL software; its source is linked, not bundled here.
The observer and tests are original Hesela code.

Captures are seven constructed configurations per version on one Linux host,
not seven independent samples from a population. Repeating a capture checks
repeatability, not generalization. No confidence interval or failure rate is
appropriate. No crash, journal recovery, mounted use, arbitrary corruption,
or other tool version is covered. The host mke2fs configuration hash and
tool hashes are in the results. Exact image hashes can vary with environment;
within each capture they establish before/after equality.

## Primary sources

- [FAST 2018 paper](https://www.usenix.org/system/files/conference/fast18/fast18-gatla.pdf)
- [v1.47.4 replay implementation](https://raw.githubusercontent.com/tytso/e2fsprogs/v1.47.4/misc/e2undo.c)
- [v1.47.4 manual](https://raw.githubusercontent.com/tytso/e2fsprogs/v1.47.4/misc/e2undo.8.in)
- [v1.47.4 undo producer](https://raw.githubusercontent.com/tytso/e2fsprogs/v1.47.4/lib/ext2fs/undo_io.c)
- [Official source archive](https://www.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/v1.47.4/e2fsprogs-1.47.4.tar.xz)
