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) 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) 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) StartDiagnostics(path string) error
- func (f *FileSystem) StatsSnapshot() Stats
- func (f *FileSystem) Sync(ctx context.Context) error
- 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 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 Config ¶
type Config struct {
Namespace *meta.Namespace
Chunks *chunk.Store
Cache *cache.Cache
Staging *writer.Store
// SyncBackend makes file fsync wait for encoding and backend persistence.
// With Staging and the default false, fsync guarantees local durability.
SyncBackend bool
ChunkSize int
Workers int
WriteQueue int
ChunkAttempts int
ChunkRetryBackoff time.Duration
// Read controls decoded backend caching and sequential read ahead. Nil
// selects bounded defaults, independently of the optional SSD cache.
Read *ReadConfig
// QuotaBytes limits the sum of logical file sizes in the namespace. Zero is
// unlimited; compressed backend bytes are reported separately by quota.
QuotaBytes int64
}
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 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.
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) (*FileSystem, error)
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) 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) Remove ¶
func (f *FileSystem) Remove(ctx context.Context, inode uint64) error
Remove retires raw data only after the namespace deletion is durable.
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) 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 stopping or pausing the filesystem.
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 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 struct {
CacheBytes int64
Workers int
Ahead int
// RawRefill asynchronously retains decoded backend data in the optional
// raw SSD cache. Nil Config.Read enables it; explicit ReadConfig opts in.
RawRefill bool
}
ReadConfig controls decoded caching and raw SSD refill. Nil in Config selects 128 MiB, four concurrent loads and four chunks of sequential read ahead. CacheBytes=0 disables this cache and read ahead. Ahead=0 disables only read ahead. The byte limit includes cached data and reserved raw load bytes; callers can retain returned slices until their read replies complete.
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"`
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"`
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.