docs: describe subtree skipping and add sequence diagrams

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-12-03 20:19:31 +01:00
1 parent 83e15bccb2
commit 831f44dbe5
4 files changed
+157 -9

No files matched your search

+112 -4
View File
@@ -83,6 +83,43 @@ running `sync` again. The native backend uses snapdiff and the Ceph inode
version, so it also detects data changes with the same size and mtime. The
rsync path uses checksums.
### Skipping unchanged subtrees
Reading all metadata of a large subvolume in every round is the main cost of
a round: in the [one-million-file test](million-local.md), even an unchanged
finalization took 1 h 20 min and 19.3 million MDS requests. Snapdiff cannot
replace this scan; in the lab it reported every directory and missed pure
chmod, xattr changes and writes through a hardlink alias.
Intermediate `sync` rounds therefore skip a subdirectory when, compared with
the base snapshot of the previous round, it has
- the same inode and the same inode version, which changes at once with
every entry added or removed and every change of its own metadata, and
- the same `ceph.dir.rctime`, the newest ctime in the whole subtree.
The index takes over the entries of a skipped subtree from the previous base
and marks them `carried`. Snapdiff, copy, pruning and verification all leave
the subtree out. The journal reports the number per round as
`skipped_subtrees`.
The rctime is not exact. Ceph propagates it to the parent directories with a
delay; in the lab, a change made milliseconds before a snapshot was not yet
visible in that snapshot's rctime. A client whose clock lags behind can also
stamp a change with a ctime older than the newest one in the subtree. An
intermediate round can therefore miss content changes deep inside a subtree.
The following design limits the effect to extra work:
- `finalize` always scans and verifies everything; it never skips.
- A carried entry describes an older round than the base snapshot, so it never
serves as base for a block delta: a changed carried file is copied in full.
- Snapshots discovered at the source (application snapshots) are always
transferred with a full scan. Only the `cephmig-*` round snapshots, which
are deleted later, can be incomplete.
`"full_scan": true` in the configuration disables the shortcut for all
rounds. It may be changed when resuming.
`finalize` relies solely on the operator's explicit confirmation of the write
stop; it does not stop or lock any application itself. All writers must stay
stopped until the cutover is complete. The job ends in `ready-for-cutover`.
@@ -106,6 +143,76 @@ Application snapshots are never deleted. The journal marks a snapshot as
`removed` before deleting it, so an interrupted run completes the deletion
next time.
## Workflow in detail
The diagram shows one migration with the native backend: an intermediate
`sync` round, `finalize` and `cleanup`. Application snapshots discovered at
the source are transferred like a round, but always with a full scan and
without being deleted.
```mermaid
sequenceDiagram
autonumber
actor Op as Operator
participant M as cephmig
participant J as Journal (local)
participant I as Index (local bbolt)
participant S as Source cluster
participant T as Target cluster
participant V as Verify client
Op->>M: sync --config --state
M->>S: fsid, subvolume info, snapshot ls
M->>T: fsid, subvolume info, snapshot ls
M->>T: lock claim in /.cephmig/claims
M->>J: record intent for round snapshot R(n)
M->>S: create snapshot R(n)
M->>J: invalidate the confirmed base
M->>I: open base R(n-1), create pending index
M->>S: snapdiff R(n-1) to R(n)
loop every directory, from the root down
M->>S: stat dir, ceph.dir.rctime in R(n) and R(n-1)
alt same inode, inode version and rctime (sync rounds only)
M->>I: carry subtree entries, marked carried
else changed
M->>I: record path inventory
M->>T: mkdir, copy changed files (blockdiff or full), symlinks, FIFOs
M->>T: xattrs and quotas, then setattr and ctime stamp
end
end
M->>T: hardlink aliases, prune surplus entries
M->>T: restore directory metadata, deepest first
M->>T: sync_fs
M->>V: connect a fresh client to the target
V->>T: compare metadata, links and copied ranges with R(n)
M->>T: create snapshot R(n), copy snapshot metadata
V->>T: compare snapshot R(n) with R(n)
M->>I: commit pending index as new base
M->>J: mark R(n) done, base = R(n)
M->>J: mark R(n-1) removed
M->>S: remove snapshot R(n-1)
M->>T: remove snapshot R(n-1)
M-->>Op: journal as JSON
Note over Op,S: all writers stopped
Op->>M: finalize --writers-stopped
M->>S: create final snapshot F
Note over M,T: same round, but a full scan: no subtree is skipped
M->>J: mark F done, R(n) removed
M->>S: remove snapshot R(n)
M->>T: remove snapshot R(n)
V->>T: verify complete inventory against F
M->>J: phase = ready-for-cutover
Note over Op,T: clients switched to the target and checked
Op->>M: cleanup
M->>J: mark F removed
M->>S: remove snapshot F
M->>T: remove snapshot F
```
## Transferred data
- Snapshot names and contents; existing snapshots are transferred in
@@ -322,13 +429,14 @@ files and short verification ranges. Unchanged owner, mode and timestamps do
not trigger another `setattr` call; a target stat read just before is reused
for the metadata check. Path and hardlink mappings live on local disk.
Snapdiff and blockdiff avoid repeated full transfers and full reads of
unchanged file contents. The implementation still scans all metadata,
including the full topology and quota check. Renamed files may be copied
again in full. Single transactions of the native index are not yet optimized
unchanged file contents. Intermediate rounds skip unchanged subtrees, but
`finalize` still scans all metadata, including the full topology and quota
check, so the write stop scales with the total number of entries. Renamed
files may be copied again in full. Single transactions of the native index are not yet optimized
for 200 million paths.
200 TB and more than 200 million files are therefore not yet proven. What is
missing for that release in particular: change planning that avoids scans,
missing for that release in particular: a final round that avoids full scans,
reliable memory and runtime measurements, a capacity model for historical
versions and an automated client cutover. A fixed maximum write-stop duration
is not guaranteed. Native API calls block; cancellation is checked between