lfs

package
v0.0.0-...-22430d5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Index

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 FakeAddress(ptr uintptr) Address

func InodeAddress

func InodeAddress(i *Inode) Address

func InodeTableAddress

func InodeTableAddress(i *InodeTable) Address

func (Address) InMemory

func (i Address) InMemory() bool

func (Address) ReadAddr

func (i Address) ReadAddr(raw bio.RawDisker, b []byte) (int, error)

func (*Address) ReadDisk

func (i *Address) ReadDisk(r bio.DiskReader) error

func (Address) Size

func (i Address) Size() int

func (*Address) Update

func (i *Address) Update(val Address)

func (Address) Valid

func (i Address) Valid() bool

func (Address) WriteDisk

func (i Address) WriteDisk(w bio.DiskWriter)

type BlockMeta

type BlockMeta int64

func (*BlockMeta) AddLength

func (b *BlockMeta) AddLength(n int)

func (BlockMeta) GetAddr

func (b BlockMeta) GetAddr() int64

func (BlockMeta) GetLength

func (b BlockMeta) GetLength() int

func (BlockMeta) IsEmpty

func (b BlockMeta) IsEmpty() bool

func (*BlockMeta) Set

func (b *BlockMeta) Set(length int, addr int64)

func (*BlockMeta) SetLength

func (b *BlockMeta) SetLength(n int)

func (*BlockMeta) SetPadding

func (b *BlockMeta) SetPadding(n int16)

func (BlockMeta) String

func (b BlockMeta) String() string

type File

type File struct {
	// contains filtered or unexported fields
}

func NewFile

func NewFile(f *flow.Flow, delegate FileDelegate, ino int32, name string) (*File, error)

func (*File) Close

func (f *File) Close()

func (*File) Flush

func (f *File) Flush()

func (*File) Name

func (f *File) Name() string

func (*File) Read

func (f *File) Read(b []byte) (n int, err error)

func (*File) ReadAt

func (f *File) ReadAt(b []byte, offset int64) (n int, err error)

func (*File) Write

func (f *File) Write(b []byte) (n int, err error)

type FileDelegate

type FileDelegate interface {
	GetFlushNotify() chan struct{}
	MallocWriter(n int) *bio.DeviceWriter
	NextInode(*Inode) (*Inode, error)
	PrevInode(*Inode) (*Inode, error)
	ForceFlush()
	ReadDeviceAt([]byte, int64) (int, error)
	GetInode(ino int32) (*Inode, error)
	DoneFlush()
}

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 (n *Inode) AddBlockSize(idx int, size int)

func (*Inode) FindAvailable

func (n *Inode) FindAvailable() int

func (*Inode) InitBlock

func (n *Inode) InitBlock(idx int, addr int64)

func (*Inode) ReadDisk

func (n *Inode) ReadDisk(r bio.DiskReader) error

func (*Inode) SetBlock

func (n *Inode) SetBlock(idx int, size int, addr int64)

func (*Inode) Size

func (n *Inode) Size() int

func (*Inode) String

func (n *Inode) String() string

func (*Inode) WriteDisk

func (n *Inode) WriteDisk(w bio.DiskWriter)

type InodeMgr

type InodeMgr struct {
	// contains filtered or unexported fields
}

func NewInodeMgr

func NewInodeMgr(f *flow.Flow) *InodeMgr

func (*InodeMgr) Close

func (i *InodeMgr) Close()

func (*InodeMgr) Flush

func (i *InodeMgr) Flush() error

func (*InodeMgr) GenNextInode

func (i *InodeMgr) GenNextInode(inode *Inode) (*Inode, error)

func (*InodeMgr) GetInode

func (i *InodeMgr) GetInode(ino int32) (*Inode, error)

func (*InodeMgr) GetInodeAddr

func (i *InodeMgr) GetInodeAddr(ino int32) (Address, error)

func (*InodeMgr) GetInodeByAddr

func (i *InodeMgr) GetInodeByAddr(addr Address) (*Inode, error)

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) GetPointer

func (i *InodeMgr) GetPointer() *int64

must Init first,

func (*InodeMgr) Init

func (i *InodeMgr) Init(raw bio.RawDisker) error

func (*InodeMgr) InodeCount

func (i *InodeMgr) InodeCount() int

func (*InodeMgr) NewInode

func (i *InodeMgr) NewInode() (*Inode, error)

func (*InodeMgr) RemoveInode

func (i *InodeMgr) RemoveInode(ino int32) error

func (*InodeMgr) Start

func (i *InodeMgr) Start(dev *bio.DeviceMgr)

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 RootDir

type RootDir struct {
	// contains filtered or unexported fields
}

func NewRootDir

func NewRootDir(v *Volume) (*RootDir, error)

func (*RootDir) Add

func (r *RootDir) Add(name string, ino int32) error

func (*RootDir) Find

func (r *RootDir) Find(name string) int32

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 NewVolume

func NewVolume(f *flow.Flow, raw bio.RawDisker) (*Volume, error)

func (*Volume) Close

func (v *Volume) Close()

func (*Volume) DoneFlush

func (v *Volume) DoneFlush()

func (*Volume) ForceFlush

func (v *Volume) ForceFlush()

func (*Volume) GetFlushNotify

func (v *Volume) GetFlushNotify() chan struct{}

func (*Volume) GetInode

func (v *Volume) GetInode(ino int32) (*Inode, error)

func (*Volume) MallocWriter

func (v *Volume) MallocWriter(n int) *bio.DeviceWriter

func (*Volume) NextInode

func (v *Volume) NextInode(i *Inode) (*Inode, error)

func (*Volume) OpenFile

func (v *Volume) OpenFile(name string, autoCreate bool) (*File, error)

func (*Volume) PrevInode

func (v *Volume) PrevInode(i *Inode) (*Inode, error)

func (*Volume) ReadDeviceAt

func (v *Volume) ReadDeviceAt(b []byte, off int64) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL