Intermediate rounds skipped a directory when its inode version and its ceph.dir.rctime matched the previous round. In the 10,000-file lab test a round snapshot taken seconds after changes skipped tree/ with about 250 changed files in its subdirectories: the inode version of tree/ changes only with its own entries, and Ceph had not yet propagated the rctime of the grandchildren. The target snapshot of that round was incomplete, and its verification skipped the same subtrees; only finalize closed the gap. Every round now scans all metadata again. Base index entries that the old version marked carried are never trusted, so such files are copied in full in the next round. The smallfiles verification now checks only snapshots that sync did not remove. BREAKING CHANGE: the configuration field "full_scan" and the transfer statistic "skipped_subtrees" are removed; a configuration with "full_scan" is rejected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
136 lines
5.5 KiB
Markdown
136 lines
5.5 KiB
Markdown
# Concept: full content verification after the cutover
|
|
|
|
Status: proposal, not implemented.
|
|
|
|
## Motivation
|
|
|
|
`finalize` verifies the metadata and the hardlink topology of every entry,
|
|
but compares file contents only where something changed since the previous
|
|
round. Unchanged bytes were compared in full in an earlier round and are
|
|
trusted since then. That holds only as long as nobody but cephmig writes to
|
|
the target (see [Resumption and verification](migration.md#resumption-and-verification)).
|
|
A process that changes the target on the side would not be reliably detected
|
|
in unchanged ranges.
|
|
|
|
A complete comparison of all contents before the cutover would make the
|
|
write stop as long as reading the whole subvolume twice. The proposal moves
|
|
it to after the cutover.
|
|
|
|
## Idea
|
|
|
|
A new read-only command compares the final source snapshot with the final
|
|
target snapshot completely:
|
|
|
|
```text
|
|
cephmig verify --config FILE --state FILE
|
|
```
|
|
|
|
Both snapshots are immutable. The comparison can therefore run while the
|
|
application already works on the target, and its result describes exactly
|
|
the state that was handed over at the cutover. It must run before
|
|
`cleanup`, which deletes the final snapshots.
|
|
|
|
```mermaid
|
|
sequenceDiagram
|
|
actor Op as Operator
|
|
participant M as cephmig
|
|
participant J as Journal
|
|
participant S as Source cluster
|
|
participant T as Target cluster
|
|
|
|
Op->>M: finalize --writers-stopped
|
|
M-->>Op: ready-for-cutover
|
|
Note over Op,T: clients switched, application writes to the target
|
|
Op->>M: verify
|
|
M->>J: check phase and final snapshot F
|
|
par read both snapshots
|
|
M->>S: walk and read snapshot F
|
|
and
|
|
M->>T: walk and read snapshot F
|
|
end
|
|
M->>J: record result, verified_at
|
|
M-->>Op: report as JSON
|
|
Op->>M: cleanup
|
|
M->>J: require a passed verify
|
|
M->>S: remove snapshot F
|
|
M->>T: remove snapshot F
|
|
```
|
|
|
|
## What is compared
|
|
|
|
Everything the migration promises, without relying on earlier rounds:
|
|
|
|
- the set of entries in both directions: missing and surplus paths
|
|
- the type of every entry, symlink text, device numbers of special files
|
|
- **every byte of every regular file**, read on both sides
|
|
- owner, mode, POSIX ACLs, portable xattrs, directory quotas
|
|
- mtime, btime and ctime (with the rule ctime ≥ mtime); atime as well,
|
|
because reading a snapshot does not change it
|
|
- the hardlink topology in both directions, with an on-disk index as today
|
|
- the custom metadata of the final snapshot and of the subvolume as it was
|
|
at `finalize` (the journal holds the values)
|
|
|
|
The journal and the native base index are not used: the point is an
|
|
independent check.
|
|
|
|
## Preconditions and behaviour
|
|
|
|
- The job is in phase `ready-for-cutover`, and the final snapshot exists at
|
|
source and target and is not marked `removed`.
|
|
- Read-only on both clusters. No claim lock is needed for reading, but the
|
|
local journal lock prevents a parallel `cleanup`.
|
|
- Snapshot paths are read with `AT_STATX_DONT_SYNC`, as in the copier.
|
|
- `workers` and `bandwidth_kib` from the configuration bound the parallelism
|
|
and the read rate, so the comparison does not slow down the application.
|
|
- **Resumable:** progress is written to a local checkpoint next to the
|
|
journal (last completed path in walk order, the hardlink index). An
|
|
interrupted `verify` continues there; `--restart` starts over.
|
|
- **Result:** a JSON report with the counts of compared entries and bytes and
|
|
the list of differences (path and attribute, no file contents). The journal
|
|
records `verify` with time, snapshot name and result.
|
|
- **Exit code** 0 only if no difference was found.
|
|
|
|
## Interaction with cleanup
|
|
|
|
`cleanup` refuses to delete the final snapshot unless the journal records a
|
|
passed `verify` for it. `cleanup --skip-verify` overrides that for operators
|
|
who accept the risk; the journal records the override.
|
|
|
|
## When verify finds a difference
|
|
|
|
At that point the application already writes to the target, so cephmig must
|
|
not repair anything on its own. The report names the affected paths. The
|
|
operator decides per path, typically by restoring it from the final source
|
|
snapshot (which still exists, because `cleanup` has not run). A later
|
|
extension could offer `verify --repair PATH…` that copies listed paths from
|
|
the source snapshot after explicit confirmation; that is out of scope here.
|
|
|
|
## Cost
|
|
|
|
- **Reads:** the full data of the subvolume once on each cluster. At the
|
|
target size of 200 TB and an assumed 2.5 GB/s per side, that is roughly
|
|
22 hours; the real rate depends on OSDs, network and the limit set.
|
|
- **Metadata:** one walk of each snapshot, comparable to a full round.
|
|
- **Space:** while the final snapshot exists, the target keeps the old
|
|
blocks of everything the application overwrites or deletes. Longer
|
|
verification means more extra space until `cleanup`.
|
|
- **Source:** the source cluster and its final snapshot must stay available
|
|
until `verify` is done.
|
|
|
|
## Tests
|
|
|
|
- Unit tests with fake file systems: every kind of difference is reported,
|
|
checkpoint and resume, refusal outside `ready-for-cutover`.
|
|
- Lab: in a catch-up round, change one byte of an unchanged file in the
|
|
target through a test hook, so that the final target snapshot contains it
|
|
while `finalize` passes. Expect `verify` to report exactly that file, and
|
|
`cleanup` to refuse until a passed `verify` or `--skip-verify`.
|
|
|
|
## Open questions
|
|
|
|
- Should `cleanup` require `verify` by default, as proposed, or only warn?
|
|
- Is a sample mode useful (for example a random fraction of the files) for a
|
|
quick check before the full run?
|
|
- Should the report be kept as a file next to the journal in addition to
|
|
standard output?
|