docs: explain why the copier binds libcephfs through CGO
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6dcb7b676f
commit
864830d044
2 files changed
+45
-1
No files matched your search
@@ -120,6 +120,50 @@ to public Ceph interfaces in `internal/cephfsnative`. Activation:
|
||||
`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
|
||||
|
||||
Reference in new issue
Block a user