scoutfs

package module
v0.0.0-...-38eb2f5 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: BSD-3-Clause Imports: 14 Imported by: 1

README

scoutfs-go

This library provides interfaces for scoutfs See godoc for more details.

GoDoc

ScoutFS Webpage

The ScoutFS repo has ScoutFS introduction and quickstart in README.md.

Visit Versity Blog Post describing example use of this interface.

Documentation

Index

Constants

View Source
const (
	// format.h: SQ_OP_INODE
	QuotaInode = 0
	// format.h: SQ_OP_DATA
	QuotaData = 1
)
View Source
const DATAWAITOPCHANGESIZE = 0x4
View Source
const DATAWAITOPREAD = 0x1
View Source
const DATAWAITOPWRITE = 0x2
View Source
const DIRENTFLAGLAST = 0x1
View Source
const IOCADDQUOTARULE = 0x4030e815
View Source
const IOCALLOCDETAIL = 0x4010e80c
View Source
const IOCDATAWAITERR = 0x4030e80b
View Source
const IOCDATAWAITING = 0x4028e806
View Source
const IOCDELQUOTARULE = 0x4030e816
View Source
const IOCGETPROJECTID = 0x8008e812
View Source
const IOCGETQUOTARULES = 0x8020e814
View Source
const IOCGETREFERRINGENTRIES = 0x4028e811
View Source
const IOCINOPATH = 0x4028e802
View Source
const IOCLISTXATTRHIDDEN = 0xc018e808
View Source
const IOCMOVEBLOCKS = 0x4030e80d
View Source
const IOCQUERYINODES = 0x4048e801
View Source
const IOCREADXATTRTOTALS = 0x4028e80f
View Source
const IOCRELEASE = 0x4018e803
View Source
const IOCSEARCHXATTRS = 0x4038e809
View Source
const IOCSETATTRMORE = 0x4030e807
View Source
const IOCSETPROJECTID = 0x4008e813
View Source
const IOCSTAGE = 0x4020e804
View Source
const IOCSTATFSMORE = 0x8030e80a
View Source
const IOCSTATMORE = 0x8038e805
View Source
const MBSTAGEFLG = 0x1
View Source
const QUERYINODESDATASEQ = 0x1
View Source
const QUERYINODESMETASEQ = 0x0
View Source
const SEARCHXATTRSOFLAGEND = 0x1

Variables

This section is empty.

Functions

func FReleaseBlocks

func FReleaseBlocks(f *os.File, offset, length, version uint64) error

FReleaseBlocks marks blocks offline and frees associated extents offset/length must be 4k aligned

func FReleaseFile

func FReleaseFile(f *os.File, version uint64) error

FReleaseFile set file offline by freeing associated extents

func FSetAttrMore

func FSetAttrMore(f *os.File, version, size, flags uint64, ctime time.Time, crtime time.Time) error

FSetAttrMore sets special scoutfs attributes for file handle

func FStageFile

func FStageFile(f *os.File, version, offset uint64, b []byte) (int, error)

FStageFile rehydrates offline file

func GetProjectID

func GetProjectID(f *os.File) (uint64, error)

func InoToPath

func InoToPath(dirfd *os.File, ino uint64) (string, error)

InoToPath converts an inode number to a path in the filesystem An open file within scoutfs is supplied for ioctls (usually just the base mount point directory)

func InoToPaths

func InoToPaths(dirfd *os.File, ino uint64) ([]string, error)

InoToPaths converts an inode number to all paths in the filesystem An open file within scoutfs is supplied for ioctls (usually just the base mount point directory)

func MoveData

func MoveData(from, to *os.File) error

MoveData will move all of the extents in "from" file handle and append to the end of "to" file handle. The end of "to" must be 4KB aligned boundary. errors this can return: EINVAL: from_off, len, or to_off aren't a multiple of 4KB; the source

and destination files are the same inode; either the source or
destination is not a regular file; the destination file has
an existing overlapping extent.

EOVERFLOW: either from_off + len or to_off + len exceeded 64bits. EBADF: from_fd isn't a valid open file descriptor. EXDEV: the source and destination files are in different filesystems. EISDIR: either the source or destination is a directory. ENODATA: either the source or destination file have offline extents.

func OpenByHandle

func OpenByHandle(dirfd *os.File, ino uint64, flags int) (uintptr, error)

OpenByHandle is similar to OpenByID, but returns just the file descriptor and does not have the added overhead of getting the filename An open file within scoutfs is supplied for ioctls (usually just the base mount point directory)

func OpenByID

func OpenByID(dirfd *os.File, ino uint64, flags int, name string) (*os.File, error)

OpenByID will open a file by inode returning a typical *os.File An open file within scoutfs is supplied for ioctls (usually just the base mount point directory) The filename supplied is used for the *os.File info, but can be "" if not known or needed

func QuotaAddDataGID

func QuotaAddDataGID(f *os.File, id1, id2, gid, limit uint64, priority uint8) error

func QuotaAddDataGIDGeneral

func QuotaAddDataGIDGeneral(f *os.File, id1, id2, limit uint64, priority uint8) error

func QuotaAddDataLiteral

func QuotaAddDataLiteral(f *os.File, id1, id2, id3, limit uint64, priority uint8) error

func QuotaAddDataProject

func QuotaAddDataProject(f *os.File, id1, id2, project, limit uint64, priority uint8) error

func QuotaAddDataProjectGeneral

func QuotaAddDataProjectGeneral(f *os.File, id1, id2, limit uint64, priority uint8) error

func QuotaAddDataUID

func QuotaAddDataUID(f *os.File, id1, id2, uid, limit uint64, priority uint8) error

func QuotaAddDataUIDGeneral

func QuotaAddDataUIDGeneral(f *os.File, id1, id2, limit uint64, priority uint8) error

func QuotaAddInodeGID

func QuotaAddInodeGID(f *os.File, id1, id2, gid, limit uint64, priority uint8) error

func QuotaAddInodeGIDGeneral

func QuotaAddInodeGIDGeneral(f *os.File, id1, id2, limit uint64, priority uint8) error

func QuotaAddInodeLiteral

func QuotaAddInodeLiteral(f *os.File, id1, id2, id3, limit uint64, priority uint8) error

func QuotaAddInodeProject

func QuotaAddInodeProject(f *os.File, id1, id2, project, limit uint64, priority uint8) error

func QuotaAddInodeProjectGeneral

func QuotaAddInodeProjectGeneral(f *os.File, id1, id2, limit uint64, priority uint8) error

func QuotaAddInodeUID

func QuotaAddInodeUID(f *os.File, id1, id2, uid, limit uint64, priority uint8) error

func QuotaAddInodeUIDGeneral

func QuotaAddInodeUIDGeneral(f *os.File, id1, id2, limit uint64, priority uint8) error

func QuotaDelete

func QuotaDelete(f *os.File, q QuotaRule) error

func ReleaseBlocks

func ReleaseBlocks(path string, offset, length, version uint64) error

ReleaseBlocks marks blocks offline and frees associated extents offset/length must be 4k aligned

func ReleaseFile

func ReleaseFile(path string, version uint64) error

ReleaseFile sets file offline by freeing associated extents

func SendDataWaitErr

func SendDataWaitErr(dirfd *os.File, ino, version, offset, op, count uint64, errno int64) error

SendDataWaitErr sends an error to the data waiter task indicating that the data is no longer aviable. An open file within scoutfs is supplied for ioctls (usually just the base mount point directory)

func SetAttrMore

func SetAttrMore(path string, version, size, flags uint64, ctime time.Time, crtime time.Time) error

SetAttrMore sets special scoutfs attributes

func SetProjectID

func SetProjectID(f *os.File, projectid uint64) error

func StageFile

func StageFile(path string, version, offset uint64, b []byte) (int, error)

StageFile rehydrates offline file

func StageMove

func StageMove(from, to *os.File, offset, version uint64) error

StageMove will move all of the extents in "from" file handle and stage the offline extents at offset "offset" in "to" file handle. The size of from and offset of "to" must be 4KB aligned boundary. errors this can return: EINVAL: from_off, len, or to_off aren't a multiple of 4KB; the source

and destination files are the same inode; either the source or
destination is not a regular file; the destination file has
an existing overlapping extent.

EOVERFLOW: either from_off + len or to_off + len exceeded 64bits. EBADF: from_fd isn't a valid open file descriptor. EXDEV: the source and destination files are in different filesystems. EISDIR: either the source or destination is a directory. ENODATA: either the source or destination file have offline extents.

func StageMoveAt

func StageMoveAt(from, to *os.File, len, fromOffset, toOffset, version uint64) error

StageMoveAt will move the extents (based on len) in "from" file handle at given offset to the "to" file handle at given offset. All offsets must be 4KB aligned boundary. All destination offsets must be offline extents. EINVAL: from_off, len, or to_off aren't a multiple of 4KB; the source

and destination files are the same inode; either the source or
destination is not a regular file; the destination file has
an existing overlapping extent.

EOVERFLOW: either from_off + len or to_off + len exceeded 64bits. EBADF: from_fd isn't a valid open file descriptor. EXDEV: the source and destination files are in different filesystems. EISDIR: either the source or destination is a directory. ENODATA: either the source or destination file have offline extents.

Types

type DataWaitingEntry

type DataWaitingEntry struct {
	Ino    uint64
	Iblock uint64
	Op     uint8
	X_pad  [7]uint8
}

type DiskUsage

type DiskUsage struct {
	TotalMetaBlocks uint64
	FreeMetaBlocks  uint64
	TotalDataBlocks uint64
	FreeDataBlocks  uint64
}

DiskUsage holds usage information reported by the filesystem

func GetDF

func GetDF(f *os.File) (DiskUsage, error)

GetDF returns usage data for the filesystem

type FSID

type FSID struct {
	FSID         uint64
	RandomID     uint64
	ShortID      string
	CommittedSeq uint64
}

FSID contains the statfs more info for mounted scoutfs filesystem

func GetIDs

func GetIDs(f *os.File) (FSID, error)

GetIDs gets the statfs more filesystem and random id from file handle within scoutfs filesystem

type InodesEntry

type InodesEntry struct {
	Major uint64
	Ino   uint64
	Minor uint32
	X_pad [4]uint8
}

func (InodesEntry) Increment

func (i InodesEntry) Increment() InodesEntry

Increment returns the next seq entry position

func (InodesEntry) String

func (i InodesEntry) String() string

String returns the string representation of InodesEntry

type ListXattrHidden

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

ListXattrHidden holds info for iterating on xattrs

func NewListXattrHidden

func NewListXattrHidden(f *os.File, b []byte) *ListXattrHidden

NewListXattrHidden will list all scoutfs xattrs (including hidden) for file. If passed in buffer is nil, call will allocate its own buffer.

func (*ListXattrHidden) Next

func (l *ListXattrHidden) Next() ([]string, error)

Next gets next set of results, complete when string slice is nil

type Option

type Option func(*Query)

Option sets various options for NewQuery

func ByDSeq

func ByDSeq(from, to InodesEntry) Option

ByDSeq gets inodes in range of data sequence from, to inclusive

func ByMSeq

func ByMSeq(from, to InodesEntry) Option

ByMSeq gets inodes in range of metadata sequence from, to inclusive

func WithBatchSize

func WithBatchSize(size uint32) Option

WithBatchSize sets the max number of inodes to be returned at a time

type Parent

type Parent struct {
	Ino  uint64 // Parent inode
	Pos  uint64 // Entry directory position in parent
	Type uint8  // Entry inode type matching DT_ enum values in readdir(3)
	Ent  string // Entry name as known by parent
}

Parent contains inode of parent and what the child inode is named within this parent

func GetParents

func GetParents(dirfd *os.File, ino uint64, b []byte) ([]Parent, error)

GetParents returns all parents for the given inode An open file within scoutfs is supplied for ioctls (usually just the base mount point directory) If passed in buffer is nil, call will allocate its own buffer.

type Query

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

Query to keep track of in-process query

func NewQuery

func NewQuery(f *os.File, opts ...Option) *Query

NewQuery creates a new scoutfs Query Specify query type with By*() option (only 1 allowed, last one wins) and specify batching with WithBatchSize() An open file within scoutfs is supplied for ioctls (usually just the base mount point directory)

func (*Query) Next

func (q *Query) Next() ([]InodesEntry, error)

Next gets the next batch of inodes

func (*Query) SetLast

func (q *Query) SetLast(l InodesEntry)

SetLast updates the sequence stopping point

type QuorumInfo

type QuorumInfo struct {
	Slot int64
	Term int64
	Role string
}

QuorumInfo holds info for current mount quorum

func GetQuorumInfo

func GetQuorumInfo(path string) (QuorumInfo, error)

GetQuorumInfo returns quorum info for curren mount

func (QuorumInfo) IsLeader

func (q QuorumInfo) IsLeader() bool

IsLeader returns true if quorum status is a leader role

type QuotaOp

type QuotaOp uint8

func (QuotaOp) String

func (q QuotaOp) String() string

type QuotaRule

type QuotaRule struct {
	Op          QuotaOp
	QuotaValue  [3]uint64
	QuotaSource [3]uint8
	QuotaFlags  [3]uint8
	Limit       uint64
	Prioirity   uint8
	Flags       uint8
}

QuotaRule is attributes for a single quota rule

func (QuotaRule) HumanString

func (q QuotaRule) HumanString() string

func (QuotaRule) IsGeneral

func (q QuotaRule) IsGeneral() bool

func (QuotaRule) QuotaType

func (q QuotaRule) QuotaType() string

func (QuotaRule) Raw

func (q QuotaRule) Raw(human bool) string

func (QuotaRule) String

func (q QuotaRule) String() string

func (QuotaRule) StringNoLimit

func (q QuotaRule) StringNoLimit() string

type QuotaType

type QuotaType uint8

func (QuotaType) String

func (q QuotaType) String() string

type Quotas

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

func GetQuotaRules

func GetQuotaRules(f *os.File, count int) (*Quotas, error)

GetQuotaRules initalizes reading the current quota set. Quota rules are not returned in sorted order, so to get the order which they are matched the full list must be collected then sorted.

func (*Quotas) Next

func (q *Quotas) Next() ([]QuotaRule, error)

Next returns next batch of quota rules.

func (*Quotas) Reset

func (t *Quotas) Reset()

Reset resets the quota listing to the start

type RuleSet

type RuleSet []QuotaRule

RuleSet is a list of quota rules, when sorted these will be in the order as the filesystem would match them

func (RuleSet) Len

func (r RuleSet) Len() int

Len returns the length of the ruleset

func (RuleSet) Less

func (r RuleSet) Less(i, j int) bool

Less returns true if the i-th rule would be matched before the j-th rule

func (RuleSet) Swap

func (r RuleSet) Swap(i, j int)

Swap will swap the i-th and j-th elements in the ruleset

type Stat

type Stat struct {
	Meta_seq       uint64
	Data_seq       uint64
	Data_version   uint64
	Online_blocks  uint64
	Offline_blocks uint64
	Crtime_sec     uint64
	Crtime_nsec    uint32
	X_pad          [4]uint8
}

func FStatMore

func FStatMore(f *os.File) (Stat, error)

FStatMore returns scoutfs specific metadata for file handle

func StatMore

func StatMore(path string) (Stat, error)

StatMore returns scoutfs specific metadata for path

type Time

type Time struct {
	Sec  uint64
	Nsec uint32
}

Time represents a time value in seconds and nanoseconds

type TotalsGroup

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

func NewTotalsGroup

func NewTotalsGroup(f *os.File, id1, id2 uint64, count int) *TotalsGroup

NewTotalsGroup creates a query to get the totals values for a defined group of totls (group is defined to match first 2 identifiers). Count specifies max number returned for each Next() call.

func (*TotalsGroup) Next

func (t *TotalsGroup) Next() ([]XattrTotal, error)

Next returns next set of total values for the group

func (*TotalsGroup) Reset

func (t *TotalsGroup) Reset()

Reset resets the totl query to the start of the group id again

type WOption

type WOption func(*Waiters)

WOption sets various options for NewWaiters

func WithWaitersCount

func WithWaitersCount(size uint16) WOption

WithWaitersCount sets the max number of inodes to be returned at a time

type Waiters

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

Waiters to keep track of data waiters

func NewWaiters

func NewWaiters(f *os.File, opts ...WOption) *Waiters

NewWaiters creates a new scoutfs Waiters An open file within scoutfs is supplied for ioctls (usually just the base mount point directory)

func (*Waiters) Next

func (w *Waiters) Next() ([]DataWaitingEntry, error)

Next gets the next batch of data waiters, returns nil, nil if no waiters

func (*Waiters) Reset

func (w *Waiters) Reset()

Reset sets the data waiters query back to inode 0, iblock 0

type XOption

type XOption func(*XattrQuery)

XOption sets various options for NewXattrQuery

func WithXBatchSize

func WithXBatchSize(size uint64) XOption

WithXBatchSize sets the max number of inodes to be returned at a time

func WithXStartIno

func WithXStartIno(ino uint64) XOption

WithXStartIno starts query at speficied inode

type XattrQuery

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

XattrQuery to keep track of in-process xattr query

func NewXattrQuery

func NewXattrQuery(f *os.File, key string, opts ...XOption) *XattrQuery

NewXattrQuery creates a new scoutfs Xattr Query Specify query xattr key and specify optinally batching with WithXBatchSize() An open file within scoutfs is supplied for ioctls (usually just the base mount point directory)

func (*XattrQuery) Next

func (q *XattrQuery) Next() ([]uint64, error)

Next gets the next batch of inodes

type XattrTotal

type XattrTotal struct {
	// Total is sum of all xattr values matching ids
	Total uint64
	// Count is number of xattrs matching ids
	Count uint64
	// ID is the id for this total
	ID [3]uint64
}

XattrTotal has the total values matching id triple

func ReadXattrTotals

func ReadXattrTotals(f *os.File, id1, id2, id3 uint64) (XattrTotal, error)

ReadXattrTotals returns the XattrTotal for the given id

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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