storage

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: May 26, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

README

Storage

Implementation of the storage module interface

Mountpoints

Every volume which is managed by the storage module is mounted in /mnt. The name of the mountpoint is the label of the volume. For instance, a volume with label volumelabel will be mounted in /mnt/volumelabel. The volumes are mounted when the storage module is started, and remain mounted after that. In case the storae module exits in any way, there is no attempt to unmount any volume.

Since filesystems are created as subvolumes within the "root" volumes, they are always mounted.

Next to the volumes, the storage module also tries to instantiate a cache. It does this by creating a subvolume, preferably in a volume which was created on SSD devices, and then creates a bind mount in the /var directory. The full path of the cache is /var/path.

Documentation

Index

Constants

View Source
const (
	// SSDOverProvisionFactor over provision factor for SSDs
	SSDOverProvisionFactor = 1
	// CacheTarget is the path where the cache disk is mounted
	CacheTarget = "/var/cache"
)

Variables

This section is empty.

Functions

func PolicyHDDOnly

func PolicyHDDOnly(s *Module) []filesystem.Pool

func PolicySSDFirst

func PolicySSDFirst(s *Module) []filesystem.Pool

func PolicySSDOnly

func PolicySSDOnly(s *Module) []filesystem.Pool

Types

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module implements functionality for pkg.StorageModule

func New

func New(ctx context.Context) (*Module, error)

New create a new storage module service

func (*Module) BrokenDevices

func (s *Module) BrokenDevices() []pkg.BrokenDevice

BrokenDevices lists the broken devices that have been detected

func (*Module) BrokenPools

func (s *Module) BrokenPools() []pkg.BrokenPool

BrokenPools lists the broken storage pools that have been detected

func (*Module) Cache

func (s *Module) Cache() (pkg.Volume, error)

Cache return the special filesystem used by 0-OS to store internal state and flist cache

func (*Module) DeviceAllocate

func (m *Module) DeviceAllocate(min gridtypes.Unit) (pkg.Device, error)

DeviceAllocate allocates a new free device, allocation is done by creation a zdb subvolume

func (*Module) DeviceLookup

func (m *Module) DeviceLookup(name string) (pkg.Device, error)

DeviceLookup looks up device by name

func (*Module) Devices

func (m *Module) Devices() ([]pkg.Device, error)

Devices list all "allocated" devices

func (*Module) DiskCreate

func (s *Module) DiskCreate(name string, size gridtypes.Unit) (disk pkg.VDisk, err error)

DiskCreate with given size, return path to virtual disk (size in MB)

func (*Module) DiskDelete

func (s *Module) DiskDelete(name string) error

DiskDelete removes a virtual disk

func (*Module) DiskExists

func (s *Module) DiskExists(id string) bool

DiskExists checks if a disk exists

func (*Module) DiskFormat

func (s *Module) DiskFormat(name string) error

DiskFormat ensures that the virtual disk has a valid filesystem currently the fs is btrfs

func (*Module) DiskList

func (s *Module) DiskList() ([]pkg.VDisk, error)

DiskList list all created disks

func (*Module) DiskLookup

func (s *Module) DiskLookup(id string) (disk pkg.VDisk, err error)

DiskLookup return info about the disk

func (*Module) DiskResize

func (s *Module) DiskResize(name string, size gridtypes.Unit) (disk pkg.VDisk, err error)

DiskCreate with given size, return path to virtual disk (size in MB)

func (*Module) DiskWrite

func (s *Module) DiskWrite(name string, image string) error

DiskWrite writes image to disk. Disk will not be changed if it already has a filesystem or partition table.

func (*Module) Metrics

func (s *Module) Metrics() ([]pkg.PoolMetrics, error)

func (*Module) Monitor

func (s *Module) Monitor(ctx context.Context) <-chan pkg.PoolsStats

Monitor implements monitor method

func (*Module) Total

func (s *Module) Total(kind pkg.DeviceType) (uint64, error)

Total gives the total amount of storage available for a device type

func (*Module) VolumeCreate

func (s *Module) VolumeCreate(name string, size gridtypes.Unit) (pkg.Volume, error)

VolumeCreate with the given size in a storage pool.

func (*Module) VolumeDelete

func (s *Module) VolumeDelete(name string) error

VolumeDelete with the given name, this will unmount and then delete the filesystem. After this call, the caller must not perform any more actions on this filesystem

func (*Module) VolumeExists

func (s *Module) VolumeExists(name string) (bool, error)

VolumeExists returns an error if the lookup failed and a bool describing if the volume exists

func (*Module) VolumeList

func (s *Module) VolumeList() ([]pkg.Volume, error)

VolumeList return all the filesystem managed by storeaged present on the nodes

func (*Module) VolumeLookup

func (s *Module) VolumeLookup(name string) (pkg.Volume, error)

VolumeLookup return the path of the mountpoint of the named filesystem if no volume with name exists, an empty path and an error is returned

func (*Module) VolumeUpdate

func (s *Module) VolumeUpdate(name string, size gridtypes.Unit) error

VolumeUpdate updates filesystem size

type Policy

type Policy func(s *Module) []filesystem.Pool

Policy needed

type TypeCache

type TypeCache struct {
	// contains filtered or unexported fields
}

func (*TypeCache) Get

func (t *TypeCache) Get(name string) (pkg.DeviceType, bool)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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