The native libcephfs backend is the only transfer path. The rsync transport, the mounted-filesystem access and its helpers (mount check, path resolution below a mount, mount claim, quota and hardlink repair through the mount) are removed, together with the rsync lab test and the client image that only added rsync. The claim and release tests now exercise the native claim through a local test file system with real flock locks. BREAKING CHANGE: "backend": "rsync" and the endpoint field "mount" are rejected. "backend" is optional and only accepts "native"; jobs created with "native" resume without it. Journals of rsync jobs cannot be resumed. Builds without the build tag ceph only support doctor and status. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
93 lines
3.1 KiB
Go
93 lines
3.1 KiB
Go
package migration
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"io"
|
|
"path"
|
|
"strings"
|
|
)
|
|
|
|
func nativePath(p string) (string, error) {
|
|
if !strings.HasPrefix(p, "/") || path.Clean(p) != p || p == "/" {
|
|
return "", fmt.Errorf("invalid Ceph data path %q", p)
|
|
}
|
|
|
|
return p, nil
|
|
}
|
|
|
|
// Access separates filesystem access from the shared snapshot/journal workflow.
|
|
type Access interface {
|
|
Inspect(context.Context, Config, Executor) (*Inspection, error)
|
|
Empty(context.Context, string) error
|
|
Claim(context.Context, Config, string, string) (io.Closer, error)
|
|
Prepare(context.Context, string, string, string) error
|
|
Apply(context.Context, string, string) error
|
|
Verify(context.Context, string, string, string) error
|
|
// Release deletes the claim of job id, and the claim directories if
|
|
// they are empty. A missing claim is not an error.
|
|
Release(context.Context, Config, string, string) error
|
|
}
|
|
|
|
func (e Engine) access() Access { return e.Access }
|
|
|
|
// Inspect checks both endpoints without changing them and reports what a
|
|
// migration would transfer.
|
|
func (e Engine) Inspect(ctx context.Context, c Config) (*Inspection, error) {
|
|
if e.Access == nil {
|
|
return nil, errors.New("missing access")
|
|
}
|
|
|
|
return e.Access.Inspect(ctx, c, e.Exec)
|
|
}
|
|
|
|
// Transport copies a source tree to the target and verifies the copy.
|
|
type Transport interface {
|
|
Copy(context.Context, string, string) error
|
|
Verify(context.Context, string, string) error
|
|
}
|
|
|
|
// Round describes one snapshot transfer handed to a RoundTransport.
|
|
// BaseName and BaseSourcePath name the last completed snapshot, if any,
|
|
// which allows an incremental transfer. SkipUnchanged permits skipping
|
|
// subtrees whose recursive ctime did not change since the base.
|
|
type Round struct {
|
|
SourcePath, TargetPath string
|
|
BaseName, BaseSourcePath string
|
|
Name, StatePath string
|
|
SkipUnchanged bool
|
|
}
|
|
|
|
// RoundTransport is a Transport that keeps state across a snapshot round,
|
|
// such as the native backend's on-disk index.
|
|
type RoundTransport interface {
|
|
BeginRound(context.Context, Round) error
|
|
Published(string)
|
|
Commit(context.Context, string) error
|
|
Statistics() TransferStats
|
|
}
|
|
|
|
// TransferStats summarizes the work done for one snapshot round.
|
|
type TransferStats struct {
|
|
Mode string `json:"mode"`
|
|
BaseSnapshot string `json:"base_snapshot,omitempty"`
|
|
FilesVisited int64 `json:"files_visited"`
|
|
FilesCopied int64 `json:"files_copied"`
|
|
BytesCopied int64 `json:"bytes_copied"`
|
|
BytesVerified int64 `json:"bytes_verified"`
|
|
BlockDiffFiles int64 `json:"blockdiff_files"`
|
|
SnapDiffEntries int64 `json:"snapdiff_entries"`
|
|
SkippedSubtrees int64 `json:"skipped_subtrees,omitempty"`
|
|
// Seconds is the duration of the round from its start to the commit,
|
|
// including verification and snapshot creation.
|
|
Seconds float64 `json:"seconds"`
|
|
}
|
|
|
|
// NewEngine returns an Engine with the native libcephfs backend and a Closer
|
|
// that releases its connections. Builds without the build tag ceph return an
|
|
// error.
|
|
func NewEngine(ctx context.Context, c Config, x Executor, log io.Writer) (Engine, io.Closer, error) {
|
|
return openNativeEngine(ctx, c, x, log)
|
|
}
|