Documentation
¶
Index ¶
- Constants
- Variables
- 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 Import(ctx context.Context, image string, destination Options) error
- func NormalizeEngine(engine string) (string, error)
- func ReadFormat(ctx context.Context, engine Engine) (volume fsformat.Volume, found bool, err 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 ValidateTransferPaths(source, destination string) error
- type AsyncUpdater
- 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 Compactor
- 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 ImageInfo
- 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 Namespace
- 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) Get(inode uint64) (Entry, error)
- func (n *Namespace) GetChunk(inode uint64, index int) (Entry, chunk.Ref, error)
- func (n *Namespace) List(parent uint64) ([]Entry, 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) Modify(ctx context.Context, inode uint64, change func(*Entry) error) (Entry, error)
- func (n *Namespace) Path(inode uint64) (string, error)
- func (n *Namespace) ReadDirPage(ctx context.Context, parent uint64, cursor string, limit int) ([]Entry, error)
- func (n *Namespace) Remove(ctx context.Context, inode uint64) error
- func (n *Namespace) Rename(ctx context.Context, inode, newParent uint64, newName string) error
- func (n *Namespace) RenameReplace(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) RestoreEntry(ctx context.Context, source Entry, parent uint64, name string, replace bool) (restored, displaced Entry, err error)
- func (n *Namespace) Snapshot() Snapshot
- func (n *Namespace) Store() *EngineStore
- func (n *Namespace) Update(ctx context.Context, entry Entry) error
- func (n *Namespace) UpdateFileChunk(ctx context.Context, inode uint64, update FileChunkUpdate) ([]chunk.Ref, error)
- func (n *Namespace) VolumeID() string
- type Options
- 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 Snapshot
- type Snapshotter
- type Store
- type SyncPolicy
- type Syncer
- type Tx
Constants ¶
const ( DefaultDirectoryPageSize = 256 MaxDirectoryPageSize = 4096 )
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" )
const CurrentVersion = 3
const DefaultBackupPrefix = "metadata/backups"
Variables ¶
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") )
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 ErrNotFound = errors.New("metadata record not found")
Functions ¶
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 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 NormalizeEngine ¶ added in v1.0.1
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 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 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 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. Namespace holds its mutation lock while crossing this boundary for paging.
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
func InspectBoltFile ¶ added in v1.0.1
func InspectBoltFile(ctx context.Context, filename string) (result BoltInspection, err error)
InspectBoltFile checks bbolt pages, the namespace, format marker, codecs and the volume ID without creating or modifying a database.
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 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 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.
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 appends only the changed records. It is the write path used by the FUSE namespace; unchanged entries are never rewritten.
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 FileChunkUpdate ¶
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 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 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 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 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) 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) 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) 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) 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.
func (*Namespace) Path ¶ added in v1.0.2
Path returns the current absolute namespace path without copying manifests.
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 database snapshot: concurrent changes may appear in later pages, and names inserted behind the cursor need a rewind to be seen.
func (*Namespace) RenameReplace ¶
func (n *Namespace) RenameReplace(ctx context.Context, inode, newParent uint64, newName string) (Entry, error)
RenameReplace atomically moves an entry, replacing an existing compatible target. It returns the removed entry, or an entry with Inode zero if absent. The caller retires removed references after the transaction is durable.
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) 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) Store ¶
func (n *Namespace) Store() *EngineStore
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.
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 a directory as Pebble; a missing path defaults to bbolt. Engine selection never converts existing data. Use Migrate or Import for conversion.
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.
type Snapshot ¶
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 )