vfs

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MODE_MASK_R = 4
	MODE_MASK_W = 2
	MODE_MASK_X = 1
)
View Source
const (
	NEW = iota
	BUSY
	REFRESH
	BREAK
	READY
	INVALID
)

* state of sliceReader * * <-- REFRESH * | | * NEW -> BUSY -> READY * | | * BREAK ---> INVALID

View Source
const F_UNLCK = syscall.F_UNLCK
View Source
const O_ACCMODE = syscall.O_ACCMODE
View Source
const O_RECOVERED = 1 << 31 // is recovered fd

Variables

View Source
var (
	LastBackupTimeG = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "last_successful_backup",
		Help: "Last successful backup.",
	})
	LastBackupDurationG = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "last_backup_duration",
		Help: "Last backup duration.",
	})
)

Functions

func Backup

func Backup(m meta.Meta, blob object.ObjectStorage, interval time.Duration, skipTrash bool)

Backup metadata periodically in the object storage

func Compact

func Compact(conf chunk.Config, store chunk.ChunkStore, slices []meta.Slice, id uint64) error

func GetACLType

func GetACLType(name string) uint8

func GetInternalNodeByName

func GetInternalNodeByName(name string) (Ino, *Attr)

func InitMetrics

func InitMetrics(registerer prometheus.Registerer)

func IsSpecialName

func IsSpecialName(name string) bool

func IsSpecialNode

func IsSpecialNode(ino Ino) bool

Types

type Attr

type Attr = meta.Attr

type CacheAction

type CacheAction uint8
const (
	WarmupCache CacheAction = iota
	EvictCache
	CheckCache = 2
)

func (CacheAction) String

func (act CacheAction) String() string

type CacheResponse

type CacheResponse struct {
	FileCount  uint64
	SliceCount uint64
	TotalBytes uint64
	MissBytes  uint64 // for check op
}

func (*CacheResponse) Add

func (resp *CacheResponse) Add(other CacheResponse)

type Config

type Config struct {
	Meta                 *meta.Config
	Format               meta.Format
	Chunk                *chunk.Config
	Port                 *Port
	Version              string
	AttrTimeout          time.Duration
	DirEntryTimeout      time.Duration
	EntryTimeout         time.Duration
	BackupMeta           time.Duration
	BackupSkipTrash      bool
	FastResolve          bool   `json:",omitempty"`
	AccessLog            string `json:",omitempty"`
	PrefixInternal       bool
	HideInternal         bool
	RootSquash           *RootSquash `json:",omitempty"`
	NonDefaultPermission bool        `json:",omitempty"`

	Pid        int
	PPid       int
	DebugAgent string
	CommPath   string       `json:",omitempty"`
	StatePath  string       `json:",omitempty"`
	FuseOpts   *FuseOptions `json:",omitempty"`
}

type Context

type Context = LogContext

type DataReader

type DataReader interface {
	Open(inode Ino, length uint64) FileReader
	Truncate(inode Ino, length uint64)
	Invalidate(inode Ino, off, length uint64)
}

func NewDataReader

func NewDataReader(conf *Config, m meta.Meta, store chunk.ChunkStore) DataReader

type DataWriter

type DataWriter interface {
	Open(inode Ino, fleng uint64) FileWriter
	Flush(ctx meta.Context, inode Ino) syscall.Errno
	GetLength(inode Ino) uint64
	Truncate(inode Ino, length uint64)
	UpdateMtime(inode Ino, mtime time.Time)
	FlushAll() error
}

func NewDataWriter

func NewDataWriter(conf *Config, m meta.Meta, store chunk.ChunkStore, reader DataReader) DataWriter

type Entry

type Entry meta.Entry

Entry is an alias of meta.Entry, which is used to generate the string representation lazily.

func (*Entry) String

func (entry *Entry) String() string

type FileReader

type FileReader interface {
	Read(ctx meta.Context, off uint64, buf []byte) (int, syscall.Errno)
	GetLength() uint64
	Close(ctx meta.Context)
}

type FileWriter

type FileWriter interface {
	Write(ctx meta.Context, offset uint64, data []byte) syscall.Errno
	Flush(ctx meta.Context) syscall.Errno
	Close(ctx meta.Context) syscall.Errno
	GetLength() uint64
	Truncate(length uint64)
}

type FuseOptions

type FuseOptions struct {
	AllowOther               bool
	Options                  []string
	MaxBackground            int
	MaxWrite                 int
	MaxReadAhead             int
	MaxPages                 int
	IgnoreSecurityLabels     bool // ignoring labels should be provided as a fusermount mount option.
	RememberInodes           bool
	FsName                   string
	Name                     string
	SingleThreaded           bool
	DisableXAttrs            bool
	Debug                    bool
	EnableLocks              bool
	ExplicitDataCacheControl bool
	DirectMount              bool
	DirectMountFlags         uintptr
	EnableAcl                bool
	EnableWriteback          bool
	EnableIoctl              bool
	DontUmask                bool
	OtherCaps                uint32
	NoAllocForRead           bool
}

FuseOptions contains options for fuse mount, keep the same structure with `fuse.MountOptions`

func (FuseOptions) StripOptions

func (o FuseOptions) StripOptions() FuseOptions

type InfoResponse

type InfoResponse struct {
	Ino     Ino
	Failed  bool
	Reason  string
	Summary meta.Summary
	Paths   []string
	Chunks  []*chunkSlice
	Objects []*chunkObj
	PLocks  []meta.PLockItem
	FLocks  []meta.FLockItem
}

type Ino

type Ino = meta.Ino

type LogContext

type LogContext interface {
	meta.Context
	Duration() time.Duration
}

LogContext is an interface to add duration on meta.Context.

func NewLogContext

func NewLogContext(ctx meta.Context) LogContext

NewLogContext creates an LogContext starting from now.

type Port

type Port struct {
	PrometheusAgent string `json:",omitempty"`
	DebugAgent      string `json:",omitempty"`
	ConsulAddr      string `json:",omitempty"`
	PyroscopeAddr   string `json:",omitempty"`
}

type RootSquash

type RootSquash struct {
	Uid uint32
	Gid uint32
}

type Statfs

type Statfs struct {
	Total  uint64
	Avail  uint64
	Files  uint64
	Favail uint64
}

type SummaryReponse

type SummaryReponse struct {
	Errno syscall.Errno
	Tree  meta.TreeSummary
}

type VFS

type VFS struct {
	Conf            *Config
	Meta            meta.Meta
	Store           chunk.ChunkStore
	InvalidateEntry func(parent meta.Ino, name string) syscall.Errno
	UpdateFormat    func(*meta.Format)
	// contains filtered or unexported fields
}

func NewVFS

func NewVFS(conf *Config, m meta.Meta, store chunk.ChunkStore, registerer prometheus.Registerer, registry *prometheus.Registry) *VFS

func (*VFS) Access

func (v *VFS) Access(ctx Context, ino Ino, mask int) (err syscall.Errno)

func (*VFS) CopyFileRange

func (v *VFS) CopyFileRange(ctx Context, nodeIn Ino, fhIn, offIn uint64, nodeOut Ino, fhOut, offOut, size uint64, flags uint32) (copied uint64, err syscall.Errno)

func (*VFS) Create

func (v *VFS) Create(ctx Context, parent Ino, name string, mode uint16, cumask uint16, flags uint32) (entry *meta.Entry, fh uint64, err syscall.Errno)

func (*VFS) Fallocate

func (v *VFS) Fallocate(ctx Context, ino Ino, mode uint8, off, size int64, fh uint64) (err syscall.Errno)

func (*VFS) Flock

func (v *VFS) Flock(ctx Context, ino Ino, fh uint64, owner uint64, typ uint32, block bool) (err syscall.Errno)

func (*VFS) Flush

func (v *VFS) Flush(ctx Context, ino Ino, fh uint64, lockOwner uint64) (err syscall.Errno)

func (*VFS) FlushAll

func (v *VFS) FlushAll(path string) (err error)

func (*VFS) Fsync

func (v *VFS) Fsync(ctx Context, ino Ino, datasync int, fh uint64) (err syscall.Errno)

func (*VFS) GetAttr

func (v *VFS) GetAttr(ctx Context, ino Ino, opened uint8) (entry *meta.Entry, err syscall.Errno)

func (*VFS) GetXattr

func (v *VFS) GetXattr(ctx Context, ino Ino, name string, size uint32) (value []byte, err syscall.Errno)

func (*VFS) Getlk

func (v *VFS) Getlk(ctx Context, ino Ino, fh uint64, owner uint64, start, len *uint64, typ *uint32, pid *uint32) (err syscall.Errno)

func (*VFS) Ioctl

func (v *VFS) Ioctl(ctx Context, ino Ino, cmd uint32, arg uint64, bufIn, bufOut []byte) (err syscall.Errno)
func (v *VFS) Link(ctx Context, ino Ino, newparent Ino, newname string) (entry *meta.Entry, err syscall.Errno)

func (*VFS) ListXattr

func (v *VFS) ListXattr(ctx Context, ino Ino, size int) (data []byte, err syscall.Errno)

func (*VFS) Lookup

func (v *VFS) Lookup(ctx Context, parent Ino, name string) (entry *meta.Entry, err syscall.Errno)

func (*VFS) Mkdir

func (v *VFS) Mkdir(ctx Context, parent Ino, name string, mode uint16, cumask uint16) (entry *meta.Entry, err syscall.Errno)

func (*VFS) Mknod

func (v *VFS) Mknod(ctx Context, parent Ino, name string, mode uint16, cumask uint16, rdev uint32) (entry *meta.Entry, err syscall.Errno)

func (*VFS) ModifiedSince

func (v *VFS) ModifiedSince(ino Ino, start time.Time) bool

func (*VFS) Open

func (v *VFS) Open(ctx Context, ino Ino, flags uint32) (entry *meta.Entry, fh uint64, err syscall.Errno)

func (*VFS) Opendir

func (v *VFS) Opendir(ctx Context, ino Ino, flags uint32) (fh uint64, err syscall.Errno)

func (*VFS) Read

func (v *VFS) Read(ctx Context, ino Ino, buf []byte, off uint64, fh uint64) (n int, err syscall.Errno)

func (*VFS) Readdir

func (v *VFS) Readdir(ctx Context, ino Ino, size uint32, off int, fh uint64, plus bool) (entries []*meta.Entry, readAt time.Time, err syscall.Errno)
func (v *VFS) Readlink(ctx Context, ino Ino) (path []byte, err syscall.Errno)

func (*VFS) Release

func (v *VFS) Release(ctx Context, ino Ino, fh uint64)

func (*VFS) ReleaseHandler

func (v *VFS) ReleaseHandler(ino Ino, fh uint64)

func (*VFS) Releasedir

func (v *VFS) Releasedir(ctx Context, ino Ino, fh uint64) int

func (*VFS) RemoveXattr

func (v *VFS) RemoveXattr(ctx Context, ino Ino, name string) (err syscall.Errno)

func (*VFS) Rename

func (v *VFS) Rename(ctx Context, parent Ino, name string, newparent Ino, newname string, flags uint32) (err syscall.Errno)

func (*VFS) Rmdir

func (v *VFS) Rmdir(ctx Context, parent Ino, name string) (err syscall.Errno)

func (*VFS) SetAttr

func (v *VFS) SetAttr(ctx Context, ino Ino, set int, fh uint64, mode, uid, gid uint32, atime, mtime int64, atimensec, mtimensec uint32, size uint64) (entry *meta.Entry, err syscall.Errno)

func (*VFS) SetXattr

func (v *VFS) SetXattr(ctx Context, ino Ino, name string, value []byte, flags uint32) (err syscall.Errno)

func (*VFS) Setlk

func (v *VFS) Setlk(ctx Context, ino Ino, fh uint64, owner uint64, start, end uint64, typ uint32, pid uint32, block bool) (err syscall.Errno)

func (*VFS) StatFS

func (v *VFS) StatFS(ctx Context, ino Ino) (st *Statfs, err syscall.Errno)
func (v *VFS) Symlink(ctx Context, path string, parent Ino, name string) (entry *meta.Entry, err syscall.Errno)

func (*VFS) Truncate

func (v *VFS) Truncate(ctx Context, ino Ino, size int64, fh uint64, attr *Attr) (err syscall.Errno)
func (v *VFS) Unlink(ctx Context, parent Ino, name string) (err syscall.Errno)

func (*VFS) UpdateLength

func (v *VFS) UpdateLength(inode Ino, attr *meta.Attr)

func (*VFS) UpdateReaddirOffset

func (v *VFS) UpdateReaddirOffset(ctx Context, ino Ino, fh uint64, off int)

func (*VFS) Write

func (v *VFS) Write(ctx Context, ino Ino, buf []byte, off, fh uint64) (err syscall.Errno)

Jump to

Keyboard shortcuts

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