meta

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 28 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultDirectoryPageSize = 256
	MaxDirectoryPageSize     = 4096
)
View Source
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
)
View Source
const (
	EngineAuto   = "auto"
	EngineBolt   = "bbolt"
	EnginePebble = "pebble"
)
View Source
const CurrentVersion = 3
View Source
const DefaultBackupPrefix = "metadata/backups"

Variables

View Source
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")
)
View Source
var ErrHistoryCapacity = errors.New("history metadata limit cannot retain this operation")
View Source
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.

View Source
var ErrNotFound = errors.New("metadata record not found")

Functions

func CompactBoltFile added in v1.0.1

func CompactBoltFile(ctx context.Context, filename string) (previous string, err error)

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

func CompactMetadata(ctx context.Context, options Options) (string, error)

CompactMetadata uses each engine's native reclaim implementation.

func EngineName added in v1.0.1

func EngineName(engine Engine) string

EngineName describes a production engine; injected implementations may return their own name through this optional interface.

func EnsureBackendIdentity added in v1.0.2

func EnsureBackendIdentity(ctx context.Context, engine Engine, identity string) error

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

func Import(ctx context.Context, image string, destination Options) error

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 NormalizeEngine(engine string) (string, error)

func ReadFormat added in v1.0.1

func ReadFormat(ctx context.Context, engine Engine) (volume fsformat.Volume, found bool, err error)

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

func StagedBoltReferences(ctx context.Context, filename string) ([]chunk.Ref, error)

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

func ValidateTransferPaths(source, destination string) error

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

type AsyncUpdater interface {
	UpdateAsync(ctx context.Context, fn func(Tx) error) error
}

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 BackupInfo struct {
	Key      string    `json:"key"`
	VolumeID string    `json:"volume_id"`
	Size     int64     `json:"size"`
	Modified time.Time `json:"modified"`
	SHA256   string    `json:"sha256"`
}

type BackupOptions added in v1.0.1

type BackupOptions struct {
	Interval time.Duration
	Timeout  time.Duration
	OnResult func(BackupInfo, error)
}

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)

func (BackupStore) Prune added in v1.0.1

func (b BackupStore) Prune(ctx context.Context) error

type Barrier added in v1.0.1

type Barrier interface{ Barrier(context.Context) error }

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

func (e *BoltEngine) Snapshot(ctx context.Context, w io.Writer) error

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) Sync added in v1.0.1

func (e *BoltEngine) Sync(ctx context.Context) error

func (*BoltEngine) Update added in v1.0.1

func (e *BoltEngine) Update(ctx context.Context, fn func(Tx) error) error

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

func (e *BoltEngine) UpdateAsync(ctx context.Context, fn func(Tx) error) error

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.

func (*BoltEngine) View added in v1.0.1

func (e *BoltEngine) View(ctx context.Context, fn func(ReadTx) error) error

View executes a consistent read transaction. Values passed to ForEach are zero-copy and remain valid only for the duration of that iteration callback.

type BoltInspection added in v1.0.1

type BoltInspection struct {
	VolumeID     string
	StagedChunks int64
	References   []chunk.Ref
}

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

type BucketReadTx interface {
	Buckets(func(bucket []byte) error) error
}

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.

func Open added in v1.0.1

func Open(options Options) (Engine, error)

Open preserves the shared namespace/chunk schema across engine choices.

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 NewStore

func NewStore(ctx context.Context, engine Engine) (*EngineStore, error)

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

func (s *EngineStore) HistoryJournalCommitted(ctx context.Context, epoch [16]byte) (bool, error)

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) Load

func (s *EngineStore) Load(ctx context.Context) (Snapshot, 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

func (s *EngineStore) RestoreOrigin(ctx context.Context, inode uint64) (origin uint64, err error)

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) Save

func (s *EngineStore) Save(ctx context.Context, snapshot Snapshot) error

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
	Kind    Kind
	Mode    uint32
	UID     uint32
	GID     uint32
	Size    int64
	ModTime time.Time
	Chunks  []chunk.Ref
}

type FileChunkUpdate

type FileChunkUpdate struct {
	Size    int64
	ModTime time.Time
	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

type HistoryPatch struct {
	Offset     int64
	DataOffset int64
	Length     int64
	Ref        chunk.Ref
}

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

type HistoryRetention struct {
	MaxVersions int
	MaxAge      time.Duration
	MaxBytes    int64
}

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 HistoryStats struct {
	LastID        uint64
	Versions      uint64
	MetadataBytes int64
}

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

func Export(ctx context.Context, source Snapshotter, destination string) (ImageInfo, error)

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

func Migrate(ctx context.Context, source, destination Options) (ImageInfo, error)

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 Kind

type Kind uint8
const (
	KindDirectory Kind = 1
	KindFile      Kind = 2
)

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.

func OpenLog

func OpenLog(path string, options LogOptions) (*LogEngine, error)

func (*LogEngine) Close

func (e *LogEngine) Close() error

func (*LogEngine) Compact

func (e *LogEngine) Compact(ctx context.Context) error

Compact rewrites only the current key/value state into a new log. Callers can run CompactAsync from a maintenance goroutine; normal updates are briefly serialized while the active log is swapped.

func (*LogEngine) CompactAsync

func (e *LogEngine) CompactAsync(ctx context.Context) <-chan error

func (*LogEngine) Sync

func (e *LogEngine) Sync(ctx context.Context) error

func (*LogEngine) Update

func (e *LogEngine) Update(ctx context.Context, fn func(Tx) error) error

func (*LogEngine) View

func (e *LogEngine) View(ctx context.Context, fn func(ReadTx) error) error

type LogOptions

type LogOptions struct {
	Mode           os.FileMode
	SyncPolicy     SyncPolicy
	SyncInterval   time.Duration
	StrictRecovery bool
}

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

func (*MemoryEngine) Update

func (e *MemoryEngine) Update(ctx context.Context, fn func(Tx) error) error

func (*MemoryEngine) View

func (e *MemoryEngine) View(ctx context.Context, fn func(ReadTx) error) 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 OpenNamespace

func OpenNamespace(ctx context.Context, engine Engine) (*Namespace, error)

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) Create

func (n *Namespace) Create(ctx context.Context, parent uint64, name string, kind Kind, mode uint32, uid, gid uint32) (Entry, error)

func (*Namespace) Get

func (n *Namespace) Get(inode uint64) (Entry, error)

func (*Namespace) GetChunk

func (n *Namespace) GetChunk(inode uint64, index int) (Entry, chunk.Ref, error)

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) List

func (n *Namespace) List(parent uint64) ([]Entry, error)

func (*Namespace) Load

func (n *Namespace) Load(ctx context.Context) error

func (*Namespace) Lookup

func (n *Namespace) Lookup(parent uint64, name string) (Entry, error)

func (*Namespace) LookupAttr added in v1.0.1

func (n *Namespace) LookupAttr(parent uint64, name string) (Entry, error)

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

func (n *Namespace) Path(inode uint64) (string, error)

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) Remove

func (n *Namespace) Remove(ctx context.Context, inode uint64) error

func (*Namespace) Rename

func (n *Namespace) Rename(ctx context.Context, inode, newParent uint64, newName string) error

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) Snapshot

func (n *Namespace) Snapshot() Snapshot

func (*Namespace) Store

func (n *Namespace) Store() *EngineStore

func (*Namespace) Update

func (n *Namespace) Update(ctx context.Context, entry Entry) error

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) VolumeID added in v1.0.1

func (n *Namespace) VolumeID() string

VolumeID returns the stable identifier used to scope remote metadata backups.

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.

func (Options) Kind added in v1.0.1

func (o Options) Kind() (string, error)

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

func (e *PebbleEngine) Snapshot(ctx context.Context, w io.Writer) error

Snapshot uses the common binary interchange image, independent of the active engine. Existing backup normalization and staged-reference pinning apply.

func (*PebbleEngine) Sync added in v1.0.1

func (e *PebbleEngine) Sync(ctx context.Context) error

func (*PebbleEngine) Update added in v1.0.1

func (e *PebbleEngine) Update(ctx context.Context, fn func(Tx) error) error

func (*PebbleEngine) View added in v1.0.1

func (e *PebbleEngine) View(ctx context.Context, fn func(ReadTx) error) error

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

type Snapshot struct {
	Version   int
	NextInode uint64
	Entries   map[uint64]Entry
}

func NewSnapshot

func NewSnapshot() Snapshot

func (Snapshot) Validate

func (s Snapshot) Validate() error

type Snapshotter added in v1.0.1

type Snapshotter interface {
	Snapshot(context.Context, io.Writer) error
}

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 Syncer

type Syncer interface {
	Sync(ctx context.Context) error
}

Syncer is implemented by engines that can force their durable state.

type Tx

type Tx interface {
	ReadTx
	Put(bucket, key, value []byte) error
	Delete(bucket, key []byte) error
}

Tx is an atomic read/write metadata transaction.

Directories

Path Synopsis
Package pebble provides an experimental, bounded-memory inode/dentry store.
Package pebble provides an experimental, bounded-memory inode/dentry store.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL