storageeff

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package storageeff is VirtoMir's storage efficiency (D15, ADR-0074): ZFS compression and deduplication per pool (with the RAM warning dedup deserves), storage tiers as labels on pools that disks move between, and NVMe/TCP namespaces that become pools. It drives zfs, zpool and nvme through a Runner, so every command is tested without them installed. NVMe/TCP is experimental: not tested on hardware.

Index

Constants

View Source
const DedupRAMWarning = "" /* 313-byte string literal not displayed */

DedupRAMWarning is why dedup needs a second thought.

Variables

View Source
var (
	ErrInvalid  = errors.New("invalid")
	ErrNotFound = errors.New("not found")
)

Errors for the API.

View Source
var Tiers = []string{"nvme", "ssd", "hdd"}

Tiers are labels for pools by speed; disks move to a tier by moving to its pool.

Functions

func Connect

func Connect(ctx context.Context, r Runner, store *Store, t Target) error

Connect connects a subsystem and keeps it to connect again at start.

func Disconnect

func Disconnect(ctx context.Context, r Runner, store *Store, nqn string) error

Disconnect disconnects a subsystem; its namespaces disappear from this host.

func Reconnect

func Reconnect(ctx context.Context, r Runner, store *Store) []error

Reconnect connects the subsystems VirtoMir connected before that are not connected now.

func SetZFS

func SetZFS(ctx context.Context, r Runner, dataset string, s ZFSSettings) error

SetZFS changes compression and dedup. Both only affect data written afterwards.

Types

type Exec

type Exec struct{}

Exec runs commands on this host.

func (Exec) Run

func (Exec) Run(ctx context.Context, name string, args ...string) ([]byte, error)

Run runs name with args; an error carries the command's standard error.

type Namespace

type Namespace struct {
	Device    string `json:"device"` // /dev/nvme0n1
	NSID      int    `json:"nsid"`
	SizeBytes uint64 `json:"sizeBytes"`
	Model     string `json:"model"`
	Serial    string `json:"serial"`
}

Namespace is a block device of a connected subsystem.

type Runner

type Runner interface {
	Run(ctx context.Context, name string, args ...string) ([]byte, error)
}

Runner runs a command and returns its standard output.

type Store

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

Store keeps -state-dir/storageeff.json.

func Open

func Open(path string) (*Store, error)

Open loads path; a missing file is an empty store.

func (*Store) Adopt

func (s *Store) Adopt(sh TiersShared) (bool, error)

Adopt takes over a member's tiers when they are newer; it reports whether it did.

func (*Store) NVMeTargets

func (s *Store) NVMeTargets() []Target

NVMeTargets are the subsystems to connect at start.

func (*Store) SetTier

func (s *Store) SetTier(pool, tier string) error

SetTier labels a pool; "" removes its label.

func (*Store) Shared

func (s *Store) Shared() TiersShared

Shared returns the tiers with their version.

func (*Store) Tiers

func (s *Store) Tiers() map[string]string

Tiers returns pool → tier.

type Subsystem

type Subsystem struct {
	NQN        string      `json:"nqn"`
	Transport  string      `json:"transport"`         // tcp, pcie, …
	Address    string      `json:"address,omitempty"` // traddr=…,trsvcid=…
	State      string      `json:"state"`             // live, connecting, …
	Namespaces []Namespace `json:"namespaces"`
	// Managed: VirtoMir connected it (and connects it again at start).
	Managed bool `json:"managed"`
}

Subsystem is a connected NVMe subsystem with its paths and namespaces.

func List

func List(ctx context.Context, r Runner, store *Store) ([]Subsystem, error)

List lists the NVMe subsystems of this host (local PCIe drives too) and their namespaces. With native multipath a namespace is /dev/nvme<subsystem>n<ns>, without it /dev/nvme<controller>n<ns>; either number finds its subsystem.

type Target

type Target struct {
	Portal string `json:"portal"`         // the target's IP address
	Port   int    `json:"port,omitempty"` // default 4420
	NQN    string `json:"nqn"`
}

Target is an NVMe/TCP subsystem at a portal.

func Discover

func Discover(ctx context.Context, r Runner, portal string, port int) ([]Target, error)

Discover lists the NVMe subsystems a portal offers.

type TiersShared

type TiersShared struct {
	Version int               `json:"version"`
	Tiers   map[string]string `json:"tiers"`
}

TiersShared is the versioned pool → tier map members exchange (newest version wins): pools of the same name on different hosts are the same kind of storage.

type ZFSEfficiency

type ZFSEfficiency struct {
	Dataset       string  `json:"dataset"`
	Compression   string  `json:"compression"`
	CompressRatio float64 `json:"compressRatio"`
	Dedup         string  `json:"dedup"`
	// DedupRatio is the whole zpool's: ZFS only counts deduplication per pool.
	DedupRatio       float64 `json:"dedupRatio"`
	UsedBytes        uint64  `json:"usedBytes"`
	LogicalUsedBytes uint64  `json:"logicalUsedBytes"`
	SavedBytes       uint64  `json:"savedBytes"` // what compression saves: logical minus used
}

ZFSEfficiency is what compression and deduplication save on a dataset (a libvirt zfs pool's source; its zvols inherit the settings).

func InspectZFS

func InspectZFS(ctx context.Context, r Runner, dataset string) (ZFSEfficiency, error)

InspectZFS reads a dataset's compression and dedup settings and what they save.

type ZFSSettings

type ZFSSettings struct {
	Compression string `json:"compression,omitempty"`
	Dedup       string `json:"dedup,omitempty"`
	// AcknowledgeDedupRAM: turning dedup on needs this, after reading what it costs.
	AcknowledgeDedupRAM bool `json:"acknowledgeDedupRam,omitempty"`
}

ZFSSettings changes a dataset; empty fields stay as they are.

Jump to

Keyboard shortcuts

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