gobuddyfs

package module
v0.0.0-...-404d872 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2019 License: MIT Imports: 13 Imported by: 1

README

GoBuddyFS

GoDoc Coverage Status

Fuse-based filesystem written in Golang which can use any key-value store as a backend.

Intended to be used with a Chord-based P2P key-value store (DHT) as implemented in https://github.com/buddyfs/buddystore.

Documentation

Index

Constants

View Source
const BLOCK_SIZE = 4096
View Source
const ROOT_BLOCK_KEY = "ROOT"

Variables

This section is empty.

Functions

This section is empty.

Types

type Addressable

type Addressable interface {
	GetId() int64
	SetId(int64)
}

type Block

type Block struct {
	Name string
	Id   int64
	// contains filtered or unexported fields
}

func (*Block) Delete

func (b *Block) Delete(store KVStore)

func (Block) GetId

func (b Block) GetId() int64

func (Block) IsDirty

func (b Block) IsDirty() bool

func (*Block) MarkClean

func (b *Block) MarkClean()

func (*Block) MarkDirty

func (b *Block) MarkDirty()

func (*Block) ReadBlock

func (b *Block) ReadBlock(m Marshalable, store KVStore) error

func (*Block) SetId

func (b *Block) SetId(id int64)

func (*Block) WriteBlock

func (b *Block) WriteBlock(m Marshalable, store KVStore) error

type BlockGenerator

type BlockGenerator interface {
	NewBlock() StorageUnit
	NewNamedBlock(name string) Block
}

type BuddyFS

type BuddyFS struct {
	Lock  sync.Mutex
	Store KVStore

	FSM *FSMeta

	fs.FS
	// contains filtered or unexported fields
}

BuddyFS implements the Buddy file system.

func NewBuddyFS

func NewBuddyFS(store KVStore) *BuddyFS

func (BuddyFS) CreateNewFSMetadata

func (bfs BuddyFS) CreateNewFSMetadata() *FSMeta

func (*BuddyFS) Root

func (bfs *BuddyFS) Root() (fs.Node, error)

type Cacheable

type Cacheable interface {
	MarkDirty()
	MarkClean()
	IsDirty() bool
}

type DataBlock

type DataBlock struct {
	StorageUnit
	Data []byte
}

func (DataBlock) Marshal

func (dBlock DataBlock) Marshal() ([]byte, error)

func (*DataBlock) Unmarshal

func (dBlock *DataBlock) Unmarshal(data []byte) error

type Dir

type Dir struct {
	Dirs  []Block
	Files []Block
	Lock  sync.RWMutex `json:"-"`

	BFS *BuddyFS `json:"-"`
	KVS KVStore  `json:"-"`

	Block
	fs.Node
	// contains filtered or unexported fields
}

Dir implements both Node and Handle for the root directory.

func (Dir) Attr

func (dir Dir) Attr(ctx context.Context, attr *fuse.Attr) error

func (*Dir) Create

func (dir *Dir) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (fs.Node, fs.Handle, error)

func (*Dir) Forget

func (dir *Dir) Forget()

func (*Dir) Lookup

func (dir *Dir) Lookup(ctx context.Context, name string) (fs.Node, error)

func (*Dir) LookupUnlocked

func (dir *Dir) LookupUnlocked(ctx context.Context, name string) (bool, int, fs.Node, error)

func (*Dir) Marshal

func (dir *Dir) Marshal() ([]byte, error)

func (*Dir) Mkdir

func (dir *Dir) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (fs.Node, error)

func (*Dir) ReadDirAll

func (dir *Dir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error)

func (*Dir) Remove

func (dir *Dir) Remove(ctx context.Context, req *fuse.RemoveRequest) error

func (*Dir) Unmarshal

func (dir *Dir) Unmarshal(data []byte) error

type FSMeta

type FSMeta struct {
	Dir
}

func (FSMeta) Marshal

func (fsm FSMeta) Marshal() ([]byte, error)

func (*FSMeta) Unmarshal

func (fsm *FSMeta) Unmarshal(data []byte) error

type File

type File struct {
	Block
	Blocks    []StorageUnit
	Size      uint64
	BlockSize uint64
	KVS       KVStore `json:"-"`

	BlockCache map[int64]*DataBlock `json:"-"`
	BFS        *BuddyFS             `json:"-"`
	// contains filtered or unexported fields
}

TODO: Determine a mechanism to spill over metadata chunks into more block(s). For files which are very large, encoded form of "Blocks" may not fit within a data block.

Currently, we do not consider this case at all. With a 4KB block size, and block list entries being approx 10 bytes long (Block contains a name field which is not always relevant), a File metadata block can contain ~408 block entries, totalling ~1.62MB. With 32K blocks, we can get 102MB. So, this

func (File) Attr

func (file File) Attr(ctx context.Context, attr *fuse.Attr) error

func (*File) Flush

func (file *File) Flush(ctx context.Context, req *fuse.FlushRequest) error

func (*File) Forget

func (file *File) Forget()

func (*File) Fsync

func (file *File) Fsync(ctx context.Context, req *fuse.FsyncRequest) error

func (*File) Marshal

func (file *File) Marshal() ([]byte, error)

func (*File) Open

func (file *File) Open(ctx context.Context, req *fuse.OpenRequest, res *fuse.OpenResponse) (fs.Handle, error)

func (*File) Read

func (file *File) Read(ctx context.Context, req *fuse.ReadRequest, res *fuse.ReadResponse) error

func (*File) Release

func (file *File) Release(ctx context.Context, req *fuse.ReleaseRequest) error

func (*File) Setattr

func (file *File) Setattr(ctx context.Context, req *fuse.SetattrRequest, res *fuse.SetattrResponse) error

func (*File) Unmarshal

func (file *File) Unmarshal(data []byte) error

func (*File) Write

func (file *File) Write(ctx context.Context, req *fuse.WriteRequest, res *fuse.WriteResponse) error

type GKVStore

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

func NewGKVStore

func NewGKVStore(collection *gkvlite.Collection, store *gkvlite.Store) *GKVStore

func (*GKVStore) Get

func (self *GKVStore) Get(key string, retry bool) ([]byte, error)

func (*GKVStore) Set

func (self *GKVStore) Set(key string, value []byte) error

type KVStore

type KVStore interface {
	Get(string, bool) ([]byte, error)
	Set(string, []byte) error
}

type Marshalable

type Marshalable interface {
	Marshal() ([]byte, error)
	Unmarshal([]byte) error
}

type MemStore

type MemStore struct {
	KVStore
	// contains filtered or unexported fields
}

func NewMemStore

func NewMemStore() *MemStore

func (*MemStore) Get

func (self *MemStore) Get(key string, retry bool) ([]byte, error)

func (*MemStore) Set

func (self *MemStore) Set(key string, value []byte) error

type RandomizedBlockGenerator

type RandomizedBlockGenerator struct {
}

func (RandomizedBlockGenerator) NewBlock

func (RandomizedBlockGenerator) NewNamedBlock

func (r RandomizedBlockGenerator) NewNamedBlock(name string) Block

type Storable

type Storable interface {
	WriteBlock(m Marshalable, store KVStore) error
	ReadBlock(m Marshalable, store KVStore) error
	Delete(store KVStore)
}

type StorageUnit

type StorageUnit interface {
	Addressable
	Cacheable
	Storable
}

Directories

Path Synopsis
main

Jump to

Keyboard shortcuts

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