fs

package
v1.3.27 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: MIT Imports: 35 Imported by: 2

Documentation

Overview

Package fs provides mountpath and FQN abstractions and methods to resolve/map stored content

  • Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.

Package fs provides mountpath and FQN abstractions and methods to resolve/map stored content

  • Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.

Package fs provides mountpath and FQN abstractions and methods to resolve/map stored content

  • Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.

Package fs provides mountpath and FQN abstractions and methods to resolve/map stored content

  • Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.

Package fs provides mountpath and FQN abstractions and methods to resolve/map stored content

  • Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.

Package fs provides mountpath and FQN abstractions and methods to resolve/map stored content

  • Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.

Package fs provides mountpath and FQN abstractions and methods to resolve/map stored content

  • Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.

Package fs provides mountpath and FQN abstractions and methods to resolve/map stored content

  • Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved.

Package fs provides mountpath and FQN abstractions and methods to resolve/map stored content

  • Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.

Package fs provides mountpath and FQN abstractions and methods to resolve/map stored content

  • Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.

Package fs provides mountpath and FQN abstractions and methods to resolve/map stored content

  • Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.

Package fs provides mountpath and FQN abstractions and methods to resolve/map stored content

  • Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.

Package fs provides mountpath and FQN abstractions and methods to resolve/map stored content

  • Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.

Package fs provides mountpath and FQN abstractions and methods to resolve/map stored content

  • Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.

Package fs provides mountpath and FQN abstractions and methods to resolve/map stored content

  • Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.

Index

Constants

View Source
const (
	DiskFault    = "(faulted)"        // disabled by FSHC
	DiskOOS      = "(out-of-space)"   // (capacity)
	Disk2Disable = "(->disabled)"     // FlagBeingDisabled (in transition)
	Disk2Detach  = "(->detach)"       // FlagBeingDetached (ditto)
	DiskHighWM   = "(low-free-space)" // (capacity)
)

available mountpaths: disk name suffix NOTE: when adding/updating, check HasAlert below

View Source
const (
	DiskDisabled = "(mp-disabled)"
	DiskDetached = "(mp-detached)"
)

!available mountpath // TODO: not yet used; readability

View Source
const (
	ObjectType   = "ob"
	WorkfileType = "wk"
	ECSliceType  = "ec"
	ECMetaType   = "mt"
)
View Source
const (
	SieMpathIDMismatch = (1 + iota) * 10
	SieTargetIDMismatch
	SieNotEqVMD
	SieMetaCorrupted
	SieFsDiffers
	SieMpathNotFound
)
View Source
const (
	// prefixes for workfiles created by various services
	WorkfileRemote       = "remote"         // getting object from neighbor target when rebalancing
	WorkfileColdget      = "cold"           // object GET: coldget
	WorkfilePut          = "put"            // object PUT
	WorkfileCopy         = "copy"           // copy object
	WorkfileAppend       = "append"         // APPEND to object (as file)
	WorkfileAppendToArch = "append-to-arch" // APPEND to existing archive
	WorkfileCreateArch   = "create-arch"    // CREATE multi-object archive
)
View Source
const (
	FlagBeingDisabled uint64 = 1 << iota
	FlagBeingDetached
	FlagDisabledByFSHC // TODO -- FIXME: niy
)

enum Mountpath.Flags

View Source
const (
	Throttle1ms   = time.Millisecond
	Throttle10ms  = 10 * time.Millisecond
	Throttle100ms = 100 * time.Millisecond
)
View Source
const MaxThrottlePct = 75 // vs ratio pct returned by ThrottlePct() below

Variables

View Source
var CSM *contentSpecMgr

Functions

func AllMpathBcks

func AllMpathBcks(opts *WalkOpts) (bcks []cmn.Bck, err error)

func CapStatusGetWhat

func CapStatusGetWhat() (fsInfo apc.CapacityInfo)

func CleanPathErr added in v1.3.18

func CleanPathErr(err error)

func ComputeDiskSize added in v1.3.21

func ComputeDiskSize()

total disk size

func ContainsCT added in v1.3.26

func ContainsCT(fqn, bname string) bool

func CountPersisted

func CountPersisted(fname string) (cnt int)

func CreateBucket

func CreateBucket(bck *cmn.Bck, nilbmd bool) (errs []error)

func Decommission

func Decommission(mdOnly bool)

func DestroyBucket

func DestroyBucket(op string, bck *cmn.Bck, bid uint64) (err error)

NOTE: caller must evict LOM cache

func DirectOpen

func DirectOpen(path string, flag int, perm os.FileMode) (*os.File, error)

DirectOpen opens a file with direct disk access (with OS caching disabled).

func DiskStats added in v1.3.24

func DiskStats(allds cos.AllDiskStats, tcdf *Tcdf, config *cmn.Config, refreshCap bool)

via (`apc.WhatDiskStats`, target_stats)

func ExpireCapCache added in v1.3.23

func ExpireCapCache()

func Get

func Get() (MPI, MPI)

returns both available and disabled mountpaths (compare with GetAvail)

func GetAllMpathUtils

func GetAllMpathUtils() (utils *ios.MpathUtil)

func GetDiskSize added in v1.3.21

func GetDiskSize() uint64

func GetMaxUtil added in v1.3.26

func GetMaxUtil() (util int64)

max disk utilization across mountpaths

func GetMpathUtil

func GetMpathUtil(mpath string) int64

func GetXattr

func GetXattr(fqn, attrName string) ([]byte, error)

GetXattr gets xattr by name - see also the buffered version below

func GetXattrBuf

func GetXattrBuf(fqn, attrName string, buf []byte) (b []byte, err error)

GetXattr gets xattr by name via provided buffer

func HasAlert added in v1.3.24

func HasAlert(disks []string) (alert string, idx int)

[convention] <DISK-NAME>[(<alert>)] Returns "" and (-1) when no alerts found otherwise, returns alert name and its index in the DISK-NAME string

func HasPrefixFntl added in v1.3.26

func HasPrefixFntl(s string) bool

func InitCDF added in v1.3.23

func InitCDF(tcdf *Tcdf)

func IsDirEmpty

func IsDirEmpty(dir string) (names []string, empty bool, err error)

func IsFntl added in v1.3.26

func IsFntl(objName string) bool

func IsMicroThrottle added in v1.3.26

func IsMicroThrottle(n int64) bool

func IsMiniThrottle added in v1.3.26

func IsMiniThrottle(n int64) bool

func IsThrottle added in v1.3.26

func IsThrottle(n int64) bool

func LikelyCT added in v1.3.26

func LikelyCT(s string) bool

func LoadNodeID

func LoadNodeID(mpaths cos.StrKVs) (mDaeID string, err error)

func MarkerExists

func MarkerExists(marker string) bool

func New

func New(fshc HC, num int) (blockDevs ios.BlockDevices)

func NoneShared added in v1.3.23

func NoneShared(numMpaths int) bool

func NumAvail

func NumAvail() int

func OnDiskSize added in v1.3.21

func OnDiskSize(bck *cmn.Bck, prefix string) (size uint64)

bucket and bucket+prefix on-disk sizing

func PersistMarker

func PersistMarker(marker string) (fatalErr, writeErr error)

func PersistOnMpaths

func PersistOnMpaths(fname, backupName string, meta jsp.Opts, atMost int, b []byte, sgl *memsys.SGL) (cnt, availCnt int)

PersistOnMpaths persists `what` on mountpaths under "mountpath.Path/path" filename. It does it on maximum `atMost` mountPaths. If `atMost == 0`, it does it on every mountpath. If `backupPath != ""`, it removes files from `backupPath` and moves files from `path` to `backupPath`. Returns how many times it has successfully stored a file.

func PutMPI

func PutMPI(avail, disabled MPI)

func RemoveAll added in v1.3.18

func RemoveAll(dir string) (err error)

retrying ENOTEMPTY - "directory not empty" race vs. new writes

func RemoveMarker

func RemoveMarker(marker string, stup cos.StatsUpdater) (err error)

func RenameBucketDirs

func RenameBucketDirs(bckFrom, bckTo *cmn.Bck) (err error)

func SetXattr

func SetXattr(fqn, attrName string, data []byte) (err error)

SetXattr sets xattr name = value

func ShortenFntl added in v1.3.26

func ShortenFntl(s string) string

func TestNew

func TestNew(iostater ios.IOS)

used only in tests

func ThrottlePct added in v1.3.26

func ThrottlePct() (int, int64, float64)

- max disk utilization across mountpaths - max (1 minute, 5 minute) load average

func ToMPL added in v1.3.24

func ToMPL() (mpl *apc.MountpathList)

func ValidateNCopies

func ValidateNCopies(tname string, copies int) (err error)

func Walk

func Walk(opts *WalkOpts) error

func WalkBck

func WalkBck(opts *WalkBckOpts) error

lso and tests

func WalkDir

func WalkDir(dir string, ucb func(string, DirEntry) error) error

NOTE: using Go filepath.WalkDir pros: lexical deterministic order; cons: reads the entire directory

Types

type CDF added in v1.3.16

type CDF struct {
	Label cos.MountpathLabel `json:"mountpath_label"`
	FS    cos.FS             `json:"fs"`
	Disks []string           `json:"disks"` // owned or shared disks (ios.FsDisks map => slice); "name[.faulted | degraded]"
	Capacity
}

Capacity, Disks, Filesystem (CDF)

type CDFv322 added in v1.3.23

type CDFv322 struct {
	FS    string   `json:"fs"`
	Disks []string `json:"disks"`
	Capacity
}

[backward compatibility]: v3.22 cdf* structures

type CapStatus

type CapStatus struct {
	// config
	HighWM int64
	OOS    int64
	// metrics
	TotalUsed  uint64 // bytes
	TotalAvail uint64 // bytes
	PctAvg     int32  // average used (%)
	PctMax     int32  // max used (%)
	PctMin     int32  // max used (%)
}

func Cap added in v1.3.16

func Cap() (cs CapStatus)

func CapPeriodic

func CapPeriodic(now int64, config *cmn.Config, tcdf *Tcdf) (cs CapStatus, updated bool, err, errCap error)

called only and exclusively by `stats.Trunner` providing `config.Periodic.StatsTime` tick

func CapRefresh added in v1.3.16

func CapRefresh(config *cmn.Config, tcdf *Tcdf) (cs CapStatus, _, errCap error)

sum up && compute %% capacities while skipping already _counted_ filesystems

func (*CapStatus) Err

func (cs *CapStatus) Err() (err error)

note: conditioning on max, not avg

func (*CapStatus) IsNil

func (cs *CapStatus) IsNil() bool

func (*CapStatus) IsOOS added in v1.3.21

func (cs *CapStatus) IsOOS() bool

func (*CapStatus) String

func (cs *CapStatus) String() (s string)

type Capacity

type Capacity struct {
	Used    uint64 `json:"used,string"`  // bytes
	Avail   uint64 `json:"avail,string"` // ditto
	PctUsed int32  `json:"pct_used"`     // %% used (redundant ok)
}

type ContentInfo

type ContentInfo struct {
	Dir  string // original directory
	Base string // original basename
	Type string // content type
	Old  bool   // true if old (subj. to space cleanup)
}

type ContentResolver

type ContentResolver interface {
	// Generates unique base name for original one. This function may add
	// additional information to the base name.
	// prefix - user-defined marker
	GenUniqueFQN(base, prefix string) (ufqn string)
	// Parses generated unique fqn to the original one.
	ParseUniqueFQN(base string) (orig string, old, ok bool)
}

type DirEntry

type DirEntry interface {
	IsDir() bool
}

type ECMetaContentResolver

type ECMetaContentResolver struct{}

func (*ECMetaContentResolver) GenUniqueFQN

func (*ECMetaContentResolver) GenUniqueFQN(base, _ string) string

func (*ECMetaContentResolver) ParseUniqueFQN

func (*ECMetaContentResolver) ParseUniqueFQN(base string) (orig string, old, ok bool)

type ECSliceContentResolver

type ECSliceContentResolver struct{}

func (*ECSliceContentResolver) GenUniqueFQN

func (*ECSliceContentResolver) GenUniqueFQN(base, _ string) string

func (*ECSliceContentResolver) ParseUniqueFQN

func (*ECSliceContentResolver) ParseUniqueFQN(base string) (orig string, old, ok bool)

type ErrStorageIntegrity

type ErrStorageIntegrity struct {
	Msg  string
	Code int // Sie* enum above
}

func (*ErrStorageIntegrity) Error

func (sie *ErrStorageIntegrity) Error() string

type HC added in v1.3.24

type HC interface {
	FSHC(err error, mi *Mountpath, fqn string)
	SoftFSHC()
}

filesystem Health Check

type MFS added in v1.3.23

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

type MPI

type MPI map[string]*Mountpath

func GetAvail

func GetAvail() MPI

func (MPI) String

func (mpi MPI) String() string

type Mountpath added in v1.3.16

type Mountpath struct {
	LomCaches cos.MultiHashMap // LOM caches

	Path   string             // clean path
	Label  cos.MountpathLabel // (disk sharing; storage class; user-defined grouping)
	cos.FS                    // underlying filesystem
	Disks  []string           // owned disks (ios.FsDisks map => slice)

	PathDigest uint64 // (HRW logic)
	// contains filtered or unexported fields
}

func Add

func Add(mpath, tid string) (mi *Mountpath, err error)

used only in tests (compare with AddMpath below)

func AddMpath

func AddMpath(tid, mpath string, label cos.MountpathLabel, cb func()) (mi *Mountpath, err error)

(via attach-mpath)

func BeginDD

func BeginDD(action string, flags uint64, mpath string) (mi *Mountpath, numAvail int, noResil bool, err error)

begin (disable | detach) transaction: CoW-mark the corresponding mountpath

func Disable

func Disable(mpath string, cb ...func()) (disabledMpath *Mountpath, err error)

Disables a mountpath, i.e., removes it from usage but keeps in the volume (for possible future re-enablement). If successful, returns the disabled mountpath. Otherwise, returns nil (also in the case if the mountpath was already disabled).

func Enable

func Enable(mpath string) (enabledMpath *Mountpath, err error)

(unit tests only - compare with EnableMpath below)

func EnableMpath

func EnableMpath(mpath, tid string, cb func()) (enabledMpath *Mountpath, err error)

Enable enables previously disabled mountpath. enabled is set to true if mountpath has been moved from disabled to available and exists is set to true if such mountpath even exists.

func FQN2Mpath

func FQN2Mpath(fqn string) (found *Mountpath, relativePath string, err error)

match FQN to mountpath and return the former and the relative path

func Hrw added in v1.3.21

func Hrw(uname []byte) (mi *Mountpath, digest uint64, err error)

func NewMountpath

func NewMountpath(mpath string, label cos.MountpathLabel) (*Mountpath, error)

func Remove

func Remove(mpath string, cb ...func()) (*Mountpath, error)

Remove removes mountpaths from the target's mountpaths. It searches for the mountpath in `available` and, if not found, in `disabled`.

func (*Mountpath) AddDisabled added in v1.3.16

func (mi *Mountpath) AddDisabled(disabled MPI)

func (*Mountpath) AddEnabled added in v1.3.16

func (mi *Mountpath) AddEnabled(tid string, avail MPI, config *cmn.Config, blockDevs ios.BlockDevices) (err error)

func (*Mountpath) CheckFS added in v1.3.24

func (mi *Mountpath) CheckFS() (err error)

func (*Mountpath) ClearDD added in v1.3.16

func (mi *Mountpath) ClearDD()

func (*Mountpath) ClearMDs added in v1.3.16

func (mi *Mountpath) ClearMDs(inclBMD bool) (rerr error)

func (*Mountpath) CreateMissingBckDirs added in v1.3.16

func (mi *Mountpath) CreateMissingBckDirs(bck *cmn.Bck) (err error)

func (*Mountpath) DeletedRoot added in v1.3.16

func (mi *Mountpath) DeletedRoot() string

func (*Mountpath) GetUtil added in v1.3.26

func (mi *Mountpath) GetUtil() int64

func (*Mountpath) IsAnySet added in v1.3.16

func (mi *Mountpath) IsAnySet(flags uint64) bool

func (*Mountpath) IsAvail added in v1.3.24

func (mi *Mountpath) IsAvail() bool

func (*Mountpath) MakePathBck added in v1.3.16

func (mi *Mountpath) MakePathBck(bck *cmn.Bck) string

func (*Mountpath) MakePathCT added in v1.3.16

func (mi *Mountpath) MakePathCT(bck *cmn.Bck, contentType string) string

func (*Mountpath) MakePathFQN added in v1.3.16

func (mi *Mountpath) MakePathFQN(bck *cmn.Bck, contentType, objName string) string

func (*Mountpath) MoveToDeleted added in v1.3.16

func (mi *Mountpath) MoveToDeleted(dir string) (err error)

MoveToDeleted removes directory in steps: 1. Synchronously gets temporary directory name 2. Synchronously renames old folder to temporary directory

func (*Mountpath) RemoveDeleted added in v1.3.16

func (mi *Mountpath) RemoveDeleted(who string) (rerr error)

func (*Mountpath) RescanDisks added in v1.3.24

func (mi *Mountpath) RescanDisks() (warn, err error)

func (*Mountpath) SetDaemonIDXattr added in v1.3.16

func (mi *Mountpath) SetDaemonIDXattr(tid string) error

func (*Mountpath) SetFlags added in v1.3.24

func (mi *Mountpath) SetFlags(flags uint64) (ok bool)

flags

func (*Mountpath) String added in v1.3.16

func (mi *Mountpath) String() string

func (*Mountpath) TempDir added in v1.3.16

func (mi *Mountpath) TempDir(dir string) string

type ObjectContentResolver

type ObjectContentResolver struct{}

func (*ObjectContentResolver) GenUniqueFQN

func (*ObjectContentResolver) GenUniqueFQN(base, _ string) string

func (*ObjectContentResolver) ParseUniqueFQN

func (*ObjectContentResolver) ParseUniqueFQN(base string) (orig string, old, ok bool)

type ParsedFQN

type ParsedFQN struct {
	Mountpath   *Mountpath
	Bck         cmn.Bck
	ContentType string // enum: { ObjectType, WorkfileType, ECSliceType, ... }
	ObjName     string
	Digest      uint64
}

func (*ParsedFQN) Init added in v1.3.23

func (parsed *ParsedFQN) Init(fqn string) (err error)

type PartsFQN

type PartsFQN interface {
	ObjectName() string
	Bucket() *cmn.Bck
	Mountpath() *Mountpath
}

type TargetCDFv322 added in v1.3.23

type TargetCDFv322 struct {
	Mountpaths map[string]*CDFv322
	CsErr      string `json:"cs_err"`
	PctMax     int32  `json:"pct_max"`
	PctAvg     int32  `json:"pct_avg"`
	PctMin     int32  `json:"pct_min"`
}

[backward compatibility]: v3.22 cdf* structures

type Tcdf added in v1.3.24

type Tcdf struct {
	Mountpaths map[string]*CDF // mpath => [Capacity, Disks, FS (CDF)]
	CsErr      string          `json:"cs_err"`             // OOS or high-wm error message; disk fault
	TotalUsed  uint64          `json:"total_used,string"`  // bytes
	TotalAvail uint64          `json:"total_avail,string"` // bytes
	PctMax     int32           `json:"pct_max"`            // max used (%)
	PctAvg     int32           `json:"pct_avg"`            // avg used (%)
	PctMin     int32           `json:"pct_min"`            // min used (%)
}

Target (cumulative) CDF

func (*Tcdf) HasAlerts added in v1.3.24

func (tcdf *Tcdf) HasAlerts() bool

type TcdfExt added in v1.3.24

type TcdfExt struct {
	cos.AllDiskStats
	Tcdf
}

type WalkBckOpts

type WalkBckOpts struct {
	ValidateCb walkFunc // should return filepath.SkipDir to skip directory without an error
	WalkOpts
}

type WalkOpts

type WalkOpts struct {
	Mi       *Mountpath
	Callback walkFunc
	Bck      cmn.Bck
	Dir      string
	Prefix   string
	CTs      []string
	Sorted   bool
}

type WorkfileContentResolver

type WorkfileContentResolver struct{}

func (*WorkfileContentResolver) GenUniqueFQN

func (*WorkfileContentResolver) GenUniqueFQN(base, prefix string) string

func (*WorkfileContentResolver) ParseUniqueFQN

func (*WorkfileContentResolver) ParseUniqueFQN(base string) (orig string, old, ok bool)

Directories

Path Synopsis
Package health is a basic mountpath health monitor.
Package health is a basic mountpath health monitor.
Package lpi: local page iterator
Package lpi: local page iterator
Package mpather provides per-mountpath concepts.
Package mpather provides per-mountpath concepts.

Jump to

Keyboard shortcuts

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