zfs

package
v0.0.0-...-a6598b8 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const VolBlockSizeBytes = uint64(16 * 1024)

VolBlockSizeBytes is the default dataset block size in bytes

Variables

This section is empty.

Functions

func AddVDev

func AddVDev(log *base.LogObject, pool, vdev string) (string, error)

AddVDev add newVdev to pool

func AttachVDev

func AttachVDev(log *base.LogObject, pool, vdev, newVdev string) (string, error)

AttachVDev attach newVdev to existing vdev

func CreateDataset

func CreateDataset(datasetName string) error

CreateDataset create and mount an empty dataset

func CreateDatasets

func CreateDatasets(log *base.LogObject, datasetName string) error

CreateDatasets - creates all the non-existing parent datasets. Datasets created in this manner are automatically mounted according to the mountpoint property inherited from their parent. Analogue of the "zfs create -p ..." command

func CreateSnapshot

func CreateSnapshot(datasetName string) (snapshotName string, err error)

CreateSnapshot creates a snapshot of the dataset Returns the name of the created snapshot that can be used to rollback

func CreateVaultDataset

func CreateVaultDataset(datasetName, zfsKeyFile string) error

CreateVaultDataset create and mount an empty vault dataset

func CreateVaultVolumeDataset

func CreateVaultVolumeDataset(log *base.LogObject, datasetName string, zfsKeyFile string, encrypted bool, sizeBytes uint64, compressionType string, blockSizeBytes uint64) error

CreateVaultVolumeDataset Create an empty vault zvol

func CreateVolumeDataset

func CreateVolumeDataset(log *base.LogObject, datasetName string, sizeBytes uint64, compression string, blockSizeBytes uint64) error

CreateVolumeDataset creates dataset of zvol type in zfs

func DatasetExist

func DatasetExist(log *base.LogObject, datasetPath string) bool

DatasetExist return true if dataset exists or false when it does not exist

func DestroyDataset

func DestroyDataset(datasetName string) error

DestroyDataset removes dataset from zfs it runs 3 times in case of errors (we can hit dataset is busy)

func GetDatasetAvailableBytes

func GetDatasetAvailableBytes(datasetName string) (uint64, error)

GetDatasetAvailableBytes Read Zfs dataset 'available' space property, parse as uint64

func GetDatasetByDevice

func GetDatasetByDevice(device string) string

GetDatasetByDevice returns dataset for provided device path

func GetDatasetKeyStatus

func GetDatasetKeyStatus(datasetName string) (string, error)

GetDatasetKeyStatus returns status of dataset key or error

func GetDatasetUsageStat

func GetDatasetUsageStat(datasetName string) (*types.UsageStat, error)

GetDatasetUsageStat returns UsageStat for provided datasetName for dataset with RefReservation it will return dataset.RefReservation as UsageStat.Total and UsageStat.Used for dataset without RefReservation it will calculate UsageStat.Total as sum of dataset.Used and dataset.Available and use dataset.LogicalUsed as UsageStat.Used to not count empty blocks of child zvols

func GetRaidTypeFromStr

func GetRaidTypeFromStr(raidName string) types.StorageRaidType

GetRaidTypeFromStr takes a RAID name as input and returns current RAID type

func GetVDevAuxMsgStr

func GetVDevAuxMsgStr(state types.VDevAux) string

GetVDevAuxMsgStr returns a verbose VDev aux message The state messages were taken as a basis from zfs/include/sys/fs/zfs.h

func GetVolumesFromDataset

func GetVolumesFromDataset(datasetName string) ([]string, error)

GetVolumesFromDataset obtains volumes list from dataset

func GetZFSVolumeInfo

func GetZFSVolumeInfo(device string) (*types.ImgInfo, error)

GetZFSVolumeInfo provides information for zfs device

func GetZVolDeviceByDataset

func GetZVolDeviceByDataset(dataset string) string

GetZVolDeviceByDataset return path to device for provided dataset

func GetZVolSectorSize

func GetZVolSectorSize(zVolName string) (uint64, error)

GetZVolSectorSize return hw_sector_size for zvol

func GetZfsCompressratio

func GetZfsCompressratio(zpoolName string) (float64, error)

GetZfsCompressratio takes a zpool name as input and returns compressratio property for zpool

func GetZfsCountVolume

func GetZfsCountVolume(datasetName string) (uint32, error)

GetZfsCountVolume takes a datasetName name as input and returns the number of zvols. Returns 0 if there are no zvols or an have error.

func GetZfsDeviceStatusFromStr

func GetZfsDeviceStatusFromStr(statusStr string) types.StorageStatus

GetZfsDeviceStatusFromStr takes a string with status as input and returns status

func GetZfsDiskAndStatus

func GetZfsDiskAndStatus(disk libzfs.VDevTree) (*types.StorageDiskState, error)

GetZfsDiskAndStatus takes a libzfs.VDevTree as input and returns *info.StorageDiskState.

func GetZfsVDevMetrics

func GetZfsVDevMetrics(zStat libzfs.VDevStat, diskName string,
	fromZfs bool) *types.ZFSVDevMetrics

GetZfsVDevMetrics read libzfs.VDevStat or /proc/diskstats and return metrics (*types.DiskMetrics) for only one device in zfs pool.

func GetZfsVersion

func GetZfsVersion() (string, error)

GetZfsVersion return zfs kernel module version

func GetZpoolMetrics

func GetZpoolMetrics(vdev libzfs.VDevTree) *types.ZFSPoolMetrics

GetZpoolMetrics returns metrics for provided zpool

func GetZpoolRaidType

func GetZpoolRaidType(vdevs libzfs.VDevTree) types.StorageRaidType

GetZpoolRaidType takes a libzfs.VDevTree as input and returns current RAID type. return RAID0 in case of mixed topology as we can mix nested topology into the stripe

func GetZpoolStatusMsgStr

func GetZpoolStatusMsgStr(status types.PoolStatus) string

GetZpoolStatusMsgStr returns a verbose zpool status message The state messages were taken as a basis from the zfs/cmd/zpool/zpool_main.c file

func GetZvolMetrics

func GetZvolMetrics(status types.VolumeStatus, poolName string) (*types.StorageZVolMetrics, error)

GetZvolMetrics returns metrics for a zvol.

func GetZvolPath

func GetZvolPath(datasetName string) string

GetZvolPath Helper to build the /dev/zvol/<dataset> path

func IsDatasetTypeZvol

func IsDatasetTypeZvol(datasetName string) (bool, error)

IsDatasetTypeZvol returns true if dataset is a zvol

func MountDataset

func MountDataset(datasetName string) error

MountDataset mounts dataset

func RemoveVDev

func RemoveVDev(log *base.LogObject, pool, vdev string) (string, error)

RemoveVDev removes vdev from the pool

func ReplaceVDev

func ReplaceVDev(log *base.LogObject, pool, oldVdev, newVdev string) (string, error)

ReplaceVDev replaces vdev from the pool

func RollbackToSnapshot

func RollbackToSnapshot(datasetName, snapshotName string) error

RollbackToSnapshot rolls back the dataset to the snapshot

func SetReserved

func SetReserved(datasetName string, percentage uint64) error

SetReserved sets the reserved percentage. The datasetName is the parent (e.g., "persist").

func UnmountDataset

func UnmountDataset(datasetName string) error

UnmountDataset unmount this filesystem and any children inheriting the mountpoint property.

Types

This section is empty.

Jump to

Keyboard shortcuts

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