Documentation ¶
Index ¶
- Variables
- func All(Pool) bool
- func BindMount(src Volume, target string) error
- func FilesUsage(path string) (uint64, error)
- func GetMountTarget(device string) (string, bool)
- func IsMountPoint(path string) bool
- func IsZDBVolume(v Volume) bool
- func Partprobe(ctx context.Context) error
- type Btrfs
- type BtrfsDevice
- type BtrfsDiskUsage
- type BtrfsQGroup
- type BtrfsUtil
- func (u *BtrfsUtil) DeviceAdd(ctx context.Context, dev string, root string) error
- func (u *BtrfsUtil) DeviceRemove(ctx context.Context, dev string, root string) error
- func (u *BtrfsUtil) GetDiskUsage(ctx context.Context, path string) (usage BtrfsDiskUsage, err error)
- func (u *BtrfsUtil) List(ctx context.Context, label string, mounted bool) ([]Btrfs, error)
- func (u *BtrfsUtil) QGroupDestroy(ctx context.Context, id, path string) error
- func (u *BtrfsUtil) QGroupEnable(ctx context.Context, root string) error
- func (u *BtrfsUtil) QGroupLimit(ctx context.Context, size uint64, path string) error
- func (u *BtrfsUtil) QGroupList(ctx context.Context, path string) (map[string]BtrfsQGroup, error)
- func (u *BtrfsUtil) SubvolumeAdd(ctx context.Context, root string) error
- func (u *BtrfsUtil) SubvolumeInfo(ctx context.Context, path string) (volume BtrfsVolume, err error)
- func (u *BtrfsUtil) SubvolumeList(ctx context.Context, root string) ([]BtrfsVolume, error)
- func (u *BtrfsUtil) SubvolumeRemove(ctx context.Context, root string) error
- type BtrfsVolume
- type ByReadTime
- type Device
- type DeviceCache
- type DeviceManager
- type DiskUsage
- type FSType
- type Filesystem
- type Filter
- type Pool
- type Usage
- type Volume
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDeviceAlreadyMounted indicates that a mounted device is attempted // to be mounted again (without MS_BIND flag). ErrDeviceAlreadyMounted = fmt.Errorf("device is already mounted") // ErrDeviceNotMounted is returned when an action is performed on a device // which requires the device to be mounted, while it is not. ErrDeviceNotMounted = fmt.Errorf("device is not mounted") )
Functions ¶
func BindMount ¶
BindMount remounts an existing directory in a given target using the mount syscall with the BIND flag set
func FilesUsage ¶
FilesUsage return the total size of files under path (recursively) in bytes
func GetMountTarget ¶
GetMountTarget returns the mount target of a device or false if the device is not mounted. panic, it panics if it can't read /proc/mounts
func IsMountPoint ¶
IsMountPoint checks if a path is a mount point
Types ¶
type Btrfs ¶
type Btrfs struct { Label string `json:"label"` UUID string `json:"uuid"` TotalDevices int `json:"total_devices"` Used int64 `json:"used"` Devices []BtrfsDevice `json:"devices"` Warnings string `json:"warnings"` }
Btrfs holds metadata of underlying btrfs filesystem
type BtrfsDevice ¶
type BtrfsDevice struct { Missing bool `json:"missing,omitempty"` DevID int `json:"dev_id"` Size int64 `json:"size"` Used int64 `json:"used"` Path string `json:"path"` }
BtrfsDevice holds metadata about a single device in a btrfs filesystem
type BtrfsDiskUsage ¶
type BtrfsDiskUsage struct { Data DiskUsage `json:"data"` System DiskUsage `json:"system"` Metadata DiskUsage `json:"metadata"` GlobalReserve DiskUsage `json:"globalreserve"` }
BtrfsDiskUsage is parsed information form btrfs fi df
type BtrfsQGroup ¶
BtrfsQGroup is parsed btrfs qgroup information
type BtrfsUtil ¶
type BtrfsUtil struct {
// contains filtered or unexported fields
}
BtrfsUtil utils for btrfs
func (*BtrfsUtil) DeviceRemove ¶
DeviceRemove removes a device from a btrfs pool
func (*BtrfsUtil) GetDiskUsage ¶
func (u *BtrfsUtil) GetDiskUsage(ctx context.Context, path string) (usage BtrfsDiskUsage, err error)
GetDiskUsage get btrfs usage
func (*BtrfsUtil) List ¶
List lists all availabel btrfs pools if label is provided, only get fs of that label, if mounted = True, only return mounted filesystems, otherwise any.
func (*BtrfsUtil) QGroupDestroy ¶
QGroupDestroy deletes a qgroup on a subvol
func (*BtrfsUtil) QGroupEnable ¶
QGroupEnable enable quota
func (*BtrfsUtil) QGroupLimit ¶
QGroupLimit limit size on subvol
func (*BtrfsUtil) QGroupList ¶
QGroupList list available qgroups
func (*BtrfsUtil) SubvolumeAdd ¶
SubvolumeAdd adds a new subvolume at path
func (*BtrfsUtil) SubvolumeInfo ¶
SubvolumeInfo get info of a subvolume giving its path
func (*BtrfsUtil) SubvolumeList ¶
SubvolumeList list direct subvolumes of this location
type BtrfsVolume ¶
BtrfsVolume holds metadata about a single subvolume
type ByReadTime ¶
type ByReadTime DeviceCache
ByReadTime implements sort.Interface for []Device based on the ReadTime field
func (ByReadTime) Len ¶
func (a ByReadTime) Len() int
func (ByReadTime) Less ¶
func (a ByReadTime) Less(i, j int) bool
func (ByReadTime) Swap ¶
func (a ByReadTime) Swap(i, j int)
type Device ¶
type Device struct { Type string `json:"type"` Path string `json:"name"` Label string `json:"label"` Filesystem FSType `json:"fstype"` Children []Device `json:"children"` DiskType pkg.DeviceType `json:"-"` ReadTime uint64 `json:"-"` Subsystems string `json:"subsystems"` //HasPartions is different from children, because once the //devices are flattend in the device, cache, the children list is //zeroed (since all devices are flat), then has partions is set to //make sure the device is not altered. HasPartions bool `json:"-"` ShutdownCount *expvar.Int }
Device represents a physical device
type DeviceCache ¶
type DeviceCache []Device
DeviceCache represents a list of cached in memory devices
type DeviceManager ¶
type DeviceManager interface { // Device returns the device at the specified path Device(ctx context.Context, device string) (*Device, error) // Devices finds all devices on a system Devices(ctx context.Context) (DeviceCache, error) // ByLabel finds all devices with the specified label ByLabel(ctx context.Context, label string) ([]*Device, error) // Raw returns the devices as represented in the kernel // without using the internal cache, nor flattened Raw(ctx context.Context) (DeviceCache, error) // Reset returns a "clean" instace of the device manager // The implementation must take care to clean any caching // or other in-memory states and starting fresh. It's called // by some routines to make sure a listing of devices will // always return the real state of the system. Reset() DeviceManager }
DeviceManager is able to list all/specific devices on a system
func DefaultDeviceManager ¶
func DefaultDeviceManager(ctx context.Context) DeviceManager
DefaultDeviceManager returns a default device manager implementation
func Migrate ¶
func Migrate(ctx context.Context, m DeviceManager) (DeviceManager, error)
Migrate is a simple migration routine that makes sure we have fresh disks to use from zos v1, in case you moving away from older version After migration you should alway use the returned Device manager, or create a new one.
type DiskUsage ¶
type DiskUsage struct { Profile pkg.RaidProfile `json:"profile"` Total uint64 `json:"total"` Used uint64 `json:"used"` }
DiskUsage is parsed information from a btrfs fi df line
type FSType ¶
type FSType string
FSType type of filesystem on device
const ( // BtrfsFSType btrfs filesystem type BtrfsFSType FSType = "btrfs" )
type Filesystem ¶
type Filesystem interface { // Create a new filesystem. // // name: name of the filesystem // devices: list of devices to use in the filesystem // profile: Raid profile of the filesystem Create(ctx context.Context, name string, profile pkg.RaidProfile, devices ...*Device) (Pool, error) // CreateForce creates a new filesystem with force // It will delete existing data and partition tables CreateForce(ctx context.Context, name string, profile pkg.RaidProfile, devices ...*Device) (Pool, error) // List all existing filesystems on the node List(ctx context.Context, filter Filter) ([]Pool, error) }
Filesystem defines a filesystem interface
func NewBtrfs ¶
func NewBtrfs(manager DeviceManager) Filesystem
NewBtrfs creates a new filesystem that implements btrfs
type Pool ¶
type Pool interface { Volume // Mounted returns whether the pool is mounted or not. If it is mounted, // the mountpoint is returned Mounted() (string, bool) // Mount the pool, the mountpoint is returned Mount() (string, error) // MountWithoutScan the pool, the mountpoint is returned. // Does not scan for btrfs MountWithoutScan() (string, error) // UnMount the pool UnMount() error //AddDevice to the pool AddDevice(device *Device) error // RemoveDevice from the pool RemoveDevice(device *Device) error // Type of the physical storage in this pool Type() pkg.DeviceType // Reserved is reserved size of the devices in bytes Reserved() (uint64, error) // Volumes are all subvolumes of this volume Volumes() ([]Volume, error) // AddVolume adds a new subvolume with the given name AddVolume(name string) (Volume, error) // RemoveVolume removes a subvolume with the given name RemoveVolume(name string) error // Devices list attached devices Devices() []*Device // Shutdown spins down the device where the pool is mounted Shutdown() error }
Pool represents a created filesystem
type Volume ¶
type Volume interface { // Volume ID ID() int // Path of the volume Path() string // Usage reports the current usage of the volume Usage() (Usage, error) // Limit the maximum size of the volume Limit(size uint64) error // Name of the volume Name() string // FsType of the volume FsType() string }
Volume represents a logical volume in the pool. Volumes can be nested