Documentation ¶
Index ¶
- Constants
- Variables
- func CalNeedInodeCnt(ino *Inode, n int) int
- func FloorBlk(n int) int
- func GetBlockCnt(n int) int
- func GetBlockIdx(offset int64) int32
- func GetInodeIdx(offset int64) int32
- func IsFileCreate(flags int) bool
- func MakeRoom(b []byte, n int) []byte
- func ReadDisk(r io.ReaderAt, d Diskable, addr Address) error
- func ResetStat()
- func WriteDisk(w io.Writer, d Diskable) error
- func WriteDiskAt(w io.WriterAt, d Diskable, addr Address) error
- type Address
- type Cobuffer
- type DataSlice
- type DiskBuffer
- type DiskItem
- type DiskReadItem
- type DiskReader
- type DiskWriteItem
- type DiskWriter
- type Diskable
- type File
- func (f *File) AddRef() bool
- func (f *File) Close() error
- func (f *File) Ino() int32
- func (f *File) Name() string
- func (f *File) ReadAt(b []byte, off int64) (readBytes int, err error)
- func (f *File) Size() int64
- func (f *File) Stat() (*Inode, error)
- func (f *File) Sync()
- func (f *File) Write(b []byte) (int, error)
- type FileConfig
- type FileDelegater
- type FileFlusher
- type FileName
- type FlushDelegate
- type Flusher
- type FlusherConfig
- type FlusherWriteReply
- type GStat
- type Handle
- type Inode
- func (i *Inode) DiskSize() int
- func (i *Inode) GetBlockIdx(off int64) int
- func (i *Inode) GetBlockSize(idx int) int
- func (i *Inode) GetRemainInBlock(off int64) int
- func (i *Inode) GetSizeIdx() int
- func (i *Inode) IsFull() bool
- func (i *Inode) Magic() Magic
- func (i *Inode) ReadDisk(b []byte) error
- func (i *Inode) SeekIdx(offset int64) (int, bool)
- func (i *Inode) SetOffset(idx int, addr ShortAddr, size int)
- func (i *Inode) WriteDisk(b []byte)
- type InodeMap
- type InodeMapDelegate
- type InodePool
- func (p *InodePool) CleanCache()
- func (i *InodePool) GetByAddr(addr Address) (*Inode, error)
- func (i *InodePool) GetLastest() (*Inode, error)
- func (p *InodePool) InitInode() *Inode
- func (p *InodePool) OnFlush(ino *Inode, addr Address)
- func (p *InodePool) RefPayloadBlock() (*Inode, int, error)
- func (p *InodePool) ResetCache()
- func (p *InodePool) SeekNext(inode *Inode) (*Inode, error)
- func (p *InodePool) SeekPrev(offset int64) (*Inode, error)
- type InodePoolDelegate
- type InodeScatter
- type Int32
- type Magic
- type NameMap
- type NameMapItem
- type ShortAddr
- type Time
- type Volume
- type VolumeConfig
- type VolumeDelegate
- type VolumeHeader
- type VolumeSource
Constants ¶
View Source
const ( BlockBit = 18 BlockSize = 1 << BlockBit )
View Source
const ( InodePadding = 36 InodeSize = 1024 InodeBlockCnt = 150 InodeCap = InodeBlockCnt * BlockSize )
View Source
const ( InodeMapCap = 1 << 20 InodeMapSize = 6 * InodeMapCap )
View Source
const ( VolumeHeaderSize = 16 VolumeHeaderMinCheckpoint = VolumeHeaderSize + InodeMapSize )
View Source
const FileNameSize = 28
View Source
const MagicSize = 4
View Source
const (
NameMapItemSize = 32
)
Variables ¶
View Source
var ( MagicEOF = Magic{0x8a, 0x9b, 0x0, 0x1} MagicVolume = Magic{0x8a, 0x9b, 0x0, 0x2} MagicInode = Magic{0x8a, 0x9b, 0x0, 0x3} )
View Source
var ErrFileNotExist = logex.Define("file is not exists")
View Source
var ErrSpaceNotEnough = fmt.Errorf("buffer space is not enough")
Functions ¶
func GetBlockCnt ¶
func GetBlockIdx ¶
func GetInodeIdx ¶
func IsFileCreate ¶
Types ¶
type Cobuffer ¶
type Cobuffer struct {
// contains filtered or unexported fields
}
func NewCobuffer ¶
type DataSlice ¶
type DataSlice struct {
// contains filtered or unexported fields
}
func NewDataSlice ¶
func (*DataSlice) WriteData ¶
func (f *DataSlice) WriteData(dw *DiskWriter, n int)
type DiskBuffer ¶
type DiskBuffer struct {
// contains filtered or unexported fields
}
func NewDiskBuffer ¶
func NewDiskBuffer(rw io.ReadWriter) *DiskBuffer
func (*DiskBuffer) ReadItem ¶
func (d *DiskBuffer) ReadItem(da Diskable) error
func (*DiskBuffer) WriteItem ¶
func (d *DiskBuffer) WriteItem(da Diskable) error
type DiskReadItem ¶
type DiskReader ¶
type DiskReader struct {
// contains filtered or unexported fields
}
func NewDiskReader ¶
func NewDiskReader(b []byte) *DiskReader
func (*DiskReader) Peek ¶
func (r *DiskReader) Peek(n int) []byte
func (*DiskReader) ReadBytes ¶
func (r *DiskReader) ReadBytes(n int) []byte
func (*DiskReader) ReadItem ¶
func (r *DiskReader) ReadItem(d DiskReadItem) error
func (*DiskReader) ReadItems ¶
func (r *DiskReader) ReadItems(ds []DiskReadItem) error
func (*DiskReader) ReadMagic ¶
func (r *DiskReader) ReadMagic(d Diskable) error
func (*DiskReader) Skip ¶
func (r *DiskReader) Skip(n int)
type DiskWriteItem ¶
type DiskWriter ¶
type DiskWriter struct {
// contains filtered or unexported fields
}
func NewDiskWriter ¶
func NewDiskWriter(b []byte) *DiskWriter
func (*DiskWriter) Mark ¶
func (w *DiskWriter) Mark()
func (*DiskWriter) Reset ¶
func (w *DiskWriter) Reset()
func (*DiskWriter) Skip ¶
func (w *DiskWriter) Skip(n int)
func (*DiskWriter) WriteBytes ¶
func (w *DiskWriter) WriteBytes(b []byte)
func (*DiskWriter) WriteItem ¶
func (w *DiskWriter) WriteItem(d DiskWriteItem)
func (*DiskWriter) WriteMagic ¶
func (w *DiskWriter) WriteMagic(d Diskable)
func (*DiskWriter) Written ¶
func (w *DiskWriter) Written() int64
type FileConfig ¶
type FileConfig struct { Ino int32 Name string Flags int Delegate FileDelegater FlushInterval time.Duration Flusher FileFlusher FlushSize int }
type FileDelegater ¶
type FileDelegater interface { InodePoolDelegate ReadData(offset ShortAddr, n int) ([]byte, error) }
type FileFlusher ¶
type FileFlusher interface { WriteByInode(*InodePool, []byte, chan *FlusherWriteReply) Flush(wait bool) }
type FileName ¶
type FileName [FileNameSize]byte
type FlushDelegate ¶
type Flusher ¶
type Flusher struct {
// contains filtered or unexported fields
}
func NewFlusher ¶
func NewFlusher(f *flow.Flow, cfg *FlusherConfig) *Flusher
func (*Flusher) WriteByInode ¶
func (f *Flusher) WriteByInode(inoPool *InodePool, data []byte, done chan *FlusherWriteReply)
type FlusherConfig ¶
type FlusherConfig struct { Interval time.Duration Delegate FlushDelegate Offset int64 }
type FlusherWriteReply ¶
type GStat ¶
type GStat struct { Volume struct { CloseTime ptrace.RatioTime } Flusher struct { BlockCopy ptrace.Size ReadTime ptrace.RatioTime HandleOp struct { Total ptrace.RatioTime DataArea ptrace.RatioTime DataAreaCopy ptrace.RatioTime Partial ptrace.RatioTime Inode ptrace.RatioTime } FlushBuffer ptrace.RatioTime FlushBufferGetOp ptrace.RatioTime Buffering struct { Size ptrace.RatioSize } Flush struct { Total ptrace.RatioTime Count ptrace.Int Size ptrace.RatioSize RawWrite ptrace.RatioTime } CloseTime ptrace.RatioTime FlushBufferAddOp ptrace.RatioTime DataSlice struct { } } Inode struct { Cache struct { NextHit ptrace.Ratio InoIdxHit ptrace.Ratio } ReadDisk ptrace.Int PrevSeekCnt ptrace.Ratio } File struct { FlushSize ptrace.RatioSize RegenBuffer ptrace.Ratio CloseTime ptrace.RatioTime Loop struct { BufferDuration ptrace.RatioTime } Flush struct { WaitSize ptrace.Ratio WaitReply ptrace.RatioTime } DiskRead ptrace.RatioTime } Cobuffer struct { Trytime ptrace.Ratio NotifyFlushByWrite ptrace.Ratio GetData struct { Lock ptrace.RatioTime Copy ptrace.RatioTime Size ptrace.RatioSize } Grow ptrace.RatioTime FlushDelay ptrace.RatioTime FullTime ptrace.RatioTime WriteTime ptrace.RatioTime } }
var Stat GStat
type Inode ¶
type Inode struct { // Magic 4 Ino Int32 Start Int32 Size Int32 // 8 // 1, 2, 4, 8, 16, 32 PrevInode [6]*Address PrevGroup Address // 7*8 GroupSize Int32 GroupIdx Int32 // 8 Mtime Time // 4 Offsets [InodeBlockCnt]ShortAddr // contains filtered or unexported fields }
size: 1kB one inode can store 37.5MB
func (*Inode) GetBlockIdx ¶
func (*Inode) GetBlockSize ¶
func (*Inode) GetRemainInBlock ¶
off: global offset off must in this Inode
func (*Inode) GetSizeIdx ¶
type InodeMap ¶
type InodeMap struct { InoMap []byte // contains filtered or unexported fields }
func NewInodeMap ¶
func NewInodeMap(offset int64, delegate InodeMapDelegate, create bool) (*InodeMap, error)
type InodeMapDelegate ¶
type InodeMapDelegate interface { bio.ReadWriterAt }
type InodePool ¶
type InodePool struct {
// contains filtered or unexported fields
}
Pool for one file
func NewInodePool ¶
func NewInodePool(ino int32, delegate InodePoolDelegate) *InodePool
func (*InodePool) CleanCache ¶
func (p *InodePool) CleanCache()
func (*InodePool) GetLastest ¶
get newest inode from memory or disk
func (*InodePool) ResetCache ¶
func (p *InodePool) ResetCache()
type InodePoolDelegate ¶
type InodeScatter ¶
type InodeScatter [32]*Inode
func (*InodeScatter) Clean ¶
func (is *InodeScatter) Clean()
func (*InodeScatter) Push ¶
func (is *InodeScatter) Push(i *Inode)
func (*InodeScatter) Top ¶
func (is *InodeScatter) Top() *Inode
type NameMap ¶
type NameMap struct {
// contains filtered or unexported fields
}
NameMap is a File which ino is 0 fd close by NameMap
func (*NameMap) GetFreeIno ¶
type NameMapItem ¶
func (*NameMapItem) DiskSize ¶
func (n *NameMapItem) DiskSize() int
func (*NameMapItem) ReadDisk ¶
func (n *NameMapItem) ReadDisk(b []byte) error
func (*NameMapItem) WriteDisk ¶
func (n *NameMapItem) WriteDisk(b []byte)
type Volume ¶
type Volume struct {
// contains filtered or unexported fields
}
func (*Volume) CleanCache ¶
func (v *Volume) CleanCache()
func (*Volume) FlushInodeMap ¶
type VolumeConfig ¶
type VolumeConfig struct { Delegate VolumeDelegate FlushInterval time.Duration FlushSize int }
type VolumeDelegate ¶
type VolumeHeader ¶
func GenNewVolumeHeader ¶
func GenNewVolumeHeader(rw bio.ReadWriterAt) (*VolumeHeader, error)
func ReadVolumeHeader ¶
func ReadVolumeHeader(rw bio.ReadWriterAt) (*VolumeHeader, error)
func (*VolumeHeader) DiskSize ¶
func (v *VolumeHeader) DiskSize() int
func (*VolumeHeader) Magic ¶
func (v *VolumeHeader) Magic() Magic
func (*VolumeHeader) ReadDisk ¶
func (v *VolumeHeader) ReadDisk(b []byte) error
func (*VolumeHeader) WriteDisk ¶
func (v *VolumeHeader) WriteDisk(b []byte)
type VolumeSource ¶
func NewVolumeSource ¶
func NewVolumeSource(dir string) (*VolumeSource, error)
func (*VolumeSource) Close ¶
func (v *VolumeSource) Close()
Click to show internal directories.
Click to hide internal directories.