zfs

package
v0.0.0-...-1987824 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DatasetTypeUnknown DatasetType = 0
	// DatasetTypeFilesystem - file system dataset
	DatasetTypeFilesystem = 1 << (iota - 1)
	// DatasetTypeSnapshot - snapshot of dataset
	DatasetTypeSnapshot
	// DatasetTypeVolume - volume (virtual block device) dataset
	DatasetTypeVolume
	// DatasetTypePool - pool dataset
	DatasetTypePool
	// DatasetTypeBookmark - bookmark dataset
	DatasetTypeBookmark
)
View Source
const (
	ESuccess              = 0               /* no error -- success */
	ENomem                = 2000 + iota - 1 /* out of memory */
	EBadprop                                /* invalid property value */
	EPropreadonly                           /* cannot set readonly property */
	EProptype                               /* property does not apply to dataset type */
	EPropnoninherit                         /* property is not inheritable */
	EPropspace                              /* bad quota or reservation */
	EBadtype                                /* dataset is not of appropriate type */
	EBusy                                   /* pool or dataset is busy */
	EExists                                 /* pool or dataset already exists */
	ENoent                                  /* no such pool or dataset */
	EBadstream                              /* bad backup stream */
	EDsreadonly                             /* dataset is readonly */
	EVoltoobig                              /* volume is too large for 32-bit system */
	EInvalidname                            /* invalid dataset name */
	EBadrestore                             /* unable to restore to destination */
	EBadbackup                              /* backup failed */
	EBadtarget                              /* bad attach/detach/replace target */
	ENodevice                               /* no such device in pool */
	EBaddev                                 /* invalid device to add */
	ENoreplicas                             /* no valid replicas */
	EResilvering                            /* currently resilvering */
	EBadversion                             /* unsupported version */
	EPoolunavail                            /* pool is currently unavailable */
	EDevoverflow                            /* too many devices in one vdev */
	EBadpath                                /* must be an absolute path */
	ECrosstarget                            /* rename or clone across pool or dataset */
	EZoned                                  /* used improperly in local zone */
	EMountfailed                            /* failed to mount dataset */
	EUmountfailed                           /* failed to unmount dataset */
	EUnsharenfsfailed                       /* unshare(1M) failed */
	ESharenfsfailed                         /* share(1M) failed */
	EPerm                                   /* permission denied */
	ENospc                                  /* out of space */
	EFault                                  /* bad address */
	EIo                                     /* I/O error */
	EIntr                                   /* signal received */
	EIsspare                                /* device is a hot spare */
	EInvalconfig                            /* invalid vdev configuration */
	ERecursive                              /* recursive dependency */
	ENohistory                              /* no history object */
	EPoolprops                              /* couldn't retrieve pool props */
	EPoolNotsup                             /* ops not supported for this type of pool */
	EPoolInvalarg                           /* invalid argument for this pool operation */
	ENametoolong                            /* dataset name is too long */
	EOpenfailed                             /* open of device failed */
	ENocap                                  /* couldn't get capacity */
	ELabelfailed                            /* write of label failed */
	EBadwho                                 /* invalid permission who */
	EBadperm                                /* invalid permission */
	EBadpermset                             /* invalid permission set name */
	ENodelegation                           /* delegated administration is disabled */
	EUnsharesmbfailed                       /* failed to unshare over smb */
	ESharesmbfailed                         /* failed to share over smb */
	EBadcache                               /* bad cache file */
	EIsl2CACHE                              /* device is for the level 2 ARC */
	EVdevnotsup                             /* unsupported vdev type */
	ENotsup                                 /* ops not supported on this dataset */
	EActiveSpare                            /* pool has active shared spare devices */
	EUnplayedLogs                           /* log device has unplayed logs */
	EReftagRele                             /* snapshot release: tag not found */
	EReftagHold                             /* snapshot hold: tag already exists */
	ETagtoolong                             /* snapshot hold/rele: tag too long */
	EPipefailed                             /* pipe create failed */
	EThreadcreatefailed                     /* thread create failed */
	EPostsplitOnline                        /* onlining a disk after splitting it */
	EScrubbing                              /* currently scrubbing */
	ENoScrub                                /* no active scrub */
	EDiff                                   /* general failure of zfs diff */
	EDiffdata                               /* bad zfs diff data */
	EPoolreadonly                           /* pool is in read-only mode */
	EScrubpaused                            /* scrub currently paused */
	EActivepool                             /* pool is imported on a different system */
	ECryptofailed                           /* failed to setup encryption */
	ENopending                              /* cannot cancel, no operation is pending */
	ECheckpointExists                       /* checkpoint exists */
	EDiscardingCheckpoint                   /* currently discarding a checkpoint */
	ENoCheckpoint                           /* pool has no checkpoint */
	EDevrmInProgress                        /* a device is currently being removed */
	EVdevTooBig                             /* a device is too big to be used */
	EIocNotsupported                        /* operation not supported by zfs module */
	EToomany                                /* argument list too long */
	EInitializing                           /* currently initializing */
	ENoInitialize                           /* no active initialize */
	EWrongParent                            /* invalid parent dataset (e.g ZVOL) */
	ETrimming                               /* currently trimming */
	ENoTrim                                 /* no active trim */
	ETrimNotsup                             /* device does not support trim */
	ENoResilverDefer                        /* pool doesn't support resilver_defer */
	EExportInProgress                       /* currently exporting the pool */
	EUnknown
)

ZFS errors

View Source
const (
	PoolConfigVersion          = "version"
	PoolConfigPoolName         = "name"
	PoolConfigPoolState        = "state"
	PoolConfigPoolTXG          = "txg"
	PoolConfigPoolGUID         = "pool_guid"
	PoolConfigCreateTXG        = "create_txg"
	PoolConfigTopGUID          = "top_guid"
	PoolConfigVdevTree         = "vdev_tree"
	PoolConfigType             = "type"
	PoolConfigChildren         = "children"
	PoolConfigID               = "id"
	PoolConfigGUID             = "guid"
	PoolConfigIndirectObject   = "com.delphix:indirect_object"
	PoolConfigIndirectBirths   = "com.delphix:indirect_births"
	PoolConfigPrevIndirectVdev = "com.delphix:prev_indirect_vdev"
	PoolConfigPath             = "path"
	PoolConfigDevId            = "devid"
	PoolConfigMetaslabArray    = "metaslab_array"
	PoolConfigMetaslabShift    = "metaslab_shift"
	PoolConfigAShift           = "ashift"
	PoolConfigASize            = "asize"
	PoolConfigDtl              = "dtl"
	PoolConfigScanStats        = "scan_stats"       /* not stored on disk */
	PoolConfigRemovalStats     = "removal_stats"    /* not stored on disk */
	PoolConfigCheckpointStats  = "checkpoint_stats" /* not on disk */
	PoolConfigVdevStats        = "vdev_stats"       /* not stored on disk */
	PoolConfigIndirectSize     = "indirect_size"    /* not stored on disk */

	/* container nvlist of extended stats */
	PoolConfigVdevStatsEx = "vdev_stats_ex"

	/* active queue read/write stats */
	PoolConfigVdevSyncRActiveQueue  = "vdev_sync_r_active_queue"
	PoolConfigVdevSyncWActiveQueue  = "vdev_sync_w_active_queue"
	PoolConfigVdevAsyncRActiveQueue = "vdev_async_r_active_queue"
	PoolConfigVdevAsyncWActiveQueue = "vdev_async_w_active_queue"
	PoolConfigVdevScrubActiveQueue  = "vdev_async_scrub_active_queue"
	PoolConfigVdevTrimActiveQueue   = "vdev_async_trim_active_queue"

	/* queue sizes */
	PoolConfigVdevSyncRPendQueue  = "vdev_sync_r_pend_queue"
	PoolConfigVdevSyncWPendQueue  = "vdev_sync_w_pend_queue"
	PoolConfigVdevAsyncRPendQueue = "vdev_async_r_pend_queue"
	PoolConfigVdevAsyncWPendQueue = "vdev_async_w_pend_queue"
	PoolConfigVdevScrubPendQueue  = "vdev_async_scrub_pend_queue"
	PoolConfigVdevTrimPendQueue   = "vdev_async_trim_pend_queue"

	/* latency read/write histogram stats */
	PoolConfigVdevTotRLatHisto   = "vdev_tot_r_lat_histo"
	PoolConfigVdevTotWLatHisto   = "vdev_tot_w_lat_histo"
	PoolConfigVdevDiskRLatHisto  = "vdev_disk_r_lat_histo"
	PoolConfigVdevDiskWLatHisto  = "vdev_disk_w_lat_histo"
	PoolConfigVdevSyncRLatHisto  = "vdev_sync_r_lat_histo"
	PoolConfigVdevSyncWLatHisto  = "vdev_sync_w_lat_histo"
	PoolConfigVdevAsyncRLatHisto = "vdev_async_r_lat_histo"
	PoolConfigVdevAsyncWLatHisto = "vdev_async_w_lat_histo"
	PoolConfigVdevScrubLatHisto  = "vdev_scrub_histo"
	PoolConfigVdevTrimLatHisto   = "vdev_trim_histo"

	/* request size histograms */
	PoolConfigVdevSyncIndRHisto  = "vdev_sync_ind_r_histo"
	PoolConfigVdevSyncIndWHisto  = "vdev_sync_ind_w_histo"
	PoolConfigVdevAsyncIndRHisto = "vdev_async_ind_r_histo"
	PoolConfigVdevAsyncIndWHisto = "vdev_async_ind_w_histo"
	PoolConfigVdevIndScrubHisto  = "vdev_ind_scrub_histo"
	PoolConfigVdevIndTrimHisto   = "vdev_ind_trim_histo"
	PoolConfigVdevSyncAggRHisto  = "vdev_sync_agg_r_histo"
	PoolConfigVdevSyncAggWHisto  = "vdev_sync_agg_w_histo"
	PoolConfigVdevAsyncAggRHisto = "vdev_async_agg_r_histo"
	PoolConfigVdevAsyncAggWHisto = "vdev_async_agg_w_histo"
	PoolConfigVdevAggScrubHisto  = "vdev_agg_scrub_histo"
	PoolConfigVdevAggTrimHisto   = "vdev_agg_trim_histo"

	/* number of slow ios */
	PoolConfigVdevSlowIos = "vdev_slow_ios"

	PoolConfigVdevEncSysfsPath = "vdev_enc_sysfs_path"

	PoolConfigWholeDisk       = "whole_disk"
	PoolConfigErrcount        = "error_count"
	PoolConfigNotPresent      = "not_present"
	PoolConfigSpares          = "spares"
	PoolConfigIsSpare         = "is_spare"
	PoolConfigNparity         = "nparity"
	PoolConfigHostid          = "hostid"
	PoolConfigHostname        = "hostname"
	PoolConfigLoadedTime      = "initial_load_time"
	PoolConfigUnspare         = "unspare"
	PoolConfigPhysPath        = "phys_path"
	PoolConfigIsLog           = "is_log"
	PoolConfigL2cache         = "l2cache"
	PoolConfigHoleArray       = "hole_array"
	PoolConfigVdevChildren    = "vdev_children"
	PoolConfigIsHole          = "is_hole"
	PoolConfigDDTHistogram    = "ddt_histogram"
	PoolConfigDDTObjStats     = "ddt_object_stats"
	PoolConfigDDTStats        = "ddt_stats"
	PoolConfigSplit           = "splitcfg"
	PoolConfigOrigGUID        = "origGUI_d"
	PoolConfigSplitGUID       = "splitGUI_d"
	PoolConfigSplitList       = "guid_list"
	PoolConfigRemoving        = "removing"
	PoolConfigResilverTXG     = "resilver_txg"
	PoolConfigRebuildTXG      = "rebuild_txg"
	PoolConfigComment         = "comment"
	PoolConfigSuspended       = "suspended"        /* not stored on disk */
	PoolConfigSuspendedReason = "suspended_reason" /* not stored */
	PoolConfigTimestamp       = "timestamp"        /* not stored on disk */
	PoolConfigBootfs          = "bootfs"           /* not stored on disk */
	PoolConfigMissingDevices  = "missing_vdevs"    /* not stored on disk */
	PoolConfigLoadInfo        = "load_info"        /* not stored on disk */
	PoolConfigRewindInfo      = "rewind_info"      /* not stored on disk */
	PoolConfigUnsupFeat       = "unsup_feat"       /* not stored on disk */
	PoolConfigEnabledFeat     = "enabled_feat"     /* not stored on disk */
	PoolConfigCanRdonly       = "can_rdonly"       /* not stored on disk */
	PoolConfigFeaturesForRead = "features_for_read"
	PoolConfigFeatureStats    = "feature_stats" /* not stored on disk */
	PoolConfigErrata          = "errata"        /* not stored on disk */
	PoolConfigVdevTopZap      = "com.delphix:vdev_zap_top"
	PoolConfigVdevLeafZap     = "com.delphix:vdev_zap_leaf"
	PoolConfigHasPerVdevZaps  = "com.delphix:has_per_vdev_zaps"
	PoolConfigResilverDefer   = "com.datto:resilver_defer"
	PoolConfigCachefile       = "cachefile"      /* not stored on disk */
	PoolConfigMmpState        = "mmp_state"      /* not stored on disk */
	PoolConfigMmpTXG          = "mmp_txg"        /* not stored on disk */
	PoolConfigMmpSeq          = "mmp_seq"        /* not stored on disk */
	PoolConfigMmpHostname     = "mmp_hostname"   /* not stored on disk */
	PoolConfigMmpHostID       = "mmp_hostid"     /* not stored on disk */
	PoolConfigAllocationBias  = "alloc_bias"     /* not stored on disk */
	PoolConfigExpansionTime   = "expansion_time" /* not stored */
	PoolConfigRebuildStats    = "org.openzfs:rebuild_stats"

	/*
	 * the persistent vdev state is stored as separate values rather than a single
	 * 'vdevState' entry.  this is because a device can be in multiple states, such
	 * as offline and degraded.
	 */
	PoolConfigOffline  = "offline"
	PoolConfigFaulted  = "faulted"
	PoolConfigDegraded = "degraded"
	PoolConfigRemoved  = "removed"
	PoolConfigFru      = "fru"
	PoolConfigAuxState = "aux_state"
)

* Source: include/sys/fs/zfs.h * The following are configuration names used in the nvlist describing a pool's * configuration. New on-disk names should be prefixed with "<reversed-DN_s>:" * (e.g. "org.openzfs:") to avoid conflicting names being developed * independently.

View Source
const (
	VDevTypeRoot      VDevType = "root"      // Root device in ZFS pool
	VDevTypeMirror             = "mirror"    // Mirror device in ZFS pool
	VDevTypeReplacing          = "replacing" // Replacing
	VDevTypeRaidz              = "raidz"     // RAIDZ device
	VDevTypeDisk               = "disk"      // Device is disk
	VDevTypeFile               = "file"      // Device is file
	VDevTypeMissing            = "missing"   // Missing device
	VDevTypeHole               = "hole"      // Hole
	VDevTypeSpare              = "spare"     // Spare device
	VDevTypeLog                = "log"       // ZIL device
	VDevTypeL2cache            = "l2cache"   // Cache device (disk)
)

Types of Virtual Devices

View Source
const (
	FENABLED  = "enabled"
	FDISABLED = "disabled"
)

Enable or disable pool feature with this constants

View Source
const (
	ZIOTypeNull = iota
	ZIOTypeRead
	ZIOTypeWrite
	ZIOTypeFree
	ZIOTypeClaim
	ZIOTypeIOCtl
	ZIOTypes
)

* ZIO types. Needed to interpret vdev statistics below.

Variables

View Source
var (
	ErrNotFound    = errors.New("nvlist named value not found")
	ErrUnknownType = errors.New("nvpair type unknown")
)

Functions

This section is empty.

Types

type Dataset

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

Dataset - ZFS dataset object

func (*Dataset) Children

func (d *Dataset) Children(types DatasetType, depth int) ([]*Dataset, error)

func (*Dataset) Close

func (d *Dataset) Close()

func (*Dataset) Get

func (*Dataset) Gets

func (*Dataset) LibZFS

func (d *Dataset) LibZFS() *LibZFS

func (*Dataset) Name

func (d *Dataset) Name() string

func (*Dataset) Pool

func (d *Dataset) Pool() *Pool

func (*Dataset) Type

func (d *Dataset) Type() DatasetType

type DatasetProperty

type DatasetProperty int
const (
	DatasetPropCont DatasetProperty = iota - 2
	DatasetPropInval

	DatasetPropType
	DatasetPropCreation
	DatasetPropUsed
	DatasetPropAvailable
	DatasetPropReferenced
	DatasetPropCompressratio
	DatasetPropMounted
	DatasetPropOrigin
	DatasetPropQuota
	DatasetPropReservation
	DatasetPropVolsize
	DatasetPropVolblocksize
	DatasetPropRecordsize
	DatasetPropMountpoint
	DatasetPropSharenfs
	DatasetPropChecksum
	DatasetPropCompression
	DatasetPropAtime
	DatasetPropDevices
	DatasetPropExec
	DatasetPropSetuid
	DatasetPropReadonly
	DatasetPropZoned
	DatasetPropSnapdir
	DatasetPropAclmode
	DatasetPropAclinherit
	DatasetPropCreateTXG
	DatasetPropName /* not exposed to the user */
	DatasetPropCanMount
	DatasetPropiSCSIOptions /* not exposed to the user */
	DatasetPropXattr
	DatasetPropNumClones /* not exposed to the user */
	DatasetPropCopies
	DatasetPropVersion
	DatasetPropUtf8Only
	DatasetPropNormalize
	DatasetPropCase
	DatasetPropVScan
	DatasetPropNbmand
	DatasetPropShareSMB
	DatasetPropRefQuota
	DatasetPropRefReservation
	DatasetPropGUID
	DatasetPropPrimaryCache
	DatasetPropSecondaryCache
	DatasetPropUsedSnap
	DatasetPropUsedDS
	DatasetPropUsedChild
	DatasetPropUsedRefReservation
	DatasetPropUserAccounting /* not exposed to the user */
	DatasetPropStmfShareInfo  /* not exposed to the user */
	DatasetPropDeferDestroy
	DatasetPropUserRefs
	DatasetPropLogBias
	DatasetPropUnique /* not exposed to the user */
	DatasetPropObjSetID
	DatasetPropDedup
	DatasetPropMlsLabel
	DatasetPropSync
	DatasetPropDnodeSize
	DatasetPropRefRatio
	DatasetPropWritten
	DatasetPropClones
	DatasetPropLogicalUsed
	DatasetPropLogicalReferenced
	DatasetPropInconsistent /* not exposed to the user */
	DatasetPropVolMode
	DatasetPropFilesystemLimit
	DatasetPropSnapshotLimit
	DatasetPropFilesystemCount
	DatasetPropSnapshotCount
	DatasetPropSnapDev
	DatasetPropAclType
	DatasetPropSelinuxContext
	DatasetPropSelinuxFSContext
	DatasetPropSelinuxDefContext
	DatasetPropSelinuxRootContext
	DatasetPropRelAtime
	DatasetPropRedundantMetadata
	DatasetPropOverlay
	DatasetPropPrevSnap
	DatasetPropReceiveResumeToken
	DatasetPropEncryption
	DatasetPropKeyLocation
	DatasetPropKeyFormat
	DatasetPropPBKDF2Salt
	DatasetPropPBKDF2Iters
	DatasetPropEncryptionRoot
	DatasetPropKeyGUID
	DatasetPropKeyStatus
	DatasetPropRemapTXG /* obsolete - no longer used */
	DatasetPropSpecialSmallBlocks
	DatasetPropIvsetGUID /* not exposed to the user */
	DatasetPropRedacted
	DatasetPropRedactSnaps

	DatasetNumProps
)

* Dataset properties are identified by these constants and must be added to * the end of this list to ensure that external consumers are not affected * by the change. If you make any changes to this list, be sure to update * the property table in module/zcommon/zfs_prop.c.

func (DatasetProperty) String

func (dp DatasetProperty) String() string

func (DatasetProperty) Type

func (dp DatasetProperty) Type() PropertyType

type DatasetPropertyIndex

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

func (DatasetPropertyIndex) Name

func (d DatasetPropertyIndex) Name() string

func (DatasetPropertyIndex) Property

func (DatasetPropertyIndex) Source

func (DatasetPropertyIndex) Type

func (DatasetPropertyIndex) Value

func (d DatasetPropertyIndex) Value() uint64

type DatasetPropertyNumber

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

func (DatasetPropertyNumber) Property

func (DatasetPropertyNumber) Source

func (DatasetPropertyNumber) Type

func (DatasetPropertyNumber) Value

func (d DatasetPropertyNumber) Value() uint64

type DatasetPropertyString

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

func (DatasetPropertyString) Property

func (DatasetPropertyString) Source

func (DatasetPropertyString) Type

func (DatasetPropertyString) Value

func (d DatasetPropertyString) Value() string

type DatasetPropertyValue

type DatasetPropertyValue interface {
	Type() PropertyType
	Property() DatasetProperty
	Source() PropertySource
}

type DatasetType

type DatasetType int32

DatasetType defines enum of dataset types

func (DatasetType) String

func (t DatasetType) String() string

type Error

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

func (Error) Errno

func (e Error) Errno() int

func (Error) Error

func (e Error) Error() string

type ExportedPool

type ExportedPool struct {
	VDevs   VDevTree
	Name    string
	Comment string
	GUID    uint64
	State   PoolState
	Status  PoolStatus
}

ExportedPool is type representing ZFS pool available for import

type LibZFS

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

func New

func New() (*LibZFS, error)

func (*LibZFS) Close

func (l *LibZFS) Close()

func (*LibZFS) DatasetOpen

func (l *LibZFS) DatasetOpen(path string) (*Dataset, error)

DatasetOpen opens a single dataset

func (*LibZFS) DatasetOpenAll

func (l *LibZFS) DatasetOpenAll(types DatasetType, depth int) ([]*Dataset, error)

DatasetOpenAll recursive get handles to all available datasets on system (file-systems, volumes or snapshots).

func (*LibZFS) Errno

func (l *LibZFS) Errno() error

func (*LibZFS) PoolOpen

func (l *LibZFS) PoolOpen(path string) (*Pool, error)

PoolOpen opens a single dataset

func (*LibZFS) PoolOpenAll

func (l *LibZFS) PoolOpenAll() (Pools, error)

PoolOpenAll open all active ZFS pools on current system. Returns array of Pool handlers, each have to be closed after not needed anymore. Call Pool.Close() method.

type NVList

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

func NewNVList

func NewNVList(hdl *C.nvlist_t) NVList

func (*NVList) Exists

func (nvl *NVList) Exists(name string) bool

func (NVList) JSON

func (nvl NVList) JSON(fd uintptr) int

func (*NVList) Lookup

func (nvl *NVList) Lookup(name string) (NVPair, bool)

func (NVList) LookupBool

func (nvl NVList) LookupBool(name string) (bool, error)

func (NVList) LookupBoolArray

func (nvl NVList) LookupBoolArray(name string) ([]bool, error)

func (NVList) LookupByte

func (nvl NVList) LookupByte(name string) (byte, error)

func (NVList) LookupByteArray

func (nvl NVList) LookupByteArray(name string) ([]byte, error)

func (NVList) LookupInt16

func (nvl NVList) LookupInt16(name string) (int16, error)

func (NVList) LookupInt16Array

func (nvl NVList) LookupInt16Array(name string) ([]int16, error)

func (NVList) LookupInt32

func (nvl NVList) LookupInt32(name string) (int32, error)

func (NVList) LookupInt32Array

func (nvl NVList) LookupInt32Array(name string) ([]int32, error)

func (NVList) LookupInt64

func (nvl NVList) LookupInt64(name string) (int64, error)

func (NVList) LookupInt64Array

func (nvl NVList) LookupInt64Array(name string) ([]int64, error)

func (NVList) LookupInt8

func (nvl NVList) LookupInt8(name string) (int8, error)

func (NVList) LookupInt8Array

func (nvl NVList) LookupInt8Array(name string) ([]int8, error)

func (NVList) LookupNVList

func (nvl NVList) LookupNVList(name string) (NVList, error)

func (NVList) LookupNVListArray

func (nvl NVList) LookupNVListArray(name string) ([]NVList, error)

func (NVList) LookupString

func (nvl NVList) LookupString(name string) (string, error)

func (NVList) LookupStringArray

func (nvl NVList) LookupStringArray(name string) ([]string, error)

func (NVList) LookupTime

func (nvl NVList) LookupTime(name string) (time.Time, error)

func (NVList) LookupUint16

func (nvl NVList) LookupUint16(name string) (uint16, error)

func (NVList) LookupUint16Array

func (nvl NVList) LookupUint16Array(name string) ([]uint16, error)

func (NVList) LookupUint32

func (nvl NVList) LookupUint32(name string) (uint32, error)

func (NVList) LookupUint32Array

func (nvl NVList) LookupUint32Array(name string) ([]uint32, error)

func (NVList) LookupUint64

func (nvl NVList) LookupUint64(name string) (uint64, error)

func (NVList) LookupUint64Array

func (nvl NVList) LookupUint64Array(name string) ([]uint64, error)

func (NVList) LookupUint8

func (nvl NVList) LookupUint8(name string) (uint8, error)

func (NVList) LookupUint8Array

func (nvl NVList) LookupUint8Array(name string) ([]uint8, error)

func (NVList) Map

func (nvl NVList) Map() map[string]interface{}

func (*NVList) Pointer

func (nvl *NVList) Pointer() *C.nvlist_t

type NVPair

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

func NewNVPair

func NewNVPair(hdl *C.nvpair_t) NVPair

func (NVPair) Bool

func (nvp NVPair) Bool() (bool, bool)

func (NVPair) BoolArray

func (nvp NVPair) BoolArray() ([]bool, bool)

func (NVPair) Byte

func (nvp NVPair) Byte() (byte, bool)

func (NVPair) ByteArray

func (nvp NVPair) ByteArray() ([]byte, bool)

func (NVPair) Int16

func (nvp NVPair) Int16() (int16, bool)

func (NVPair) Int16Array

func (nvp NVPair) Int16Array() ([]int16, bool)

func (NVPair) Int32

func (nvp NVPair) Int32() (int32, bool)

func (NVPair) Int32Array

func (nvp NVPair) Int32Array() ([]int32, bool)

func (NVPair) Int64

func (nvp NVPair) Int64() (int64, bool)

func (NVPair) Int64Array

func (nvp NVPair) Int64Array() ([]int64, bool)

func (NVPair) Int8

func (nvp NVPair) Int8() (int8, bool)

func (NVPair) Int8Array

func (nvp NVPair) Int8Array() ([]int8, bool)

func (NVPair) NVList

func (nvp NVPair) NVList() (NVList, bool)

func (NVPair) NVListArray

func (nvp NVPair) NVListArray() ([]NVList, bool)

func (NVPair) Name

func (nvp NVPair) Name() string

func (NVPair) String

func (nvp NVPair) String() (string, bool)

func (NVPair) StringArray

func (nvp NVPair) StringArray() ([]string, bool)

func (NVPair) Time

func (nvp NVPair) Time() (time.Time, bool)

func (NVPair) Type

func (nvp NVPair) Type() NVType

func (NVPair) Uint16

func (nvp NVPair) Uint16() (uint16, bool)

func (NVPair) Uint16Array

func (nvp NVPair) Uint16Array() ([]uint16, bool)

func (NVPair) Uint32

func (nvp NVPair) Uint32() (uint32, bool)

func (NVPair) Uint32Array

func (nvp NVPair) Uint32Array() ([]uint32, bool)

func (NVPair) Uint64

func (nvp NVPair) Uint64() (uint64, bool)

func (NVPair) Uint64Array

func (nvp NVPair) Uint64Array() ([]uint64, bool)

func (NVPair) Uint8

func (nvp NVPair) Uint8() (uint8, bool)

func (NVPair) Uint8Array

func (nvp NVPair) Uint8Array() ([]uint8, bool)

func (NVPair) Value

func (nvp NVPair) Value() interface{}

type NVType

type NVType uint
const (
	TypeUnknown NVType = iota
	TypeBoolean
	TypeByte
	TypeInt16
	TypeUint16
	TypeInt32
	TypeUint32
	TypeInt64
	TypeUint64
	TypeString
	TypeByteArray
	TypeInt16Array
	TypeUint16Array
	TypeInt32Array
	TypeUint32Array
	TypeInt64Array
	TypeUint64Array
	TypeStringArray
	TypeTime
	TypeNVList
	TypeNVListArray
	TypeBooleanValue
	TypeInt8
	TypeUint8
	TypeBooleanArray
	TypeInt8Array
	TypeUint8Array
)

func (NVType) String

func (i NVType) String() string

type Pool

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

Pool object represents handler to single ZFS pool Map of all ZFS pool properties, changing any of this will not affect ZFS pool, for that use SetProperty( name, value string) method of the pool object. This map is initial loaded when ever you open or create pool to give easy access to listing all available properties. It can be refreshed with up to date values with call to (*Pool) ReloadProperties

func (*Pool) Close

func (p *Pool) Close()

func (*Pool) Config

func (p *Pool) Config() (NVList, error)

func (*Pool) Get

func (p *Pool) Get(prop PoolProperty) (*PoolPropertyValue, error)

func (*Pool) LibZFS

func (p *Pool) LibZFS() *LibZFS

func (*Pool) Name

func (p *Pool) Name() string

func (*Pool) State

func (p *Pool) State() PoolState

State get ZFS pool state Return the state of the pool (ACTIVE or UNAVAILABLE)

func (*Pool) Status

func (p *Pool) Status() PoolStatus

Status get pool status. Let you check if pool healthy.

func (*Pool) VDevTree

func (p *Pool) VDevTree() (VDevTree, error)

VDevTree - Fetch pool's current vdev tree configuration, state and stats

type PoolInitializeAction

type PoolInitializeAction int

PoolInitializeAction type representing pool initialize action

const (
	PoolInitializeStart   PoolInitializeAction = iota // start initialization
	PoolInitializeCancel                              // cancel initialization
	PoolInitializeSuspend                             // suspend initialization
)

Initialize actions

func (PoolInitializeAction) String

func (s PoolInitializeAction) String() string

type PoolProperty

type PoolProperty int
const (
	PoolPropCont PoolProperty = iota - 2
	PoolPropInval
	PoolPropName
	PoolPropSize
	PoolPropCapacity
	PoolPropAltroot
	PoolPropHealth
	PoolPropGUID
	PoolPropVersion
	PoolPropBootfs
	PoolPropDelegation
	PoolPropAutoreplace
	PoolPropCachefile
	PoolPropFailuremode
	PoolPropListsnaps
	PoolPropAutoexpand
	PoolPropDedupditto
	PoolPropDedupratio
	PoolPropFree
	PoolPropAllocated
	PoolPropReadonly
	PoolPropAshift
	PoolPropComment
	PoolPropExpandsz
	PoolPropFreeing
	PoolPropFragmentaion
	PoolPropLeaked
	PoolPropMaxBlockSize
	PoolPropTName
	PoolPropMaxNodeSize
	PoolPropMultiHost
	PoolPropCheckpoint
	PoolPropLoadGUID
	PoolPropAutotrim
	PoolNumProps
)

Pool properties. Enumerates available ZFS pool properties. Use it to access pool properties either to read or set specific property.

func (PoolProperty) String

func (pp PoolProperty) String() string

func (PoolProperty) Type

func (pp PoolProperty) Type() PropertyType

type PoolPropertyValue

type PoolPropertyValue struct {
	Property PoolProperty
	Source   PropertySource
	Value    string
}

PoolPropertyValue ZFS pool property value

type PoolScanStat

type PoolScanStat struct {
	// Values stored on disk
	Func      ScanFunc  // Current scan function e.g. none, scrub ...
	State     ScanState // Current scan state e.g. scanning, finished ...
	StartTime time.Time // Scan start time
	EndTime   time.Time // Scan end time
	ToExamine uint64    // Total bytes to scan
	Examined  uint64    // Total bytes scanned
	Skipped   uint64    // Total bytes skipped
	Processed uint64    // Total bytes processed
	Errors    uint64    // Scan errors
	// Values not stored on disk
	PassExam       uint64    // Examined bytes per scan pass
	PassStart      time.Time // Start time of scan pass
	PassScrubPause time.Time
}

PoolScanStat - Pool scan statistics

type PoolState

type PoolState uint64

PoolState type representing pool state

const (
	PoolStateActive            PoolState = iota /* In active use		*/
	PoolStateExported                           /* Explicitly exported		*/
	PoolStateDestroyed                          /* Explicitly destroyed		*/
	PoolStateSpare                              /* Reserved for hot spare use	*/
	PoolStateL2cache                            /* Level 2 ARC device		*/
	PoolStateUninitialized                      /* Internal spa_t state		*/
	PoolStateUnavailable                        /* Internal libzfs state	*/
	PoolStatePotentiallyActive                  /* Internal libzfs state	*/
)

Possible ZFS pool states

func (PoolState) String

func (ps PoolState) String() string

type PoolStatus

type PoolStatus int

PoolStatus type representing status of the pool

const (
	/*
	 * The following correspond to faults as defined in the (fault.fs.zfs.*)
	 * event namespace.  Each is associated with a corresponding message ID.
	 */
	PoolStatusCorruptCache      PoolStatus = iota /* corrupt /kernel/drv/zpool.cache */
	PoolStatusMissingDevR                         /* missing device with replicas */
	PoolStatusMissingDevNr                        /* missing device with no replicas */
	PoolStatusCorruptLabelR                       /* bad device label with replicas */
	PoolStatusCorruptLabelNr                      /* bad device label with no replicas */
	PoolStatusBadGUIDSum                          /* sum of device guids didn't match */
	PoolStatusCorruptPool                         /* pool metadata is corrupted */
	PoolStatusCorruptData                         /* data errors in user (meta)data */
	PoolStatusFailingDev                          /* device experiencing errors */
	PoolStatusVersionNewer                        /* newer on-disk version */
	PoolStatusHostidMismatch                      /* last accessed by another system */
	PoolStatusHosidActive                         /* currently active on another system */
	PoolStatusHostidRequired                      /* multihost=on and hostid=0 */
	PoolStatusIoFailureWait                       /* failed I/O, failmode 'wait' */
	PoolStatusIoFailureContinue                   /* failed I/O, failmode 'continue' */
	PoolStatusIOFailureMMP                        /* ailed MMP, failmode not 'panic' */
	PoolStatusBadLog                              /* cannot read log chain(s) */
	PoolStatusErrata                              /* informational errata available */

	/*
	 * If the pool has unsupported features but can still be opened in
	 * read-only mode, its status is ZPOOL_STATUS_UNSUP_FEAT_WRITE. If the
	 * pool has unsupported features but cannot be opened at all, its
	 * status is ZPOOL_STATUS_UNSUP_FEAT_READ.
	 */
	PoolStatusUnsupFeatRead  /* unsupported features for read */
	PoolStatusUnsupFeatWrite /* unsupported features for write */

	/*
	 * These faults have no corresponding message ID.  At the time we are
	 * checking the status, the original reason for the FMA fault (I/O or
	 * checksum errors) has been lost.
	 */
	PoolStatusFaultedDevR  /* faulted device with replicas */
	PoolStatusFaultedDevNr /* faulted device with no replicas */

	/*
	 * The following are not faults per se, but still an error possibly
	 * requiring administrative attention.  There is no corresponding
	 * message ID.
	 */
	PoolStatusVersionOlder    /* older legacy on-disk version */
	PoolStatusFeatDisabled    /* supported features are disabled */
	PoolStatusResilvering     /* device being resilvered */
	PoolStatusOfflineDev      /* device offline */
	PoolStatusRemovedDev      /* removed device */
	PoolStatusRebuilding      /* device being rebuilt */
	PoolStatusRebuildScrub    /* recommend scrubbing the pool */
	PoolStatusNonNativeAshift /* (e.g. 512e dev with ashift of 9) */

	/*
	 * Finally, the following indicates a healthy pool.
	 */
	PoolStatusOk
)

Pool status https://github.com/openzfs/zfs/blob/e5e76bd6432de9592c4b4319fa826ad39971abd7/include/libzfs.h#L339-L405

func (PoolStatus) String

func (i PoolStatus) String() string

type Pools

type Pools []*Pool

func (Pools) Close

func (ps Pools) Close()

type PropertySource

type PropertySource int
const (
	SourceNone PropertySource = 1 << iota
	SourceDefault
	SourceTemporary
	SourceLocal
	SourceInherited
	SourceReceived

	SourceAll = SourceNone | SourceDefault | SourceTemporary |
		SourceLocal | SourceInherited | SourceReceived
)

func (PropertySource) String

func (ps PropertySource) String() string

type PropertyType

type PropertyType int
const (
	PropertyTypeNumber PropertyType = iota /* numeric value */
	PropertyTypeString                     /* string value */
	PropertyTypeIndex                      /* numeric value indexed by string */
)

func (PropertyType) String

func (i PropertyType) String() string

type ScanFunc

type ScanFunc int
const (
	ScanNone     ScanFunc = iota // No scan function
	ScanScrub                    // Pools is checked against errors
	ScanResilver                 // Pool is resilvering
	ScanNumFuncs                 // Number of scan functions
)

Scan functions

func (ScanFunc) String

func (sf ScanFunc) String() string

type ScanState

type ScanState int
const (
	DSSNone     ScanState = iota // No scan
	DSSScanning                  // Scanning
	DSSFinished                  // Scan finished
	DSSCanceled                  // Scan canceled

	DSSNumStates // Total number of scan states
)

Scan states

func (ScanState) String

func (ss ScanState) String() string

type VDevAux

type VDevAux uint64

VDevAux - vdev aux states

const (
	VDevAuxNone         VDevAux = iota // No error
	VDevAuxOpenFailed                  // Ldi_open_*() or vn_open() failed
	VDevAuxCorruptData                 // Bad label or disk contents
	VDevAuxNoReplicas                  // Insufficient number of replicas
	VDevAuxBadGUIDSum                  // Vdev guid sum doesn't match
	VDevAuxTooSmall                    // Vdev size is too small
	VDevAuxBadLabel                    // The label is OK but invalid
	VDevAuxVersionNewer                // On-disk version is too new
	VDevAuxVersionOlder                // On-disk version is too old
	VDevAuxUnsupFeat                   // Unsupported features
	VDevAuxSpared                      // Hot spare used in another pool
	VDevAuxErrExceeded                 // Too many errors
	VDevAuxIOFailure                   // Experienced I/O failure
	VDevAuxBadLog                      // Cannot read log chain(s)
	VDevAuxExternal                    // External diagnosis
	VDevAuxSplitPool                   // Vdev was split off into another pool
)

vdev aux states. When a vdev is in the VDevStateCantOpen state, the aux field of the vdev stats structure uses these constants to distinguish why.

type VDevStat

type VDevStat struct {
	Timestamp      time.Time        // Time since vdev load
	State          VDevState        // vdev state
	Aux            VDevAux          // See vdev_aux_t
	Alloc          uint64           // Space allocated
	Space          uint64           // Total capacity
	DSpace         uint64           // Deflated capacity
	RSize          uint64           // Replaceable dev size
	ESize          uint64           // Expandable dev size
	Ops            [ZIOTypes]uint64 // Operation count
	Bytes          [ZIOTypes]uint64 // Bytes read/written
	ReadErrors     uint64           // Read errors
	WriteErrors    uint64           // Write errors
	ChecksumErrors uint64           // Checksum errors
	SelfHealed     uint64           // Self-healed bytes
	ScanRemoving   uint64           // Removing?
	ScanProcessed  uint64           // Scan processed bytes
	Fragmentation  uint64           // Device fragmentation
}

VDevStat are vdev statistics. All fields should be 64-bit because this is passed between kernel and userland as an nvlist uint64 array.

type VDevState

type VDevState uint64

VDevState values are ordered from least to most healthy. Less than or equal to VDevStateCantOpen is considered unusable.

const (
	VDevStateUnknown  VDevState = iota // Uninitialized vdev
	VDevStateClosed                    // Not currently open
	VDevStateOffline                   // Not allowed to open
	VDevStateRemoved                   // Explicitly removed from system
	VDevStateCantOpen                  // Tried to open, but failed
	VDevStateFaulted                   // External request to fault device
	VDevStateDegraded                  // Replicated vdev with unhealthy kids
	VDevStateHealthy                   // Presumed good
)

func (VDevState) String

func (s VDevState) String() string

type VDevTree

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

VDevTree ZFS virtual device tree

func (VDevTree) Children

func (vdt VDevTree) Children() []VDevTree

func (VDevTree) Config

func (vdt VDevTree) Config() NVList

func (VDevTree) GUID

func (vdt VDevTree) GUID() uint64

func (VDevTree) ID

func (vdt VDevTree) ID() uint64

func (VDevTree) Name

func (vdt VDevTree) Name() string

func (VDevTree) Path

func (vdt VDevTree) Path() string

func (VDevTree) ScanStat

func (vdt VDevTree) ScanStat() (PoolScanStat, error)

func (VDevTree) Stat

func (vdt VDevTree) Stat() (VDevStat, error)

func (VDevTree) Type

func (vdt VDevTree) Type() VDevType

type VDevType

type VDevType string

VDevType type of device in the pool

Jump to

Keyboard shortcuts

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