Documentation
¶
Index ¶
- Constants
- func Create(name string, uuid string) error
- func CreateAndLoad(name string, uuid string, flags uint32, tables ...Table) error
- func GetVersion() (major, minor, patch uint32, err error)
- func Load(name string, flags uint32, tables ...Table) error
- func Message(name string, sector int, message string) error
- func Remove(name string) error
- func Rename(old, new string) error
- func Resume(name string) error
- func SetUUID(name, uuid string) error
- func Suspend(name string) error
- type CacheTable
- type CryptTable
- type DelayTable
- type DeviceInfo
- type DustTable
- type EraTable
- type ErrorTable
- type FlakeyTable
- type IntegrityTable
- type LinearTable
- type ListItem
- type LogWritesTable
- type MirrorDevice
- type MirrorTable
- type MultipathGroup
- type MultipathPath
- type MultipathTable
- type RaidDevice
- type RaidTable
- type SnapshotMergeTable
- type SnapshotOriginTable
- type SnapshotTable
- type StripeDevice
- type StripeTable
- type SwitchDevice
- type SwitchTable
- type Table
- type ThinPoolTable
- type ThinTable
- type UnstripedTable
- type VerityTable
- type Volume
- type WritecacheTable
- type ZeroTable
Constants ¶
const ( // CryptFlagAllowDiscards is an equivalent of 'allow_discards' crypt option CryptFlagAllowDiscards = "allow_discards" // CryptFlagSameCPUCrypt is an equivalent of 'same_cpu_crypt' crypt option CryptFlagSameCPUCrypt = "same_cpu_crypt" // CryptFlagSubmitFromCryptCPUs is an equivalent of 'submit_from_crypt_cpus' crypt option CryptFlagSubmitFromCryptCPUs = "submit_from_crypt_cpus" // CryptFlagNoReadWorkqueue is an equivalent of 'no_read_workqueue' crypt option CryptFlagNoReadWorkqueue = "no_read_workqueue" // CryptFlagNoWriteWorkqueue is an equivalent of 'no_write_workqueue' crypt option CryptFlagNoWriteWorkqueue = "no_write_workqueue" )
const ( // ReadOnlyFlag is a devmapper readonly flag value ReadOnlyFlag = unix.DM_READONLY_FLAG )
const SectorSize = 512
SectorSize is a device size used for devmapper calculations. Currently this value hardcoded to 512.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
Create creates a new device. No table will be loaded. The device will be in suspended state. Any IO to this device will fail.
func CreateAndLoad ¶
CreateAndLoad creates, loads the provided tables and resumes the device.
func GetVersion ¶
GetVersion returns version for the dm-mapper kernel interface
Types ¶
type CacheTable ¶
type CacheTable struct {
Start uint64
Length uint64
MetadataDevice string
CacheDevice string
OriginDevice string
BlockSize uint64 // cache block size in bytes
Features []string
Policy string // cache policy, e.g. "smq"
PolicyArgs []string // policy-specific arguments
}
CacheTable represents information needed for 'cache' target creation. It uses a fast device (e.g. SSD) to cache a slower origin device.
type CryptTable ¶
type CryptTable struct {
Start uint64
Length uint64
BackendDevice string // device that stores the encrypted data
BackendOffset uint64
Encryption string
Key []byte
KeyID string // key id in the keystore e.g. ":32:logon:foobarkey"
IVTweak uint64
Flags []string // TODO: maybe convert it to bitflag instead?
SectorSize uint64 // size of the sector the crypto device operates with
}
CryptTable represents information needed for 'crypt' target creation
type DelayTable ¶
type DelayTable struct {
Start uint64
Length uint64
ReadDevice string
ReadOffset uint64
ReadDelay uint64 // delay in milliseconds
WriteDevice string // optional, defaults to ReadDevice
WriteOffset uint64
WriteDelay uint64 // delay in milliseconds
FlushDevice string // optional, defaults to WriteDevice
FlushOffset uint64
FlushDelay uint64 // delay in milliseconds
}
DelayTable represents information needed for 'delay' target creation. It delays I/O for testing purposes.
type DeviceInfo ¶
type DeviceInfo struct {
Name string
UUID string
DevNo uint64
OpenCount int32
TargetsNum uint32
Flags uint32 // combination of unix.DM_*_FLAG
}
DeviceInfo is a type that holds devmapper device information
func InfoByDevno ¶
func InfoByDevno(devno uint64) (*DeviceInfo, error)
InfoByDevno returns device mapper information by its block device number (major/minor)
func InfoByName ¶
func InfoByName(name string) (*DeviceInfo, error)
InfoByName returns device information by its name
type DustTable ¶
type DustTable struct {
Start uint64
Length uint64
Device string
Offset uint64
BlockSize uint64 // block size in bytes
}
DustTable represents information needed for 'dust' target creation. It simulates failing sectors on a device for testing purposes.
type EraTable ¶
type EraTable struct {
Start uint64
Length uint64
MetadataDevice string
OriginDevice string
BlockSize uint64 // block size in bytes
}
EraTable represents information needed for 'era' target creation. It tracks which blocks were written within a given period (era).
type ErrorTable ¶
ErrorTable represents information needed for 'error' target creation. Any I/O to this target always fails with EIO.
type FlakeyTable ¶
type FlakeyTable struct {
Start uint64
Length uint64
Device string
Offset uint64
UpInterval uint64 // number of seconds device is available
DownInterval uint64 // number of seconds device returns errors
Features []string
}
FlakeyTable represents information needed for 'flakey' target creation. It creates an unreliable device for testing purposes, periodically returning errors for all I/O.
type IntegrityTable ¶
type IntegrityTable struct {
Start uint64
Length uint64
Device string
Offset uint64
TagSize uint64
Mode string // "J" (journal), "B" (bitmap), "D" (direct)
Features []string
}
IntegrityTable represents information needed for 'integrity' target creation. It provides block-level data integrity protection (dm-integrity).
type LinearTable ¶
LinearTable represents information needed for 'linear' target creation
type LogWritesTable ¶
LogWritesTable represents information needed for 'log-writes' target creation. It logs all write operations to a separate device for crash consistency testing.
type MirrorDevice ¶
MirrorDevice represents one device in a mirror set
type MirrorTable ¶
type MirrorTable struct {
Start uint64
Length uint64
LogType string // e.g. "core" or "disk"
LogArgs []string // arguments for the log type
Devices []MirrorDevice
Features []string // optional features like "handle_errors"
}
MirrorTable represents information needed for 'mirror' target creation. It mirrors I/O across multiple devices (RAID-1).
type MultipathGroup ¶
type MultipathGroup struct {
PathSelector string // e.g. "round-robin"
SelectorArgs []string
Paths []MultipathPath
}
MultipathGroup represents a path group in a multipath target
type MultipathPath ¶
MultipathPath represents a single path in a multipath path group
type MultipathTable ¶
type MultipathTable struct {
Start uint64
Length uint64
Features []string
HWHandler string // hardware handler, e.g. "0" for none
HWArgs []string
PathGroups []MultipathGroup
}
MultipathTable represents information needed for 'multipath' target creation. It provides I/O failover and load balancing across multiple paths.
type RaidDevice ¶
type RaidDevice struct {
MetaDevice string // metadata device, or "-" if not used
DataDevice string
}
RaidDevice represents one device pair in a RAID set (metadata + data)
type RaidTable ¶
type RaidTable struct {
Start uint64
Length uint64
RaidType string // e.g. "raid0", "raid1", "raid4", "raid5_ls", "raid6_zr", "raid10"
Params []string
Devices []RaidDevice
}
RaidTable represents information needed for 'raid' target creation. It implements various RAID levels using the md (multiple devices) framework.
type SnapshotMergeTable ¶
type SnapshotMergeTable struct {
Start uint64
Length uint64
OriginDevice string
COWDevice string
Persistent bool
ChunkSize uint64 // chunk size in bytes
}
SnapshotMergeTable represents information needed for 'snapshot-merge' target creation. It merges a snapshot back into its origin.
type SnapshotOriginTable ¶
SnapshotOriginTable represents information needed for 'snapshot-origin' target creation. It marks a device as the origin for snapshots.
type SnapshotTable ¶
type SnapshotTable struct {
Start uint64
Length uint64
OriginDevice string
COWDevice string // copy-on-write device
Persistent bool // persistent (P) or transient (N)
ChunkSize uint64 // chunk size in bytes
}
SnapshotTable represents information needed for 'snapshot' target creation. It creates a copy-on-write snapshot of the origin device.
type StripeDevice ¶
StripeDevice represents one device in a stripe set
type StripeTable ¶
type StripeTable struct {
Start uint64
Length uint64
ChunkSize uint64 // chunk size in bytes
Devices []StripeDevice
}
StripeTable represents information needed for 'striped' target creation. It stripes I/O across multiple devices (RAID-0).
type SwitchDevice ¶
SwitchDevice represents one path in a switch target
type SwitchTable ¶
type SwitchTable struct {
Start uint64
Length uint64
RegionSize uint64 // region size in bytes
Devices []SwitchDevice
}
SwitchTable represents information needed for 'switch' target creation. It allows switching between multiple backend devices on a per-region basis.
type Table ¶
type Table interface {
// contains filtered or unexported methods
}
Table is a type to represent different devmapper targets like 'zero', 'crypt', ...
type ThinPoolTable ¶
type ThinPoolTable struct {
Start uint64
Length uint64
MetadataDevice string
DataDevice string
DataBlockSize uint64 // block size in bytes
LowWaterMark uint64 // free space threshold in blocks
Features []string
}
ThinPoolTable represents information needed for 'thin-pool' target creation. It manages a pool of blocks shared between thin devices.
type ThinTable ¶
type ThinTable struct {
Start uint64
Length uint64
PoolDevice string
DeviceID uint64
ExternalOrigin string // optional external origin device
}
ThinTable represents information needed for 'thin' target creation. It creates a thin provisioned device backed by a thin-pool.
type UnstripedTable ¶
type UnstripedTable struct {
Start uint64
Length uint64
NumStripes uint64
ChunkSize uint64 // chunk size in bytes
StripeNum uint64 // which stripe to extract (0-indexed)
Device string
Offset uint64
}
UnstripedTable represents information needed for 'unstriped' target creation. It extracts a single stripe from a striped device.
type VerityTable ¶
type VerityTable struct {
Start uint64
Length uint64
HashType uint64
DataDevice string // the device containing data, the integrity of which needs to be checked
HashDevice string // device that supplies the hash tree data
DataBlockSize, HashBlockSize uint64
NumDataBlocks, HashStartBlock uint64
Algorithm, Digest, Salt string
Params []string
}
VerityTable represents information needed for 'verity' target creation
type Volume ¶
Volume represents reader/writer for the data handled by the device mapper table. Due to constrains the reader and writer operate at SectorSize size. Some targets may put further restrictions on the buffer alignment, e.g. CryptTarget operates at CryptTarget.SectorSize instead
func OpenUserspaceVolume ¶
OpenUserspaceVolume opens a volume that allows to read/write data. It performs the data processing at user-space level without using device-mapper kernel framework. flag and perm parameters are applied to os.OpenFile() when opening the underlying files
type WritecacheTable ¶
type WritecacheTable struct {
Start uint64
Length uint64
Type uint64 // 0 for pmem (DAX), 1 for SSD (block device)
DataDevice string
CacheDevice string
BlockSize uint64 // block size in bytes
Features []string
}
WritecacheTable represents information needed for 'writecache' target creation. It caches writes on a fast device and later flushes them to the slower origin device.