Documentation ¶
Overview ¶
Package fsutil provides utilities for implementing vfs.FileDescriptionImpl and vfs.FilesystemImpl.
Index ¶
- func SyncDirty(ctx context.Context, mr memmap.MappableRange, cache *FileRangeSet, ...) error
- func SyncDirtyAll(ctx context.Context, cache *FileRangeSet, dirty *DirtySet, max uint64, ...) error
- type DirtyInfo
- type FileRangeSetFunctions
- func (FileRangeSetFunctions) ClearValue(_ *uint64)
- func (FileRangeSetFunctions) MaxKey() uint64
- func (FileRangeSetFunctions) Merge(mr1 memmap.MappableRange, frstart1 uint64, _ memmap.MappableRange, ...) (uint64, bool)
- func (FileRangeSetFunctions) MinKey() uint64
- func (FileRangeSetFunctions) Split(mr memmap.MappableRange, frstart uint64, split uint64) (uint64, uint64)
- type FrameRefSetFunctions
- func (FrameRefSetFunctions) ClearValue(val *uint64)
- func (FrameRefSetFunctions) MaxKey() uint64
- func (FrameRefSetFunctions) Merge(_ memmap.FileRange, val1 uint64, _ memmap.FileRange, val2 uint64) (uint64, bool)
- func (FrameRefSetFunctions) MinKey() uint64
- func (FrameRefSetFunctions) Split(_ memmap.FileRange, val uint64, _ uint64) (uint64, uint64)
- type HostFileMapper
- func (f *HostFileMapper) DecRefOn(mr memmap.MappableRange)
- func (f *HostFileMapper) IncRefOn(mr memmap.MappableRange)
- func (f *HostFileMapper) Init()
- func (f *HostFileMapper) IsInited() bool
- func (f *HostFileMapper) MapInternal(fr memmap.FileRange, fd int, write bool) (safemem.BlockSeq, error)
- func (f *HostFileMapper) RegenerateMappings(fd int) error
- func (f *HostFileMapper) UnmapAll()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SyncDirty ¶
func SyncDirty(ctx context.Context, mr memmap.MappableRange, cache *FileRangeSet, dirty *DirtySet, max uint64, mem memmap.File, writeAt func(ctx context.Context, srcs safemem.BlockSeq, offset uint64) (uint64, error)) error
SyncDirty passes pages in the range mr that are stored in cache and identified as dirty to writeAt, updating dirty to reflect successful writes. If writeAt returns a successful partial write, SyncDirty will call it repeatedly until all bytes have been written. max is the true size of the cached object; offsets beyond max will not be passed to writeAt, even if they are marked dirty.
func SyncDirtyAll ¶
func SyncDirtyAll(ctx context.Context, cache *FileRangeSet, dirty *DirtySet, max uint64, mem memmap.File, writeAt func(ctx context.Context, srcs safemem.BlockSeq, offset uint64) (uint64, error)) error
SyncDirtyAll passes all pages stored in cache identified as dirty to writeAt, updating dirty to reflect successful writes. If writeAt returns a successful partial write, SyncDirtyAll will call it repeatedly until all bytes have been written. max is the true size of the cached object; offsets beyond max will not be passed to writeAt, even if they are marked dirty.
Types ¶
type DirtyInfo ¶
type DirtyInfo struct { // Keep is true if the represented offset is concurrently writable, such // that writing the data for that offset back to the source does not // guarantee that the offset is clean (since it may be concurrently // rewritten after the writeback). Keep bool }
DirtyInfo is the value type of DirtySet, and represents information about a Mappable offset that is dirty (the cached data for that offset is newer than its source).
+stateify savable
type FileRangeSetFunctions ¶
type FileRangeSetFunctions struct{}
FileRangeSetFunctions implements segment.Functions for FileRangeSet.
func (FileRangeSetFunctions) ClearValue ¶
func (FileRangeSetFunctions) ClearValue(_ *uint64)
ClearValue implements segment.Functions.ClearValue.
func (FileRangeSetFunctions) MaxKey ¶
func (FileRangeSetFunctions) MaxKey() uint64
MaxKey implements segment.Functions.MaxKey.
func (FileRangeSetFunctions) Merge ¶
func (FileRangeSetFunctions) Merge(mr1 memmap.MappableRange, frstart1 uint64, _ memmap.MappableRange, frstart2 uint64) (uint64, bool)
Merge implements segment.Functions.Merge.
func (FileRangeSetFunctions) MinKey ¶
func (FileRangeSetFunctions) MinKey() uint64
MinKey implements segment.Functions.MinKey.
func (FileRangeSetFunctions) Split ¶
func (FileRangeSetFunctions) Split(mr memmap.MappableRange, frstart uint64, split uint64) (uint64, uint64)
Split implements segment.Functions.Split.
type FrameRefSetFunctions ¶
type FrameRefSetFunctions struct{}
FrameRefSetFunctions implements segment.Functions for FrameRefSet.
func (FrameRefSetFunctions) ClearValue ¶
func (FrameRefSetFunctions) ClearValue(val *uint64)
ClearValue implements segment.Functions.ClearValue.
func (FrameRefSetFunctions) MaxKey ¶
func (FrameRefSetFunctions) MaxKey() uint64
MaxKey implements segment.Functions.MaxKey.
func (FrameRefSetFunctions) Merge ¶
func (FrameRefSetFunctions) Merge(_ memmap.FileRange, val1 uint64, _ memmap.FileRange, val2 uint64) (uint64, bool)
Merge implements segment.Functions.Merge.
func (FrameRefSetFunctions) MinKey ¶
func (FrameRefSetFunctions) MinKey() uint64
MinKey implements segment.Functions.MinKey.
type HostFileMapper ¶
type HostFileMapper struct {
// contains filtered or unexported fields
}
HostFileMapper caches mappings of an arbitrary host file descriptor. It is used by implementations of memmap.Mappable that represent a host file descriptor.
+stateify savable
func NewHostFileMapper ¶
func NewHostFileMapper() *HostFileMapper
NewHostFileMapper returns an initialized HostFileMapper allocated on the heap with no references or cached mappings.
func (*HostFileMapper) DecRefOn ¶
func (f *HostFileMapper) DecRefOn(mr memmap.MappableRange)
DecRefOn decrements the reference count on all offsets in mr.
Preconditions:
- mr.Length() != 0.
- mr.Start and mr.End must be page-aligned.
func (*HostFileMapper) IncRefOn ¶
func (f *HostFileMapper) IncRefOn(mr memmap.MappableRange)
IncRefOn increments the reference count on all offsets in mr.
Preconditions:
- mr.Length() != 0.
- mr.Start and mr.End must be page-aligned.
func (*HostFileMapper) Init ¶
func (f *HostFileMapper) Init()
Init must be called on zero-value HostFileMappers before first use.
func (*HostFileMapper) IsInited ¶
func (f *HostFileMapper) IsInited() bool
IsInited returns true if f.Init() has been called. This is used when restoring a checkpoint that contains a HostFileMapper that may or may not have been initialized.
func (*HostFileMapper) MapInternal ¶
func (f *HostFileMapper) MapInternal(fr memmap.FileRange, fd int, write bool) (safemem.BlockSeq, error)
MapInternal returns a mapping of offsets in fr from fd. The returned safemem.BlockSeq is valid as long as at least one reference is held on all offsets in fr or until the next call to UnmapAll.
Preconditions: The caller must hold a reference on all offsets in fr.
func (*HostFileMapper) RegenerateMappings ¶
func (f *HostFileMapper) RegenerateMappings(fd int) error
RegenerateMappings must be called when the file description mapped by f changes, to replace existing mappings of the previous file description.
func (*HostFileMapper) UnmapAll ¶
func (f *HostFileMapper) UnmapAll()
UnmapAll unmaps all cached mappings. Callers are responsible for synchronization with mappings returned by previous calls to MapInternal.