Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
205 lines
10 KiB
Markdown
205 lines
10 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 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 | Ceph 21.2.0 (lab) | Ceph `main` (2026-12-03) |
|
|
| --- | --- | --- |
|
|
| ceph_open_snapdiff | yes | yes |
|
|
| ceph_open_snapdiff2 | no | yes, unreleased |
|
|
| ceph_readdir_snapdiff2 | no | yes, unreleased |
|
|
| ceph_close_snapdiff2 | no | yes, unreleased |
|
|
| ceph_file_blockdiff_init | yes | yes |
|
|
| ceph_file_blockdiff | yes | yes |
|
|
| ceph_file_blockdiff_finish | yes | yes |
|
|
|
|
### snapdiff2: available in Ceph `main` only
|
|
|
|
As of 2026-12-03, the snapdiff2 interface exists in the development branch
|
|
`main` of Ceph, but in no release: the v21.2.0 header does not declare it,
|
|
and the lab library does not export it. cephmig does not use it; nothing is
|
|
built until a release contains it.
|
|
|
|
What `main` contains, read from the source code:
|
|
|
|
- `ceph_open_snapdiff2(cmount, root_path, rel_path, snap1, snap2, diff_mask, &out)`,
|
|
`ceph_readdir_snapdiff2` and `ceph_close_snapdiff2`, with an opaque handle
|
|
`struct ceph_snapdiff_info2`. The entries have the same type as in v1
|
|
(`ceph_snapdiff_entry_t`: directory entry and snapshot ID; removed entries
|
|
carry the former snapshot ID).
|
|
- `diff_mask` selects which file metadata changes count as a difference:
|
|
`CEPH_SNAPDIFF_MODE`, `_UID`, `_GID`, `_SIZE`, `_NLINK`, `_MTIME`, `_ATIME`,
|
|
`_CTIME`, `_BTIME`.
|
|
- libcephfs only passes the mask through. It is a field `mask` of the MDS
|
|
request `CEPH_MDS_OP_READDIR_SNAPDIFF` (`ceph_mds_request_args.snapdiff`),
|
|
so it is most likely evaluated by the MDS. The MDS handler itself was not
|
|
read; this point is unconfirmed.
|
|
- Sources: [libcephfs.h](https://github.com/ceph/ceph/blob/main/src/include/cephfs/libcephfs.h),
|
|
[libcephfs.cc](https://github.com/ceph/ceph/blob/main/src/libcephfs.cc),
|
|
[ceph_fs.h](https://github.com/ceph/ceph/blob/main/src/include/ceph_fs.h).
|
|
|
|
Consequences for cephmig:
|
|
|
|
- Snapdiff runs against the **source** cluster. A newer libcephfs alone is
|
|
not enough; the source MDS must run a release that evaluates the mask.
|
|
An older MDS presumably ignores the field and behaves like v1.
|
|
- With `CEPH_SNAPDIFF_CTIME`, snapdiff2 should report the changes v1 missed
|
|
in the lab (chmod, xattr changes, writes through a hardlink alias,
|
|
overwrites with a reset mtime), because all of them change the ctime.
|
|
- It compares the two snapshots in the MDS, so unlike the removed rctime
|
|
shortcut (see [metadata scan](migration.md#metadata-scan)) it depends
|
|
neither on delayed rctime propagation nor on client clocks. After a lab
|
|
proof, it could shorten rounds and possibly `finalize`.
|
|
- Open: v1 reported every directory, including unchanged ones. The sources
|
|
do not say whether snapdiff2 behaves differently; without that, it cannot
|
|
be used to skip subtrees.
|
|
|
|
Once a release contains snapdiff2, the next step is a lab test with that
|
|
release: repeat the snapdiff test cases (chmod, xattr change, alias write,
|
|
overwrite with reset mtime, untouched subtrees) and check which entries are
|
|
reported. The copier would then detect the symbol at runtime and fall back
|
|
to the current path without it.
|
|
|
|
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.
|
|
|
|
### Why a C binding and not a Go library
|
|
|
|
No CephFS client is written in pure Go. Every Go route ends in the C library
|
|
libcephfs or in a kernel mount:
|
|
|
|
- **go-ceph** (`github.com/ceph/go-ceph`) is itself a CGO wrapper around
|
|
libcephfs and librados. It would keep CGO, `-lcephfs` and the build
|
|
dependency, and add a layer between the copier and the library.
|
|
- **A CephFS client in Go** would have to implement msgr2, cephx, the MDS
|
|
protocol with its capability handling and direct object I/O against the
|
|
OSDs. That is a large, error-prone project; the cap handling alone decides
|
|
whether verification waits seconds per entry (see the client replacement
|
|
in [migration.md](migration.md)).
|
|
- **A kernel mount and the Go standard library** was the former rsync
|
|
backend. It cannot do what the copier needs (list below).
|
|
|
|
What the copier uses from libcephfs and gets nowhere else:
|
|
|
|
- `ceph_open_snapdiff`/`ceph_readdir_snapdiff`: changed directory entries
|
|
between two snapshots.
|
|
- `ceph_file_blockdiff_*`: changed data ranges of one file between two
|
|
snapshots.
|
|
- `ceph_setattrx` with the birth time; POSIX interfaces cannot set btime.
|
|
- `ceph_ll_walk`/`ceph_ll_link`: inode-level operations for hardlinks.
|
|
- The ctime: libcephfs stamps each request with `clock_gettime`, and the
|
|
backend replaces that function in its own process (see
|
|
[migration.md](migration.md)). This works only with the client library
|
|
inside the process.
|
|
- Separate client instances per purpose (writer, verifier, claim), so caps
|
|
are returned together when a client closes. On a kernel mount all callers
|
|
share one client.
|
|
- Both clusters in one process, without mounts and without root privileges.
|
|
|
|
The binding in `internal/cephfsnative` is our own instead of go-ceph. It
|
|
wraps only the roughly 45 functions the copier calls, and it can call a new
|
|
interface such as snapdiff or blockdiff as soon as the installed libcephfs
|
|
provides it, without waiting for a wrapper release. In return, we maintain it
|
|
ourselves.
|
|
|
|
Costs of CGO: the copier build needs a C compiler, the libcephfs headers and
|
|
the build tag `ceph`; the binary links dynamically against libcephfs; cross
|
|
compiling is harder. A build without libcephfs supports only `doctor` and
|
|
`status`.
|
|
|
|
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 fallback to another
|
|
transfer method.
|
|
|
|
Snapdiff cannot replace the metadata scan (see
|
|
[metadata scan](migration.md#metadata-scan)). Every round scans all metadata
|
|
and checks 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/)
|