Documentation
¶
Overview ¶
Package blockio contains the device-mapper ownership and state primitives shared by block I/O fixtures and their integration checks.
Index ¶
- Constants
- func Classify(rec Record, want string, v View) string
- func Forward(state string) string
- func JudgeLoopRelease(own LoopIdentity, seen View, kept []string) (bool, string)
- func JudgeRelease(rec Record, v View) (string, string)
- func Normalize(s string) string
- func Refuses(state string) bool
- type LoopIdentity
- type Record
- type View
Constants ¶
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.
const ( Releasable = "releasable" ReleaseHeld = "held" )
Release verdicts of an owned node.
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.
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 ¶
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 ¶
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 ¶
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.
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.
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.