Implement basic operations (#7)

* Implement basic operations

Signed-off-by: Xuanwo <github@xuanwo.io>

* Remove build on windows

Signed-off-by: Xuanwo <github@xuanwo.io>

* Fix build

Signed-off-by: Xuanwo <github@xuanwo.io>

* Update badger

Signed-off-by: Xuanwo <github@xuanwo.io>

* Readdir is work

Signed-off-by: Xuanwo <github@xuanwo.io>

* Fix inode not found

Signed-off-by: Xuanwo <github@xuanwo.io>
This commit is contained in:
Xuanwo 2021-07-15 17:59:57 +08:00 committed by GitHub
parent 236c009d20
commit 55e69864a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 1804 additions and 20 deletions

View File

@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
go: [ "1.15", "1.16" ]
os: [ubuntu-latest, windows-latest, macos-latest]
os: [ubuntu-latest, macos-latest]
steps:
- name: Set up Go 1.x

View File

@ -8,29 +8,25 @@ help:
@echo " build to create bin directory and build"
@echo " test to run test"
check: vet
format:
@echo "go fmt"
@go fmt ./...
@echo "ok"
go fmt ./...
vet:
@echo "go vet"
@go vet ./...
@echo "ok"
go vet ./...
build: tidy format check
@echo "build storage"
@go build -o bin/beyondfs ./cmd/beyondfs
@echo "ok"
generate:
go generate ./...
build: tidy generate format vet
go build -o bin/beyondfs ./cmd/beyondfs
test:
@echo "run test"
@go test -race -coverprofile=coverage.txt -covermode=atomic -v ./...
@go tool cover -html="coverage.txt" -o "coverage.html"
@echo "ok"
go test -race -coverprofile=coverage.txt -covermode=atomic -v ./...
go tool cover -html="coverage.txt" -o "coverage.html"
tidy:
@go mod tidy
@go mod verify
go mod tidy
go mod verify
clean:
find . -type f -name '*gen*.go' -delete

View File

@ -1,5 +1,38 @@
package main
import (
"os"
"go.uber.org/zap"
"github.com/beyondstorage/beyond-fs/fuse/hanwen"
"github.com/beyondstorage/beyond-fs/vfs"
)
func main() {
print("Hello, world!")
logger, _ := zap.NewDevelopment()
cfg := &vfs.Config{
StoragePath: os.Getenv("BEYONDFS_UNDER_PATH"),
Logger: logger,
}
fs, err := vfs.NewFS(cfg)
if err != nil {
logger.Error("new fs", zap.Error(err))
return
}
srv, err := hanwen.New(&hanwen.Config{
FileSystem: fs,
MountPoint: os.Getenv("BEYONDFS_MOUNT_PATH"),
Logger: logger,
})
if err != nil {
logger.Error("new hanwen fuse", zap.Error(err))
return
}
srv.Serve()
}

10
fuse/hanwen/const.go Normal file
View File

@ -0,0 +1,10 @@
package hanwen
import "math"
const (
BlockSize = 4096
MaximumSpace = 1024 * 1024 * 1024 * 1024 * 1024 // Set total space to 1PB
MaximumBlocks = MaximumSpace / BlockSize
MaximumInodes = math.MaxUint64 // Set maximum inodes to max uint64.
)

480
fuse/hanwen/fs.go Normal file
View File

@ -0,0 +1,480 @@
package hanwen
import (
"errors"
"os"
"time"
"github.com/beyondstorage/go-storage/v4/services"
"github.com/hanwen/go-fuse/v2/fuse"
"go.uber.org/zap"
"github.com/beyondstorage/beyond-fs/vfs"
)
type FS struct {
fs *vfs.FS
logger *zap.Logger
}
type Config struct {
FileSystem *vfs.FS
MountPoint string
Logger *zap.Logger
}
func New(cfg *Config) (srv *fuse.Server, err error) {
fuseFS := &FS{
fs: cfg.FileSystem,
logger: cfg.Logger,
}
if fuseFS.logger == nil {
fuseFS.logger, _ = zap.NewDevelopment()
}
return fuse.NewServer(fuseFS, cfg.MountPoint, &fuse.MountOptions{
AllowOther: true,
Options: nil,
MaxBackground: 0,
MaxWrite: 0,
MaxReadAhead: 0,
IgnoreSecurityLabels: false,
RememberInodes: false,
FsName: "",
Name: "",
SingleThreaded: false,
DisableXAttrs: false,
Debug: true,
EnableLocks: false,
ExplicitDataCacheControl: false,
DirectMount: false,
DirectMountFlags: 0,
})
}
func fillEntryOut(i *vfs.Inode, out *fuse.EntryOut) fuse.Status {
out.SetAttrTimeout(time.Minute)
out.SetEntryTimeout(10 * time.Minute)
out.NodeId = i.ID
out.Generation = 1
out.Ino = i.ID
out.Size = i.Size
out.Mode = parseMode(i.Mode)
out.Blocks = (out.Size + 255) / 256
out.Nlink = 1
out.Gid = 1000
out.Uid = 1000
out.SetTimes(&i.Atime, &i.Mtime, &i.Ctime)
return fuse.OK
}
func fillAttrOut(i *vfs.Inode, out *fuse.AttrOut) fuse.Status {
out.SetTimeout(time.Minute)
out.Ino = i.ID
out.Size = i.Size
out.Mode = parseMode(i.Mode)
out.Blocks = (out.Size + 255) / 256
out.Nlink = 1
out.Gid = 1000
out.Uid = 1000
out.SetTimes(&i.Atime, &i.Mtime, &i.Ctime)
return fuse.OK
}
func parseError(err error) fuse.Status {
switch {
case errors.Is(err, services.ErrObjectNotExist):
return fuse.ENOENT
case errors.Is(err, services.ErrPermissionDenied):
return fuse.EACCES
default:
return fuse.EAGAIN
}
}
func parseType(o uint32) uint32 {
osMode := os.FileMode(o)
var mode uint32
if osMode.IsDir() {
mode = fuse.S_IFDIR
} else {
mode = fuse.S_IFREG
}
return mode
}
func parseMode(o uint32) uint32 {
osMode := os.FileMode(o)
var mode uint32
if osMode.IsDir() {
mode = fuse.S_IFDIR | 0755
} else {
mode = fuse.S_IFREG | 0644
}
return mode
}
func (fs *FS) String() string {
return "beyondfs"
}
func (fs *FS) SetDebug(debug bool) {
return
}
func (fs *FS) Lookup(cancel <-chan struct{}, header *fuse.InHeader, name string, out *fuse.EntryOut) (status fuse.Status) {
ino, err := fs.fs.GetInode(header.NodeId)
if err != nil {
fs.logger.Error("internal error", zap.Error(err))
return fuse.EAGAIN
}
if ino == nil {
fs.logger.Error("parent inode not found",
zap.Uint64("parent", header.NodeId))
return fuse.ENOENT
}
if !ino.IsDir() {
fs.logger.Error("parent inode is not a dir",
zap.Uint64("parent", header.NodeId),
zap.Uint32("mode", ino.Mode))
return fuse.EINVAL
}
node, err := fs.fs.GetEntry(ino.ID, name)
if err != nil {
return
}
if node == nil {
return fuse.ENOENT
}
return fillEntryOut(node, out)
}
func (fs *FS) Forget(nodeid, nlookup uint64) {
fs.fs.DeleteInode(nodeid)
}
func (fs *FS) GetAttr(cancel <-chan struct{}, input *fuse.GetAttrIn, out *fuse.AttrOut) (code fuse.Status) {
ino, err := fs.fs.GetInode(input.NodeId)
if err != nil {
fs.logger.Error("internal error",
zap.Error(err))
return fuse.EAGAIN
}
if ino == nil {
fs.logger.Error("inode not found",
zap.Uint64("inode", input.NodeId))
return fuse.ENOENT
}
return fillAttrOut(ino, out)
}
func (fs *FS) SetAttr(cancel <-chan struct{}, input *fuse.SetAttrIn, out *fuse.AttrOut) (code fuse.Status) {
ino, err := fs.fs.GetInode(input.NodeId)
if err != nil {
fs.logger.Error("internal error",
zap.Error(err))
return fuse.EAGAIN
}
if ino == nil {
fs.logger.Error("inode not found",
zap.Uint64("inode", input.NodeId))
return fuse.ENOENT
}
// TODO: we need to update attr
return fillAttrOut(ino, out)
}
func (fs *FS) Mknod(cancel <-chan struct{}, input *fuse.MknodIn, name string, out *fuse.EntryOut) (code fuse.Status) {
panic("implement me")
}
func (fs *FS) Mkdir(cancel <-chan struct{}, input *fuse.MkdirIn, name string, out *fuse.EntryOut) (code fuse.Status) {
return fuse.ENOSYS
}
func (fs *FS) Unlink(cancel <-chan struct{}, header *fuse.InHeader, name string) (code fuse.Status) {
ino, err := fs.fs.GetInode(header.NodeId)
if err != nil {
fs.logger.Error("internal error",
zap.Error(err))
return fuse.EAGAIN
}
if ino == nil {
fs.logger.Error("inode not found",
zap.Uint64("inode", header.NodeId))
return fuse.ENOENT
}
if !ino.IsDir() {
fs.logger.Error("parent inode is not a dir",
zap.Uint64("parent", header.NodeId),
zap.Uint32("mode", ino.Mode))
return fuse.EINVAL
}
err = fs.fs.Delete(ino.ID, name)
if err != nil {
fs.logger.Error("internal error",
zap.Error(err))
return fuse.EAGAIN
}
return fuse.OK
}
func (fs *FS) Rmdir(cancel <-chan struct{}, header *fuse.InHeader, name string) (code fuse.Status) {
return fuse.ENOSYS
}
func (fs *FS) Rename(cancel <-chan struct{}, input *fuse.RenameIn, oldName string, newName string) (code fuse.Status) {
return fuse.ENOSYS
}
func (fs *FS) Link(cancel <-chan struct{}, input *fuse.LinkIn, filename string, out *fuse.EntryOut) (code fuse.Status) {
return fuse.ENOSYS
}
func (fs *FS) Symlink(cancel <-chan struct{}, header *fuse.InHeader, pointedTo string, linkName string, out *fuse.EntryOut) (code fuse.Status) {
return fuse.ENOSYS
}
func (fs *FS) Readlink(cancel <-chan struct{}, header *fuse.InHeader) (out []byte, code fuse.Status) {
return nil, fuse.ENOSYS
}
func (fs *FS) Access(cancel <-chan struct{}, input *fuse.AccessIn) (code fuse.Status) {
return fuse.OK
}
func (fs *FS) GetXAttr(cancel <-chan struct{}, header *fuse.InHeader, attr string, dest []byte) (sz uint32, code fuse.Status) {
return 0, fuse.ENOSYS
}
func (fs *FS) ListXAttr(cancel <-chan struct{}, header *fuse.InHeader, dest []byte) (uint32, fuse.Status) {
return 0, fuse.ENOSYS
}
func (fs *FS) SetXAttr(cancel <-chan struct{}, input *fuse.SetXAttrIn, attr string, data []byte) fuse.Status {
return fuse.ENOSYS
}
func (fs *FS) RemoveXAttr(cancel <-chan struct{}, header *fuse.InHeader, attr string) (code fuse.Status) {
return fuse.ENOSYS
}
func (fs *FS) Create(cancel <-chan struct{}, input *fuse.CreateIn, name string, out *fuse.CreateOut) (code fuse.Status) {
ino, err := fs.fs.GetInode(input.NodeId)
if err != nil {
fs.logger.Error("internal error",
zap.Error(err))
return fuse.EAGAIN
}
if ino == nil {
fs.logger.Error("inode not found",
zap.Uint64("inode", input.NodeId))
return fuse.ENOENT
}
if !ino.IsDir() {
fs.logger.Error("parent inode is not a dir",
zap.Uint64("parent", input.NodeId),
zap.Uint32("mode", ino.Mode))
return fuse.EINVAL
}
// Implement me
return fuse.OK
}
func (fs *FS) Open(cancel <-chan struct{}, input *fuse.OpenIn, out *fuse.OpenOut) (status fuse.Status) {
ino, err := fs.fs.GetInode(input.NodeId)
if err != nil {
fs.logger.Error("internal error",
zap.Error(err))
return fuse.EAGAIN
}
if ino == nil {
fs.logger.Error("inode not found",
zap.Uint64("inode", input.NodeId))
return fuse.ENOENT
}
panic("implement me")
}
func (fs *FS) Read(cancel <-chan struct{}, input *fuse.ReadIn, buf []byte) (fuse.ReadResult, fuse.Status) {
panic("implement me")
}
func (fs *FS) Lseek(cancel <-chan struct{}, in *fuse.LseekIn, out *fuse.LseekOut) fuse.Status {
panic("implement me")
}
func (fs *FS) GetLk(cancel <-chan struct{}, input *fuse.LkIn, out *fuse.LkOut) (code fuse.Status) {
return fuse.ENOSYS
}
func (fs *FS) SetLk(cancel <-chan struct{}, input *fuse.LkIn) (code fuse.Status) {
return fuse.ENOSYS
}
func (fs *FS) SetLkw(cancel <-chan struct{}, input *fuse.LkIn) (code fuse.Status) {
return fuse.ENOSYS
}
func (fs *FS) Release(cancel <-chan struct{}, input *fuse.ReleaseIn) {
panic("implement me")
}
func (fs *FS) Write(cancel <-chan struct{}, input *fuse.WriteIn, data []byte) (written uint32, code fuse.Status) {
panic("implement me")
}
func (fs *FS) CopyFileRange(cancel <-chan struct{}, input *fuse.CopyFileRangeIn) (written uint32, code fuse.Status) {
return 0, fuse.ENOSYS
}
func (fs *FS) Flush(cancel <-chan struct{}, input *fuse.FlushIn) fuse.Status {
panic("implement me")
}
func (fs *FS) Fsync(cancel <-chan struct{}, input *fuse.FsyncIn) (code fuse.Status) {
return fuse.OK
}
func (fs *FS) Fallocate(cancel <-chan struct{}, input *fuse.FallocateIn) (code fuse.Status) {
return fuse.OK
}
func (fs *FS) OpenDir(cancel <-chan struct{}, input *fuse.OpenIn, out *fuse.OpenOut) (status fuse.Status) {
ino, err := fs.fs.GetInode(input.NodeId)
if err != nil {
fs.logger.Error("internal error",
zap.Error(err))
return fuse.EAGAIN
}
if ino == nil {
fs.logger.Error("inode not found",
zap.Uint64("inode", input.NodeId))
return fuse.ENOENT
}
if !ino.IsDir() {
fs.logger.Error("parent inode is not a dir",
zap.Uint64("parent", input.NodeId),
zap.Uint32("mode", ino.Mode))
return fuse.EINVAL
}
dh, err := fs.fs.CreateDirHandle(ino)
if err != nil {
fs.logger.Error("open dir",
zap.Uint64("parent", input.NodeId),
zap.Error(err))
return fuse.EAGAIN
}
out.Fh = dh.ID
return fuse.OK
}
func (fs *FS) ReadDir(cancel <-chan struct{}, input *fuse.ReadIn, out *fuse.DirEntryList) fuse.Status {
dh, err := fs.fs.GetDirHandle(input.Fh)
if err != nil {
fs.logger.Error("get dir handle", zap.Error(err))
return fuse.EAGAIN
}
for {
node, err := dh.Next()
if err != nil {
fs.logger.Error("get next inode", zap.Error(err))
return fuse.EAGAIN
}
if node == nil {
break
}
ok := out.AddDirEntry(fuse.DirEntry{
Mode: parseMode(node.Mode),
Name: node.Name,
Ino: node.ID,
})
if !ok {
break
}
}
return fuse.OK
}
func (fs *FS) ReadDirPlus(cancel <-chan struct{}, input *fuse.ReadIn, out *fuse.DirEntryList) fuse.Status {
dh, err := fs.fs.GetDirHandle(input.Fh)
if err != nil {
fs.logger.Error("get dir handle", zap.Error(err))
return fuse.EAGAIN
}
for {
node, err := dh.Next()
if err != nil {
fs.logger.Error("get next inode", zap.Error(err))
return fuse.EAGAIN
}
if node == nil {
break
}
entry := out.AddDirLookupEntry(fuse.DirEntry{
Mode: parseMode(node.Mode),
Name: node.Name,
Ino: node.ID,
})
if entry == nil {
break
}
fillEntryOut(node, entry)
}
return fuse.OK
}
func (fs *FS) ReleaseDir(input *fuse.ReleaseIn) {
err := fs.fs.DeleteDirHandle(input.Fh)
if err != nil {
fs.logger.Error("delete dir handle", zap.Error(err))
}
}
func (fs *FS) FsyncDir(cancel <-chan struct{}, input *fuse.FsyncIn) (code fuse.Status) {
return fuse.OK
}
func (fs *FS) StatFs(cancel <-chan struct{}, input *fuse.InHeader, out *fuse.StatfsOut) (code fuse.Status) {
out.Bsize = BlockSize
out.Blocks = MaximumBlocks
out.Bfree = MaximumBlocks
out.Bavail = MaximumBlocks
out.Ffree = MaximumSpace
return fuse.OK
}
func (fs *FS) Init(server *fuse.Server) {
}

14
go.mod
View File

@ -1,3 +1,17 @@
module github.com/beyondstorage/beyond-fs
go 1.15
require (
github.com/Xuanwo/go-bufferpool v0.1.0
github.com/beyondstorage/go-service-fs/v3 v3.2.0
github.com/beyondstorage/go-service-s3/v2 v2.2.0
github.com/beyondstorage/go-storage/v4 v4.2.0
github.com/dgraph-io/badger/v3 v3.2103.1
github.com/golang/protobuf v1.4.2 // indirect
github.com/hanwen/go-fuse/v2 v2.1.0
github.com/tinylib/msgp v1.1.6
go.uber.org/atomic v1.7.0
go.uber.org/zap v1.18.1
gopkg.in/yaml.v2 v2.3.0 // indirect
)

249
go.sum Normal file
View File

@ -0,0 +1,249 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/Xuanwo/go-bufferpool v0.1.0 h1:f8eEZcAa/pe+baqTRXwgrVYQpqGX0TC26qCxQvLNlKA=
github.com/Xuanwo/go-bufferpool v0.1.0/go.mod h1:Mle++9GGouhOwGj52i9PJLNAPmW2nb8PWBP7JJzNCzk=
github.com/Xuanwo/templateutils v0.1.0 h1:WpkWOqQtIQ2vAIpJLa727DdN8WtxhUkkbDGa6UhntJY=
github.com/Xuanwo/templateutils v0.1.0/go.mod h1:OdE0DJ+CJxDBq6psX5DPV+gOZi8bhuHuVUpPCG++Wb8=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/aws/aws-sdk-go v1.38.68 h1:aOG8geU4SohNp659eKBHRBgbqSrZ6jNZlfimIuJAwL8=
github.com/aws/aws-sdk-go v1.38.68/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beyondstorage/go-endpoint v1.0.1 h1:F8x2dGLMu9je6g7zPbKoxCXDlug97K26SeCx7KEHgyg=
github.com/beyondstorage/go-endpoint v1.0.1/go.mod h1:P2hknaGrziOJJKySv/XnAiVw/d3v12/LZu2gSxEx4nM=
github.com/beyondstorage/go-integration-test/v4 v4.1.1/go.mod h1:ihtCaOJvaHGE0v+IhY6ZUF5NU1IND6xmdrJI9Lq/jhc=
github.com/beyondstorage/go-service-fs/v3 v3.2.0 h1:POC1Z9b7Z6dTQycPnEsjRVtq7PndFInHzsP/A1Y9T+0=
github.com/beyondstorage/go-service-fs/v3 v3.2.0/go.mod h1:dHLOhJtn8Uh1WGuL5m6DN9/ZtWbBFD+CKRhga535wkY=
github.com/beyondstorage/go-service-s3/v2 v2.2.0 h1:aAQa4yXMb1AoeZWaQI5bhDbKARSbg/avRb0yu09Wlrc=
github.com/beyondstorage/go-service-s3/v2 v2.2.0/go.mod h1:R5W0FHPt6RmFAEO/ngoJ04q3G/i+mb38GCJNPZPwtxc=
github.com/beyondstorage/go-storage/v4 v4.2.0 h1:J0xqqy4qEQRtIS2zUWMA5wRXVHx/cxX5fHsU2ezA3+I=
github.com/beyondstorage/go-storage/v4 v4.2.0/go.mod h1:rUNzOXcikYk5w0ewvNsKbztg7ndQDyDvjDuP0bznSLU=
github.com/beyondstorage/specs/go v0.0.0-20210623065218-d1c2d7d81259 h1:mW9XpHLc6pdXBRnsha1VlqF0rNsB/Oc+8l+5UYngmRA=
github.com/beyondstorage/specs/go v0.0.0-20210623065218-d1c2d7d81259/go.mod h1:vF/Q0P1tCvhVAUrxg7i6NvrARRMQVTAuQdDNqpSzR1w=
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/dave/dst v0.26.2 h1:lnxLAKI3tx7MgLNVDirFCsDTlTG9nKTk7GcptKcWSwY=
github.com/dave/dst v0.26.2/go.mod h1:UMDJuIRPfyUCC78eFuB+SV/WI8oDeyFDvM/JR6NI3IU=
github.com/dave/gopackages v0.0.0-20170318123100-46e7023ec56e/go.mod h1:i00+b/gKdIDIxuLDFob7ustLAVqhsZRk2qVZrArELGQ=
github.com/dave/jennifer v1.2.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg=
github.com/dave/kerr v0.0.0-20170318121727-bc25dd6abe8e/go.mod h1:qZqlPyPvfsDJt+3wHJ1EvSXDuVjFTK0j2p/ca+gtsb8=
github.com/dave/rebecca v0.9.1/go.mod h1:N6XYdMD/OKw3lkF3ywh8Z6wPGuwNFDNtWYEMFWEmXBA=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgraph-io/badger/v3 v3.2103.1 h1:zaX53IRg7ycxVlkd5pYdCeFp1FynD6qBGQoQql3R3Hk=
github.com/dgraph-io/badger/v3 v3.2103.1/go.mod h1:dULbq6ehJ5K0cGW/1TQ9iSfUk0gbSiToDWmWmTsJ53E=
github.com/dgraph-io/ristretto v0.1.0 h1:Jv3CGQHp9OjuMBSne1485aDpUkTKEcUqF+jm/LuerPI=
github.com/dgraph-io/ristretto v0.1.0/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 h1:ZgQEtGgCBiWRM39fZuwSd1LwSqqSW0hOdXCYYDX0R3I=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.5.0 h1:jlYHihg//f7RRwuPfptm04yp4s7O6Kw8EZiVYIGcH0g=
github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA=
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/flatbuffers v1.12.0 h1:/PtAHvnBY4Kqnx/xCQ3OIV9uYcSFGScBsWI3Oogeh6w=
github.com/google/flatbuffers v1.12.0/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/pprof v0.0.0-20181127221834-b4f47329b966/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs=
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/hanwen/go-fuse v1.0.0 h1:GxS9Zrn6c35/BnfiVsZVWmsG803xwE7eVRDvcf/BEVc=
github.com/hanwen/go-fuse v1.0.0/go.mod h1:unqXarDXqzAk0rt98O2tVndEPIpUgLD9+rwFisZH3Ok=
github.com/hanwen/go-fuse/v2 v2.1.0 h1:+32ffteETaLYClUj0a3aHjZ1hOPxxaNEHiZiujuDaek=
github.com/hanwen/go-fuse/v2 v2.1.0/go.mod h1:oRyA5eK+pvJyv5otpO/DgccS8y/RvYMaO00GgRLGryc=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kevinburke/go-bindata v3.22.0+incompatible h1:/JmqEhIWQ7GRScV0WjX/0tqBrC5D21ALg0H0U/KZ/ts=
github.com/kevinburke/go-bindata v3.22.0+incompatible/go.mod h1:/pEEZ72flUW2p0yi30bslSp9YqD9pysLxunQDdb2CPM=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.12.3 h1:G5AfA94pHPysR56qqrkO2pxEexdDzrpFJ6yt/VqWxVU=
github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml v1.9.3 h1:zeC5b1GviRUyKYd6OJPvBU/mcVDVoL1OhT17FCt5dSQ=
github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/philhofer/fwd v1.1.1 h1:GdGcTjf5RNAxwS4QLsiMzJYj5KEvPJD3Abr261yRQXQ=
github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/qingstor/go-mime v0.1.0 h1:FhTJtM7TRm9pfgCXpjGUxqwbumGojrgE9ecRz5PXvfc=
github.com/qingstor/go-mime v0.1.0/go.mod h1:EDwWgaMufg74m7futsF0ZGkdA52ajjAycY+XDeV8M88=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tinylib/msgp v1.1.6 h1:i+SbKraHhnrf9M5MYmvQhFnbLhAXSDWF8WWsuyRdocw=
github.com/tinylib/msgp v1.1.6/go.mod h1:75BAfg2hauQhs3qedfdDZmWAPcFMAvJE5b9rGOMufyw=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.opencensus.io v0.22.5 h1:dntmOdLpSpHlVqbW5Eay97DelsZHe+55D+xC6i0dDS0=
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0=
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/zap v1.18.1 h1:CSUJ2mjFszzEWt4CdKISEuChVIXGBn3lAPwkRGyVrc4=
go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
golang.org/x/arch v0.0.0-20180920145803-b19384d3c130/go.mod h1:cYlCBUl1MsqxdiKgmc4uh7TxZfWSFLOGSRR090WDxt8=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7 h1:iGu644GcxtEcrInvDsQRCwJjtCIOlT2V7IRt6ah2Whw=
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a h1:CB3a9Nez8M13wwlr/E2YtwoU+qYHKfC+JrDa45RXXoQ=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/src-d/go-billy.v4 v4.3.0 h1:KtlZ4c1OWbIs4jCv5ZXrTqG8EQocr0g/d4DjNg70aek=
gopkg.in/src-d/go-billy.v4 v4.3.0/go.mod h1:tm33zBoOwxjYHZIE+OV8bxTWFMJLrconzFMd38aARFk=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

128
meta/badger.go Normal file
View File

@ -0,0 +1,128 @@
package meta
import (
"fmt"
"time"
"github.com/dgraph-io/badger/v3"
)
type badgerDB struct {
db *badger.DB
}
func NewBadger() (Service, error) {
db, err := badger.Open(badger.DefaultOptions("").
WithLogger(nil).
WithMetricsEnabled(false).
WithInMemory(true))
if err != nil {
return nil, fmt.Errorf("new pebble: %w", err)
}
return badgerDB{db: db}, nil
}
func (db badgerDB) Get(key []byte) (value []byte, err error) {
txn := db.db.NewTransaction(false)
defer txn.Discard()
v, err := txn.Get(key)
if err != nil && err == badger.ErrKeyNotFound {
return nil, nil
}
if err != nil {
return nil, fmt.Errorf("get key %s: %w", key, err)
}
return v.ValueCopy(nil)
}
func (db badgerDB) Set(key, value []byte, ttl time.Duration) (err error) {
txn := db.db.NewTransaction(true)
defer txn.Discard()
e := &badger.Entry{
Key: key,
Value: value,
}
if ttl != 0 {
e.ExpiresAt = uint64(time.Now().Add(ttl).Unix())
}
err = txn.SetEntry(e)
if err != nil {
return err
}
return txn.Commit()
}
func (db badgerDB) Delete(key []byte) (err error) {
txn := db.db.NewTransaction(true)
defer txn.Discard()
err = txn.Delete(key)
if err != nil {
return err
}
return txn.Commit()
}
func (db badgerDB) PrefixDelete(prefix []byte) (err error) {
txn := db.db.NewTransaction(true)
defer txn.Discard()
it := txn.NewIterator(badger.IteratorOptions{
Prefix: prefix,
})
defer it.Close()
for it.Rewind(); it.Valid(); it.Next() {
item := it.Item()
err = txn.Delete(item.Key())
if err != nil {
return err
}
}
return txn.Commit()
}
func (db badgerDB) Scan(prefix []byte) Iterator {
txn := db.db.NewTransaction(false)
defer txn.Discard()
it := txn.NewIterator(badger.IteratorOptions{
Prefix: prefix,
})
it.Rewind()
return badgerIterator{it: it}
}
type badgerIterator struct {
it *badger.Iterator
}
func (b badgerIterator) Next() bool {
b.it.Next()
return b.it.Valid()
}
func (b badgerIterator) Seek(key []byte) {
b.it.Seek(key)
}
func (b badgerIterator) Entry() (key, value []byte, err error) {
item := b.it.Item()
key = item.KeyCopy(nil)
value, err = item.ValueCopy(nil)
return
}
func (b badgerIterator) Close() {
b.it.Close()
b.it = nil
}

43
meta/badger_bench_test.go Normal file
View File

@ -0,0 +1,43 @@
package meta
import (
"bytes"
"testing"
"time"
)
func BenchmarkGet(b *testing.B) {
srv, err := NewBadger()
if err != nil {
b.Error(err)
return
}
key := bytes.Repeat([]byte{'a'}, 128)
value := bytes.Repeat([]byte{'a'}, 1024)
err = srv.Set(key, value, time.Hour)
if err != nil {
b.Error(err)
return
}
for i := 0; i < b.N; i++ {
_, _ = srv.Get(key)
}
}
func BenchmarkSet(b *testing.B) {
srv, err := NewBadger()
if err != nil {
b.Error(err)
return
}
key := bytes.Repeat([]byte{'a'}, 128)
value := bytes.Repeat([]byte{'a'}, 1024)
for i := 0; i < b.N; i++ {
_ = srv.Set(key, value, time.Hour)
}
}

45
meta/const.go Normal file
View File

@ -0,0 +1,45 @@
package meta
import "github.com/Xuanwo/go-bufferpool"
var (
pool = bufferpool.New(128)
// i:<ino> => Inode
inodePrefix = []byte("i:")
// d:<ino>:<name> => Inode
dirPrefix = []byte("d:")
)
func InodeKey(id uint64) []byte {
buf := pool.Get()
defer buf.Free()
buf.AppendBytes(inodePrefix)
buf.AppendUint(id)
return buf.BytesCopy()
}
func EntryKey(id uint64, name string) []byte {
buf := pool.Get()
defer buf.Free()
buf.AppendBytes(dirPrefix)
buf.AppendUint(id)
buf.AppendByte(':')
buf.AppendString(name)
return buf.BytesCopy()
}
func EntryPrefix(id uint64) []byte {
buf := pool.Get()
defer buf.Free()
buf.AppendBytes(dirPrefix)
buf.AppendUint(id)
buf.AppendByte(':')
return buf.BytesCopy()
}

21
meta/meta.go Normal file
View File

@ -0,0 +1,21 @@
package meta
import "time"
type Service interface {
// Get will get the value with specified key.
//
// value will be nil if key not found.
Get(key []byte) (value []byte, err error)
Set(key, value []byte, ttl time.Duration) (err error)
Delete(key []byte) (err error)
PrefixDelete(prefix []byte) (err error)
Scan(prefix []byte) Iterator
}
type Iterator interface {
Next() bool
Seek(key []byte)
Entry() (key, value []byte, err error)
Close()
}

67
vfs/dir.go Normal file
View File

@ -0,0 +1,67 @@
package vfs
import (
"errors"
"github.com/beyondstorage/beyond-fs/meta"
"github.com/beyondstorage/go-storage/v4/types"
"sync"
"time"
)
type dirHandleMap struct {
lock sync.Mutex
m map[uint64]*DirHandle
}
func newDirHandleMap() *dirHandleMap {
return &dirHandleMap{
m: make(map[uint64]*DirHandle),
}
}
func (dhm *dirHandleMap) Get(id uint64) *DirHandle {
dhm.lock.Lock()
defer dhm.lock.Unlock()
return dhm.m[id]
}
func (dhm *dirHandleMap) Set(id uint64, dh *DirHandle) {
dhm.lock.Lock()
defer dhm.lock.Unlock()
dhm.m[id] = dh
}
func (dhm *dirHandleMap) Delete(id uint64) {
dhm.lock.Lock()
defer dhm.lock.Unlock()
delete(dhm.m, id)
}
type DirHandle struct {
ID uint64
ino *Inode
fs *FS
it *types.ObjectIterator
meta meta.Service
}
func (dh *DirHandle) Next() (ino *Inode, err error) {
o, err := dh.it.Next()
if err != nil && errors.Is(err, types.IterateDone) {
return nil, nil
}
if err != nil {
return nil, err
}
ino = newInode(dh.ino.ID, o)
err = dh.fs.SetInode(ino, time.Minute)
if err != nil {
return
}
return
}

172
vfs/fs.go Normal file
View File

@ -0,0 +1,172 @@
package vfs
import (
"fmt"
"go.uber.org/atomic"
"time"
_ "github.com/beyondstorage/go-service-fs/v3"
_ "github.com/beyondstorage/go-service-s3/v2"
"github.com/beyondstorage/go-storage/v4/pairs"
"github.com/beyondstorage/go-storage/v4/services"
"github.com/beyondstorage/go-storage/v4/types"
"go.uber.org/zap"
"github.com/beyondstorage/beyond-fs/meta"
)
var (
nextInode = atomic.NewUint64(0)
nextHandle = atomic.NewUint64(0)
)
func NextInodeID() uint64 {
return nextInode.Inc()
}
func NextHandle() uint64 {
return nextHandle.Inc()
}
type FS struct {
s types.Storager
meta meta.Service
dhm *dirHandleMap
logger *zap.Logger
}
type Config struct {
StoragePath string
Logger *zap.Logger
}
func NewFS(cfg *Config) (fs *FS, err error) {
store, err := services.NewStoragerFromString(cfg.StoragePath)
if err != nil {
return nil, err
}
metaSrv, err := meta.NewBadger()
if err != nil {
return nil, err
}
fs = &FS{
s: store,
meta: metaSrv,
dhm: newDirHandleMap(),
logger: cfg.Logger,
}
o := types.NewObject(nil, true)
o.ID = store.Metadata().WorkDir
o.Path = ""
o.Mode = types.ModeDir
err = fs.SetInode(newInode(1, o), 0)
if err != nil {
return nil, err
}
return fs, err
}
func (fs *FS) Delete(parent uint64, name string) (err error) {
panic("implement me")
}
func (fs *FS) DeleteDir(path string) (err error) {
panic("implement me")
}
func (fs *FS) CreateDirHandle(ino *Inode) (dh *DirHandle, err error) {
it, err := fs.s.List(ino.Path, pairs.WithListMode(types.ListModeDir))
if err != nil {
return
}
dh = &DirHandle{
ID: NextHandle(),
ino: ino,
fs: fs,
it: it,
meta: fs.meta,
}
fs.dhm.Set(dh.ID, dh)
return dh, err
}
func (fs *FS) GetDirHandle(dhid uint64) (dh *DirHandle, err error) {
return fs.dhm.Get(dhid), nil
}
func (fs *FS) DeleteDirHandle(dhid uint64) (err error) {
fs.dhm.Delete(dhid)
return nil
}
func (fs *FS) SetInode(ino *Inode, ttl time.Duration) (err error) {
bs, err := ino.MarshalMsg(nil)
if err != nil {
return fmt.Errorf("marshal inode: %w", err)
}
err = fs.meta.Set(meta.InodeKey(ino.ID), bs, ttl)
if err != nil {
return fmt.Errorf("set inode: %w", err)
}
if ino.ID == ino.ParentID {
// Don't set entry key for root directory.
return nil
}
err = fs.meta.Set(meta.EntryKey(ino.ParentID, ino.Name), bs, ttl)
if err != nil {
return fmt.Errorf("set entry: %w", err)
}
return nil
}
func (fs *FS) GetInode(id uint64) (ino *Inode, err error) {
bs, err := fs.meta.Get(meta.InodeKey(id))
if err != nil {
return nil, fmt.Errorf("get inode: %w", err)
}
if bs == nil {
return nil, nil
}
ino = &Inode{}
_, err = ino.UnmarshalMsg(bs)
if err != nil {
return nil, fmt.Errorf("unmarshal inode: %w", err)
}
return
}
func (fs *FS) DeleteInode(id uint64) (err error) {
err = fs.meta.Delete(meta.InodeKey(id))
if err != nil {
return fmt.Errorf("del inode: %w", err)
}
return
}
func (fs *FS) GetEntry(parent uint64, name string) (ino *Inode, err error) {
bs, err := fs.meta.Get(meta.EntryKey(parent, name))
if err != nil {
return nil, fmt.Errorf("get entry: %w", err)
}
if bs == nil {
return nil, nil
}
ino = &Inode{}
_, err = ino.UnmarshalMsg(bs)
if err != nil {
return nil, fmt.Errorf("unmarshal inode: %w", err)
}
return
}

61
vfs/inode.go Normal file
View File

@ -0,0 +1,61 @@
package vfs
import (
"github.com/beyondstorage/go-storage/v4/types"
"os"
"path"
"time"
)
//go:generate go run github.com/tinylib/msgp
type Inode struct {
ID uint64
ParentID uint64
Path string
Name string
Generation uint64
Size uint64
Mode uint32 // The same with os.FileMode
Atime time.Time
Mtime time.Time
Ctime time.Time
}
func (ino *Inode) IsDir() bool {
return ino.Mode&uint32(os.ModeDir) != 0
}
func newInode(parent uint64, o *types.Object) *Inode {
ino := &Inode{
ID: NextInodeID(),
ParentID: parent,
Path: o.Path,
Name: path.Base(o.Path),
Generation: 1,
Mode: formatMode(o.Mode),
}
if v, ok := o.GetContentLength(); ok {
ino.Size = uint64(v)
}
// TODO: we will support other time later
if v, ok := o.GetLastModified(); ok {
ino.Atime = v
ino.Mtime = v
ino.Ctime = v
}
return ino
}
func formatMode(o types.ObjectMode) uint32 {
var mode uint32
if o.IsDir() {
mode = uint32(os.ModeDir) | 0755
} else {
mode = 0644
}
return mode
}

335
vfs/inode_gen.go Normal file
View File

@ -0,0 +1,335 @@
package vfs
// Code generated by github.com/tinylib/msgp DO NOT EDIT.
import (
"github.com/tinylib/msgp/msgp"
)
// DecodeMsg implements msgp.Decodable
func (z *Inode) DecodeMsg(dc *msgp.Reader) (err error) {
var field []byte
_ = field
var zb0001 uint32
zb0001, err = dc.ReadMapHeader()
if err != nil {
err = msgp.WrapError(err)
return
}
for zb0001 > 0 {
zb0001--
field, err = dc.ReadMapKeyPtr()
if err != nil {
err = msgp.WrapError(err)
return
}
switch msgp.UnsafeString(field) {
case "ID":
z.ID, err = dc.ReadUint64()
if err != nil {
err = msgp.WrapError(err, "ID")
return
}
case "ParentID":
z.ParentID, err = dc.ReadUint64()
if err != nil {
err = msgp.WrapError(err, "ParentID")
return
}
case "Path":
z.Path, err = dc.ReadString()
if err != nil {
err = msgp.WrapError(err, "Path")
return
}
case "Name":
z.Name, err = dc.ReadString()
if err != nil {
err = msgp.WrapError(err, "Name")
return
}
case "Generation":
z.Generation, err = dc.ReadUint64()
if err != nil {
err = msgp.WrapError(err, "Generation")
return
}
case "Size":
z.Size, err = dc.ReadUint64()
if err != nil {
err = msgp.WrapError(err, "Size")
return
}
case "Mode":
z.Mode, err = dc.ReadUint32()
if err != nil {
err = msgp.WrapError(err, "Mode")
return
}
case "Atime":
z.Atime, err = dc.ReadTime()
if err != nil {
err = msgp.WrapError(err, "Atime")
return
}
case "Mtime":
z.Mtime, err = dc.ReadTime()
if err != nil {
err = msgp.WrapError(err, "Mtime")
return
}
case "Ctime":
z.Ctime, err = dc.ReadTime()
if err != nil {
err = msgp.WrapError(err, "Ctime")
return
}
default:
err = dc.Skip()
if err != nil {
err = msgp.WrapError(err)
return
}
}
}
return
}
// EncodeMsg implements msgp.Encodable
func (z *Inode) EncodeMsg(en *msgp.Writer) (err error) {
// map header, size 10
// write "ID"
err = en.Append(0x8a, 0xa2, 0x49, 0x44)
if err != nil {
return
}
err = en.WriteUint64(z.ID)
if err != nil {
err = msgp.WrapError(err, "ID")
return
}
// write "ParentID"
err = en.Append(0xa8, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x49, 0x44)
if err != nil {
return
}
err = en.WriteUint64(z.ParentID)
if err != nil {
err = msgp.WrapError(err, "ParentID")
return
}
// write "Path"
err = en.Append(0xa4, 0x50, 0x61, 0x74, 0x68)
if err != nil {
return
}
err = en.WriteString(z.Path)
if err != nil {
err = msgp.WrapError(err, "Path")
return
}
// write "Name"
err = en.Append(0xa4, 0x4e, 0x61, 0x6d, 0x65)
if err != nil {
return
}
err = en.WriteString(z.Name)
if err != nil {
err = msgp.WrapError(err, "Name")
return
}
// write "Generation"
err = en.Append(0xaa, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e)
if err != nil {
return
}
err = en.WriteUint64(z.Generation)
if err != nil {
err = msgp.WrapError(err, "Generation")
return
}
// write "Size"
err = en.Append(0xa4, 0x53, 0x69, 0x7a, 0x65)
if err != nil {
return
}
err = en.WriteUint64(z.Size)
if err != nil {
err = msgp.WrapError(err, "Size")
return
}
// write "Mode"
err = en.Append(0xa4, 0x4d, 0x6f, 0x64, 0x65)
if err != nil {
return
}
err = en.WriteUint32(z.Mode)
if err != nil {
err = msgp.WrapError(err, "Mode")
return
}
// write "Atime"
err = en.Append(0xa5, 0x41, 0x74, 0x69, 0x6d, 0x65)
if err != nil {
return
}
err = en.WriteTime(z.Atime)
if err != nil {
err = msgp.WrapError(err, "Atime")
return
}
// write "Mtime"
err = en.Append(0xa5, 0x4d, 0x74, 0x69, 0x6d, 0x65)
if err != nil {
return
}
err = en.WriteTime(z.Mtime)
if err != nil {
err = msgp.WrapError(err, "Mtime")
return
}
// write "Ctime"
err = en.Append(0xa5, 0x43, 0x74, 0x69, 0x6d, 0x65)
if err != nil {
return
}
err = en.WriteTime(z.Ctime)
if err != nil {
err = msgp.WrapError(err, "Ctime")
return
}
return
}
// MarshalMsg implements msgp.Marshaler
func (z *Inode) MarshalMsg(b []byte) (o []byte, err error) {
o = msgp.Require(b, z.Msgsize())
// map header, size 10
// string "ID"
o = append(o, 0x8a, 0xa2, 0x49, 0x44)
o = msgp.AppendUint64(o, z.ID)
// string "ParentID"
o = append(o, 0xa8, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x49, 0x44)
o = msgp.AppendUint64(o, z.ParentID)
// string "Path"
o = append(o, 0xa4, 0x50, 0x61, 0x74, 0x68)
o = msgp.AppendString(o, z.Path)
// string "Name"
o = append(o, 0xa4, 0x4e, 0x61, 0x6d, 0x65)
o = msgp.AppendString(o, z.Name)
// string "Generation"
o = append(o, 0xaa, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e)
o = msgp.AppendUint64(o, z.Generation)
// string "Size"
o = append(o, 0xa4, 0x53, 0x69, 0x7a, 0x65)
o = msgp.AppendUint64(o, z.Size)
// string "Mode"
o = append(o, 0xa4, 0x4d, 0x6f, 0x64, 0x65)
o = msgp.AppendUint32(o, z.Mode)
// string "Atime"
o = append(o, 0xa5, 0x41, 0x74, 0x69, 0x6d, 0x65)
o = msgp.AppendTime(o, z.Atime)
// string "Mtime"
o = append(o, 0xa5, 0x4d, 0x74, 0x69, 0x6d, 0x65)
o = msgp.AppendTime(o, z.Mtime)
// string "Ctime"
o = append(o, 0xa5, 0x43, 0x74, 0x69, 0x6d, 0x65)
o = msgp.AppendTime(o, z.Ctime)
return
}
// UnmarshalMsg implements msgp.Unmarshaler
func (z *Inode) UnmarshalMsg(bts []byte) (o []byte, err error) {
var field []byte
_ = field
var zb0001 uint32
zb0001, bts, err = msgp.ReadMapHeaderBytes(bts)
if err != nil {
err = msgp.WrapError(err)
return
}
for zb0001 > 0 {
zb0001--
field, bts, err = msgp.ReadMapKeyZC(bts)
if err != nil {
err = msgp.WrapError(err)
return
}
switch msgp.UnsafeString(field) {
case "ID":
z.ID, bts, err = msgp.ReadUint64Bytes(bts)
if err != nil {
err = msgp.WrapError(err, "ID")
return
}
case "ParentID":
z.ParentID, bts, err = msgp.ReadUint64Bytes(bts)
if err != nil {
err = msgp.WrapError(err, "ParentID")
return
}
case "Path":
z.Path, bts, err = msgp.ReadStringBytes(bts)
if err != nil {
err = msgp.WrapError(err, "Path")
return
}
case "Name":
z.Name, bts, err = msgp.ReadStringBytes(bts)
if err != nil {
err = msgp.WrapError(err, "Name")
return
}
case "Generation":
z.Generation, bts, err = msgp.ReadUint64Bytes(bts)
if err != nil {
err = msgp.WrapError(err, "Generation")
return
}
case "Size":
z.Size, bts, err = msgp.ReadUint64Bytes(bts)
if err != nil {
err = msgp.WrapError(err, "Size")
return
}
case "Mode":
z.Mode, bts, err = msgp.ReadUint32Bytes(bts)
if err != nil {
err = msgp.WrapError(err, "Mode")
return
}
case "Atime":
z.Atime, bts, err = msgp.ReadTimeBytes(bts)
if err != nil {
err = msgp.WrapError(err, "Atime")
return
}
case "Mtime":
z.Mtime, bts, err = msgp.ReadTimeBytes(bts)
if err != nil {
err = msgp.WrapError(err, "Mtime")
return
}
case "Ctime":
z.Ctime, bts, err = msgp.ReadTimeBytes(bts)
if err != nil {
err = msgp.WrapError(err, "Ctime")
return
}
default:
bts, err = msgp.Skip(bts)
if err != nil {
err = msgp.WrapError(err)
return
}
}
}
o = bts
return
}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *Inode) Msgsize() (s int) {
s = 1 + 3 + msgp.Uint64Size + 9 + msgp.Uint64Size + 5 + msgp.StringPrefixSize + len(z.Path) + 5 + msgp.StringPrefixSize + len(z.Name) + 11 + msgp.Uint64Size + 5 + msgp.Uint64Size + 5 + msgp.Uint32Size + 6 + msgp.TimeSize + 6 + msgp.TimeSize + 6 + msgp.TimeSize
return
}

123
vfs/inode_gen_test.go Normal file
View File

@ -0,0 +1,123 @@
package vfs
// Code generated by github.com/tinylib/msgp DO NOT EDIT.
import (
"bytes"
"testing"
"github.com/tinylib/msgp/msgp"
)
func TestMarshalUnmarshalInode(t *testing.T) {
v := Inode{}
bts, err := v.MarshalMsg(nil)
if err != nil {
t.Fatal(err)
}
left, err := v.UnmarshalMsg(bts)
if err != nil {
t.Fatal(err)
}
if len(left) > 0 {
t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
}
left, err = msgp.Skip(bts)
if err != nil {
t.Fatal(err)
}
if len(left) > 0 {
t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
}
}
func BenchmarkMarshalMsgInode(b *testing.B) {
v := Inode{}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
v.MarshalMsg(nil)
}
}
func BenchmarkAppendMsgInode(b *testing.B) {
v := Inode{}
bts := make([]byte, 0, v.Msgsize())
bts, _ = v.MarshalMsg(bts[0:0])
b.SetBytes(int64(len(bts)))
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
bts, _ = v.MarshalMsg(bts[0:0])
}
}
func BenchmarkUnmarshalInode(b *testing.B) {
v := Inode{}
bts, _ := v.MarshalMsg(nil)
b.ReportAllocs()
b.SetBytes(int64(len(bts)))
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, err := v.UnmarshalMsg(bts)
if err != nil {
b.Fatal(err)
}
}
}
func TestEncodeDecodeInode(t *testing.T) {
v := Inode{}
var buf bytes.Buffer
msgp.Encode(&buf, &v)
m := v.Msgsize()
if buf.Len() > m {
t.Log("WARNING: TestEncodeDecodeInode Msgsize() is inaccurate")
}
vn := Inode{}
err := msgp.Decode(&buf, &vn)
if err != nil {
t.Error(err)
}
buf.Reset()
msgp.Encode(&buf, &v)
err = msgp.NewReader(&buf).Skip()
if err != nil {
t.Error(err)
}
}
func BenchmarkEncodeInode(b *testing.B) {
v := Inode{}
var buf bytes.Buffer
msgp.Encode(&buf, &v)
b.SetBytes(int64(buf.Len()))
en := msgp.NewWriter(msgp.Nowhere)
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
v.EncodeMsg(en)
}
en.Flush()
}
func BenchmarkDecodeInode(b *testing.B) {
v := Inode{}
var buf bytes.Buffer
msgp.Encode(&buf, &v)
b.SetBytes(int64(buf.Len()))
rd := msgp.NewEndlessReader(buf.Bytes(), b)
dc := msgp.NewReader(rd)
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
err := v.DecodeMsg(dc)
if err != nil {
b.Fatal(err)
}
}
}

7
vfs/tools.go Normal file
View File

@ -0,0 +1,7 @@
//+build tools
package vfs
import "github.com/tinylib/msgp/msgp"
var _ msgp.Marshaler