Documentation
¶
Overview ¶
Package core implements the shared file storage engine used by protocol exports.
Index ¶
- func ControlSocketPath(mountpoint string) (string, error)
- func Errno(err error) syscall.Errno
- type AttrUpdate
- type Config
- type File
- func (f *File) Close(ctx context.Context) error
- func (f *File) CloseLocal(ctx context.Context) error
- func (f *File) Discard(ctx context.Context, off, length int64) error
- func (f *File) Inode() uint64
- func (f *File) ReadAt(ctx context.Context, p []byte, off int64) (int, error)
- func (f *File) SetAttr(ctx context.Context, update AttrUpdate) (meta.Entry, error)
- func (f *File) Stat(ctx context.Context) (meta.Entry, error)
- func (f *File) Sync(ctx context.Context, backend bool) error
- func (f *File) Truncate(ctx context.Context, size int64) error
- func (f *File) WriteAt(ctx context.Context, p []byte, off int64) (int, error)
- type FileReadResult
- type FileSystem
- func (f *FileSystem) Attr(inode uint64) (meta.Entry, error)
- func (f *FileSystem) ChunkSize() int
- func (f *FileSystem) Close() error
- func (f *FileSystem) CreateFile(ctx context.Context, parent uint64, name string, size int64) (*File, error)
- func (f *FileSystem) DirectoryPageSize() int
- func (f *FileSystem) Format() fsformat.Volume
- func (f *FileSystem) HasWriteback() bool
- func (f *FileSystem) Logs(after uint64, limit int, errorsOnly bool, pathFilter string) LogSnapshot
- func (f *FileSystem) Namespace() *meta.Namespace
- func (f *FileSystem) Open(inode uint64) (*Handle, error)
- func (f *FileSystem) OpenFile(ctx context.Context, parent uint64, name string) (*File, error)
- func (f *FileSystem) RecordFuseMetadata(operation string)
- func (f *FileSystem) Remove(ctx context.Context, inode uint64) error
- func (f *FileSystem) Rename(ctx context.Context, inode, newParent uint64, newName string) error
- func (f *FileSystem) SetAttr(ctx context.Context, inode uint64, update AttrUpdate) (meta.Entry, error)
- func (f *FileSystem) Snapshot(ctx context.Context, output io.Writer) error
- func (f *FileSystem) StartDiagnostics(path string) error
- func (f *FileSystem) StatsSnapshot() Stats
- func (f *FileSystem) Sync(ctx context.Context) error
- type FuseMetadataStats
- type Handle
- func (h *Handle) Flush(ctx context.Context) syscall.Errno
- func (h *Handle) Fsync(ctx context.Context) syscall.Errno
- func (h *Handle) Read(ctx context.Context, dest []byte, off int64) (ReadResult, syscall.Errno)
- func (h *Handle) Release(ctx context.Context) syscall.Errno
- func (h *Handle) Write(ctx context.Context, data []byte, off int64) (uint32, syscall.Errno)
- type LogEntry
- type LogSnapshot
- type MemoryStats
- type MetadataBackupConfig
- type RawRefillStats
- type ReadConfig
- type ReadResult
- type Stats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ControlSocketPath ¶
ControlSocketPath returns the per-mount diagnostics socket used by the CLI. A hash avoids Unix socket path length limits and keeps separate mounts independent even when their mountpoint names are similar.
Types ¶
type AttrUpdate ¶
AttrUpdate changes only the fields whose pointers are non-nil.
type File ¶
type File struct {
// contains filtered or unexported fields
}
File exposes the shared chunk/cache/writeback engine without a FUSE mount. Share one File between users of an inode so unstaged writes remain coherent. The owner must stop using the File before closing its FileSystem.
func (*File) CloseLocal ¶
CloseLocal closes the handle after its data and metadata are recoverable. With a raw cache, encoding and backend uploads remain owned by FileSystem; without that cache or with Config.SyncBackend this waits for the backend. A failed close may be retried.
func (*File) Discard ¶
Discard makes a range read as zero. Whole chunks lose their mappings; partial chunks retain bytes outside the discarded range. It never deletes shared immutable backend objects. Durability is established by Sync.
func (*File) SetAttr ¶
SetAttr orders attribute changes against this File's pending writes. Callers sharing an inode must share the File rather than modifying metadata directly.
func (*File) Stat ¶
Stat includes this File's buffered writes, even without a raw writeback cache. Chunk references are omitted so checking the size does not copy a manifest.
func (*File) Sync ¶
Sync makes all writes on this shared file durable. backend=false may stop at recoverable local raw storage; backend=true also waits for encoding/upload. Config.SyncBackend establishes a minimum that backend=false cannot weaken.
type FileReadResult ¶
FileReadResult owns a read-only descriptor to an immutable range. Unlinking the source name does not affect the result's lifetime.
func (*FileReadResult) Done ¶
func (r *FileReadResult) Done()
func (*FileReadResult) Size ¶
func (r *FileReadResult) Size() int
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
FileSystem is a persistent chunk-backed namespace shared by file and block exports.
func New ¶
func New(config Config, options ...option.Option) (filesystem *FileSystem, err error)
New applies shared options, validates the resulting config and starts the storage engine. Configure it once, then select a FUSE, Afero or blk export.
func (*FileSystem) Attr ¶
func (f *FileSystem) Attr(inode uint64) (meta.Entry, error)
Attr includes mutable raw writes that have not yet reached metadata.
func (*FileSystem) ChunkSize ¶
func (f *FileSystem) ChunkSize() int
func (*FileSystem) Close ¶
func (f *FileSystem) Close() error
Close persists local writes and stops workers. With raw writeback, call Sync first to also drain backend uploads. Release FUSE handles before closing.
func (*FileSystem) CreateFile ¶
func (f *FileSystem) CreateFile(ctx context.Context, parent uint64, name string, size int64) (*File, error)
CreateFile creates a sparse file: unwritten ranges do not allocate chunks.
func (*FileSystem) DirectoryPageSize ¶ added in v1.0.1
func (f *FileSystem) DirectoryPageSize() int
DirectoryPageSize is the bounded page shared by FUSE and Afero enumeration.
func (*FileSystem) Format ¶ added in v1.0.1
func (f *FileSystem) Format() fsformat.Volume
Format returns the versioned structural format confirmed when the engine was opened. Compression is selected by each chunk reference's codec.
func (*FileSystem) HasWriteback ¶
func (f *FileSystem) HasWriteback() bool
func (*FileSystem) Logs ¶
func (f *FileSystem) Logs(after uint64, limit int, errorsOnly bool, pathFilter string) LogSnapshot
Logs returns recent events after a cursor. A zero cursor returns the tail.
func (*FileSystem) Namespace ¶
func (f *FileSystem) Namespace() *meta.Namespace
Namespace is the authoritative metadata view shared by storage frontends.
func (*FileSystem) Open ¶
func (f *FileSystem) Open(inode uint64) (*Handle, error)
Open creates a handle for an existing regular-file inode.
func (*FileSystem) RecordFuseMetadata ¶ added in v1.0.1
func (f *FileSystem) RecordFuseMetadata(operation string)
RecordFuseMetadata counts one supported metadata callback without per-name allocations or logging. Calls handled inside go-fuse itself are not included.
func (*FileSystem) Remove ¶
func (f *FileSystem) Remove(ctx context.Context, inode uint64) error
Remove retires raw data only after the namespace deletion is durable. Files without chunk references do not pin cache data, so their namespace update can stay in the normal asynchronous metadata commit path without a per-unlink fsync barrier.
func (*FileSystem) Rename ¶
Rename atomically replaces a compatible destination and retires its quota and raw-cache references. Frontends must order this operation against their own open handles: flush mutable source manifests and do not replace an open destination unless the frontend implements detached-inode lifetime.
func (*FileSystem) SetAttr ¶
func (f *FileSystem) SetAttr(ctx context.Context, inode uint64, update AttrUpdate) (meta.Entry, error)
SetAttr preserves pending writes and retires truncated raw references through the same durable metadata path used by regular writes.
func (*FileSystem) Snapshot ¶ added in v1.0.1
Snapshot implements meta.Snapshotter. The resulting bbolt image is a standalone recovery point: every staged raw reference is uploaded and rewritten in the copy only. Mutable RAM writes must first be fsynced to be included. New writes and live manifests continue independently.
func (*FileSystem) StartDiagnostics ¶
func (f *FileSystem) StartDiagnostics(path string) error
StartDiagnostics exposes the shared storage diagnostics without mounting FUSE. Use the same path with compactfs stat/log/sync. Close stops the server.
func (*FileSystem) StatsSnapshot ¶
func (f *FileSystem) StatsSnapshot() Stats
StatsSnapshot returns counters without draining the writeback queues.
type FuseMetadataStats ¶ added in v1.0.1
type FuseMetadataStats struct {
LookupRequests uint64 `json:"lookup_requests"`
GetattrRequests uint64 `json:"getattr_requests"`
OpenDirRequests uint64 `json:"opendir_requests"`
ReadDirRequests uint64 `json:"readdir_requests"`
ReadDirPlusRequests uint64 `json:"readdirplus_requests"`
GetXattrRequests uint64 `json:"getxattr_requests"`
}
FuseMetadataStats counts requests delivered by go-fuse to the protocol adapter. Internal LOOKUPs used to populate READDIRPLUS are not counted as independent kernel LOOKUPs. Other exports leave these protocol-specific counters at zero.
type Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
Handle owns one open file's mutable I/O state. Protocol adapters translate its read results and errors; the shared engine owns write ordering and sync.
type LogEntry ¶
type LogEntry struct {
Seq uint64 `json:"seq"`
Time time.Time `json:"time"`
Kind string `json:"kind"`
Operation string `json:"operation"`
Path string `json:"path,omitempty"`
Inode uint64 `json:"inode,omitempty"`
Offset int64 `json:"offset,omitempty"`
Bytes int64 `json:"bytes,omitempty"`
DurationNanos int64 `json:"duration_nanos,omitempty"`
Error string `json:"error,omitempty"`
}
LogEntry is one recent write-back or FUSE error event. The ring is kept in memory so diagnostics never turn a high-throughput mount into a synchronous log writer.
type LogSnapshot ¶
type LogSnapshot struct {
Entries []LogEntry `json:"entries"`
NextSeq uint64 `json:"next_seq"`
Dropped uint64 `json:"dropped"`
}
LogSnapshot is returned by the /logs endpoint. NextSeq is the cursor to use in a later request; it advances even when filters hide all returned events.
type MemoryStats ¶ added in v1.0.1
type MemoryStats struct {
HeapAlloc uint64 `json:"heap_alloc"`
HeapObjects uint64 `json:"heap_objects"`
TotalAlloc uint64 `json:"total_alloc"`
NumGC uint32 `json:"num_gc"`
PauseTotalNS uint64 `json:"pause_total_ns"`
StagedInodes int `json:"staged_inodes"`
}
MemoryStats distinguishes Go heap growth from the process RSS reported by the OS. It includes all Go packages in this daemon, not just metadata.
type MetadataBackupConfig ¶ added in v1.0.1
type MetadataBackupConfig = option.MetadataBackupConfig
MetadataBackupConfig configures shared automatic backend snapshots.
type RawRefillStats ¶
type RawRefillStats struct {
CapacityBytes int64 `json:"capacity_bytes"`
PendingBytes int64 `json:"pending_bytes"`
Pending int `json:"pending"`
Submitted int64 `json:"submitted"`
Completed int64 `json:"completed"`
Bytes int64 `json:"bytes"`
Skipped int64 `json:"skipped"`
Errors int64 `json:"errors"`
}
RawRefillStats counts optional SSD fills independently of durable writes. PendingBytes includes the active fill and every queued immutable raw slice.
type ReadConfig ¶
type ReadConfig = option.ReadConfig
ReadConfig configures the shared decoded cache and raw refill.
type ReadResult ¶
ReadResult owns immutable bytes or an open file range. The caller must call Done after consuming the result; file-backed replies can be sent without first copying the range into an application buffer.
type Stats ¶
type Stats struct {
MountPoint string `json:"mount_point"`
PID int `json:"pid"`
StartedAt time.Time `json:"started_at"`
UpdatedAt time.Time `json:"updated_at"`
UptimeNanos int64 `json:"uptime_nanos"`
CodecName string `json:"codec_name,omitempty"`
MetadataEngine string `json:"metadata_engine"`
HashAlgorithm string `json:"hash_algorithm"`
CodecHealth string `json:"codec_health,omitempty"`
CodecWorker *codec.WorkerStatus `json:"codec_worker,omitempty"`
SyncMode string `json:"sync_mode"`
Writeback *writer.Stats `json:"writeback,omitempty"`
WriteBufferBytes int64 `json:"write_buffer_bytes"`
WriteBufferPoolBytes int64 `json:"write_buffer_pool_bytes"`
WriteBufferAllocations int64 `json:"write_buffer_allocations"`
WriteBufferReuses int64 `json:"write_buffer_reuses"`
WriteBufferZeroBytes int64 `json:"write_buffer_zero_bytes"`
RawPendingJobs int64 `json:"raw_pending_jobs"`
RawPendingBytes int64 `json:"raw_pending_bytes"`
RawErrors int64 `json:"raw_errors"`
RawRefill *RawRefillStats `json:"raw_refill,omitempty"`
ReadCache *reader.Stats `json:"read_cache,omitempty"`
MetadataBackup *meta.BackupStats `json:"metadata_backup,omitempty"`
Memory MemoryStats `json:"memory"`
FuseMetadata FuseMetadataStats `json:"fuse_metadata"`
FuseOperations int64 `json:"fuse_operations"`
ReadOperations int64 `json:"read_operations"`
ReadBytes int64 `json:"read_bytes"`
ReadNanos int64 `json:"read_nanos"`
WriteOperations int64 `json:"write_operations"`
WriteBytes int64 `json:"write_bytes"`
WriteNanos int64 `json:"write_nanos"`
FlushOperations int64 `json:"flush_operations"`
FlushNanos int64 `json:"flush_nanos"`
FsyncOperations int64 `json:"fsync_operations"`
FsyncNanos int64 `json:"fsync_nanos"`
ReleaseOperations int64 `json:"release_operations"`
ReleaseNanos int64 `json:"release_nanos"`
QueueSubmittedJobs int64 `json:"queue_submitted_jobs"`
QueueCompletedJobs int64 `json:"queue_completed_jobs"`
QueuePendingJobs int64 `json:"queue_pending_jobs"`
QueuePendingBytes int64 `json:"queue_pending_bytes"`
QueueErrors int64 `json:"queue_errors"`
ChunkPutOperations int64 `json:"chunk_put_operations"`
ChunkPutBytes int64 `json:"chunk_put_bytes"`
ChunkPutNanos int64 `json:"chunk_put_nanos"`
ChunkPutErrors int64 `json:"chunk_put_errors"`
PutOperations int64 `json:"put_operations"`
PutBytes int64 `json:"put_bytes"`
PutNanos int64 `json:"put_nanos"`
PutErrors int64 `json:"put_errors"`
EncodeOperations int64 `json:"encode_operations"`
EncodeBytes int64 `json:"encode_bytes"`
EncodeNanos int64 `json:"encode_nanos"`
EncodeErrors int64 `json:"encode_errors"`
EncodeBufferAllocations int64 `json:"encode_buffer_allocations"`
EncodeBufferReuses int64 `json:"encode_buffer_reuses"`
EncodeBufferPoolBytes int64 `json:"encode_buffer_pool_bytes"`
BackendStatOperations int64 `json:"backend_stat_operations"`
BackendStatNanos int64 `json:"backend_stat_nanos"`
BackendStatErrors int64 `json:"backend_stat_errors"`
BackendPutOperations int64 `json:"backend_put_operations"`
BackendPutBytes int64 `json:"backend_put_bytes"`
BackendPutNanos int64 `json:"backend_put_nanos"`
BackendPutErrors int64 `json:"backend_put_errors"`
BackendImportOperations int64 `json:"backend_import_operations"`
BackendImportBytes int64 `json:"backend_import_bytes"`
BackendImportNanos int64 `json:"backend_import_nanos"`
BackendImportFallbacks int64 `json:"backend_import_fallbacks"`
BackendRangeOperations int64 `json:"backend_range_operations"`
BackendRangeBytes int64 `json:"backend_range_bytes"`
BackendGetOperations int64 `json:"backend_get_operations"`
BackendGetBytes int64 `json:"backend_get_bytes"`
BackendGetNanos int64 `json:"backend_get_nanos"`
BackendGetErrors int64 `json:"backend_get_errors"`
CacheGetOperations int64 `json:"cache_get_operations"`
CacheGetBytes int64 `json:"cache_get_bytes"`
CacheGetNanos int64 `json:"cache_get_nanos"`
CacheGetErrors int64 `json:"cache_get_errors"`
CacheHits int64 `json:"cache_hits"`
CacheMisses int64 `json:"cache_misses"`
CachePutOperations int64 `json:"cache_put_operations"`
CachePutBytes int64 `json:"cache_put_bytes"`
CachePutNanos int64 `json:"cache_put_nanos"`
CachePutErrors int64 `json:"cache_put_errors"`
DecodeOperations int64 `json:"decode_operations"`
DecodeBytes int64 `json:"decode_bytes"`
DecodeNanos int64 `json:"decode_nanos"`
DecodeErrors int64 `json:"decode_errors"`
LastError string `json:"last_error,omitempty"`
LastErrorAt time.Time `json:"last_error_at,omitempty"`
}
Stats is a cumulative snapshot of one mounted filesystem. Byte counters are logical bytes unless their name says stored or compressed; durations are in nanoseconds. The CLI turns these counters into rates for human output.