Documentation ¶
Index ¶
- Constants
- Variables
- type Address
- type BlockMeta
- func (b *BlockMeta) AddLength(n int)
- func (b BlockMeta) GetAddr() int64
- func (b BlockMeta) GetLength() int
- func (b BlockMeta) IsEmpty() bool
- func (b *BlockMeta) Set(length int, addr int64)
- func (b *BlockMeta) SetLength(n int)
- func (b *BlockMeta) SetPadding(n int16)
- func (b BlockMeta) String() string
- type File
- type FileDelegate
- type Inode
- func (n *Inode) AddBlockSize(idx int, size int)
- func (n *Inode) FindAvailable() int
- func (n *Inode) InitBlock(idx int, addr int64)
- func (n *Inode) ReadDisk(r bio.DiskReader) error
- func (n *Inode) SetBlock(idx int, size int, addr int64)
- func (n *Inode) Size() int
- func (n *Inode) String() string
- func (n *Inode) WriteDisk(w bio.DiskWriter)
- type InodeMgr
- func (i *InodeMgr) Close()
- func (i *InodeMgr) Flush() error
- func (i *InodeMgr) GenNextInode(inode *Inode) (*Inode, error)
- func (i *InodeMgr) GetInode(ino int32) (*Inode, error)
- func (i *InodeMgr) GetInodeAddr(ino int32) (Address, error)
- func (i *InodeMgr) GetInodeByAddr(addr Address) (*Inode, error)
- func (i *InodeMgr) GetInodeTable(addr Address) (*InodeTable, error)
- func (i *InodeMgr) GetPointer() *int64
- func (i *InodeMgr) Init(raw bio.RawDisker) error
- func (i *InodeMgr) InodeCount() int
- func (i *InodeMgr) NewInode() (*Inode, error)
- func (i *InodeMgr) RemoveInode(ino int32) error
- func (i *InodeMgr) Start(dev *bio.DeviceMgr)
- type InodeMgrState
- type InodeTable
- type ReservedArea
- type RootDir
- type Superblock
- type Volume
- func (v *Volume) Close()
- func (v *Volume) DoneFlush()
- func (v *Volume) ForceFlush()
- func (v *Volume) GetFlushNotify() chan struct{}
- func (v *Volume) GetInode(ino int32) (*Inode, error)
- func (v *Volume) MallocWriter(n int) *bio.DeviceWriter
- func (v *Volume) NextInode(i *Inode) (*Inode, error)
- func (v *Volume) OpenFile(name string, autoCreate bool) (*File, error)
- func (v *Volume) PrevInode(i *Inode) (*Inode, error)
- func (v *Volume) ReadDeviceAt(b []byte, off int64) (int, error)
Constants ¶
View Source
const ( BlockBit = 12 BlockSize = 1 << BlockBit Ones52 = 0xFFFFFFFFFFFFF Ones12 = 0xFFF )
View Source
const ( InodeTableCap = 15 MaxInodeSize = 127 * 512 * InodeTableCap )
View Source
const AddressSize = 8
View Source
const InodeSize = 128
View Source
const InodeTableSize = 128
View Source
const (
ReservedAreaSize = 128 * BlockSize
)
ReservedArea
View Source
const SuperblockSize = BlockSize
Variables ¶
View Source
var ( InodeTableMagic = []byte{0x8a, 0x9c, 0x0, 0x1} ErrDecodeNotInodeTable = logex.Define("not inodeTable") )
View Source
var ( InodeMagic = []byte{0x8a, 0x9c, 0x0, 0x2} ErrDecodeNotInode = logex.Define("not inode") )
View Source
var ( ErrAddressIsInMemory = logex.Define("address is in memory") ErrAddressNotValid = logex.Define("address is not valid") ErrInodeMgrNotStarted = logex.Define("not started") ErrInodeMgrInodeNotFound = logex.Define("inode is not found") )
View Source
var ( ErrInodeHasNotPrev = logex.Define("the prev of inode is nil") ErrVolumeFileNotExists = logex.Define("file is not exists") ErrVolumeFileAlreadyExists = logex.Define("file is already exists") )
View Source
var (
ErrFileClosed = logex.Define("file is closed")
)
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address int64
func FakeAddress ¶
func InodeAddress ¶
func InodeTableAddress ¶
func InodeTableAddress(i *InodeTable) Address
func (Address) WriteDisk ¶
func (i Address) WriteDisk(w bio.DiskWriter)
type FileDelegate ¶
type Inode ¶
type Inode struct { Magic [4]byte Ino int32 Start int64 End int64 Create int64 // the address of previous IndirectBlock/Inode/IndirectIndo Prev int64 BlockMeta [11]BlockMeta }
1G 要读1万个 ...
func (*Inode) AddBlockSize ¶
func (*Inode) FindAvailable ¶
func (*Inode) WriteDisk ¶
func (n *Inode) WriteDisk(w bio.DiskWriter)
type InodeMgr ¶
type InodeMgr struct {
// contains filtered or unexported fields
}
func NewInodeMgr ¶
func (*InodeMgr) GetInodeByAddr ¶
make sure addr is Valid()
func (*InodeMgr) GetInodeTable ¶
func (i *InodeMgr) GetInodeTable(addr Address) (*InodeTable, error)
get inode table from cache or disk
func (*InodeMgr) InodeCount ¶
func (*InodeMgr) RemoveInode ¶
type InodeMgrState ¶
type InodeMgrState int32
const ( InodeMgrStateInit InodeMgrState = iota InodeMgrStateStarting InodeMgrStateStarted InodeMgrStateClosed )
func (*InodeMgrState) After ¶
func (i *InodeMgrState) After(val InodeMgrState) bool
func (*InodeMgrState) Set ¶
func (i *InodeMgrState) Set(val InodeMgrState) bool
type InodeTable ¶
type InodeTable struct { Magic [4]byte Address [15]Address // contains filtered or unexported fields }
func (*InodeTable) FindAvailable ¶
func (i *InodeTable) FindAvailable() int
func (*InodeTable) ReadDisk ¶
func (i *InodeTable) ReadDisk(r bio.DiskReader) error
func (*InodeTable) Size ¶
func (i *InodeTable) Size() int
func (*InodeTable) WriteDisk ¶
func (i *InodeTable) WriteDisk(w bio.DiskWriter)
type ReservedArea ¶
type ReservedArea struct { Superblock Superblock IndirectInodeTable [MaxInodeSize / InodeTableCap]Address }
TODO(chzyer): add the size on Tables in testcase
func NewReservedArea ¶
func NewReservedArea() *ReservedArea
func (*ReservedArea) GetIdx ¶
func (r *ReservedArea) GetIdx(ino int32) (idxL1, idxL2 int)
get the index of IndirectInodeTable and InodeTable
func (*ReservedArea) GetInoStartByIndirInodeTbl ¶
func (r *ReservedArea) GetInoStartByIndirInodeTbl(i int) int
func (*ReservedArea) ReadDisk ¶
func (r *ReservedArea) ReadDisk(reader bio.DiskReader) error
func (*ReservedArea) Size ¶
func (*ReservedArea) Size() int
func (*ReservedArea) WriteDisk ¶
func (r *ReservedArea) WriteDisk(w bio.DiskWriter)
type Superblock ¶
type Superblock struct { Version int32 InodeCnt int32 Checkpoint int64 // contains filtered or unexported fields }
1 block
func (*Superblock) Init ¶
func (s *Superblock) Init()
func (*Superblock) ReadDisk ¶
func (s *Superblock) ReadDisk(r bio.DiskReader) error
func (*Superblock) Size ¶
func (*Superblock) Size() int
func (*Superblock) WriteDisk ¶
func (s *Superblock) WriteDisk(w bio.DiskWriter)
type Volume ¶
type Volume struct {
// contains filtered or unexported fields
}
func (*Volume) ForceFlush ¶
func (v *Volume) ForceFlush()
func (*Volume) GetFlushNotify ¶
func (v *Volume) GetFlushNotify() chan struct{}
func (*Volume) MallocWriter ¶
func (v *Volume) MallocWriter(n int) *bio.DeviceWriter
Click to show internal directories.
Click to hide internal directories.