Documentation ¶
Index ¶
- Constants
- Variables
- func PrometheusRegister(registry prometheus.Registerer) error
- func ZFSBookmark(fs *DatasetPath, snapshot, bookmark string) (err error)
- func ZFSCreatePlaceholderFilesystem(p *DatasetPath) (err error)
- func ZFSDestroy(arg string) (err error)
- func ZFSDestroyFilesystemVersion(filesystem *DatasetPath, version *FilesystemVersion) (err error)
- func ZFSDestroyFilesystemVersions(reqs []*DestroySnapOp)
- func ZFSGetReceiveResumeToken(fs *DatasetPath) (string, error)
- func ZFSList(properties []string, zfsArgs ...string) (res [][]string, err error)
- func ZFSListChan(ctx context.Context, out chan ZFSListResult, properties []string, ...)
- func ZFSRecv(ctx context.Context, fs string, streamCopier StreamCopier, opts RecvOptions) (err error)
- func ZFSRecvClearResumeToken(fs string) (err error)
- func ZFSRollback(fs *DatasetPath, snapshot FilesystemVersion, rollbackArgs ...string) (err error)
- func ZFSSet(fs *DatasetPath, props *ZFSProperties) (err error)
- func ZFSSetPlaceholder(p *DatasetPath, isPlaceholder bool) error
- func ZFSSetReplicationCursor(fs *DatasetPath, snapname string) (guid uint64, err error)
- func ZFSSnapshot(fs *DatasetPath, name string, recursive bool) (err error)
- type ClearResumeTokenError
- type DatasetDoesNotExist
- type DatasetFilter
- type DatasetPath
- func (p *DatasetPath) Copy() (c *DatasetPath)
- func (p *DatasetPath) Empty() bool
- func (p DatasetPath) Equal(q *DatasetPath) bool
- func (p *DatasetPath) Extend(extend *DatasetPath)
- func (p *DatasetPath) HasPrefix(prefix *DatasetPath) bool
- func (p *DatasetPath) Length() int
- func (p *DatasetPath) MarshalJSON() ([]byte, error)
- func (p *DatasetPath) ToString() string
- func (p *DatasetPath) TrimNPrefixComps(n int)
- func (p *DatasetPath) TrimPrefix(prefix *DatasetPath)
- func (p *DatasetPath) UnmarshalJSON(b []byte) error
- type DatasetPathForest
- type DatasetPathVisit
- type DatasetPathsVisitor
- type DestroySnapOp
- type DestroySnapshotsError
- type DrySendInfo
- type DrySendType
- type FilesystemPlaceholderState
- type FilesystemVersion
- type FilesystemVersionFilter
- type MigrateHashBasedPlaceholderReport
- type RecvOptions
- type ResumeToken
- type StreamCopier
- type StreamCopierError
- type VersionType
- type ZFSError
- type ZFSListMappingPropertiesResult
- type ZFSListResult
- type ZFSPropCreateTxgAndGuidProps
- type ZFSProperties
Constants ¶
const ( // For a placeholder filesystem to be a placeholder, the property source must be local, // i.e. not inherited. PlaceholderPropertyName string = "zrepl:placeholder" )
const ReplicationCursorBookmarkName = "zrepl_replication_cursor"
Variables ¶
var ( ZFSSendPipeCapacityHint = int(envconst.Int64("ZFS_SEND_PIPE_CAPACITY_HINT", 1<<25)) ZFSRecvPipeCapacityHint = int(envconst.Int64("ZFS_RECV_PIPE_CAPACITY_HINT", 1<<25)) )
var ResumeTokenCorruptError = errors.New("resume token is corrupt")
var ResumeTokenDecodingNotSupported = errors.New("zfs binary does not allow decoding resume token or zrepl cannot scrape zfs output")
var ResumeTokenParsingError = errors.New("zrepl cannot parse resume token values")
var ZFS_BINARY string = "zfs"
Functions ¶
func PrometheusRegister ¶
func PrometheusRegister(registry prometheus.Registerer) error
func ZFSBookmark ¶
func ZFSBookmark(fs *DatasetPath, snapshot, bookmark string) (err error)
func ZFSCreatePlaceholderFilesystem ¶
func ZFSCreatePlaceholderFilesystem(p *DatasetPath) (err error)
func ZFSDestroy ¶
func ZFSDestroyFilesystemVersion ¶
func ZFSDestroyFilesystemVersion(filesystem *DatasetPath, version *FilesystemVersion) (err error)
func ZFSDestroyFilesystemVersions ¶ added in v0.2.0
func ZFSDestroyFilesystemVersions(reqs []*DestroySnapOp)
func ZFSGetReceiveResumeToken ¶
func ZFSGetReceiveResumeToken(fs *DatasetPath) (string, error)
func ZFSListChan ¶
func ZFSListChan(ctx context.Context, out chan ZFSListResult, properties []string, zfsArgs ...string)
ZFSListChan executes `zfs list` and sends the results to the `out` channel. The `out` channel is always closed by ZFSListChan: If an error occurs, it is closed after sending a result with the Err field set. If no error occurs, it is just closed. If the operation is cancelled via context, the channel is just closed.
However, if callers do not drain `out` or cancel via `ctx`, the process will leak either running because IO is pending or as a zombie.
func ZFSRecv ¶
func ZFSRecv(ctx context.Context, fs string, streamCopier StreamCopier, opts RecvOptions) (err error)
func ZFSRecvClearResumeToken ¶
always returns *ClearResumeTokenError
func ZFSRollback ¶
func ZFSRollback(fs *DatasetPath, snapshot FilesystemVersion, rollbackArgs ...string) (err error)
func ZFSSet ¶
func ZFSSet(fs *DatasetPath, props *ZFSProperties) (err error)
func ZFSSetPlaceholder ¶
func ZFSSetPlaceholder(p *DatasetPath, isPlaceholder bool) error
func ZFSSetReplicationCursor ¶
func ZFSSetReplicationCursor(fs *DatasetPath, snapname string) (guid uint64, err error)
func ZFSSnapshot ¶
func ZFSSnapshot(fs *DatasetPath, name string, recursive bool) (err error)
Types ¶
type ClearResumeTokenError ¶
func (ClearResumeTokenError) Error ¶
func (e ClearResumeTokenError) Error() string
type DatasetDoesNotExist ¶
type DatasetDoesNotExist struct {
Path string
}
func (*DatasetDoesNotExist) Error ¶
func (d *DatasetDoesNotExist) Error() string
type DatasetFilter ¶
type DatasetFilter interface {
Filter(p *DatasetPath) (pass bool, err error)
}
func NoFilter ¶
func NoFilter() DatasetFilter
Returns a DatasetFilter that does not filter (passes all paths)
type DatasetPath ¶
type DatasetPath struct {
// contains filtered or unexported fields
}
func NewDatasetPath ¶
func NewDatasetPath(s string) (p *DatasetPath, err error)
func ZFSListMapping ¶
func ZFSListMapping(ctx context.Context, filter DatasetFilter) (datasets []*DatasetPath, err error)
func (*DatasetPath) Copy ¶
func (p *DatasetPath) Copy() (c *DatasetPath)
func (*DatasetPath) Empty ¶
func (p *DatasetPath) Empty() bool
func (DatasetPath) Equal ¶
func (p DatasetPath) Equal(q *DatasetPath) bool
func (*DatasetPath) Extend ¶
func (p *DatasetPath) Extend(extend *DatasetPath)
func (*DatasetPath) HasPrefix ¶
func (p *DatasetPath) HasPrefix(prefix *DatasetPath) bool
func (*DatasetPath) Length ¶
func (p *DatasetPath) Length() int
func (*DatasetPath) MarshalJSON ¶
func (p *DatasetPath) MarshalJSON() ([]byte, error)
func (*DatasetPath) ToString ¶
func (p *DatasetPath) ToString() string
func (*DatasetPath) TrimNPrefixComps ¶
func (p *DatasetPath) TrimNPrefixComps(n int)
func (*DatasetPath) TrimPrefix ¶
func (p *DatasetPath) TrimPrefix(prefix *DatasetPath)
func (*DatasetPath) UnmarshalJSON ¶
func (p *DatasetPath) UnmarshalJSON(b []byte) error
type DatasetPathForest ¶
type DatasetPathForest struct {
// contains filtered or unexported fields
}
func NewDatasetPathForest ¶
func NewDatasetPathForest() *DatasetPathForest
func (*DatasetPathForest) Add ¶
func (f *DatasetPathForest) Add(p *DatasetPath)
func (*DatasetPathForest) WalkTopDown ¶
func (f *DatasetPathForest) WalkTopDown(visitor DatasetPathsVisitor)
Traverse a list of DatasetPaths top down, i.e. given a set of datasets with same path prefix, those with shorter prefix are traversed first. If there are gaps, i.e. the intermediary component a/b bewtween a and a/b/c, those gaps are still visited but the FilledIn property of the visit is set to true.
type DatasetPathVisit ¶
type DatasetPathVisit struct { Path *DatasetPath // If true, the dataset referenced by Path was not in the list of datasets to traverse FilledIn bool }
type DatasetPathsVisitor ¶
type DatasetPathsVisitor func(v DatasetPathVisit) (visitChildTree bool)
type DestroySnapOp ¶ added in v0.2.0
func (*DestroySnapOp) String ¶ added in v0.2.0
func (o *DestroySnapOp) String() string
type DestroySnapshotsError ¶ added in v0.2.0
type DestroySnapshotsError struct { RawLines []string Filesystem string Undestroyable []string // snapshot name only (filesystem@ stripped) Reason []string }
func (*DestroySnapshotsError) Error ¶ added in v0.2.0
func (e *DestroySnapshotsError) Error() string
type DrySendInfo ¶
type DrySendInfo struct { Type DrySendType Filesystem string // parsed from To field From, To string // direct copy from ZFS output SizeEstimate int64 // -1 if size estimate is not possible }
func ZFSSendDry ¶
func ZFSSendDry(fs string, from, to string, token string) (_ *DrySendInfo, err error)
from may be "", in which case a full ZFS send is done May return BookmarkSizeEstimationNotSupported as err if from is a bookmark.
type DrySendType ¶
type DrySendType string
const ( DrySendTypeFull DrySendType = "full" DrySendTypeIncremental DrySendType = "incremental" )
func DrySendTypeFromString ¶
func DrySendTypeFromString(s string) (DrySendType, error)
type FilesystemPlaceholderState ¶
type FilesystemPlaceholderState struct { FS string FSExists bool IsPlaceholder bool RawLocalPropertyValue string }
func ZFSGetFilesystemPlaceholderState ¶
func ZFSGetFilesystemPlaceholderState(p *DatasetPath) (state *FilesystemPlaceholderState, err error)
ZFSGetFilesystemPlaceholderState is the authoritative way to determine whether a filesystem is a placeholder. Note that the property source must be `local` for the returned value to be valid.
For nonexistent FS, err == nil and state.FSExists == false
type FilesystemVersion ¶
type FilesystemVersion struct { Type VersionType // Display name. Should not be used for identification, only for user output Name string // GUID as exported by ZFS. Uniquely identifies a snapshot across pools Guid uint64 // The TXG in which the snapshot was created. For bookmarks, // this is the GUID of the snapshot it was initially tied to. CreateTXG uint64 // The time the dataset was created Creation time.Time }
func ZFSGetReplicationCursor ¶
func ZFSGetReplicationCursor(fs *DatasetPath) (*FilesystemVersion, error)
may return nil for both values, indicating there is no cursor
func ZFSListFilesystemVersions ¶
func ZFSListFilesystemVersions(fs *DatasetPath, filter FilesystemVersionFilter) (res []FilesystemVersion, err error)
func (FilesystemVersion) String ¶
func (v FilesystemVersion) String() string
func (FilesystemVersion) ToAbsPath ¶
func (v FilesystemVersion) ToAbsPath(p *DatasetPath) string
type FilesystemVersionFilter ¶
type FilesystemVersionFilter interface {
Filter(t VersionType, name string) (accept bool, err error)
}
type MigrateHashBasedPlaceholderReport ¶
type MigrateHashBasedPlaceholderReport struct { OriginalState FilesystemPlaceholderState NeedsModification bool }
func ZFSMigrateHashBasedPlaceholderToCurrent ¶
func ZFSMigrateHashBasedPlaceholderToCurrent(fs *DatasetPath, dryRun bool) (*MigrateHashBasedPlaceholderReport, error)
fs must exist, will panic otherwise
type RecvOptions ¶
type RecvOptions struct { // Rollback to the oldest snapshot, destroy it, then perform `recv -F`. // Note that this doesn't change property values, i.e. an existing local property value will be kept. RollbackAndForceRecv bool }
type ResumeToken ¶
func ParseResumeToken ¶
func ParseResumeToken(ctx context.Context, token string) (*ResumeToken, error)
Abuse 'zfs send' to decode the resume token
FIXME: implement nvlist unpacking in Go and read through libzfs_sendrecv.c
type StreamCopier ¶
type StreamCopier interface { // WriteStreamTo writes the stream represented by this StreamCopier // to the given io.Writer. WriteStreamTo(w io.Writer) StreamCopierError // Close must be called as soon as it is clear that no more data will // be read from the StreamCopier. // If StreamCopier gets its data from a connection, it might hold // a lock on the connection until Close is called. Only closing ensures // that the connection can be used afterwards. Close() error }
type StreamCopierError ¶
type VersionType ¶
type VersionType string
const ( Bookmark VersionType = "bookmark" Snapshot VersionType = "snapshot" )
func DecomposeVersionString ¶
func DecomposeVersionString(v string) (fs string, versionType VersionType, name string, err error)
func (VersionType) DelimiterChar ¶
func (t VersionType) DelimiterChar() string
func (VersionType) String ¶
func (t VersionType) String() string
type ZFSListMappingPropertiesResult ¶
type ZFSListMappingPropertiesResult struct { Path *DatasetPath // Guaranteed to have the same length as properties in the originating call Fields []string }
func ZFSListMappingProperties ¶
func ZFSListMappingProperties(ctx context.Context, filter DatasetFilter, properties []string) (datasets []ZFSListMappingPropertiesResult, err error)
properties must not contain 'name'
type ZFSListResult ¶
type ZFSPropCreateTxgAndGuidProps ¶ added in v0.2.1
type ZFSPropCreateTxgAndGuidProps struct {
CreateTXG, Guid uint64
}
func ZFSGetCreateTXGAndGuid ¶ added in v0.2.1
func ZFSGetCreateTXGAndGuid(ds string) (ZFSPropCreateTxgAndGuidProps, error)
type ZFSProperties ¶
type ZFSProperties struct {
// contains filtered or unexported fields
}
func NewZFSProperties ¶
func NewZFSProperties() *ZFSProperties
func ZFSGet ¶
func ZFSGet(fs *DatasetPath, props []string) (*ZFSProperties, error)
func ZFSGetRawAnySource ¶ added in v0.2.0
func ZFSGetRawAnySource(path string, props []string) (*ZFSProperties, error)
func (*ZFSProperties) Get ¶
func (p *ZFSProperties) Get(key string) string
func (*ZFSProperties) Set ¶
func (p *ZFSProperties) Set(key, val string)