Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyMutationEvent(ctx context.Context, base Engine, event MutationEvent) error
- func ApplyReplication(ctx context.Context, base Engine, domain string, seq uint64, payload []byte) error
- func CompactBoltFile(ctx context.Context, filename string) (previous string, err error)
- func CompactMetadata(ctx context.Context, options Options) (string, error)
- func EngineName(engine Engine) string
- func EnsureBackendIdentity(ctx context.Context, engine Engine, identity string) error
- func EnsureFormat(ctx context.Context, engine Engine, expected fsformat.Volume) (fsformat.Volume, error)
- func EnsureNamespaces(ctx context.Context, engine Engine, requested map[string]string) error
- func EventID(domain string, sequence uint64) string
- func Import(ctx context.Context, image string, destination Options) error
- func InitMutationReplica(ctx context.Context, base Engine, config HomeConfig) error
- func NamespaceReplacementMutations(ctx context.Context, current, selected, namespaceID string, ...) ([][]byte, error)
- func NormalizeEngine(engine string) (string, error)
- func PrepareReplication(ctx context.Context, base Engine, fn func(Tx) error) ([]byte, error)
- func PutMutationEvent(tx Tx, event MutationEvent) error
- func ReadFormat(ctx context.Context, engine Engine) (volume fsformat.Volume, found bool, err error)
- func ReadMutationSequence(ctx context.Context, base Engine, domain string) (uint64, error)
- func ReadNamespaces(ctx context.Context, engine Engine) (map[string]string, error)
- func ReadReplicatedSequence(ctx context.Context, base Engine, domain string) (uint64, error)
- func ReconcileNamespaces(ctx context.Context, engine Engine, requested map[string]string) error
- func RestoreBackup(ctx context.Context, objects backend.Backend, info BackupInfo, ...) (string, error)
- func RestoreBoltBackup(ctx context.Context, objects backend.Backend, info BackupInfo, ...) (string, error)
- func RewriteBoltReferences(ctx context.Context, filename string, fn func(chunk.Ref) (chunk.Ref, error)) error
- func StagedBoltReferences(ctx context.Context, filename string) ([]chunk.Ref, error)
- func ValidateRenameFlags(flags RenameFlags) error
- func ValidateTransferPaths(source, destination string) error
- type AsyncUpdater
- type AttributeUpdate
- type BackupInfo
- type BackupOptions
- type BackupService
- type BackupStats
- type BackupStore
- type Barrier
- type BoltEngine
- func (e *BoltEngine) Barrier(ctx context.Context) error
- func (e *BoltEngine) Close() error
- func (*BoltEngine) Name() string
- func (e *BoltEngine) Snapshot(ctx context.Context, w io.Writer) error
- func (e *BoltEngine) Sync(ctx context.Context) error
- func (e *BoltEngine) Update(ctx context.Context, fn func(Tx) error) error
- func (e *BoltEngine) UpdateAsync(ctx context.Context, fn func(Tx) error) error
- func (e *BoltEngine) View(ctx context.Context, fn func(ReadTx) error) error
- type BoltInspection
- type BoltOptions
- type BucketReadTx
- type ChangeBatch
- type ChangeCursor
- type ChangePage
- type Compactor
- type Dentry
- type DentryChange
- type DirectoryItem
- type Engine
- type EngineStore
- func (s *EngineStore) ActiveHistoryJournal(ctx context.Context) (epoch [16]byte, found bool, err error)
- func (s *EngineStore) Apply(ctx context.Context, puts []Entry, deletes []uint64, nextInode uint64) error
- func (s *EngineStore) BeginHistoryJournal(ctx context.Context, epoch [16]byte) error
- func (s *EngineStore) HistoryJournalCommitted(ctx context.Context, epoch [16]byte) (bool, error)
- func (s *EngineStore) HistoryStats(ctx context.Context) (result HistoryStats, err error)
- func (s *EngineStore) HistoryVersion(ctx context.Context, id uint64) (version HistoryVersion, err error)
- func (s *EngineStore) ListHistory(ctx context.Context, q HistoryQuery) (result []HistoryVersion, err error)
- func (s *EngineStore) Load(ctx context.Context) (Snapshot, error)
- func (s *EngineStore) PruneHistory(ctx context.Context, retention HistoryRetention) (removed uint64, err error)
- func (s *EngineStore) RecordHistory(ctx context.Context, versions []HistoryVersion, retention HistoryRetention) ([]HistoryVersion, error)
- func (s *EngineStore) RecordHistoryJournal(ctx context.Context, epoch [16]byte, versions []HistoryVersion, ...) error
- func (s *EngineStore) RestoreOrigin(ctx context.Context, inode uint64) (origin uint64, err error)
- func (s *EngineStore) Save(ctx context.Context, snapshot Snapshot) error
- func (s *EngineStore) WalkHistory(ctx context.Context, visit func(HistoryVersion) error) error
- type Entry
- type FileChunkUpdate
- type HistoryPatch
- type HistoryQuery
- type HistoryRetention
- type HistoryStats
- type HistoryVersion
- type HomeCommit
- type HomeConfig
- type HomeWriter
- type ImageInfo
- type InodeChange
- type Kind
- type LogEngine
- func (e *LogEngine) Close() error
- func (e *LogEngine) Compact(ctx context.Context) error
- func (e *LogEngine) CompactAsync(ctx context.Context) <-chan error
- func (e *LogEngine) Sync(ctx context.Context) error
- func (e *LogEngine) Update(ctx context.Context, fn func(Tx) error) error
- func (e *LogEngine) View(ctx context.Context, fn func(ReadTx) error) error
- type LogOptions
- type MemoryEngine
- type MutationEvent
- type MutationPlan
- type MutationPosition
- type MutationSnapshotInfo
- type MutationSnapshotInstallResult
- type MutationSnapshotLimits
- type Namespace
- func (n *Namespace) AttrWithWrite(inode uint64, size int64, stamp WriteStamp) (Entry, error)
- func (n *Namespace) CheckRemoveXattr(ctx context.Context, inode uint64, name string) error
- func (n *Namespace) CheckSetXattr(ctx context.Context, inode uint64, name string, value []byte, flags uint32) error
- func (n *Namespace) ClearChunks(ctx context.Context, inode uint64, first, count int) ([]chunk.Ref, error)
- func (n *Namespace) Create(ctx context.Context, parent uint64, name string, kind Kind, mode uint32, ...) (Entry, error)
- func (n *Namespace) CreateDevice(ctx context.Context, parent uint64, name string, kind Kind, ...) (Entry, error)
- func (n *Namespace) DirectoryEntryCount(ctx context.Context, parent uint64) (int, error)
- func (n *Namespace) DisableChangeJournal()
- func (n *Namespace) EnableChangeJournal(capacity int) (ChangeCursor, error)
- func (n *Namespace) Get(inode uint64) (Entry, error)
- func (n *Namespace) GetAttrSnapshot(inode uint64) (Entry, ChangeCursor, error)
- func (n *Namespace) GetChunk(inode uint64, index int) (Entry, chunk.Ref, error)
- func (n *Namespace) GetDataEntry(inode uint64) (Entry, error)
- func (n *Namespace) GetXattr(ctx context.Context, inode uint64, name string) ([]byte, error)
- func (n *Namespace) IsOrphan(inode uint64) bool
- func (n *Namespace) Link(ctx context.Context, inode, parent uint64, name string) (Entry, error)
- func (n *Namespace) List(parent uint64) ([]Entry, error)
- func (n *Namespace) ListXattr(ctx context.Context, inode uint64) ([]byte, error)
- func (n *Namespace) Load(ctx context.Context) error
- func (n *Namespace) Lookup(parent uint64, name string) (Entry, error)
- func (n *Namespace) LookupAttr(parent uint64, name string) (Entry, error)
- func (n *Namespace) LookupAttrSnapshot(parent uint64, name string) (Entry, ChangeCursor, error)
- func (n *Namespace) Modify(ctx context.Context, inode uint64, change func(*Entry) error) (Entry, error)
- func (n *Namespace) NewWriteStamp() WriteStamp
- func (n *Namespace) OrphanInodes() []uint64
- func (n *Namespace) Path(inode uint64) (string, error)
- func (n *Namespace) ReadChanges(after ChangeCursor, limit int) (ChangePage, error)
- func (n *Namespace) ReadDirNames(ctx context.Context, parent uint64, cursor string, limit int) ([]DirectoryItem, error)
- func (n *Namespace) ReadDirPage(ctx context.Context, parent uint64, cursor string, limit int) ([]Entry, error)
- func (n *Namespace) ReadDirPageInto(ctx context.Context, parent uint64, cursor string, limit int, reuse []Entry) ([]Entry, error)
- func (n *Namespace) ReadDirPageSnapshot(ctx context.Context, parent uint64, cursor string, limit int) ([]Entry, ChangeCursor, error)
- func (n *Namespace) Readlink(inode uint64) (string, error)
- func (n *Namespace) ReapOrphan(ctx context.Context, inode uint64) (Entry, error)
- func (n *Namespace) Remove(ctx context.Context, inode uint64) error
- func (n *Namespace) RemoveXattr(ctx context.Context, inode uint64, name string) error
- func (n *Namespace) Rename(ctx context.Context, inode, newParent uint64, newName string) error
- func (n *Namespace) RenameEntry(ctx context.Context, parent uint64, name string, newParent uint64, ...) (Entry, error)
- func (n *Namespace) RenameEntryFlags(ctx context.Context, parent uint64, name string, newParent uint64, ...) (Entry, error)
- func (n *Namespace) RenameEntryFlagsRetained(ctx context.Context, parent uint64, name string, newParent uint64, ...) (Entry, error)
- func (n *Namespace) RenameEntryFlagsWithPlan(ctx context.Context, parent uint64, name string, newParent uint64, ...) (Entry, error)
- func (n *Namespace) RenameEntryRetained(ctx context.Context, parent uint64, name string, newParent uint64, ...) (Entry, error)
- func (n *Namespace) RenameEntryWithPlan(ctx context.Context, parent uint64, name string, newParent uint64, ...) (Entry, error)
- func (n *Namespace) RenameReplace(ctx context.Context, inode, newParent uint64, newName string) (Entry, error)
- func (n *Namespace) RenameReplaceRetained(ctx context.Context, inode, newParent uint64, newName string) (Entry, error)
- func (n *Namespace) RenameReplaceWithPlan(ctx context.Context, inode, newParent uint64, newName string, ...) (Entry, error)
- func (n *Namespace) ReplaceChunk(ctx context.Context, inode uint64, index int, expected, replacement chunk.Ref) (bool, error)
- func (n *Namespace) ReplayWriteStamp(modTime, changeTime time.Time) WriteStamp
- func (n *Namespace) RestoreAttributes(ctx context.Context, inode uint64, source Entry) (Entry, error)
- func (n *Namespace) RestoreEntry(ctx context.Context, source Entry, parent uint64, name string, replace bool) (restored, displaced Entry, err error)
- func (n *Namespace) SetXattr(ctx context.Context, inode uint64, name string, value []byte, flags uint32) error
- func (n *Namespace) Snapshot() Snapshot
- func (n *Namespace) Store() *EngineStore
- func (n *Namespace) Symlink(ctx context.Context, parent uint64, name, target string, uid, gid uint32) (Entry, error)
- func (n *Namespace) Unlink(ctx context.Context, parent uint64, name string, kind UnlinkKind) (Entry, error)
- func (n *Namespace) UnlinkInode(ctx context.Context, inode uint64) (Entry, error)
- func (n *Namespace) UnlinkInodeRetained(ctx context.Context, inode uint64) (Entry, error)
- func (n *Namespace) UnlinkInodeWithPlan(ctx context.Context, inode uint64, plan MutationPlan) (Entry, error)
- func (n *Namespace) UnlinkRetained(ctx context.Context, parent uint64, name string, kind UnlinkKind) (Entry, error)
- func (n *Namespace) UnlinkWithPlan(ctx context.Context, parent uint64, name string, kind UnlinkKind, ...) (Entry, error)
- func (n *Namespace) Update(ctx context.Context, entry Entry) error
- func (n *Namespace) UpdateAttributes(ctx context.Context, inode uint64, update AttributeUpdate) (Entry, error)
- func (n *Namespace) UpdateFileChunk(ctx context.Context, inode uint64, update FileChunkUpdate) ([]chunk.Ref, error)
- func (n *Namespace) ViewPublished(ctx context.Context, fn func() error) error
- func (n *Namespace) VolumeID() string
- type NativeEngine
- func (e *NativeEngine) Barrier(ctx context.Context) error
- func (e *NativeEngine) Close() error
- func (e *NativeEngine) Compact(ctx context.Context) (result error)
- func (e *NativeEngine) CompactAsync(ctx context.Context) <-chan error
- func (*NativeEngine) Name() string
- func (e *NativeEngine) Snapshot(ctx context.Context, w io.Writer) error
- func (e *NativeEngine) Sync(ctx context.Context) error
- func (e *NativeEngine) Update(ctx context.Context, fn func(Tx) error) error
- func (e *NativeEngine) UpdateAsync(ctx context.Context, fn func(Tx) error) error
- func (e *NativeEngine) View(ctx context.Context, fn func(ReadTx) error) error
- type NativeOptions
- type Options
- type Outbox
- func (o *Outbox) Ack(ctx context.Context, replica string, sequence uint64, hash string) error
- func (o *Outbox) AckCursor(ctx context.Context, replica string) (uint64, error)
- func (o *Outbox) AckSnapshot(ctx context.Context, replica string, info MutationSnapshotInfo) error
- func (o *Outbox) Enqueue(ctx context.Context, event MutationEvent) error
- func (o *Outbox) IssueSnapshot(ctx context.Context, replica string, info MutationSnapshotInfo) error
- func (o *Outbox) PendingSnapshot(ctx context.Context, replica string) (MutationSnapshotInfo, bool, error)
- func (o *Outbox) Prune(ctx context.Context, through uint64, replicas []string, limit int) (uint64, error)
- func (o *Outbox) Read(ctx context.Context, after uint64, limit int) ([]MutationEvent, error)
- func (o *Outbox) State(ctx context.Context) (OutboxState, error)
- type OutboxState
- type PebbleEngine
- func (e *PebbleEngine) Barrier(ctx context.Context) error
- func (e *PebbleEngine) Close() error
- func (e *PebbleEngine) Compact(ctx context.Context) error
- func (*PebbleEngine) Name() string
- func (e *PebbleEngine) Snapshot(ctx context.Context, w io.Writer) error
- func (e *PebbleEngine) Sync(ctx context.Context) error
- func (e *PebbleEngine) Update(ctx context.Context, fn func(Tx) error) error
- func (e *PebbleEngine) View(ctx context.Context, fn func(ReadTx) error) error
- type PebbleOptions
- type RangeReadTx
- type ReadTx
- type RenameFlags
- type Snapshot
- type Snapshotter
- type Store
- type SyncPolicy
- type Syncer
- type Tx
- type UnlinkKind
- type WriteStamp
Constants ¶
const ( MaxChangeJournalCapacity = 65536 MaxChangeReadLimit = 4096 MaxChangeNameBytes = 255 )
const ( DefaultDirectoryPageSize = 256 MaxDirectoryPageSize = 4096 )
const ( MutationEventVersion = 1 // Leave room for JSON/base64 framing inside the existing 64 MiB RPC bound. MaxMutationEventBytes = 32 << 20 MaxMutationEventReadLimit = 4096 MaxMutationPageBytes = 64 << 20 )
const ( MaxHistoryRecordBytes = 64 << 20 // A page may return fewer than Limit records to bound manifest memory. // One larger record is returned alone so callers can always advance. MaxHistoryPageBytes = 8 << 20 )
const ( EngineAuto = "auto" EngineBolt = "bbolt" EnginePebble = "pebble" EngineNative = "native" )
const ( XattrCreate uint32 = 1 XattrReplace uint32 = 2 MaxXattrNameBytes = 255 MaxXattrValueBytes = 65536 MaxXattrListBytes = 65536 MaxXattrCount = 4096 // Values and names are separately bounded: at most 1 MiB of values and // MaxXattrCount names of MaxXattrNameBytes each may belong to one inode. MaxXattrTotalValueBytes = 1 << 20 )
const CurrentVersion = 8
const DefaultBackupPrefix = "metadata/backups"
const MaxSymlinkTarget = 4095
MaxSymlinkTarget is Linux's maximum symlink target in bytes, excluding NUL.
const (
MutationSnapshotVersion = 1
)
Variables ¶
var ( ErrMutationEvent = errors.New("invalid metadata mutation event") ErrMutationEventConflict = errors.New("metadata mutation event conflicts with durable outbox") ErrMutationEventOrder = errors.New("metadata mutation event sequence is out of order") ErrMutationSnapshot = errors.New("metadata replica requires a snapshot") ErrMutationBackpressure = errors.New("metadata outbox capacity exceeded") )
var ( ErrHomeWriter = errors.New("invalid eventual metadata home writer") ErrHomeEpoch = errors.New("metadata home epoch or incarnation mismatch") ErrHomeOwner = errors.New("metadata home writer already owned") )
var ( ErrExists = errors.New("metadata entry already exists") ErrNotDirectory = errors.New("metadata parent is not a directory") ErrIsDirectory = errors.New("metadata entry is a directory") ErrNotEmpty = errors.New("metadata directory is not empty") ErrInvalidName = errors.New("metadata entry name is invalid") ErrRootMutation = errors.New("metadata root cannot be mutated") ErrInvalidMove = errors.New("metadata directory cannot be moved into itself") ErrInvalidEntry = errors.New("metadata entry attributes are invalid") )
var ErrChangeJournalDisabled = errors.New("metadata change journal is disabled")
var ErrHistoryCapacity = errors.New("history metadata limit cannot retain this operation")
var ErrLegacyVolume = errors.New("metadata predates versioned compactfs volume format")
ErrLegacyVolume means chunk refs exist without the versioned volume-format marker. Such a volume cannot be assigned a chunk size or codec registry safely from current defaults.
var ErrLinkDirectory = errors.New("cannot hard link a directory")
var ErrNotFound = errors.New("metadata record not found")
var ErrRenameFlags = errors.New("invalid rename flags")
var ErrReplicationSequence = errors.New("invalid replicated metadata sequence")
ErrReplicationSequence rejects a zero application sequence. Authority adapters translate it into their own sequence error without coupling metadata to them.
var ErrStaleWriteStamp = errors.New("stale metadata write timestamp")
ErrStaleWriteStamp rejects work owned by a replaced or reloaded Namespace.
Functions ¶
func ApplyMutationEvent ¶ added in v1.0.3
func ApplyMutationEvent(ctx context.Context, base Engine, event MutationEvent) error
ApplyMutationEvent applies the edits, generation, sequence and exact event digest in one transaction. Only the next sequence can advance the replica; retries of identical events are idempotent. Every success, including a retry, completes the engine's Sync barrier when available. An Apply loop must not acknowledge an event before this returns nil.
func ApplyReplication ¶ added in v1.0.3
func ApplyReplication(ctx context.Context, base Engine, domain string, seq uint64, payload []byte) error
ApplyReplication atomically commits deterministic edits and the domain replay marker, then forces native durability. The caller serializes ordered Apply calls; retrying an already-applied or older seq never rewrites state.
func CompactBoltFile ¶ added in v1.0.1
CompactBoltFile reclaims free pages into a new file and atomically replaces the original. The caller must hold storage ownership and stop every opener. A pre-compact copy is retained until explicitly removed by the operator.
func CompactMetadata ¶ added in v1.0.1
CompactMetadata uses each engine's native reclaim implementation.
func EngineName ¶ added in v1.0.1
EngineName describes a production engine; injected implementations may return their own name through this optional interface.
func EnsureBackendIdentity ¶ added in v1.0.2
EnsureBackendIdentity binds an array layout to the metadata independently of codec/chunk geometry. Cache hits must not hide a mistakenly selected array. Plain backends use an empty identity. Copies/backups preserve this record.
func EnsureFormat ¶ added in v1.0.1
func EnsureFormat(ctx context.Context, engine Engine, expected fsformat.Volume) (fsformat.Volume, error)
EnsureFormat creates the volume-format record once and verifies every later open against it. The metadata writer lock must already be held. A missing marker with existing chunks is rejected instead of guessing their geometry.
func EnsureNamespaces ¶ added in v1.0.3
EnsureNamespaces atomically appends namespace identities through engine. Existing names/IDs cannot be rebound. Omitted existing entries are retained; callers must either serve all returned namespaces or reject missing config.
func Import ¶ added in v1.0.1
Import validates and builds a new native database beside destination, then publishes it atomically. Existing paths are never overwritten. The caller excludes active writers with the same ownership lock used for mounting.
func InitMutationReplica ¶ added in v1.0.3
func InitMutationReplica(ctx context.Context, base Engine, config HomeConfig) error
InitMutationReplica durably pins a replication-only engine to one Home. Existing namespace state without a replica cursor requires explicit snapshot installation, rather than applying event 1 over unrelated live metadata.
func NamespaceReplacementMutations ¶ added in v1.0.3
func NamespaceReplacementMutations(ctx context.Context, current, selected, namespaceID string, maxBytes, maxPayload int) ([][]byte, error)
NamespaceReplacementMutations returns deterministic normal replication payloads which replace only one namespace. It does not mutate either source. The caller appends them under a fresh, inactive authority generation and only publishes the resulting directory after the complete batch succeeds. maxBytes bounds all returned payloads; maxPayload bounds each WAL entry.
func NormalizeEngine ¶ added in v1.0.1
func PrepareReplication ¶ added in v1.0.3
PrepareReplication captures a transaction as deterministic bucket edits. The caller holds its commit serialization gate until the edits are applied; the callback reads one native view and never updates the base engine itself.
func PutMutationEvent ¶ added in v1.0.3
func PutMutationEvent(tx Tx, event MutationEvent) error
PutMutationEvent appends an event to the durable outbox in the caller's metadata transaction. This is the atomic hook for a future namespace writer: metadata edits and the event can be committed together. It never calls Sync.
func ReadFormat ¶ added in v1.0.1
ReadFormat returns the structural format of an initialized volume. A new or legacy metadata engine reports found=false.
func ReadMutationSequence ¶ added in v1.0.3
ReadMutationSequence is the durable eventual replica cursor. It is separate from strict authority's global sequence, which may legitimately have gaps.
func ReadNamespaces ¶ added in v1.0.3
ReadNamespaces returns the durable display-name to stable-ID catalog. Legacy databases without a catalog contain only the default namespace.
func ReadReplicatedSequence ¶ added in v1.0.3
func ReconcileNamespaces ¶ added in v1.0.3
ReconcileNamespaces replaces display names from a trusted identity catalog. Every persisted stable ID must remain present; removing storage identities is never an implicit consequence of an account rename or configuration change. Static configuration should use EnsureNamespaces, which also fixes names.
func RestoreBackup ¶ added in v1.0.1
func RestoreBackup(ctx context.Context, objects backend.Backend, info BackupInfo, destination Options) (string, error)
RestoreBackup verifies checksum, volume ID and backend dependencies before replacing a stopped native database. The previous database is retained.
func RestoreBoltBackup ¶ added in v1.0.1
func RestoreBoltBackup(ctx context.Context, objects backend.Backend, info BackupInfo, destination string) (string, error)
RestoreBoltBackup restores a selected standalone snapshot after checking its SHA-256, pages, namespace, volume ID, and the existence of its backend objects. An existing database is preserved; the caller holds the storage ownership lock.
func RewriteBoltReferences ¶ added in v1.0.1
func RewriteBoltReferences(ctx context.Context, filename string, fn func(chunk.Ref) (chunk.Ref, error)) error
RewriteBoltReferences rewrites references in an OFFLINE snapshot only. The callback resolves local raw references into immutable backend objects.
func StagedBoltReferences ¶ added in v1.0.1
StagedBoltReferences enumerates local-cache dependencies of a freshly generated snapshot; full page/namespace validation is done before publishing.
func ValidateRenameFlags ¶ added in v1.0.3
func ValidateRenameFlags(flags RenameFlags) error
func ValidateTransferPaths ¶ added in v1.0.1
ValidateTransferPaths rejects equal or nested source/destination paths, resolving existing symlink parents. Call before acquiring maintenance locks.
Types ¶
type AsyncUpdater ¶ added in v1.0.1
AsyncUpdater accepts an atomic metadata mutation without waiting for the storage commit. Callers use Sync as the durability barrier. The function must remain idempotent because a grouped implementation may retry a batch after a different callback fails.
type AttributeUpdate ¶ added in v1.0.3
type AttributeUpdate struct {
Mode *uint32
UID *uint32
GID *uint32
ModTime *time.Time
AccessTime *time.Time
}
AttributeUpdate changes only inode permissions, ownership and access/modify times. Any nonempty request updates ctime, including setting the same value. A nil field preserves its current value; Mode contains permission and special bits only (0o7777), without file-type bits.
type BackupInfo ¶ added in v1.0.1
type BackupOptions ¶ added in v1.0.1
type BackupService ¶ added in v1.0.1
type BackupService struct {
// contains filtered or unexported fields
}
BackupService runs one backup at a time, initially, periodically, and on orderly shutdown. Failures are retried on the next interval and observable.
func StartBackup ¶ added in v1.0.1
func StartBackup(store BackupStore, source Snapshotter, opts BackupOptions) (*BackupService, error)
func (*BackupService) Close ¶ added in v1.0.1
func (s *BackupService) Close() error
func (*BackupService) Stats ¶ added in v1.0.1
func (s *BackupService) Stats() BackupStats
func (*BackupService) Stop ¶ added in v1.0.1
func (s *BackupService) Stop()
Stop ends periodic work without taking the final shutdown snapshot yet.
type BackupStats ¶ added in v1.0.1
type BackupStats struct {
VolumeID string `json:"volume_id"`
Running bool `json:"running"`
Completed uint64 `json:"completed"`
Errors uint64 `json:"errors"`
LastKey string `json:"last_key,omitempty"`
LastSuccess time.Time `json:"last_success,omitempty"`
LastError string `json:"last_error,omitempty"`
}
type BackupStore ¶ added in v1.0.1
type BackupStore struct {
Backend backend.Backend
VolumeID string // required to create/prune; empty lists every volume
Prefix string
Retention int // zero selects seven completed snapshots
TempDir string
}
BackupStore stores independent binary bbolt snapshots. Each object name includes a volume ID and SHA-256; failed uploads never replace a good image. A backend prefix belongs to one active writer per volume.
func (BackupStore) Create ¶ added in v1.0.1
func (b BackupStore) Create(ctx context.Context, source Snapshotter) (BackupInfo, error)
Create generates a local consistent image before uploading, so slow backend transfers do not hold an old bbolt read transaction or prevent page reuse.
func (BackupStore) List ¶ added in v1.0.1
func (b BackupStore) List(ctx context.Context) ([]BackupInfo, error)
type Barrier ¶ added in v1.0.1
Barrier applies previously accepted updates without promising an fsync.
type BoltEngine ¶ added in v1.0.1
type BoltEngine struct {
// contains filtered or unexported fields
}
BoltEngine stores each metadata key as a native bbolt B+tree record. Startup loads the live keyspace directly rather than replaying operation history.
func OpenBolt ¶ added in v1.0.1
func OpenBolt(path string, options BoltOptions) (*BoltEngine, error)
OpenBolt opens or creates an embedded metadata database.
func (*BoltEngine) Barrier ¶ added in v1.0.1
func (e *BoltEngine) Barrier(ctx context.Context) error
Barrier makes accepted updates visible to database readers without fsync. It is cheap on an idle engine; callers must exclude namespace mutations if they need the persistent dentry index and the RAM namespace at one boundary.
func (*BoltEngine) Close ¶ added in v1.0.1
func (e *BoltEngine) Close() error
func (*BoltEngine) Name ¶ added in v1.0.1
func (*BoltEngine) Name() string
func (*BoltEngine) Snapshot ¶ added in v1.0.1
Snapshot writes a transactionally consistent copy of the live database. It first applies queued updates and fsyncs the database, then streams a read transaction to w so callers can upload it without copying a live mmap file.
func (*BoltEngine) Update ¶ added in v1.0.1
Update commits one atomic bbolt transaction. Independent callers are grouped into one writer transaction for a short window so concurrent FUSE creates do not each pay for a B+tree root update.
func (*BoltEngine) UpdateAsync ¶ added in v1.0.1
UpdateAsync queues a mutation for the next grouped bbolt transaction. The namespace publishes its in-memory view after this call succeeds; Sync waits for every queued mutation and drives the database fsync barrier.
type BoltInspection ¶ added in v1.0.1
type BoltInspection struct {
VolumeID string
Format fsformat.Volume
StagedChunks int64
References []chunk.Ref
}
func InspectBoltFile ¶ added in v1.0.1
func InspectBoltFile(ctx context.Context, filename string) (BoltInspection, error)
InspectBoltFile checks bbolt pages, the namespace, format marker, codecs and the volume ID without creating or modifying a database.
func InspectBoltNamespace ¶ added in v1.0.3
func InspectBoltNamespace(ctx context.Context, filename, namespaceID string) (BoltInspection, error)
InspectBoltNamespace validates one namespace view and the complete scope catalog without changing the image. Nondefault views require catalog entries.
type BoltOptions ¶ added in v1.0.1
type BoltOptions struct {
Mode os.FileMode
Timeout time.Duration
SyncPolicy SyncPolicy
SyncInterval time.Duration
InitialMmapSize int
}
BoltOptions controls the embedded B+tree metadata store. SyncInterval has the same durability boundary as LogOptions: commits are written immediately but fsync is coalesced until the interval expires or Sync is called.
type BucketReadTx ¶ added in v1.0.1
BucketReadTx enumerates all bucket names, including extension records which must survive exports even when not interpreted by the current namespace.
type ChangeBatch ¶ added in v1.0.3
type ChangeBatch struct {
Cursor ChangeCursor
Inodes []InodeChange
Dentries []DentryChange
}
ChangeBatch describes one complete logical RAM publication. Inodes contains at most four distinct IDs; Dentries contains at most two actual names. It has no file data, chunk manifests or full Entry snapshots.
type ChangeCursor ¶ added in v1.0.3
ChangeCursor identifies a successful RAM publication in one enabled journal. It is unrelated to durability, WriteStamp, replicated log or RPC sequences. Incarnation changes across Namespace instances or journal replacement; Generation changes when Load replaces RAM or retained history is reset. The zero cursor is returned while journaling is disabled.
type ChangePage ¶ added in v1.0.3
type ChangePage struct {
Head ChangeCursor
Next ChangeCursor
Reset bool
Batches []ChangeBatch
}
ChangePage is an independent bounded copy of journal records after a cursor. Next advances only through returned complete batches; Head is the publication boundary observed under the same RAM read lock. Reset means no batches can be used: discard the dependent cache and obtain fresh attribute/name snapshots. Next equals Head on reset and is not proof that any snapshot was refreshed.
type Compactor ¶
type Compactor interface {
Compact(ctx context.Context) error
CompactAsync(ctx context.Context) <-chan error
}
Compactor is implemented by engines that can asynchronously reclaim old log records without changing the namespace API.
type DentryChange ¶ added in v1.0.3
DentryChange invalidates one actual parent/name, including negative lookups. An inode's canonical Entry.Name is not a substitute for this name.
type DirectoryItem ¶ added in v1.0.3
DirectoryItem is the compact, immutable part of a directory entry. Name is an opaque byte string. Inode attributes must be obtained separately when a protocol needs more than directory names and file types.
type Engine ¶
type Engine interface {
View(ctx context.Context, fn func(ReadTx) error) error
Update(ctx context.Context, fn func(Tx) error) error
Close() error
}
Engine is the extension point for metadata persistence. Implementations may be append-only local logs, embedded databases, or remote transactional stores. Values are binary records; the namespace layer owns their encoding.
func Scope ¶ added in v1.0.3
Scope returns a borrowed namespace view. Every bucket in a nondefault view is length-prefixed with its stable ID. Updates retain the base engine's transaction and replication boundary; Close never closes the base engine. Empty ID preserves the existing default namespace's bucket layout.
type EngineStore ¶
type EngineStore struct {
Engine Engine
}
EngineStore persists namespace entries as independent binary records inside an Engine. It does not serialize the complete namespace as JSON or rewrite a monolithic manifest for every write.
func (*EngineStore) ActiveHistoryJournal ¶ added in v1.0.2
func (s *EngineStore) ActiveHistoryJournal(ctx context.Context) (epoch [16]byte, found bool, err error)
ActiveHistoryJournal prevents opening a volume without its unconsumed log.
func (*EngineStore) Apply ¶
func (s *EngineStore) Apply(ctx context.Context, puts []Entry, deletes []uint64, nextInode uint64) error
Apply writes complete caller-owned inode images, including xattrs. Live Namespace paths use incremental helpers and preserve current xattr records.
func (*EngineStore) BeginHistoryJournal ¶ added in v1.0.2
func (s *EngineStore) BeginHistoryJournal(ctx context.Context, epoch [16]byte) error
BeginHistoryJournal commits the epoch after namespace creation and before the first append. Like ordinary buffered writes it does not add an fsync; the core's local/backend sync must synchronize both metadata and the log.
func (*EngineStore) HistoryJournalCommitted ¶ added in v1.0.2
HistoryJournalCommitted tests the last atomically applied local journal. Only one journal/owner may consume this store; the marker has bounded size.
func (*EngineStore) HistoryStats ¶ added in v1.0.2
func (s *EngineStore) HistoryStats(ctx context.Context) (result HistoryStats, err error)
func (*EngineStore) HistoryVersion ¶ added in v1.0.2
func (s *EngineStore) HistoryVersion(ctx context.Context, id uint64) (version HistoryVersion, err error)
func (*EngineStore) ListHistory ¶ added in v1.0.2
func (s *EngineStore) ListHistory(ctx context.Context, q HistoryQuery) (result []HistoryVersion, err error)
func (*EngineStore) PruneHistory ¶ added in v1.0.2
func (s *EngineStore) PruneHistory(ctx context.Context, retention HistoryRetention) (removed uint64, err error)
PruneHistory expires old records and enforces global metadata capacity. Per-inode limits are applied as each inode is recorded. It never deletes shared backend chunks; backend garbage collection is a separate concern.
func (*EngineStore) RecordHistory ¶ added in v1.0.2
func (s *EngineStore) RecordHistory(ctx context.Context, versions []HistoryVersion, retention HistoryRetention) ([]HistoryVersion, error)
RecordHistory durably appends a group before its destructive mutation. The group and retention/index updates are one transaction. A failure prevents the caller from proceeding; recorded attempts may outlive a failed mutation.
func (*EngineStore) RecordHistoryJournal ¶ added in v1.0.2
func (s *EngineStore) RecordHistoryJournal(ctx context.Context, epoch [16]byte, versions []HistoryVersion, retention HistoryRetention) error
RecordHistoryJournal commits a sealed epoch's versions and marker together. Retrying the same epoch never records duplicate versions.
func (*EngineStore) RestoreOrigin ¶ added in v1.0.2
RestoreOrigin returns an inode's original identity for immutable, inode-bound extension records (for example a block volume's geometry). Restoration records a flattened origin in the same namespace transaction. This is provenance only: it must never redirect live file I/O to an old inode.
func (*EngineStore) WalkHistory ¶ added in v1.0.2
func (s *EngineStore) WalkHistory(ctx context.Context, visit func(HistoryVersion) error) error
WalkHistory validates counters and indexes while streaming retained records. Backups and future reference collectors must include every returned entry.
type Entry ¶
type Entry struct {
Inode uint64
Parent uint64
Name string
// SymlinkTarget is an opaque byte string, persisted inline only for symlinks.
// RPCs transport it separately as bytes to preserve non-UTF8 targets.
SymlinkTarget string `json:"-"`
Kind Kind
// Rdev is a Linux 32-bit encoded device number.
Rdev uint32
// Nlink is derived from dentries, never encoded in the inode record.
Nlink uint32
Mode uint32
UID uint32
GID uint32
Size int64
ModTime time.Time
AccessTime time.Time
ChangeTime time.Time
Chunks []chunk.Ref
// Xattrs is owned only by complete inode images; bounded attribute reads omit it.
// Names and values are opaque bytes, so generic JSON must not encode map keys.
Xattrs map[string][]byte `json:"-"`
}
type FileChunkUpdate ¶
type FileChunkUpdate struct {
Size int64
ModTime time.Time
// WriteStamp orders a foreground write against later metadata mutations.
WriteStamp WriteStamp
// PreserveTimes commits refs/size without treating a clean flush as a write.
PreserveTimes bool
Count int
Index int
Ref chunk.Ref
}
FileChunkUpdate commits attributes and at most one chunk. Index -1 changes attributes/length only. Count bounds the logical manifest after truncation.
type HistoryPatch ¶ added in v1.0.2
HistoryPatch overlays a byte range from a packed immutable data object. Keeping ranges avoids re-encoding the entire window for each small write.
type HistoryQuery ¶ added in v1.0.2
type HistoryQuery struct {
Inode uint64
Path string
After uint64
Limit int
// Recursive includes Path and all saved descendant paths, even after unlink.
Recursive bool
}
HistoryQuery returns an ascending, bounded page strictly after After. Path refers to the saved absolute path, including names no longer present.
type HistoryRetention ¶ added in v1.0.2
HistoryRetention bounds retained version records, not physical backend data. Zero fields select 64 versions per inode, seven days, and 256 MiB of records. Expiration runs on append or explicit PruneHistory, not on reads.
func (HistoryRetention) Normalize ¶ added in v1.0.2
func (r HistoryRetention) Normalize() (HistoryRetention, error)
type HistoryStats ¶ added in v1.0.2
type HistoryVersion ¶ added in v1.0.2
type HistoryVersion struct {
ID uint64
Time time.Time
Operation string
Label string
Path string
Offset int64
Length int64
Entry Entry
Patches []HistoryPatch
}
HistoryVersion is an immutable PRE-operation image, or an explicit checkpoint. Entry and Patches only refer to immutable backend objects. Patches replay writes over Entry.Chunks in order; Entry attributes describe the saved image.
func (HistoryVersion) MarshalBinary ¶ added in v1.0.2
func (v HistoryVersion) MarshalBinary() ([]byte, error)
func (HistoryVersion) References ¶ added in v1.0.2
func (v HistoryVersion) References() []chunk.Ref
References includes base windows and packed delta objects, for backup/GC.
func (*HistoryVersion) UnmarshalBinary ¶ added in v1.0.2
func (v *HistoryVersion) UnmarshalBinary(data []byte) error
type HomeCommit ¶ added in v1.0.3
type HomeCommit struct {
Event MutationEvent
LocalApplied bool
LocalDurable bool
}
HomeCommit describes the local result. Event is returned with a non-nil error when the metadata transaction committed but the durability barrier failed; callers must reconcile this event instead of replaying the mutation.
type HomeConfig ¶ added in v1.0.3
type HomeConfig struct {
Domain string
HomeIncarnation string
HomeEpoch string
// MaxPendingBytes bounds durable replication backlog; zero uses 256 MiB.
MaxPendingBytes uint64
}
HomeConfig identifies one namespace's single eventual-consistency writer. The writer identity is persisted with its sequence so a second process cannot silently reuse the same database as a different Home generation. The enclosing runtime owns the persistent engine lock; process ownership checks supplement that lock and never provide cross-host fencing.
type HomeWriter ¶ added in v1.0.3
type HomeWriter struct {
// contains filtered or unexported fields
}
HomeWriter serializes one namespace's topology mutations, assigns a local sequence, and appends the deterministic replication event in the same Engine transaction. It has no network or Raft dependency. A caller may run the returned event through Outbox delivery after local commit.
func NewHomeWriter ¶ added in v1.0.3
func NewHomeWriter(ctx context.Context, base Engine, config HomeConfig) (*HomeWriter, error)
NewHomeWriter opens an eventual Home on an existing metadata Engine. A persisted writer identity must match exactly; promotion to a new identity requires an explicit snapshot/recovery step instead of an implicit takeover.
func (*HomeWriter) Close ¶ added in v1.0.3
func (h *HomeWriter) Close() error
Close releases this process's Home ownership. It does not close the borrowed metadata Engine; callers retain ownership of that lifecycle.
func (*HomeWriter) Config ¶ added in v1.0.3
func (h *HomeWriter) Config() HomeConfig
func (*HomeWriter) Mutate ¶ added in v1.0.3
func (h *HomeWriter) Mutate(ctx context.Context, fn func(Tx) error) (HomeCommit, error)
Mutate executes one namespace transaction and records the exact bucket edits as a deterministic event. The callback runs under the Home writer's serial admission lock and must not retain the transaction after returning.
func (*HomeWriter) Sequence ¶ added in v1.0.3
func (h *HomeWriter) Sequence() uint64
type ImageInfo ¶ added in v1.0.1
type ImageInfo struct {
Path string `json:"path"`
VolumeID string `json:"volume_id"`
Size int64 `json:"size"`
SHA256 string `json:"sha256"`
}
Images use a binary bbolt container as interchange, regardless of the live engine. All buckets (including extension records), format, ID and chunk refs are preserved. It is not a copy of a live Pebble directory or a JSON dump.
func Export ¶ added in v1.0.1
Export writes and validates a standalone image, then publishes it without overwriting an existing path. A core.FileSystem source normalizes staged raw refs; a bare Engine with such refs is rejected. Data objects stay in backend.
func ExportNamespaceImage ¶ added in v1.0.3
func ExportNamespaceImage(ctx context.Context, source, namespaceID, destination string) (ImageInfo, error)
ExportNamespaceImage publishes a standalone logical image of one namespace. The source must be an immutable checkpoint or an offline database. Global catalog/markers and every other namespace are excluded; histories and unknown local extension buckets are retained. The destination is never overwritten.
func Migrate ¶ added in v1.0.1
Migrate leaves the source untouched and creates a new target engine. Pending local-only chunks are rejected; callers must sync to backend before migrating. The returned Path names the new database; Size/SHA256 describe the interchange image used for conversion, rather than the engine's native files.
type InodeChange ¶ added in v1.0.3
InodeChange invalidates attributes of an inode and therefore all its aliases. Content is conservative: it may also invalidate unchanged content. Removed means the inode was absent after this publication, not just that one name was removed. An open orphan remains present until ReapOrphan. For a directory, Content invalidates directory pages and derived child-name, negative-name and virtual "."/".." mappings, including its changed parent. Consumers must also invalidate any paths derived from a moved directory.
type LogEngine ¶
type LogEngine struct {
// contains filtered or unexported fields
}
LogEngine is an append-only metadata engine. Transactions append one checksummed binary batch to a sequential log and update an in-memory index. Recovery replays complete batches and truncates an incomplete tail left by a crash, so a partially written multi-key transaction is never published.
type LogOptions ¶
type MemoryEngine ¶
type MemoryEngine struct {
// contains filtered or unexported fields
}
MemoryEngine is a transactional in-memory Engine for tests and ephemeral mounts.
func NewMemoryEngine ¶
func NewMemoryEngine() *MemoryEngine
func (*MemoryEngine) Close ¶
func (e *MemoryEngine) Close() error
type MutationEvent ¶ added in v1.0.3
type MutationEvent struct {
Version int `json:"version"`
ID string `json:"id"`
Domain string `json:"domain"`
HomeIncarnation string `json:"home_incarnation,omitempty"`
HomeEpoch string `json:"home_epoch,omitempty"`
Sequence uint64 `json:"sequence"`
Payload []byte `json:"payload"`
Hash string `json:"hash"`
}
MutationEvent is an immutable, deterministic metadata batch for eventual delivery to another metadata engine. ID binds Domain, Home incarnation, epoch and Sequence; Hash covers the exact payload. The payload is produced by PrepareReplication and is never a callback to be re-executed remotely.
func NewHomeMutationEvent ¶ added in v1.0.3
func NewHomeMutationEvent(domain, incarnation, epoch string, sequence uint64, payload []byte) (MutationEvent, error)
NewHomeMutationEvent creates an event bound to one Home identity. The incarnation is part of the event identity so a rebuilt writer cannot reuse a sequence from an older durable generation.
func NewMutationEvent ¶ added in v1.0.3
func NewMutationEvent(domain string, sequence uint64, payload []byte) (MutationEvent, error)
NewMutationEvent validates a deterministic replication payload and assigns its stable event ID and XXH3 payload digest. It does not persist anything.
func (MutationEvent) Validate ¶ added in v1.0.3
func (e MutationEvent) Validate() error
Validate checks identity, size and payload ownership-independent integrity.
type MutationPlan ¶ added in v1.0.3
type MutationPlan struct {
Retain bool
}
MutationPlan carries the ownership decision made by the caller while it holds its topology admission lock. The namespace still validates the dentry, type, destination and all other mutation rules while holding its own mutation lock; Retain only controls whether a final unlink/replace is recorded as an orphan for an active owner.
Keeping this decision in the plan lets closed-file callers avoid a lookup followed by a second lookup inside the topology operation. Callers that cannot prove the inode has no owner must use Retain=true or the existing preflight path.
type MutationPosition ¶ added in v1.0.3
MutationPosition describes the generation and durable event cursor of an eventual replica. Reading it does not synchronize or publish Namespace RAM.
func ReadMutationPosition ¶ added in v1.0.3
type MutationSnapshotInfo ¶ added in v1.0.3
type MutationSnapshotInfo struct {
Version int `json:"version"`
Domain string `json:"domain"`
HomeIncarnation string `json:"home_incarnation"`
HomeEpoch string `json:"home_epoch"`
Sequence uint64 `json:"sequence"`
Records uint64 `json:"records"`
Bytes uint64 `json:"bytes"`
XXH3 string `json:"xxh3_128"`
}
MutationSnapshotInfo identifies a complete canonical namespace image, not a placement/Auth checkpoint or a promotable Meta. Bytes includes the complete stream. XXH3 covers the header, records and footer counts/length, excluding only the final 16-byte digest. It provides integrity, not authentication.
func CaptureMutationSnapshot ¶ added in v1.0.3
func CaptureMutationSnapshot(ctx context.Context, source Engine, expected HomeConfig, w io.Writer, limits MutationSnapshotLimits) (MutationSnapshotInfo, error)
CaptureMutationSnapshot writes a deterministic binary record stream from one consistent View, including that View's Home marker. The caller must exclude all writers for Sync through capture, stop exports and drain backend writes; this function alone is not an online checkpoint gate. Source and writer are borrowed and remain open. Source Sync failures also return ErrHomeUnavailable. Partial output is unusable and must be discarded on every error.
func ReadMutationSnapshotReceipt ¶ added in v1.0.3
func ReadMutationSnapshotReceipt(ctx context.Context, base Engine, domain string) (info MutationSnapshotInfo, found bool, err error)
ReadMutationSnapshotReceipt reads the installed image identity. It does not Sync and cannot independently prove durability; an RPC advertiser must first complete the engine's Sync barrier. Subsequent S+1 mutations keep this receipt.
func (MutationSnapshotInfo) Validate ¶ added in v1.0.3
func (info MutationSnapshotInfo) Validate() error
Validate checks the canonical identity and bounded framing metadata of a complete mutation snapshot. It cannot authenticate the stream or prove that a replica installed it; those are the transport owner's responsibilities.
type MutationSnapshotInstallResult ¶ added in v1.0.3
type MutationSnapshotInstallResult struct {
Info MutationSnapshotInfo
Published bool
Durable bool
}
MutationSnapshotInstallResult distinguishes publication from its durability. An error after rename can leave Published=true, Durable=false. The caller must retain that destination and inspect/recover it, rather than retry over it.
func InstallMutationSnapshot ¶ added in v1.0.3
func InstallMutationSnapshot(ctx context.Context, r io.Reader, expected HomeConfig, destination Options, limits MutationSnapshotLimits) (MutationSnapshotInstallResult, error)
InstallMutationSnapshot builds and validates a private database, persists its replica cursor and receipt, then atomically publishes only a new destination. It never replaces an existing target or opens file/placement/Auth services. The caller holds destination's writer lock throughout installation and later startup. The reader is borrowed and is never closed. EOF is required after the checksum. Use Published/Durable even when err is non-nil.
type MutationSnapshotLimits ¶ added in v1.0.3
type MutationSnapshotLimits struct {
MaxBytes int64
MaxRecords uint64
MaxBuckets int
MaxRecordBytes uint64
}
MutationSnapshotLimits bounds both the stream and its private installation. Zero fields select 1 GiB, 1,000,000 records/decoded manifest slots, 4096 buckets, and one maximum native KV record. Nonzero values may raise aggregate limits; hard ceilings are 1 TiB, min(2^24, MaxInt/256) records/slots and 65536 business buckets. The record/slot ceiling also bounds decoder allocation arithmetic. a record can never exceed native's 65535-byte bucket, 1 MiB key and 64 MiB value. These are metadata bounds, independent of the 32 MiB mutation event limit.
type Namespace ¶
type Namespace struct {
// contains filtered or unexported fields
}
Namespace is the in-memory inode index backed by a transactional Engine. Lookups and directory listings do not hit the backend; mutations persist only changed records through a grouped engine update before publishing the new in-memory mapping.
func (*Namespace) AttrWithWrite ¶ added in v1.0.3
AttrWithWrite returns a bounded attribute snapshot combined with uncommitted foreground size/times. It never clones or exposes a chunk manifest. Comparing each time under the same read lock preserves a later explicit metadata change.
func (*Namespace) CheckRemoveXattr ¶ added in v1.0.3
func (*Namespace) CheckSetXattr ¶ added in v1.0.3
func (n *Namespace) CheckSetXattr(ctx context.Context, inode uint64, name string, value []byte, flags uint32) error
CheckSetXattr performs the same validation as SetXattr without publishing, allocating a timestamp or touching the engine. The mutation rechecks it.
func (*Namespace) ClearChunks ¶
func (n *Namespace) ClearChunks(ctx context.Context, inode uint64, first, count int) ([]chunk.Ref, error)
ClearChunks atomically removes chunk mappings without changing file size. It returns retired references only after the metadata transaction commits. Content-addressed backend objects may still be shared by other files.
func (*Namespace) CreateDevice ¶ added in v1.0.3
func (n *Namespace) CreateDevice(ctx context.Context, parent uint64, name string, kind Kind, mode, uid, gid, rdev uint32) (Entry, error)
CreateDevice publishes the device number and name in one transaction.
func (*Namespace) DirectoryEntryCount ¶ added in v1.0.3
DirectoryEntryCount returns a current directory size hint without materializing entries. It is not a snapshot and must not replace paged traversal.
func (*Namespace) DisableChangeJournal ¶ added in v1.0.3
func (n *Namespace) DisableChangeJournal()
DisableChangeJournal releases retained history. A later enable creates a new incarnation. It does not stop exports or change any metadata read guarantees.
func (*Namespace) EnableChangeJournal ¶ added in v1.0.3
func (n *Namespace) EnableChangeJournal(capacity int) (ChangeCursor, error)
EnableChangeJournal opts this Namespace into an ephemeral, fixed-capacity invalidation ring. The default disabled path has no ring or goroutine. Repeating the same capacity preserves the journal; changing capacity replaces its incarnation and invalidates every old cursor. Callers own activation and must coordinate Disable with other readers; there are no subscriber ACKs.
func (*Namespace) GetAttrSnapshot ¶ added in v1.0.3
func (n *Namespace) GetAttrSnapshot(inode uint64) (Entry, ChangeCursor, error)
GetAttrSnapshot returns only Namespace's accepted RAM attributes and their cursor under one lock. Chunks is nil. It does not include core handle/staged pending size/times, establish an engine/quorum barrier, or promise durability. A negative query also returns the observed cursor; disabled journals return the zero cursor. An asynchronous event stream alone cannot authorize strongly consistent client cache reads.
func (*Namespace) GetChunk ¶
GetChunk returns inode attributes and one reference without copying the full file manifest. The returned Entry has no Chunks; negative indexes return attributes only. Hot raw-cache range reads should use this bounded lookup.
func (*Namespace) GetDataEntry ¶ added in v1.0.3
GetDataEntry returns an owned manifest without unrelated xattr payloads. Writers must publish through methods which preserve current inode xattrs; use Get for complete history, restore or external-version images.
func (*Namespace) GetXattr ¶ added in v1.0.3
GetXattr returns caller-owned bytes. A present empty value is distinct from ENODATA; inode absence remains ErrNotFound. No manifest is read or copied.
func (*Namespace) Link ¶ added in v1.0.3
Link publishes an additional name for one non-directory inode.
func (*Namespace) ListXattr ¶ added in v1.0.3
ListXattr returns a byte-sorted, NUL-delimited name list. The list may exceed Linux's response limit even when individual attributes fit storage limits.
func (*Namespace) LookupAttr ¶ added in v1.0.1
LookupAttr resolves one dentry without copying the file's chunk manifest. Use Lookup when the caller also needs the file's content references.
func (*Namespace) LookupAttrSnapshot ¶ added in v1.0.3
LookupAttrSnapshot is the point-name equivalent of GetAttrSnapshot, preserving the actual requested dentry and returning a cursor even for ErrNotFound.
func (*Namespace) Modify ¶
func (n *Namespace) Modify(ctx context.Context, inode uint64, change func(*Entry) error) (Entry, error)
Modify changes the latest inode atomically. Background chunk replacement must not overwrite a concurrent write, rename, chmod, or truncation. The callback owns an independent Entry and must not retain it after returning. It must only inspect or edit that entry, without reentering namespace mutations or core file operations while the mutation lock is held.
func (*Namespace) NewWriteStamp ¶ added in v1.0.3
func (n *Namespace) NewWriteStamp() WriteStamp
NewWriteStamp allocates a timestamp without changing or persisting an inode.
func (*Namespace) OrphanInodes ¶ added in v1.0.3
OrphanInodes returns only detached inode IDs, without copying live manifests.
func (*Namespace) Path ¶ added in v1.0.2
Path returns the current absolute namespace path without copying manifests.
func (*Namespace) ReadChanges ¶ added in v1.0.3
func (n *Namespace) ReadChanges(after ChangeCursor, limit int) (ChangePage, error)
ReadChanges returns immediately; stalled readers never delay a publisher. A foreign, reset, future or overwritten cursor returns Reset rather than a partial history. Disable returns Reset with ErrChangeJournalDisabled.
func (*Namespace) ReadDirNames ¶ added in v1.0.3
func (n *Namespace) ReadDirNames(ctx context.Context, parent uint64, cursor string, limit int) ([]DirectoryItem, error)
ReadDirNames returns at most limit compact entries strictly after cursor in raw-byte name order. It shares ReadDirPage's accepted RAM visibility and independent page/rewind semantics, without copying mutable inode attributes or waiting for the engine. An empty page means EOF.
func (*Namespace) ReadDirPage ¶ added in v1.0.1
func (n *Namespace) ReadDirPage(ctx context.Context, parent uint64, cursor string, limit int) ([]Entry, error)
ReadDirPage returns at most limit attributes ordered by name, strictly after cursor. Returned entries never contain chunk manifests. Use the last name as the next cursor; an empty page means EOF. Each page is consistent, but pages do not hold a long-lived directory snapshot: concurrent changes may appear in later pages, and names inserted behind the cursor need a rewind to be seen.
func (*Namespace) ReadDirPageInto ¶ added in v1.0.3
func (n *Namespace) ReadDirPageInto(ctx context.Context, parent uint64, cursor string, limit int, reuse []Entry) ([]Entry, error)
ReadDirPageInto is the bounded attribute page with caller-owned reuse. The caller must not retain or mutate the returned backing array after the next call using the same buffer. It has the same cursor, lock, and visibility semantics as ReadDirPage; the buffer only removes per-page slice allocation.
func (*Namespace) ReadDirPageSnapshot ¶ added in v1.0.3
func (n *Namespace) ReadDirPageSnapshot(ctx context.Context, parent uint64, cursor string, limit int) ([]Entry, ChangeCursor, error)
ReadDirPageSnapshot returns the same bounded page and its accepted Namespace RAM cursor under one short read lock. It reads the Namespace's ordered RAM index without waiting for engine admission, a Barrier or persistence. This is not a distributed quorum read barrier. Pages remain independent snapshots.
func (*Namespace) ReapOrphan ¶ added in v1.0.3
ReapOrphan removes only an already detached inode. Its former name may have been reused, so reaping never touches the dentry index.
func (*Namespace) RemoveXattr ¶ added in v1.0.3
func (*Namespace) RenameEntry ¶ added in v1.0.3
func (*Namespace) RenameEntryFlags ¶ added in v1.0.3
func (n *Namespace) RenameEntryFlags(ctx context.Context, parent uint64, name string, newParent uint64, newName string, flags RenameFlags) (Entry, error)
RenameEntryFlags moves or exchanges names in one namespace transaction.
func (*Namespace) RenameEntryFlagsRetained ¶ added in v1.0.3
func (n *Namespace) RenameEntryFlagsRetained(ctx context.Context, parent uint64, name string, newParent uint64, newName string, flags RenameFlags) (Entry, error)
RenameEntryFlagsRetained preserves an overwritten last-link target for owners. Exchange never detaches either inode, so it requires no orphan marker.
func (*Namespace) RenameEntryFlagsWithPlan ¶ added in v1.0.3
func (n *Namespace) RenameEntryFlagsWithPlan(ctx context.Context, parent uint64, name string, newParent uint64, newName string, flags RenameFlags, plan MutationPlan) (Entry, error)
RenameEntryFlagsWithPlan validates and commits one flagged rename while holding the namespace mutation lock. The caller supplies only the owner retention decision; all dentry and flag checks remain in this package.
func (*Namespace) RenameEntryRetained ¶ added in v1.0.3
func (*Namespace) RenameEntryWithPlan ¶ added in v1.0.3
func (n *Namespace) RenameEntryWithPlan(ctx context.Context, parent uint64, name string, newParent uint64, newName string, plan MutationPlan) (Entry, error)
RenameEntryWithPlan validates and commits one dentry rename while holding the namespace mutation lock. The source and destination are checked by renameEntryLocked; no caller-side destination lookup is required.
func (*Namespace) RenameReplace ¶
func (n *Namespace) RenameReplace(ctx context.Context, inode, newParent uint64, newName string) (Entry, error)
RenameReplace moves the canonical name, returning only an inode whose last name was replaced. Other aliases retain both their inode and data.
func (*Namespace) RenameReplaceRetained ¶ added in v1.0.3
func (*Namespace) RenameReplaceWithPlan ¶ added in v1.0.3
func (n *Namespace) RenameReplaceWithPlan(ctx context.Context, inode, newParent uint64, newName string, plan MutationPlan) (Entry, error)
RenameReplaceWithPlan moves a canonical name while using the caller's owner-retention plan. The source and destination are validated in one namespace mutation critical section.
func (*Namespace) ReplaceChunk ¶
func (n *Namespace) ReplaceChunk(ctx context.Context, inode uint64, index int, expected, replacement chunk.Ref) (bool, error)
ReplaceChunk atomically replaces exactly one expected reference. It leaves attributes and other chunk slots untouched, including concurrent changes.
func (*Namespace) ReplayWriteStamp ¶ added in v1.0.3
func (n *Namespace) ReplayWriteStamp(modTime, changeTime time.Time) WriteStamp
ReplayWriteStamp assigns recovery scan order to the exact journaled times. Recovery must quiesce exports and process records in their original order.
func (*Namespace) RestoreAttributes ¶ added in v1.0.3
func (n *Namespace) RestoreAttributes(ctx context.Context, inode uint64, source Entry) (Entry, error)
RestoreAttributes restores a complete historical attribute image, including xattrs, while preserving the current inode identity, names and file data. Ordinary Update/Modify deliberately cannot replace current xattrs.
func (*Namespace) RestoreEntry ¶ added in v1.0.2
func (n *Namespace) RestoreEntry(ctx context.Context, source Entry, parent uint64, name string, replace bool) (restored, displaced Entry, err error)
RestoreEntry atomically publishes a complete image under a fresh inode. Existing handles cannot write through the restored inode. The caller must quiesce exports before replacement and account for the returned displaced file.
func (*Namespace) SetXattr ¶ added in v1.0.3
func (n *Namespace) SetXattr(ctx context.Context, inode uint64, name string, value []byte, flags uint32) error
SetXattr atomically stores one value and ctime. Namespace strings and byte slices are immutable after publication; only the new value is copied here.
func (*Namespace) Store ¶
func (n *Namespace) Store() *EngineStore
func (*Namespace) Symlink ¶ added in v1.0.3
func (n *Namespace) Symlink(ctx context.Context, parent uint64, name, target string, uid, gid uint32) (Entry, error)
Symlink atomically creates the inline target with its name and inode. A generic Create cannot publish a symlink without a target for later filling.
func (*Namespace) Unlink ¶ added in v1.0.3
func (n *Namespace) Unlink(ctx context.Context, parent uint64, name string, kind UnlinkKind) (Entry, error)
Unlink removes exactly one name. Only the last link returns a removed inode.
func (*Namespace) UnlinkInode ¶ added in v1.0.3
UnlinkInode removes the current canonical name atomically with its lookup.
func (*Namespace) UnlinkInodeRetained ¶ added in v1.0.3
func (*Namespace) UnlinkInodeWithPlan ¶ added in v1.0.3
func (n *Namespace) UnlinkInodeWithPlan(ctx context.Context, inode uint64, plan MutationPlan) (Entry, error)
UnlinkInodeWithPlan removes the current canonical name while using the caller's owner-retention plan. Source validation and the topology commit remain one namespace mutation operation.
func (*Namespace) UnlinkRetained ¶ added in v1.0.3
func (n *Namespace) UnlinkRetained(ctx context.Context, parent uint64, name string, kind UnlinkKind) (Entry, error)
UnlinkRetained removes a name while retaining a last-link inode for its owner. The caller must serialize new opens and eventually call ReapOrphan.
func (*Namespace) UnlinkWithPlan ¶ added in v1.0.3
func (n *Namespace) UnlinkWithPlan(ctx context.Context, parent uint64, name string, kind UnlinkKind, plan MutationPlan) (Entry, error)
UnlinkWithPlan validates and commits one unlink while holding the namespace mutation lock. The target is looked up exactly once.
func (*Namespace) UpdateAttributes ¶ added in v1.0.3
func (n *Namespace) UpdateAttributes(ctx context.Context, inode uint64, update AttributeUpdate) (Entry, error)
UpdateAttributes updates the latest inode without copying or diffing its manifest. It preserves file data and namespace topology, and returns inode attributes with Chunks nil. As with other namespace mutations, asynchronous engines acknowledge queue acceptance; Sync establishes durability.
func (*Namespace) UpdateFileChunk ¶
func (n *Namespace) UpdateFileChunk(ctx context.Context, inode uint64, update FileChunkUpdate) ([]chunk.Ref, error)
UpdateFileChunk avoids copying and diffing a growing file manifest for each chunk. Retired references are returned only after the transaction commits.
func (*Namespace) ViewPublished ¶ added in v1.0.3
ViewPublished samples external state after every admitted Namespace mutation has finished publishing its RAM indexes. It excludes new mutations for fn's lifetime, but does not hold the RAM read lock or add work to ordinary reads. fn may read Namespace state and its Engine cursor; it must not mutate this Namespace, re-enter ViewPublished, or retain the publication boundary. Engine durability and health remain the callback's responsibility.
type NativeEngine ¶ added in v1.0.3
type NativeEngine struct {
// contains filtered or unexported fields
}
NativeEngine stores binary bucket records in a checksummed WAL and an immutable ordered RAM tree. Namespace still has its own RAM inode indexes. A writer is serialized across append/fsync/compaction, but readers capture one tree root under a short lock and never hold a RAM lock across file I/O. Async admission is bounded; Sync and Barrier drain accepted work in order.
func OpenNative ¶ added in v1.0.3
func OpenNative(directory string, options NativeOptions) (*NativeEngine, error)
func (*NativeEngine) Barrier ¶ added in v1.0.3
func (e *NativeEngine) Barrier(ctx context.Context) error
func (*NativeEngine) Close ¶ added in v1.0.3
func (e *NativeEngine) Close() error
func (*NativeEngine) Compact ¶ added in v1.0.3
func (e *NativeEngine) Compact(ctx context.Context) (result error)
Compact blocks other writers while it streams a new checkpoint. Existing and new readers continue using immutable RAM roots. There is no auto-compact: the long writer pause is an explicit maintenance decision.
func (*NativeEngine) CompactAsync ¶ added in v1.0.3
func (e *NativeEngine) CompactAsync(ctx context.Context) <-chan error
func (*NativeEngine) Name ¶ added in v1.0.3
func (*NativeEngine) Name() string
func (*NativeEngine) Update ¶ added in v1.0.3
Update returns the result of a committed callback. Cancellation while waiting for queue capacity rejects it; after enqueue it waits for the worker decision. The worker can reject a canceled callback before append starts, but accepted disk I/O must finish without making a committed mutation look canceled.
func (*NativeEngine) UpdateAsync ¶ added in v1.0.3
UpdateAsync transfers ownership of an idempotent callback on queue admission. Cancellation after admission cannot discard an edit already visible in the Namespace RAM view. Callback or I/O failure poisons the engine and its barriers.
type NativeOptions ¶ added in v1.0.3
type NativeOptions struct {
SyncPolicy SyncPolicy
SyncInterval time.Duration
}
NativeOptions selects the durability boundary of the native sequential WAL. SyncInterval defaults to 50ms; ordinary Update does not promise an fsync.
type Options ¶ added in v1.0.1
type Options struct {
Path string
Engine string
CacheBytes int64 // Pebble block cache, not total RSS; zero selects 128 MiB
SyncPolicy SyncPolicy
SyncInterval time.Duration
}
Options selects an on-disk engine. Auto recognizes an existing file as bbolt and native/Pebble directories by format; a missing path defaults to bbolt. Selection never converts existing data. Use Migrate or Import for conversion.
type Outbox ¶ added in v1.0.3
type Outbox struct {
// contains filtered or unexported fields
}
Outbox owns no engine and never closes it. Enqueue, Read and Ack are safe to use with all Engine implementations. Sync, when provided by the engine, is called after writes; callers must treat a Sync error as an uncertain result and retry the same event ID.
func (*Outbox) Ack ¶ added in v1.0.3
Ack advances one replica's durable cursor after checking the event's exact digest. Events remain in the outbox until every configured replica has acknowledged them and the owner explicitly prunes them. This is required because one event is delivered to multiple asynchronous replicas.
func (*Outbox) AckCursor ¶ added in v1.0.3
AckCursor returns the last event acknowledged by replica. A missing cursor is zero, which is also the initial replication position.
func (*Outbox) AckSnapshot ¶ added in v1.0.3
AckSnapshot advances a peer's ACK only for its exact, durably issued image. A target status sequence alone is never sufficient. The caller verifies the authenticated durable install receipt before invoking this method. ACK and offer confirmation share one transaction. Confirmed Info is retained so a lost reply or failed source Sync can retry without an event record at S. Every success, including an identical retry after later event ACKs, Syncs.
func (*Outbox) Enqueue ¶ added in v1.0.3
func (o *Outbox) Enqueue(ctx context.Context, event MutationEvent) error
Enqueue persists one event. Re-enqueuing the same ID and bytes is idempotent; a sequence reused with different bytes is rejected.
func (*Outbox) IssueSnapshot ¶ added in v1.0.3
func (o *Outbox) IssueSnapshot(ctx context.Context, replica string, info MutationSnapshotInfo) error
IssueSnapshot durably authorizes one peer's exact snapshot receipt. The caller must have captured/verified the complete image, serialize that peer's event delivery and retain its S+1 suffix until acknowledgement. A newer offer supersedes the previous one. The same sequence may only reuse identical Info; issuing that same Info again makes it pending again, allowing a lost disk to be rebuilt even when Home has made no new mutation. No ACK is advanced here.
func (*Outbox) PendingSnapshot ¶ added in v1.0.3
func (o *Outbox) PendingSnapshot(ctx context.Context, replica string) (MutationSnapshotInfo, bool, error)
PendingSnapshot returns a durably issued, unconfirmed offer. It Syncs after reading so even a concurrently issued RAM offer is covered by that barrier. Failed barriers never expose an uncertain offer. Confirmed offers remain stored for AckSnapshot retries, but are not pending. The returned Info owns all its data.
func (*Outbox) Prune ¶ added in v1.0.3
func (o *Outbox) Prune(ctx context.Context, through uint64, replicas []string, limit int) (uint64, error)
Prune deletes at most limit events, only when all named replicas have durably acknowledged through. The runtime supplies its complete configured replica set; an empty set cannot authorize deleting replay history.
type OutboxState ¶ added in v1.0.3
OutboxState reports pending encoded bytes and the retained replay interval. Head includes already-pruned events; TrimmedThrough requires snapshot recovery for any replica whose cursor precedes it.
type PebbleEngine ¶ added in v1.0.1
type PebbleEngine struct {
// contains filtered or unexported fields
}
PebbleEngine implements the same bucket transaction contract as BoltEngine. Namespace still owns its current RAM index. This engine is separate from the standalone low-memory inode/dentry research Store in meta/pebble.
func OpenPebble ¶ added in v1.0.1
func OpenPebble(directory string, options PebbleOptions) (*PebbleEngine, error)
func (*PebbleEngine) Barrier ¶ added in v1.0.1
func (e *PebbleEngine) Barrier(ctx context.Context) error
Barrier needs no queue flush: every accepted Update is already committed.
func (*PebbleEngine) Close ¶ added in v1.0.1
func (e *PebbleEngine) Close() error
func (*PebbleEngine) Compact ¶ added in v1.0.1
func (e *PebbleEngine) Compact(ctx context.Context) error
func (*PebbleEngine) Name ¶ added in v1.0.1
func (*PebbleEngine) Name() string
func (*PebbleEngine) Snapshot ¶ added in v1.0.1
Snapshot uses the common binary interchange image, independent of the active engine. Existing backup normalization and staged-reference pinning apply.
type PebbleOptions ¶ added in v1.0.1
type PebbleOptions struct {
CacheBytes int64
SyncPolicy SyncPolicy
SyncInterval time.Duration
}
type RangeReadTx ¶ added in v1.0.1
type RangeReadTx interface {
Range(bucket, prefix, after []byte, fn func(key, value []byte) (bool, error)) error
}
RangeReadTx can seek directly past an exclusive key within a bucket prefix. Keys and values are borrowed only for the duration of fn. A false result stops iteration without treating a full page as a storage error.
type ReadTx ¶
type ReadTx interface {
Get(bucket, key []byte) ([]byte, error)
ForEach(bucket, prefix []byte, fn func(key, value []byte) error) error
}
ReadTx is a read-only transaction over named binary buckets. A transaction is valid only during its Engine callback and must not be retained or used from concurrent goroutines. Get returns owned bytes; ForEach arguments are borrowed for that invocation of its callback.
type RenameFlags ¶ added in v1.0.3
type RenameFlags uint32
RenameFlags uses the Linux renameat2 bit values at the shared API boundary.
const ( RenameNoReplace RenameFlags = 1 RenameExchange RenameFlags = 2 )
type Snapshot ¶
type Snapshot struct {
Version int
NextInode uint64
Entries map[uint64]Entry
// Dentries includes every name, including hard-link aliases. Nil permits
// callers constructing a single-name image to use Entry.Parent/Name.
Dentries []Dentry
// Orphans retain unlinked open inodes and their last absolute history path.
Orphans map[uint64]string
}
func NewSnapshot ¶
func NewSnapshot() Snapshot
type Snapshotter ¶ added in v1.0.1
Snapshotter writes a consistent metadata image. Remote recovery images must contain backend references only; local-only raw references are rejected.
type Store ¶
type Store interface {
Load(ctx context.Context) (Snapshot, error)
Save(ctx context.Context, snapshot Snapshot) error
}
Store is the high-level metadata persistence contract used by the daemon.
type SyncPolicy ¶
type SyncPolicy uint8
const ( SyncAlways SyncPolicy = iota + 1 SyncInterval SyncNever )
type Tx ¶
Tx is an atomic read/write metadata transaction with the same lifetime as ReadTx. Keep Put inputs unchanged until the Engine callback returns.
type UnlinkKind ¶ added in v1.0.3
type UnlinkKind uint8
UnlinkKind specifies which current dentry type a deletion may remove. It is checked again under the namespace mutation lock, rather than trusting an earlier lookup by a caller.
const ( UnlinkAny UnlinkKind = iota UnlinkNonDirectory UnlinkDirectory )
func (UnlinkKind) Check ¶ added in v1.0.3
func (kind UnlinkKind) Check(target Kind) error
Check checks a current inode kind against the deletion requirement.
func (UnlinkKind) Validate ¶ added in v1.0.3
func (kind UnlinkKind) Validate() error
Validate rejects unknown deletion requirements without changing metadata.
type WriteStamp ¶ added in v1.0.3
type WriteStamp struct {
ModTime time.Time
ChangeTime time.Time
// contains filtered or unexported fields
}
WriteStamp identifies one foreground data mutation. Its sequence is local to this Namespace; it is deliberately absent from persisted inode attributes. A delayed chunk publication may commit its reference without undoing newer chmod, utimens, link or directory operations.
Source Files
¶
- attributes.go
- backup.go
- bolt.go
- change.go
- create.go
- device.go
- directory.go
- directory_index.go
- engine.go
- eventual.go
- eventual_home.go
- eventual_snapshot.go
- eventual_snapshot_ack.go
- eventual_snapshot_validate.go
- format.go
- history.go
- install_linux.go
- links.go
- log.go
- maintenance.go
- memory.go
- namespace_transfer.go
- native.go
- native_format.go
- native_queue.go
- native_tree.go
- open.go
- orphan.go
- pebble.go
- publication.go
- punch.go
- rename_flags.go
- replication.go
- scope.go
- store.go
- symlink.go
- times.go
- transfer.go
- unlink.go
- xattr.go