zfs

package
v3.0.0-rc67 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 22 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// DatasetTypeFilesystem - file system dataset
	DatasetTypeFilesystem DatasetType = (1 << 0)
	// DatasetTypeSnapshot - snapshot of dataset
	DatasetTypeSnapshot = (1 << 1)
	// DatasetTypeVolume - volume (virtual block device) dataset
	DatasetTypeVolume = (1 << 2)
	// DatasetTypePool - pool dataset
	DatasetTypePool = (1 << 3)
	// DatasetTypeBookmark - bookmark dataset
	DatasetTypeBookmark = (1 << 4)
)
View Source
const MoveSnapshotPrefix = "osvc_move_"

MoveSnapshotPrefix begins the name of the snapshots a move sends. The snapshots of other names, those of a sync.zfs among them, are serving an increment as a base, and are never destroyed by a move.

Variables

This section is empty.

Functions

func FilesystemCreateWithArgs

func FilesystemCreateWithArgs(l []string) funcopt.O

FilesystemCreateWithArgs defines the shlex split list of arguments to prepend to the command.

func FilesystemCreateWithNode

func FilesystemCreateWithNode(s string) funcopt.O

func FilesystemCreateWithQuota

func FilesystemCreateWithQuota(size *int64) funcopt.O

FilesystemCreateWithQuota Limits the amount of space a dataset and its descendents can consume. This property enforces a hard limit on the amount of space used. This includes all space consumed by descendents, including file systems and snapshots. Setting a quota on a descendent of a dataset that already has a quota does not override the ancestor's quota, but rather imposes an additional limit.

func FilesystemCreateWithRefQuota

func FilesystemCreateWithRefQuota(size *int64) funcopt.O

FilesystemCreateWithRefQuota Limits the amount of space a dataset can consume. This property enforces a hard limit on the amount of space used. This hard limit does not include space used by descendents, including file systems and snapshots.

func FilesystemCreateWithRefReservation

func FilesystemCreateWithRefReservation(size *int64) funcopt.O

FilesystemCreateWithRefReservation is the minimum amount of space guaranteed to a dataset, not including its descendents. When the amount of space used is below this value, the dataset is treated as if it were taking up the amount of space specified by refreservation. The refreservation reservation is accounted for in the parent datasets' space used, and counts against the parent datasets' quotas and reservations.

If refreservation is set, a snapshot is only allowed if there is enough free pool space outside of this reservation to accommodate the current number of "referenced" bytes in the dataset.

func FilesystemCreateWithReservation

func FilesystemCreateWithReservation(size *int64) funcopt.O

FilesystemCreateWithReservation is the minimum amount of space guaranteed to a dataset and its descendents. When the amount of space used is below this value, the dataset is treated as if it were taking up the amount of space specified by its reservation. Reservations are accounted for in the parent datasets' space used, and count against the parent datasets' quotas and reservations.

func FilesystemDestroyWithNode

func FilesystemDestroyWithNode(s string) funcopt.O

func FilesystemDestroyWithRecurse

func FilesystemDestroyWithRecurse(v bool) funcopt.O

FilesystemDestroyWithRecurse recursively destroys all clones of these snapshots, including the clones, snapshots, and children. If this flag is specified, the FilesystemDestroyWithTryImmediate flag will have no effect.

func FilesystemDestroyWithRemoveSnapshots

func FilesystemDestroyWithRemoveSnapshots(v bool) funcopt.O

FilesystemDestroyWithRemoveSnapshots, destroying a snapshot, destroys the snapshots of the same name in the descendant datasets too (zfs destroy -r).

func FilesystemDestroyWithTryImmediate

func FilesystemDestroyWithTryImmediate(v bool) funcopt.O

FilesystemDestroyWithTryImmediate destroys immediately. If a snapshot cannot be destroyed now, mark it for deferred destruction.

func FilesystemMountWithOverlay

func FilesystemMountWithOverlay(v bool) funcopt.O

FilesystemMountWithOverlay performs an overlay mount. Allows mounting in non-empty mountpoint.

func FilesystemRenameWithNode

func FilesystemRenameWithNode(s string) funcopt.O

func FilesystemRenameWithRecurse

func FilesystemRenameWithRecurse(v bool) funcopt.O

FilesystemRenameWithRecurse recursively renames all datasets

func FilesystemSnapshotWithArgs

func FilesystemSnapshotWithArgs(l []string) funcopt.O

FilesystemSnapshotWithArgs defines the shlex split list of arguments to prepend to the command.

func FilesystemSnapshotWithRecursive

func FilesystemSnapshotWithRecursive(v bool) funcopt.O

func FilesystemUmountWithForce

func FilesystemUmountWithForce(v bool) funcopt.O

FilesystemUmountWithForce forcefully unmounts the file system, even if it is currently in use. This option is not supported on Linux.

func IsCapable

func IsCapable() bool

func ListWithLogger

func ListWithLogger(l *plog.Logger) funcopt.O

func ListWithNames

func ListWithNames(l ...string) funcopt.O

func ListWithOrderBy

func ListWithOrderBy(l ...string) funcopt.O

func ListWithOrderReverse

func ListWithOrderReverse() funcopt.O

func ListWithTypes

func ListWithTypes(l ...DatasetType) funcopt.O

func PoolCreateWithArgs

func PoolCreateWithArgs(l []string) funcopt.O

PoolCreateWithArgs defines the shlex split list of arguments to prepend to the command.

func PoolCreateWithVDevs

func PoolCreateWithVDevs(l []string) funcopt.O

PoolCreateWithVDevs defines the list of block devices paths to add to the pool.

func PoolDestroyWithForce

func PoolDestroyWithForce() funcopt.O

PoolDestroyWithForce forces any active datasets contained within the pool to be unmounted.

func PoolExportWithForce

func PoolExportWithForce() funcopt.O

PoolExportWithForce forcefully unmounts all datasets, using the unmount -f command. This option is not supported on Linux.

func PoolImportWithCacheFile

func PoolImportWithCacheFile(s string) funcopt.O

PoolImportWithCacheFile reads configuration from the given cachefile that was created with the cachefile pool property. This cachefile is used instead of searching for devices.

func PoolImportWithDevice

func PoolImportWithDevice(s string) funcopt.O

PoolImportWithDevice uses device or searches for devices or files in dir. PoolImportWithDevice can be specified multiple times. PoolImportWithDevice incompatible with PoolImportWithCacheFile.

func PoolImportWithForce

func PoolImportWithForce() funcopt.O

PoolImportWithForce forcefully unmounts all datasets, using the unmount -f command. This option is not supported on Linux.

func PoolImportWithOption

func PoolImportWithOption(option, value string) funcopt.O

PoolImportWithOption is a mount option to use when mounting datasets within the pool.

func PoolImportWithQuiet

func PoolImportWithQuiet() funcopt.O

PoolImportWithQuiet sets debug level for error and output logging

func PoolStatusWithVerbose

func PoolStatusWithVerbose() funcopt.O

PoolStatusWithVerbose displays verbose data error information, printing out a complete list of all data errors since the last complete pool scrub.

func VolCreateWithArgs

func VolCreateWithArgs(l []string) funcopt.O

VolCreateWithArgs defines the shlex split list of arguments to prepend to the command.

func VolCreateWithBlockSize

func VolCreateWithBlockSize(size uint64) funcopt.O

VolCreateWithBlockSize defines the block size of the volume in bytes

func VolCreateWithSize

func VolCreateWithSize(size uint64) funcopt.O

VolCreateWithSize defines the size of the volume in bytes

func VolDestroyWithBusyRetries

func VolDestroyWithBusyRetries(count int) funcopt.O

VolDestroyWithBusyRetries is the number of retries when the destroy command reports "busy".

func VolDestroyWithForce

func VolDestroyWithForce() funcopt.O

VolDestroyWithForce forces an unmount of any file systems using the unmount -f command. This option has no effect on non-file systems or unmounted file systems.

func VolDestroyWithRecursive

func VolDestroyWithRecursive() funcopt.O

VolDestroyWithRecursive destroys the snapshots of the volume too, which zfs refuses to destroy it from under. The clones of one still refuse it, those being other volumes.

Types

type Dataset

type Dataset interface {
	GetName() string
	GetLog() *plog.Logger
}

type DatasetName

type DatasetName string

func (DatasetName) BaseName

func (t DatasetName) BaseName() string

BaseName returns the basename extracted from a <pool>/<basename> string.

func (DatasetName) PoolName

func (t DatasetName) PoolName() string

PoolName returns the pool name extracted from a <pool>/<basename> string.

func (DatasetName) String

func (t DatasetName) String() string

String implements the stringer interface.

type DatasetType

type DatasetType int32

func (DatasetType) String

func (t DatasetType) String() string

type DatasetTypes

type DatasetTypes []DatasetType

func (DatasetTypes) String

func (t DatasetTypes) String() string

type Filesystem

type Filesystem struct {
	Name string
	Log  *plog.Logger

	SSHKeyFile string
}

func (Filesystem) BaseName

func (t Filesystem) BaseName() string

func (*Filesystem) Create

func (t *Filesystem) Create(fopts ...funcopt.O) error

func (*Filesystem) Destroy

func (t *Filesystem) Destroy(fopts ...funcopt.O) error

func (*Filesystem) Exists

func (t *Filesystem) Exists() (bool, error)

func (Filesystem) GetLog

func (t Filesystem) GetLog() *plog.Logger

func (Filesystem) GetName

func (t Filesystem) GetName() string

func (*Filesystem) GetProperty

func (t *Filesystem) GetProperty(prop string) (string, error)

GetProperty returns a dataset property value

func (*Filesystem) Mount

func (t *Filesystem) Mount(fopts ...funcopt.O) error

func (Filesystem) PoolName

func (t Filesystem) PoolName() string

func (*Filesystem) Rename

func (t *Filesystem) Rename(dst string, fopts ...funcopt.O) error

func (*Filesystem) SetProperty

func (t *Filesystem) SetProperty(prop, value string) error

SetProperty sets a dataset property value

func (*Filesystem) Snapshot

func (t *Filesystem) Snapshot(fopts ...funcopt.O) error

func (*Filesystem) SnapshotExists

func (t *Filesystem) SnapshotExists() (bool, error)

func (*Filesystem) Umount

func (t *Filesystem) Umount(fopts ...funcopt.O) error

type Filesystems

type Filesystems []Filesystem

func ListFilesystems

func ListFilesystems(fopts ...funcopt.O) (Filesystems, error)

type ListDatasetsOpts

type ListDatasetsOpts struct {
	Names        []string
	Types        DatasetTypes
	Log          *plog.Logger
	OrderBy      []string
	OrderReverse bool
}

type Mover

type Mover struct {
	// Name is the dataset to copy, the same on both nodes.
	Name string

	// Node is the node to copy it to, which Client is connected to.
	Node   string
	Client *ssh.Client

	Log *plog.Logger
	// contains filtered or unexported fields
}

Mover copies a dataset, a filesystem or a volume, to the node a container is moving to, so the files and devices the container opens exist there when its disks are mirrored to them.

The copy is a snapshot sent incrementally from the newest snapshot both nodes hold, the one a previous move or a sync.zfs left, and in full when there is none. The destination receives it unmounted.

func (*Mover) Prune

func (t *Mover) Prune(ctx context.Context, keep string) error

Prune destroys the move snapshots of the dataset older than keep, here and on the destination. The one kept is the base of the next move.

func (*Mover) Remote

func (t *Mover) Remote(ctx context.Context, cmdline string) error

Remote runs a command on the destination.

func (*Mover) Send

func (t *Mover) Send(ctx context.Context) (string, error)

Send snapshots the dataset and sends the snapshot to the destination, and returns the snapshot name.

A destination that holds the dataset with no snapshot in common is refused: receiving a full copy over it would destroy what it holds, which may be the only copy of something.

type Pool

type Pool struct {
	Name      string
	Log       *plog.Logger
	LogPrefix string
}

func (*Pool) Create

func (t *Pool) Create(fopts ...funcopt.O) error

func (*Pool) Destroy

func (t *Pool) Destroy(fopts ...funcopt.O) error

func (*Pool) Exists

func (t *Pool) Exists(ctx context.Context) (bool, error)

func (*Pool) ExpandDevice

func (t *Pool) ExpandDevice(ctx context.Context, devpath string) error

ExpandDevice makes the pool take the space a device of it has gained.

A pool is not given a size: it is what its vdevs hold, less what zfs keeps for its labels and its reserve. So growing one is telling it to look at a device again, the way a filesystem is told to take up the device under it.

func (*Pool) Export

func (t *Pool) Export(fopts ...funcopt.O) error

func (*Pool) GetProperty

func (t *Pool) GetProperty(prop string) (string, error)

GetProperty returns a dataset property value

func (*Pool) Import

func (t *Pool) Import(fopts ...funcopt.O) error

func (*Pool) ListVolumes

func (t *Pool) ListVolumes(ctx context.Context, fopts ...funcopt.O) (Vols, error)

func (*Pool) SetProperty

func (t *Pool) SetProperty(prop, value string) error

func (*Pool) Status

func (t *Pool) Status(ctx context.Context, fopts ...funcopt.O) (PoolStatusData, error)

func (*Pool) Usage

func (t *Pool) Usage(ctx context.Context, fopts ...funcopt.O) (PoolUsage, error)

Usage returns the size of the pool, and what is used and free of it as its datasets see it, which is the question its callers ask: can a volume of a size be created there.

What zpool get tells of them is another thing, the blocks written. A zvol reserves its whole size when created, and that reservation is no block of the pool until it is written: zpool says free the space no zfs create can have. The used of the root dataset counts the reservations, and available is what is left of them. Their sum is the size less what zfs keeps for itself, which is why Size stays what zpool says: a resize compares it to a device.

func (*Pool) VDevDevices

func (t *Pool) VDevDevices(ctx context.Context) (device.L, error)

func (*Pool) VDevPaths

func (t *Pool) VDevPaths(ctx context.Context) ([]string, error)

type PoolStatusData

type PoolStatusData struct {
	State  string
	Errors string
	VDevs  poolStatusVDevs
}

type PoolUsage

type PoolUsage struct {
	Size  int64
	Alloc int64
	Free  int64
}

PoolUsage is the space of a pool, as what is stored in it is told.

func (PoolUsage) Usable

func (t PoolUsage) Usable() int64

Usable is what the datasets of the pool can hold, the size less what zfs keeps for itself: what the used and free of the pool are parts of.

type Vol

type Vol struct {
	Name      string
	Size      uint64
	BlockSize uint64
	Log       *plog.Logger
}

func (Vol) BaseName

func (t Vol) BaseName() string

func (*Vol) Create

func (t *Vol) Create(fopts ...funcopt.O) error

func (*Vol) Destroy

func (t *Vol) Destroy(fopts ...funcopt.O) error

Destroy destroys the volume, a volume already gone being destroyed.

A volume just released, as the zvol under a drbd device brought down, is reported busy by zfs for a moment: the destroy is tried again a second later, as many times as VolDestroyWithBusyRetries says. A destroy that fails is an error, the busy one once the retries are spent: the caller would otherwise report the volume unprovisioned and leave it behind.

func (*Vol) Exists

func (t *Vol) Exists() (bool, error)

func (Vol) GetLog

func (t Vol) GetLog() *plog.Logger

func (Vol) GetName

func (t Vol) GetName() string

func (*Vol) GetProperty

func (t *Vol) GetProperty(prop string) (string, error)

GetProperty returns a dataset property value

func (Vol) PoolName

func (t Vol) PoolName() string

func (*Vol) SetProperty

func (t *Vol) SetProperty(prop, value string) error

SetProperty sets a dataset property value

type Vols

type Vols []Vol

func ListVolumes

func ListVolumes(fopts ...funcopt.O) (Vols, error)

func (Vols) Paths

func (t Vols) Paths() []string

Jump to

Keyboard shortcuts

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