Files
CephfsMig/docs/raw-transfer.md
T

114 lines
5.5 KiB
Markdown

# Direct RADOS transfer of a single subvolume
Evaluated on 2026-11-05 against the requirement: migrate exactly one CephFS
subvolume between independent clusters while other subvolumes keep running.
Native snapshot IDs and birth times may differ.
## Result
Under these conditions, a raw import of RADOS data and metadata objects is
not a verified replacement for the existing transport. The code was
therefore not switched to such an import.
RADOS can read and write object contents, xattrs and OMAP. That alone does
not transfer a separately mountable CephFS subvolume:
- The MDS metadata pool holds the hierarchy and file-system-wide state, such
as journals, inode and snapshot management and client sessions.
- A subvolume has no metadata pool of its own. A separate data namespace
would only help to map data objects.
- File layouts and metadata refer to the inodes, pools and snapshots of the
source. They must not be imported unchanged into a running target file
system with a different structure.
- The examined RADOS pool export explicitly writes only HEAD objects.
Historical RADOS snapshot versions are therefore not migrated as a complete
CephFS snapshot history.
- The documented pool migration covers migration between pools within the
same cluster. It is not subvolume replication between independent
clusters.
The conclusion follows from these management and consistency dependencies:
a raw copier of its own would additionally have to export a consistent
subset of the CephFS metadata, map it to the target identities and
coordinate with the target's running MDS. An ordinary object copier does not
do that. An object transfer, too, has to move the required payload to the
target.
## Verified native alternative
The Go transport `backend: native` uses libcephfs without rsync and without a
kernel or FUSE mount. Metadata operations go through the target MDS; data
I/O is handled by the native Ceph client directly against RADOS. A raw import
of the shared MDS metadata pool remains outside the migration.
The following symbols were checked in the library actually running in the
lab:
| Interface | Present |
| --- | --- |
| ceph_open_snapdiff | yes |
| ceph_open_snapdiff2 | no |
| ceph_readdir_snapdiff2 | no |
| ceph_file_blockdiff_init | yes |
| ceph_file_blockdiff | yes |
| ceph_file_blockdiff_finish | yes |
The installed Ceph 21.2.0 configuration knows
`cephfs_mirror_blockdiff_min_file_size` with a default of 16 MiB.
Implemented workflow:
1. Initial native transfer of the snapshot state.
2. Snapdiff to find changed directory entries.
3. Blockdiff for suitable changed files; transfer of the required data
ranges.
4. Hardlink mappings, ACLs, xattrs, quotas and the journal are still managed
explicitly.
5. Targeted verification of the changes and a final round at the write stop.
The backend lives in `internal/migration/native_*.go`, the thin CGO binding
to public Ceph interfaces in `internal/cephfsnative`. Activation:
`go build -tags ceph` with CGO, a C compiler and matching libcephfs headers.
`make dev-native-test` builds these dependencies in a container and checks
the transport between the independent lab clusters.
Snapdiff marks changed inodes; in addition, comparing the Ceph inode version
ensures that data changes with the same size and mtime are not missed.
Blockdiff is used from 16 MiB on, provided a confirmed base with matching
source and target inodes exists. If the diff interfaces are unavailable, the
state is reconstructed fully and natively. There is no silent rsync fallback.
Snapdiff cannot replace the metadata scan (see
[skipping unchanged subtrees](migration.md#skipping-unchanged-subtrees)).
Intermediate rounds skip subtrees whose recursive ctime did not change;
application snapshots and the final round still scan all metadata and check
the full hardlink topology.
Data verification reads all bytes for the first state and only the copied
ranges for confirmed later states. Unchanged ranges are taken from the
previously verified base. The target must belong exclusively to the
migration job; foreign changes to unchanged ranges are not fully detected
this way.
An index on local disk binds the base to clusters, data paths and journal.
Before every change its validity is withdrawn in the journal. An
interruption forces a full reconstruction of the open state in the next
process.
Evidence of runtime or throughput for 200 TB / 200 million files is missing.
After an interruption, too, the full reconstruction can take correspondingly
long. The number of bytes changed by the application is not a fixed upper
bound for the changed ranges reported by the OSD.
The ready-made cephfs-mirror uses native replication but, according to its
documentation, does not preserve shared hardlink inodes. It would synchronize
hardlinked files as separate files. An unverified switch to cephfs-mirror
would therefore not satisfy the agreed link requirements.
## Primary sources
- [MDS metadata pool and journals](https://docs.ceph.com/en/latest/cephfs/mds-journaling/)
- [CephFS architecture and direct RADOS data access](https://docs.ceph.com/en/latest/cephfs/index.html)
- [PoolDump: export of the HEAD state only](https://github.com/ceph/ceph/blob/main/src/tools/rados/PoolDump.cc)
- [Pool migration within the same cluster](https://docs.ceph.com/en/latest/dev/pool-migration-design/)
- [libcephfs: snapdiff and blockdiff](https://github.com/ceph/ceph/blob/main/src/include/cephfs/libcephfs.h)
- [CephFS mirroring: blockdiff and hardlink limits](https://docs.ceph.com/en/latest/cephfs/cephfs-mirroring/)