blockio

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package blockio contains the device-mapper ownership and state primitives shared by block I/O fixtures and their integration checks.

Index

Constants

View Source
const (
	Gone            = "gone"             // no node of that name
	IdentityChanged = "identity-changed" // the name now has another UUID or device number
	Foreign         = "foreign"          // a table neither the record nor the wanted one, live or inactive
	StepUnsettled   = "step-unsettled"   // a step the control started is still running in the kernel
	Applied         = "applied"          // the wanted table is live, active, nothing inactive
	Unchanged       = "unchanged"        // the recorded table is live, active, nothing inactive
	Loaded          = "loaded"           // recorded table live, wanted table inactive, active
	Suspended       = "suspended"        // recorded table live, nothing inactive, suspended
	SuspendedLoaded = "suspended-loaded" // recorded table live, wanted table inactive, suspended
	SwappedOnHold   = "swapped-on-hold"  // wanted table live, suspended
	// LoadRefused is what apply returns when the kernel refused the wanted
	// table; the node keeps the recorded one.
	LoadRefused = "load-refused"
)

The states of an owned node, as classified against its record and the table the control wants live.

View Source
const (
	Releasable  = "releasable"
	ReleaseHeld = "held"
)

Release verdicts of an owned node.

View Source
const Script = scriptPrelude + scriptActions + scriptEnd

Script runs the owned keeper control protocol. A dispatched kernel step outlives the invocation until its recorded status says that it finished. Cancellation is not rollback; callers retain its step identity and poll it.

View Source
const TestScript = scriptPrelude + scriptTestPrelude + scriptActions + scriptTestActions + scriptEnd

TestScript adds direct-I/O probes and a temporary loop opener to Script's shared control implementation. Production control does not dispatch these test workload actions.

Variables

This section is empty.

Functions

func Classify

func Classify(rec Record, want string, v View) string

Classify classifies an observation of the node of rec against rec and the wanted live table. Identity comes first: a node that is not the recorded one is never acted on, whatever its tables. A step the control has not seen finish comes next: until it ends, any other step could block behind it or race it.

func Forward

func Forward(state string) string

Forward is the next step that moves a node in state toward the wanted table, or "" when it is there or when nothing may be done.

func JudgeLoopRelease

func JudgeLoopRelease(own LoopIdentity, seen View, kept []string) (bool, string)

JudgeLoopRelease allows detaching loop only while it still backs the file the control attached, nothing holds it, and no mapping the fixture built on it was kept or is in an unknown state (kept): a loop number the kernel gave to another file after a release is someone else's, and a loop under a remaining mapping is still in use.

func JudgeRelease

func JudgeRelease(rec Record, v View) (string, string)

JudgeRelease decides whether the owned node may be removed: it must be the recorded node, with the recorded table live and active, no inactive table, no unsettled step, no opener and no I/O in flight. Anything else keeps the node, its loop and its file, with the reason.

func Normalize

func Normalize(s string) string

Normalize makes table strings comparable: dmsetup prints a trailing space after a target without arguments.

func Refuses

func Refuses(state string) bool

Refuses reports the states in which the control does nothing at all to the node: it is not the owned node, or another actor or an unsettled step holds it.

Types

type LoopIdentity

type LoopIdentity struct {
	Loop  string
	File  string
	Inode uint64
	// Dev is the loop's major:minor, the lower device of mappings over it.
	Dev string
}

LoopIdentity is a loop device as the control attached it: the loop node, its device number and the inode of its backing file.

type Record

type Record struct {
	Name, UUID   string
	Major, Minor uint32
	// Live is the live table the control last observed after a step it
	// confirmed, or after creating the node.
	Live string
	// Loaded is the table the control loaded into the inactive slot and has
	// not seen swapped in, or "".
	Loaded string
	// Unsettled is a step the control may have started and has not seen
	// finish, or "". It is recorded before the step is dispatched, so a lost
	// reply or an ended context leaves it here, with the table of a load
	// (UnsettledTable) and the id of its status file (UnsettledID).
	Unsettled, UnsettledTable, UnsettledID string
}

Record is what the control knows about the node it owns: its identity, the live table it last confirmed, and a step it started without seeing it finish.

func (*Record) Begin

func (rec *Record) Begin(op, table, id string)

Begin records a step before it is dispatched.

func (*Record) Settle

func (rec *Record) Settle(r View)

Settle records the reply of the recorded step: nothing while it is not done, and once it is, what a successful step changed.

type View

type View struct {
	Action  string `json:"action"`
	Name    string `json:"name"`
	Created bool   `json:"created"`
	Error   string `json:"error"`
	// observe
	Exists   bool    `json:"exists"`
	State    string  `json:"state"`
	UUID     string  `json:"uuid"`
	Open     int     `json:"open"`
	Event    int     `json:"event"`
	Major    uint32  `json:"major"`
	Minor    uint32  `json:"minor"`
	Live     *string `json:"live"`
	Inactive *string `json:"inactive"`
	InFlight []int64 `json:"in_flight"`
	// step, settled, written
	Op   string `json:"op"`
	ID   string `json:"id"`
	Done bool   `json:"done"`
	RC   int    `json:"rc"`
	// write, read
	SHA256  string `json:"sha256"`
	Started bool   `json:"started"`
	// loop, loopid, unloop
	Loop        string   `json:"loop"`
	File        string   `json:"file"`
	Inode       uint64   `json:"inode"`
	Detached    bool     `json:"detached"`
	FileRemoved bool     `json:"file_removed"`
	Holders     []string `json:"holders"`
	// Lazy is a detach the kernel accepted for a busy loop and has not done.
	Lazy bool `json:"lazy"`
}

View is one reply of blockControlScript.

func Parse

func Parse(raw []byte, action string) (View, error)

Jump to

Keyboard shortcuts

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