lxd: github.com/lxc/lxd/lxd/storage/drivers Index | Files

package drivers

import "github.com/lxc/lxd/lxd/storage/drivers"

Index

Package Files

driver_btrfs.go driver_btrfs_utils.go driver_btrfs_volumes.go driver_ceph.go driver_ceph_utils.go driver_ceph_volumes.go driver_cephfs.go driver_cephfs_utils.go driver_cephfs_volumes.go driver_common.go driver_dir.go driver_dir_utils.go driver_dir_volumes.go driver_lvm.go driver_lvm_utils.go driver_lvm_volumes.go driver_types.go driver_zfs.go driver_zfs_patches.go driver_zfs_utils.go driver_zfs_volumes.go drivers_mock.go errors.go generic_vfs.go interface.go load.go utils.go utils_cgo.go volume.go

Constants

const ContentTypeBlock = ContentType("block")

ContentTypeBlock indicates the volume will be a block device and its contents and we do not know which filesystem(s) (if any) are in use.

const ContentTypeFS = ContentType("fs")

ContentTypeFS indicates the volume will be populated with a mountabble filesystem.

const DefaultFilesystem = "ext4"

DefaultFilesystem filesytem to use for block devices by default.

const LoFlagsAutoclear int = C.LO_FLAGS_AUTOCLEAR

LoFlagsAutoclear determines whether the loop device will autodestruct on last close.

const VolumeTypeContainer = VolumeType("containers")

VolumeTypeContainer represents a container storage volume.

const VolumeTypeCustom = VolumeType("custom")

VolumeTypeCustom represents a custom storage volume.

const VolumeTypeImage = VolumeType("images")

VolumeTypeImage represents an image storage volume.

const VolumeTypeVM = VolumeType("virtual-machines")

VolumeTypeVM represents a virtual-machine storage volume.

Variables

var BaseDirectories = map[VolumeType][]string{
    VolumeTypeContainer: {"containers", "containers-snapshots"},
    VolumeTypeCustom:    {"custom", "custom-snapshots"},
    VolumeTypeImage:     {"images"},
    VolumeTypeVM:        {"virtual-machines", "virtual-machines-snapshots"},
}

BaseDirectories maps volume types to the expected directories.

var ErrNotImplemented = fmt.Errorf("Not implemented")

ErrNotImplemented is the "Not implemented" error

var ErrNotSupported = fmt.Errorf("Not supported")

ErrNotSupported is the "Not supported" error

var ErrUnknownDriver = fmt.Errorf("Unknown driver")

ErrUnknownDriver is the "Unknown driver" error

func AllDriverNames Uses

func AllDriverNames() []string

AllDriverNames returns a list of all storage driver names.

func BTRFSSubVolumeIsRo Uses

func BTRFSSubVolumeIsRo(path string) bool

BTRFSSubVolumeIsRo returns if subvolume is read only.

func BTRFSSubVolumeMakeRo Uses

func BTRFSSubVolumeMakeRo(path string) error

BTRFSSubVolumeMakeRo makes a subvolume read only.

func BTRFSSubVolumeMakeRw Uses

func BTRFSSubVolumeMakeRw(path string) error

BTRFSSubVolumeMakeRw makes a sub volume read/write.

func BTRFSSubVolumesGet Uses

func BTRFSSubVolumesGet(path string) ([]string, error)

BTRFSSubVolumesGet gets subvolumes.

func GetPoolMountPath Uses

func GetPoolMountPath(poolName string) string

GetPoolMountPath returns the mountpoint of the given pool. {LXD_DIR}/storage-pools/<pool>

func GetSnapshotVolumeName Uses

func GetSnapshotVolumeName(parentName, snapshotName string) string

GetSnapshotVolumeName returns the full volume name for a parent volume and snapshot name.

func GetVolumeMountPath Uses

func GetVolumeMountPath(poolName string, volType VolumeType, volName string) string

GetVolumeMountPath returns the mount path for a specific volume based on its pool and type and whether it is a snapshot or not. For VolumeTypeImage the volName is the image fingerprint.

func GetVolumeSnapshotDir Uses

func GetVolumeSnapshotDir(poolName string, volType VolumeType, volName string) string

GetVolumeSnapshotDir gets the snapshot mount directory for the parent volume.

func PrepareLoopDev Uses

func PrepareLoopDev(source string, flags int) (*os.File, error)

PrepareLoopDev detects and sets up a loop device for source. It returns an open file descriptor to the free loop device and the path of the free loop device. It's the callers responsibility to close the open file descriptor.

func SetAutoclearOnLoopDev Uses

func SetAutoclearOnLoopDev(loopFd int) error

SetAutoclearOnLoopDev enables autodestruction of the provided loopback device.

func ShiftBtrfsRootfs Uses

func ShiftBtrfsRootfs(path string, diskIdmap *idmap.IdmapSet) error

ShiftBtrfsRootfs shifts the BTRFS root filesystem.

func ShiftZFSSkipper Uses

func ShiftZFSSkipper(dir string, absPath string, fi os.FileInfo) bool

ShiftZFSSkipper indicates which files not to shift for ZFS.

func TryMount Uses

func TryMount(src string, dst string, fs string, flags uintptr, options string) error

TryMount tries mounting a filesystem multiple times. This is useful for unreliable backends.

func TryUnmount Uses

func TryUnmount(path string, flags int) error

TryUnmount tries unmounting a filesystem multiple times. This is useful for unreliable backends.

func UnsetAutoclearOnLoopDev Uses

func UnsetAutoclearOnLoopDev(loopFd int) error

UnsetAutoclearOnLoopDev disables autodestruction of the provided loopback device.

func UnshiftBtrfsRootfs Uses

func UnshiftBtrfsRootfs(path string, diskIdmap *idmap.IdmapSet) error

UnshiftBtrfsRootfs unshifts the BTRFS root filesystem.

type ContentType Uses

type ContentType string

ContentType indicates the format of the volume.

type Driver Uses

type Driver interface {
    // Internal.
    Info() Info
    HasVolume(vol Volume) bool

    // Export struct details.
    Name() string
    Config() map[string]string
    Logger() logger.Logger

    // Pool.
    Create() error
    Delete(op *operations.Operation) error
    // Mount mounts a storage pool if needed, returns true if we caused a new mount, false if already mounted.
    Mount() (bool, error)

    // Unmount unmounts a storage pool if needed, returns true if unmounted, false if was not mounted.
    Unmount() (bool, error)
    GetResources() (*api.ResourcesStoragePool, error)
    Validate(config map[string]string) error
    Update(changedConfig map[string]string) error
    ApplyPatch(name string) error

    // Volumes.
    ValidateVolume(vol Volume, removeUnknownKeys bool) error
    CreateVolume(vol Volume, filler *VolumeFiller, op *operations.Operation) error
    CreateVolumeFromCopy(vol Volume, srcVol Volume, copySnapshots bool, op *operations.Operation) error
    RefreshVolume(vol Volume, srcVol Volume, srcSnapshots []Volume, op *operations.Operation) error
    DeleteVolume(vol Volume, op *operations.Operation) error
    RenameVolume(vol Volume, newName string, op *operations.Operation) error
    UpdateVolume(vol Volume, changedConfig map[string]string) error
    GetVolumeUsage(vol Volume) (int64, error)
    SetVolumeQuota(vol Volume, size string, op *operations.Operation) error
    GetVolumeDiskPath(vol Volume) (string, error)

    // MountVolume mounts a storage volume, returns true if we caused a new mount, false if
    // already mounted.
    MountVolume(vol Volume, op *operations.Operation) (bool, error)

    // MountVolumeSnapshot mounts a storage volume snapshot as readonly, returns true if we
    // caused a new mount, false if already mounted.
    MountVolumeSnapshot(snapVol Volume, op *operations.Operation) (bool, error)

    // UnmountVolume unmounts a storage volume, returns true if unmounted, false if was not
    // mounted.
    UnmountVolume(vol Volume, op *operations.Operation) (bool, error)

    // UnmountVolume unmounts a storage volume snapshot, returns true if unmounted, false if was
    // not mounted.
    UnmountVolumeSnapshot(snapVol Volume, op *operations.Operation) (bool, error)

    CreateVolumeSnapshot(snapVol Volume, op *operations.Operation) error
    DeleteVolumeSnapshot(snapVol Volume, op *operations.Operation) error
    RenameVolumeSnapshot(snapVol Volume, newSnapshotName string, op *operations.Operation) error
    VolumeSnapshots(vol Volume, op *operations.Operation) ([]string, error)
    RestoreVolume(vol Volume, snapshotName string, op *operations.Operation) error

    // Migration.
    MigrationTypes(contentType ContentType, refresh bool) []migration.Type
    MigrateVolume(vol Volume, conn io.ReadWriteCloser, volSrcArgs *migration.VolumeSourceArgs, op *operations.Operation) error
    CreateVolumeFromMigration(vol Volume, conn io.ReadWriteCloser, volTargetArgs migration.VolumeTargetArgs, preFiller *VolumeFiller, op *operations.Operation) error

    // Backup.
    BackupVolume(vol Volume, tarWriter *instancewriter.InstanceTarWriter, optimized bool, snapshots bool, op *operations.Operation) error
    CreateVolumeFromBackup(vol Volume, snapshots []string, srcData io.ReadSeeker, optimizedStorage bool, op *operations.Operation) (func(vol Volume) error, func(), error)
}

Driver represents a low-level storage driver.

func Load Uses

func Load(state *state.State, driverName string, name string, config map[string]string, logger logger.Logger, volIDFunc func(volType VolumeType, volName string) (int64, error), commonRules *Validators) (Driver, error)

Load returns a Driver for an existing low-level storage pool.

type ErrDeleteSnapshots Uses

type ErrDeleteSnapshots struct {
    Snapshots []string
}

ErrDeleteSnapshots is a special error used to tell the backend to delete more recent snapshots

func (ErrDeleteSnapshots) Error Uses

func (e ErrDeleteSnapshots) Error() string

type Info Uses

type Info struct {
    Name                  string
    Version               string
    VolumeTypes           []VolumeType // Supported volume types.
    Remote                bool         // Whether the driver uses a remote backing store.
    OptimizedImages       bool         // Whether driver stores images as separate volume.
    OptimizedBackups      bool         // Whether driver supports optimized volume backups.
    PreservesInodes       bool         // Whether driver preserves inodes when volumes are moved hosts.
    BlockBacking          bool         // Whether driver uses block devices as backing store.
    RunningQuotaResize    bool         // Whether quota resize is supported whilst instance running.
    RunningSnapshotFreeze bool         // Whether instance should be frozen during snapshot if running.
    DirectIO              bool         // Whether the driver supports direct I/O.
    MountedRoot           bool         // Whether the pool directory itself is a mount.
}

Info represents information about a storage driver.

func SupportedDrivers Uses

func SupportedDrivers(s *state.State) []Info

SupportedDrivers returns a list of supported storage drivers.

type Validators Uses

type Validators struct {
    PoolRules   func() map[string]func(string) error
    VolumeRules func(vol Volume) map[string]func(string) error
}

Validators contains functions used for validating a drivers's config.

type Volume Uses

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

Volume represents a storage volume, and provides functions to mount and unmount it.

func NewVolume Uses

func NewVolume(driver Driver, poolName string, volType VolumeType, contentType ContentType, volName string, volConfig, poolConfig map[string]string) Volume

NewVolume instantiates a new Volume struct.

func (Volume) Config Uses

func (v Volume) Config() map[string]string

Config returns the volumes (unexpanded) config.

func (Volume) ContentType Uses

func (v Volume) ContentType() ContentType

ContentType returns the content type.

func (Volume) EnsureMountPath Uses

func (v Volume) EnsureMountPath() error

EnsureMountPath creates the volume's mount path if missing, then sets the correct permission for the type.

func (Volume) ExpandedConfig Uses

func (v Volume) ExpandedConfig(key string) string

ExpandedConfig returns either the value of the volume's config key or the pool's config "volume.{key}" value.

func (Volume) IsBlockBacked Uses

func (v Volume) IsBlockBacked() bool

IsBlockBacked indicates whether storage device is block backed.

func (Volume) IsSnapshot Uses

func (v Volume) IsSnapshot() bool

IsSnapshot indicates if volume is a snapshot.

func (Volume) IsVMBlock Uses

func (v Volume) IsVMBlock() bool

IsVMBlock returns true if volume is a block volume for virtual machines or associated images.

func (Volume) MountPath Uses

func (v Volume) MountPath() string

MountPath returns the path where the volume will be mounted.

func (Volume) MountTask Uses

func (v Volume) MountTask(task func(mountPath string, op *operations.Operation) error, op *operations.Operation) error

MountTask runs the supplied task after mounting the volume if needed. If the volume was mounted for this then it is unmounted when the task finishes.

func (Volume) Name Uses

func (v Volume) Name() string

Name returns volume's name.

func (Volume) NewSnapshot Uses

func (v Volume) NewSnapshot(snapshotName string) (Volume, error)

NewSnapshot instantiates a new Volume struct representing a snapshot of the parent volume.

func (Volume) NewVMBlockFilesystemVolume Uses

func (v Volume) NewVMBlockFilesystemVolume() Volume

NewVMBlockFilesystemVolume returns a copy of the volume with the content type set to ContentTypeFS and the config "size" property set to vmBlockFilesystemSize.

func (Volume) Snapshots Uses

func (v Volume) Snapshots(op *operations.Operation) ([]Volume, error)

Snapshots returns a list of snapshots for the volume.

func (Volume) Type Uses

func (v Volume) Type() VolumeType

Type returns the volume type.

func (Volume) UnmountTask Uses

func (v Volume) UnmountTask(task func(op *operations.Operation) error, op *operations.Operation) error

UnmountTask runs the supplied task after unmounting the volume if needed. If the volume was unmounted for this then it is mounted when the task finishes.

type VolumeFiller Uses

type VolumeFiller struct {
    Fill func(mountPath, rootBlockPath string) error // Function to fill the volume.

    Fingerprint string // If the Filler will unpack an image, it should be this fingerprint.
}

VolumeFiller provides a struct for filling a volume.

type VolumeType Uses

type VolumeType string

VolumeType represents a storage volume type.

Package drivers imports 39 packages (graph) and is imported by 8 packages. Updated 2020-04-01. Refresh now. Tools for package owners.