btrfs

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2025 License: Apache-2.0 Imports: 10 Imported by: 14

Documentation

Overview

Package btrfs provides access to statistics exposed by Btrfs filesystems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Allocation

type Allocation struct {
	GlobalRsvReserved, GlobalRsvSize uint64
	Data, Metadata, System           *AllocationStats
}

Allocation contains allocation statistics for data, metadata and system data.

type AllocationStats

type AllocationStats struct {
	// Usage statistics
	DiskUsedBytes    uint64
	DiskTotalBytes   uint64
	MayUseBytes      uint64
	PinnedBytes      uint64
	TotalPinnedBytes uint64
	ReadOnlyBytes    uint64
	ReservedBytes    uint64
	UsedBytes        uint64
	TotalBytes       uint64

	// Flags marking filesystem state
	// See Linux fs/btrfs/ctree.h for more information.
	Flags uint64

	// Additional disk usage statistics depending on the disk layout.
	// At least one of these will exist and not be nil.
	Layouts map[string]*LayoutUsage
}

AllocationStats contains allocation statistics for a data type.

type CommitStats added in v0.13.0

type CommitStats struct {
	Commits       uint64
	LastCommitMs  uint64
	MaxCommitMs   uint64
	TotalCommitMs uint64
}

Number of commits and various time related statistics. See Linux fs/btrfs/sysfs.c with 6.x version.

type Device

type Device struct {
	Size uint64
}

Device contains information about a device that is part of a Btrfs filesystem.

type FS

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

FS represents the pseudo-filesystem sys, which provides an interface to kernel data structures.

func NewDefaultFS

func NewDefaultFS() (FS, error)

NewDefaultFS returns a new Bcache using the default sys fs mount point. It will error if the mount point can't be read.

func NewFS

func NewFS(mountPoint string) (FS, error)

NewFS returns a new Btrfs filesystem using the given sys fs mount point. It will error if the mount point can't be read.

func (FS) Stats

func (fs FS) Stats() ([]*Stats, error)

Stats retrieves Btrfs filesystem runtime statistics for each mounted Btrfs filesystem.

type LayoutUsage

type LayoutUsage struct {
	UsedBytes, TotalBytes uint64
	Ratio                 float64
}

LayoutUsage contains additional usage statistics for a disk layout.

type Stats

type Stats struct {
	UUID, Label    string
	Allocation     Allocation
	Devices        map[string]*Device
	Features       []string
	CloneAlignment uint64
	NodeSize       uint64
	QuotaOverride  uint64
	SectorSize     uint64
	CommitStats    CommitStats
}

Stats contains statistics for a single Btrfs filesystem. See Linux fs/btrfs/sysfs.c for more information.

func GetStats

func GetStats(uuidPath string) (*Stats, error)

GetStats collects all Btrfs statistics from sysfs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳