Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertToOffset(nvm NonVolatileMemory, offset int64, whence int) (int64, error)
- func Open(path string) (nvm *FileNVM, header *StorageHeader, err error)
- type BackingFile
- func (bf *BackingFile) Close()
- func (bf *BackingFile) Delete()
- func (bf *BackingFile) GetCopyOffset(start uint64, end uint64) (onBacking []uint32, onOrigin []uint32)
- func (bf *BackingFile) GetFileName() string
- func (bf *BackingFile) ReadFromOffset(buf []byte, offset uint32) (int, error)
- func (bf *BackingFile) RegionSize() uint64
- func (bf *BackingFile) Sync()
- func (bf *BackingFile) WriteOffset(buf []byte, offset uint32)
- type BackingFileHeader
- type BitmapEntry
- type FileNVM
- func (nvm *FileNVM) BlockSize() block.BlockSize
- func (nvm *FileNVM) Capacity() uint64
- func (nvm *FileNVM) Close() error
- func (self *FileNVM) Position() uint64
- func (nvm *FileNVM) RawSize() int64
- func (nvm *FileNVM) Read(buf []byte) (n int, err error)
- func (nvm *FileNVM) Seek(offset int64, whence int) (int64, error)
- func (nvm *FileNVM) Split(position uint64) (sp1 NonVolatileMemory, sp2 NonVolatileMemory, err error)
- func (self *FileNVM) Sync() error
- func (self *FileNVM) ViewEnd() uint64
- func (self *FileNVM) ViewStart() uint64
- func (nvm *FileNVM) Write(buf []byte) (n int, err error)
- type MemoryNVM
- func (memory *MemoryNVM) AsBytes() []byte
- func (memory *MemoryNVM) BlockSize() block.BlockSize
- func (memory *MemoryNVM) Capacity() uint64
- func (memory *MemoryNVM) Close() error
- func (memory *MemoryNVM) Position() uint64
- func (memory *MemoryNVM) RawSize() int64
- func (memory *MemoryNVM) Read(buf []byte) (n int, err error)
- func (memory *MemoryNVM) Seek(offset int64, whence int) (int64, error)
- func (memory *MemoryNVM) Split(p uint64) (sp1 NonVolatileMemory, sp2 NonVolatileMemory, err error)
- func (memory *MemoryNVM) Sync() error
- func (memory *MemoryNVM) Write(p []byte) (n int, err error)
- type NonVolatileMemory
- type SnapNVM
- func (self *SnapNVM) BlockSize() block.BlockSize
- func (self *SnapNVM) Capacity() uint64
- func (self *SnapNVM) Close() error
- func (self *SnapNVM) CreateSnapshotIfNeeded() (err error)
- func (self *SnapNVM) DeleteSnapshot() error
- func (self *SnapNVM) GetSnapshotReader() (*SnapshotReader, error)
- func (self *SnapNVM) Position() uint64
- func (self *SnapNVM) RawSize() int64
- func (self *SnapNVM) Read(buf []byte) (n int, err error)
- func (self *SnapNVM) Seek(offset int64, whence int) (int64, error)
- func (self *SnapNVM) Split(position uint64) (sp1 NonVolatileMemory, sp2 NonVolatileMemory, err error)
- func (self *SnapNVM) Sync() error
- func (self *SnapNVM) Write(buf []byte) (n int, err error)
- type SnapshotReader
- type StorageHeader
- func (self *StorageHeader) RegionSize() uint64
- func (self *StorageHeader) SplitRegion(nvm NonVolatileMemory) (NonVolatileMemory, NonVolatileMemory)
- func (self *StorageHeader) StorageSize() uint64
- func (self *StorageHeader) WriteHeaderRegionTo(writer io.Writer) (err error)
- func (self *StorageHeader) WriteTo(writer io.Writer) (err error)
Constants ¶
View Source
const ( HEADER_SIZE uint16 = 2 + 2 + 2 + 16 + 8 + 8 /* data_region_size */ FULL_HEADER_SIZE uint16 = 4 + 2 + HEADER_SIZE )
View Source
const ( MAJOR_VERSION uint16 = 2 MINOR_VERSION uint16 = 1 MAX_JOURNAL_REGION_SIZE uint64 = (1 << 40) - 1 MAX_DATA_REGION_SIZE uint64 = MAX_JOURNAL_REGION_SIZE * uint64(block.MIN) )
Variables ¶
View Source
var ( SNAP_MAGIC_NUMBER = [4]byte{'s', 'n', 'a', 'p'} SNAP_MAJOR_VERSION uint16 = 0 SNAP_MINOR_VERSION uint16 = 3 DEFAULT_REGION_SHIFT uint16 = 25 )
View Source
var (
MAGIC_NUMBER = [4]byte{'l', 'u', 's', 'f'}
)
Functions ¶
func ConvertToOffset ¶
func ConvertToOffset(nvm NonVolatileMemory, offset int64, whence int) (int64, error)
Types ¶
type BackingFile ¶ added in v0.2.0
type BackingFile struct { JournalStart uint64 JournalEnd uint64 // contains filtered or unexported fields }
func CreateBackingFile ¶ added in v0.2.0
func CreateBackingFile(prefix string, maxCapacity uint64, currentCapacity uint64) (*BackingFile, error)
func OpenBackingFile ¶ added in v0.2.0
func OpenBackingFile(fileName string) (*BackingFile, error)
func (*BackingFile) Close ¶ added in v0.2.0
func (bf *BackingFile) Close()
func (*BackingFile) Delete ¶ added in v0.2.0
func (bf *BackingFile) Delete()
func (*BackingFile) GetCopyOffset ¶ added in v0.2.0
func (bf *BackingFile) GetCopyOffset(start uint64, end uint64) (onBacking []uint32, onOrigin []uint32)
give [start, end) of the buf onBacking[] offset of backing file in the unit of byte onOrigin[] offset of origing file in the unit of byte all aligned to regionSize
func (*BackingFile) GetFileName ¶ added in v0.2.0
func (bf *BackingFile) GetFileName() string
func (*BackingFile) ReadFromOffset ¶ added in v0.2.0
func (bf *BackingFile) ReadFromOffset(buf []byte, offset uint32) (int, error)
offset is the start of backing file
func (*BackingFile) RegionSize ¶ added in v0.2.0
func (bf *BackingFile) RegionSize() uint64
func (*BackingFile) Sync ¶ added in v0.2.0
func (bf *BackingFile) Sync()
func (*BackingFile) WriteOffset ¶ added in v0.2.0
func (bf *BackingFile) WriteOffset(buf []byte, offset uint32)
WriteOffset would write buf into backing file. buf's size must be regionSize, offset is buf's offset in origin file WriteOffset write journal first, and then write the buf
type BackingFileHeader ¶ added in v0.2.0
type BackingFileHeader struct { MajorVersion uint16 MinorVersion uint16 UUID uuid.UUID RegionShift uint16 MaxCapacity uint64 JournalSize uint64 CreateTime int64 RawCapacity uint64 }
Default RegionShift is 25 : 1<<25 == 32MB
type BitmapEntry ¶ added in v0.2.0
the unit is fraction of "1 << RegionShift" , default is 32MB
func ReadRecordFrom ¶ added in v0.2.0
func ReadRecordFrom(reader io.Reader) BitmapEntry
func (BitmapEntry) CheckSum ¶ added in v0.2.0
func (entry BitmapEntry) CheckSum() uint32
func (BitmapEntry) Size ¶ added in v0.2.0
func (entry BitmapEntry) Size() uint64
type FileNVM ¶
type FileNVM struct {
// contains filtered or unexported fields
}
func (*FileNVM) Split ¶
func (nvm *FileNVM) Split(position uint64) (sp1 NonVolatileMemory, sp2 NonVolatileMemory, err error)
type MemoryNVM ¶
type MemoryNVM struct {
// contains filtered or unexported fields
}
func NewFromVec ¶
func (*MemoryNVM) Split ¶
func (memory *MemoryNVM) Split(p uint64) (sp1 NonVolatileMemory, sp2 NonVolatileMemory, err error)
type NonVolatileMemory ¶
type NonVolatileMemory interface { io.ReadWriteSeeker io.Closer Sync() error Position() uint64 Capacity() uint64 BlockSize() block.BlockSize Split(position uint64) (NonVolatileMemory, NonVolatileMemory, error) RawSize() int64 }
type SnapNVM ¶ added in v0.2.0
type SnapNVM struct {
// contains filtered or unexported fields
}
func NewSnapshotNVM ¶ added in v0.2.0
func (*SnapNVM) CreateSnapshotIfNeeded ¶ added in v0.2.0
func (*SnapNVM) DeleteSnapshot ¶ added in v0.2.0
func (*SnapNVM) GetSnapshotReader ¶ added in v0.2.0
func (self *SnapNVM) GetSnapshotReader() (*SnapshotReader, error)
func (*SnapNVM) Split ¶ added in v0.2.0
func (self *SnapNVM) Split(position uint64) (sp1 NonVolatileMemory, sp2 NonVolatileMemory, err error)
type SnapshotReader ¶ added in v0.2.0
type SnapshotReader struct {
// contains filtered or unexported fields
}
type StorageHeader ¶
type StorageHeader struct { MajorVersion uint16 MinorVersion uint16 BlockSize block.BlockSize UUID uuid.UUID JournalRegionSize uint64 DataRegionSize uint64 }
func DefaultStorageHeader ¶
func DefaultStorageHeader() *StorageHeader
func ReadFromFile ¶
func ReadFromFile(f *os.File) (*StorageHeader, error)
func (*StorageHeader) RegionSize ¶
func (self *StorageHeader) RegionSize() uint64
func (*StorageHeader) SplitRegion ¶
func (self *StorageHeader) SplitRegion(nvm NonVolatileMemory) (NonVolatileMemory, NonVolatileMemory)
func (*StorageHeader) StorageSize ¶
func (self *StorageHeader) StorageSize() uint64
func (*StorageHeader) WriteHeaderRegionTo ¶
func (self *StorageHeader) WriteHeaderRegionTo(writer io.Writer) (err error)
Click to show internal directories.
Click to hide internal directories.