Documentation
¶
Index ¶
- Variables
- func DMDevPath(vg, lv string) string
- func DMName(vg, lv string) string
- func IsCapable() bool
- func PVScan(log *plog.Logger) error
- func WithLogger(log *plog.Logger) funcopt.O
- type LV
- func (t *LV) Activate(ctx context.Context) error
- func (t *LV) Attrs(ctx context.Context) (LVAttrs, error)
- func (t *LV) Create(ctx context.Context, size string, args []string) error
- func (t *LV) CreateSnapshot(ctx context.Context, name string, size int64) (*LV, error)
- func (t *LV) CreateThin(ctx context.Context, size string, pool string, args []string) error
- func (t *LV) Deactivate(ctx context.Context) error
- func (t LV) DevPath() string
- func (t *LV) Devices(ctx context.Context) (device.L, error)
- func (t LV) DriverName() string
- func (t *LV) Exists(ctx context.Context) (bool, error)
- func (t LV) FQN() string
- func (t *LV) IsActive(ctx context.Context) (bool, error)
- func (t *LV) Log() *plog.Logger
- func (t *LV) Remove(ctx context.Context, args []string) error
- func (t *LV) Resize(ctx context.Context, size int64) error
- func (t *LV) SetLog(log *plog.Logger)
- func (t *LV) Show(ctx context.Context) (*LVInfo, error)
- func (t *LV) Size(ctx context.Context) (int64, error)
- func (t *LV) Wipe(ctx context.Context) error
- func (t *LV) ZeroTail(_ context.Context) error
- type LVAttr
- type LVAttrIndex
- type LVAttrs
- type LVInfo
- type LVReport
- type LVSummary
- type ShowData
- type VG
- func (t *VG) Activate(ctx context.Context) error
- func (t *VG) ActiveLVDevices() (device.L, error)
- func (t *VG) AddNodeTag(ctx context.Context) error
- func (t *VG) AddTag(ctx context.Context, s string) error
- func (t *VG) Attrs(ctx context.Context) (VGAttrs, error)
- func (t *VG) CachedDevicesShow(ctx context.Context) (*VGInfo, error)
- func (t *VG) CachedNormalShow(ctx context.Context) (l []VGInfo, err error)
- func (t *VG) Create(ctx context.Context, size string, pvs []string, options []string) error
- func (t *VG) Deactivate(ctx context.Context) error
- func (t *VG) DelNodeTag(ctx context.Context) error
- func (t *VG) DelTag(ctx context.Context, s string) error
- func (t *VG) Devices(ctx context.Context) (device.L, error)
- func (t VG) DriverName() string
- func (t *VG) Exists(ctx context.Context) (bool, error)
- func (t *VG) ExtentSize(ctx context.Context) (int64, error)
- func (t *VG) FQN() string
- func (t *VG) Free(ctx context.Context) (int64, error)
- func (t *VG) GetLVSummary(ctx context.Context) (LVSummary, error)
- func (t *VG) HasNodeTag(ctx context.Context) (bool, error)
- func (t *VG) HasTag(ctx context.Context, s string) (bool, error)
- func (t *VG) ImportDevices(ctx context.Context) error
- func (t *VG) IsActive(ctx context.Context) (bool, error)
- func (t *VG) LVInfos(ctx context.Context) ([]LVInfo, error)
- func (t *VG) Log() *plog.Logger
- func (t *VG) NeedActivate(s LVSummary) bool
- func (t *VG) PEStart(ctx context.Context) (int64, error)
- func (t *VG) PVs(ctx context.Context) (device.L, error)
- func (t *VG) Remove(ctx context.Context, args []string) error
- func (t *VG) RemovePVs(ctx context.Context, pvs device.L) error
- func (t *VG) ResizePV(ctx context.Context, pv string, size int64) error
- func (t *VG) SetLog(log *plog.Logger)
- func (t *VG) Show(ctx context.Context, fields string) (*VGInfo, error)
- func (t *VG) Size(ctx context.Context) (int64, error)
- func (t *VG) Tags(ctx context.Context) ([]string, error)
- func (t *VG) Wipe() error
- type VGAttr
- type VGAttrIndex
- type VGAttrs
- type VGInfo
Constants ¶
This section is empty.
Variables ¶
var (
ErrExist = errors.New("does not exist")
)
Functions ¶
Types ¶
type LV ¶
func LVOfDevice ¶
LVOfDevice returns the logical volume dev is, and nil when it is none, or when lvm is not installed.
func (*LV) Create ¶
Create makes the logical volume, of the size given as the configuration spells it.
A share of the volume group is what lvm2 computes, from an extent count, so it is handed over as written. Everything else is a count of bytes, and the unit is spelled out because lvcreate does not default to bytes.
func (*LV) CreateSnapshot ¶
CreateSnapshot creates the snapshot name of the volume, and returns it. A thin volume is snapshotted in its pool, and size is ignored. A thick one is given size bytes to hold what is written to the volume while the snapshot lives: lvm drops a snapshot running out of it.
Taking the snapshot suspends the volume, which freezes the filesystem on it first, so the snapshot holds a clean filesystem.
func (*LV) CreateThin ¶
CreateThin makes the logical volume a thin volume of the thin pool named pool, in the same volume group, of the size it is seen with. A share of the volume group is no size a thin volume is made with.
func (LV) DriverName ¶
func (t LV) DriverName() string
func (*LV) Resize ¶
Resize sets the size of the logical volume, in bytes.
The filesystem on it is not touched. Which of the things stacked on a volume to resize, and in which order, is the caller's to decide, where lvresize --resizefs would decide it here.
func (*LV) Wipe ¶
Wipe erases the signatures of the volume, and zeroes its end, so the extents it frees hand nothing of what it held to the next volume made on them.
func (*LV) ZeroTail ¶
ZeroTail zeroes the last device.TailWipeSize bytes of the volume. lvcreate wipes the signatures its libblkid knows, and zeroes the first 4 KiB: on an older distribution, the drbd metadata a volume left at the end of its extents is found by the next volume made on them, and taken for its own.
type LVAttr ¶
type LVAttr rune
const ( LVAttrStateActive LVAttr = 'a' LVAttrStateHistorical LVAttr = 'h' LVAttrStateSuspended LVAttr = 's' LVAttrStateInvalidSnapshot LVAttr = 'I' LVAttrStateSuspendedSnapshot LVAttr = 'S' LVAttrStateSnapshotMergeFailed LVAttr = 'm' LVAttrStateSuspendedSnapshotMergeFailed LVAttr = 'M' LVAttrStateMappedDevicePresentWithoutTable LVAttr = 'd' LVAttrStateMappedDevicePresentWithInactiveTable LVAttr = 'i' LVAttrStateThinPoolCheckNeeded LVAttr = 'c' LVAttrStateSuspendedThinPoolCheckNeeded LVAttr = 'C' LVAttrStateUnknown LVAttr = 'X' )
type LVAttrIndex ¶
type LVAttrIndex uint8
const ( LVAttrIndexType LVAttrIndex = 0 LVAttrIndexPermissions LVAttrIndex = iota LVAttrIndexAllocationPolicy LVAttrIndexAllocationFixedMinor LVAttrIndexState LVAttrIndexDeviceOpen LVAttrIndexTargetType LVAttrIndexZeroDataBlocks LVAttrIndexVolumeHealth LVAttrIndexSkipActivation )
type LVAttrs ¶
type LVAttrs string
func (LVAttrs) Attr ¶
func (t LVAttrs) Attr(index LVAttrIndex) LVAttr
type LVInfo ¶
type LVInfo struct {
LVName string `json:"lv_name"`
VGName string `json:"vg_name"`
LVAttr string `json:"lv_attr"`
LVSize string `json:"lv_size"`
Origin string `json:"origin"`
DataPercent string `json:"data_percent"`
CopyPercent string `json:"copy_percent"`
MetadataPercent string `json:"metadata_percent"`
MetadataDevices string `json:"metadata_devices"`
MovePV string `json:"move_pv"`
ConvertPV string `json:"convert_pv"`
MirrorLog string `json:"mirror_log"`
Devices string `json:"devices"`
// SegType is the type of the volume, as thin, which is not
// snapshotted as a linear one is.
SegType string `json:"segtype"`
// PoolLV is the thin pool a thin volume is in, empty for
// another volume.
PoolLV string `json:"pool_lv"`
}
type VG ¶
type VG struct {
VGName string
// contains filtered or unexported fields
}
func (*VG) CachedNormalShow ¶
CachedNormalShow retrieves cached volume group information, unmarshals the output data, and filters by the specified VGName.
It uses the command: vgs --reportformat json -o "+tags,pv_name". => The following cmd output will return 2 entries when t.VGName == "data"
{
"report": [
{"vg": [
{"vg_name": "data", "pv_count": "1", "lv_count": "0", "snap_count": "0", "vg_attr": "wz--n-","vg_size": "<5.00g", "vg_free": "<5.00g", "vg_tags": "local", "pv_name": "/dev/vdb"},
{"vg_name": "data", "pv_count": "1", "lv_count": "0", "snap_count": "0", "vg_attr": "wz--n-","vg_size": "<5.00g", "vg_free": "<5.00g", "vg_tags": "local", "pv_name": "/dev/vdc"},
{"vg_name": "root", "pv_count": "1", "lv_count": "2", "snap_count": "0", "vg_attr": "wz--n-","vg_size": "<38.75g", "vg_free": "0 ", "vg_tags": "local", "pv_name": "/dev/vda3"}
]}
]
}
func (VG) DriverName ¶
func (t VG) DriverName() string
func (*VG) ExtentSize ¶
ExtentSize is the bytes of the unit a volume group hands out. A logical volume is a whole number of them, so a group asked for a size that is not has to round up or the volume does not fit.
func (*VG) Free ¶
Free is the bytes of the group nothing has taken yet, rounded down to a whole number of extents.
Rounded down, where every other size om asks for is rounded up: this is what is there, not what is wanted, and a caller asking for all of it must ask for a size that fits. lvcreate rounds a size up to the next extent, so a byte count that is not a whole number of them is one extent more than the group has.
func (*VG) LVInfos ¶
LVInfos retrieves information about logical volumes (LVs) in the volume group (VG) as a list of LVInfo structures. It runs the "lvs" command with JSON output format and processes the result. Returns an error if the command fails.
func (*VG) NeedActivate ¶
func (*VG) PEStart ¶
PEStart is the offset of the first extent of the physical volume of a group of one: the bytes the group keeps of its device for its metadata, before the extents it hands out.
It is what the group keeps for itself whatever the device holds, where the gap between the device and the group counts, once the device has grown and the group has not been grown onto it, the growth itself. lvm reports the size of the physical volume as its extents, so that gap says nothing either.
func (*VG) RemovePVs ¶
RemovePVs removes the lvm label of the physical volumes pvs, freed by the removal of their group. A vgcreate labels the devices it is given, so the group removed, the label is all that is left of it on them.
func (*VG) ResizePV ¶
ResizePV makes the volume group use the current size of one of its physical volumes.
A size of 0 takes the whole device, which is what a group growing onto a device that just grew wants. A size is set explicitly to give space back, which lvm refuses if extents beyond it are in use.
type VGAttr ¶
type VGAttr rune
const ( VGAttrStateWriteable VGAttr = 'w' VGAttrStateReadOnly VGAttr = 'r' VGAttrStateResizeable VGAttr = 'z' VGAttrStateExported VGAttr = 'x' VGAttrStatePartial VGAttr = 'p' VGAttrStateAllocContiguous VGAttr = 'c' VGAttrStateAllocCling VGAttr = 'l' VGAttrStateAllocNormal VGAttr = 'n' VGAttrStateAllocAnywhere VGAttr = 'a' VGAttrStateClustered VGAttr = 'c' )
type VGAttrIndex ¶
type VGAttrIndex uint8
const ( VGAttrIndexPermissions VGAttrIndex = 0 VGAttrIndexResizeable VGAttrIndex = iota VGAttrIndexExported VGAttrIndexPartial VGAttrIndexAllocationPolicy )
type VGAttrs ¶
type VGAttrs string
func (VGAttrs) Attr ¶
func (t VGAttrs) Attr(index VGAttrIndex) VGAttr
type VGInfo ¶
type VGInfo struct {
VGName string `json:"vg_name"`
VGAttr string `json:"vg_attr"`
VGSize string `json:"vg_size"`
VGFree string `json:"vg_free"`
VGExtSize string `json:"vg_extent_size"`
VGTags string `json:"vg_tags"`
SnapCount string `json:"snap_count"`
PVCount string `json:"pv_count"`
LVCount string `json:"lv_count"`
PVName string `json:"pv_name"`
PEStart string `json:"pe_start"`
LVName string `json:"lv_name"`
Devices string `json:"devices"`
}
func (*VGInfo) PEStartBytes ¶
PEStartBytes is the offset of the first extent of the physical volume of the row.