zfs

package
v3.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2022 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package zfs provides an interface to work with ZFS.

Index

Constants

View Source
const (

	// PoolMode defines the zfs filesystem name.
	PoolMode = "zfs"
)

Variables

This section is empty.

Functions

func PoolMappings

func PoolMappings(runner runners.Runner, mountDir, preSnapshotSuffix string) (map[string]string, error)

PoolMappings provides a mapping of pool name and mount point directory.

func RollbackSnapshot

func RollbackSnapshot(r runners.Runner, pool string, snapshot string) error

RollbackSnapshot rollbacks ZFS snapshot.

Types

type Config

type Config struct {
	Pool              *resources.Pool
	PreSnapshotSuffix string
	OSUsername        string
}

Config defines configuration for ZFS filesystem manager.

type EmptyPoolError

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

EmptyPoolError defines an error when storage pool has no available elements.

func NewEmptyPoolError

func NewEmptyPoolError(dsType dsType, pool string) *EmptyPoolError

NewEmptyPoolError creates a new EmptyPoolError.

func (*EmptyPoolError) Error

func (e *EmptyPoolError) Error() string

Error prints a message describing EmptyPoolError.

type ListEntry

type ListEntry struct {
	Name string

	// Read-only property that identifies the amount of disk space consumed
	// by a dataset and all its descendents.
	Used uint64

	// Controls the mount point used for this file system. When the mountpoint
	// property is changed for a file system, the file system and
	// any descendents that inherit the mount point are unmounted.
	// If the new value is legacy, then they remain unmounted. Otherwise,
	// they are automatically remounted in a new location if the property
	// was previously legacy or none, or if they were mounted before
	// the property was changed. In addition, any shared file systems are
	// unshared and shared in the new location.
	MountPoint string

	// Read-only property that identifies the compression ratio achieved for
	// a dataset, expressed as a multiplier. Compression can be enabled by the
	// zfs set compression=on dataset command.
	// The value is calculated from the logical size of all files and
	// the amount of referenced physical data. It includes explicit savings
	// through the use of the compression property.
	CompressRatio float64

	// Read-only property that identifies the amount of disk space available
	// to a file system and all its children, assuming no other activity in
	// the pool. Because disk space is shared within a pool, available space
	// can be limited by various factors including physical pool size, quotas,
	// reservations, and other datasets within the pool.
	Available uint64

	// Read-only property that identifies the dataset type as filesystem
	// (file system or clone), volume, or snapshot.
	Type string

	// Read-only property for cloned file systems or volumes that identifies
	// the snapshot from which the clone was created. The origin cannot be
	// destroyed (even with the –r or –f option) as long as a clone exists.
	// Non-cloned file systems have an origin of none.
	Origin string

	// Read-only property that identifies the date and time that a dataset
	// was created.
	Creation time.Time

	// The amount of data that is accessible by this dataset, which may
	// or may not be shared with other datasets in the pool. When a snapshot
	// or clone is created, it initially references the same amount of space
	// as the  file system or snapshot it was created from, since its contents
	// are identical.
	Referenced uint64

	// The amount of space that is "logically" accessible by this dataset.
	// See the referenced property. The logical space ignores the effect
	// of the compression and copies properties, giving a quantity closer
	// to the amount of data that applications see. However, it does include
	// space consumed by metadata.
	LogicalReferenced uint64

	// The amount of space that is "logically" consumed by this dataset
	// and all its descendents. See the used property. The logical space
	// ignores the effect of the compression and copies properties, giving
	// a quantity closer to the amount of data that applications see. However,
	// it does include space consumed by metadata.
	LogicalUsed uint64

	// The amount of space consumed by snapshots of this dataset.
	// In particular, it is the amount of space that would be freed
	// if all of this dataset's snapshots were destroyed.
	// Note that this is not simply the sum of the snapshots' used properties
	// because space can be shared by multiple snapshots.
	UsedBySnapshots uint64

	// The amount of space used by children of this dataset,
	// which would be freed if all the dataset's children were destroyed.
	UsedByChildren uint64

	// Data state timestamp.
	DataStateAt time.Time
}

ListEntry defines entry of ZFS list command.

type Manager

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

Manager describes a filesystem manager for ZFS.

func NewFSManager

func NewFSManager(runner runners.Runner, config Config) *Manager

NewFSManager creates a new Manager instance for ZFS.

func (*Manager) CleanupSnapshots

func (m *Manager) CleanupSnapshots(retentionLimit int) ([]string, error)

CleanupSnapshots destroys old snapshots considering retention limit and related clones.

func (*Manager) CreateClone

func (m *Manager) CreateClone(cloneName, snapshotID string) error

CreateClone creates a new ZFS clone.

func (*Manager) CreateSnapshot

func (m *Manager) CreateSnapshot(poolSuffix, dataStateAt string) (string, error)

CreateSnapshot creates a new snapshot.

func (*Manager) DestroyClone

func (m *Manager) DestroyClone(cloneName string) error

DestroyClone destroys a ZFS clone.

func (*Manager) DestroySnapshot

func (m *Manager) DestroySnapshot(snapshotName string) error

DestroySnapshot destroys the snapshot.

func (*Manager) GetFilesystemState

func (m *Manager) GetFilesystemState() (models.FileSystem, error)

GetFilesystemState returns a disk state.

func (*Manager) GetSessionState

func (m *Manager) GetSessionState(name string) (*resources.SessionState, error)

GetSessionState returns a state of a session.

func (*Manager) GetSnapshots

func (m *Manager) GetSnapshots() ([]resources.Snapshot, error)

GetSnapshots returns a snapshot list.

func (*Manager) ListClonesNames

func (m *Manager) ListClonesNames() ([]string, error)

ListClonesNames lists ZFS clones.

func (*Manager) Pool

func (m *Manager) Pool() *resources.Pool

Pool gets a storage pool.

Jump to

Keyboard shortcuts

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