Documentation ¶
Index ¶
- Constants
- func DeleteSnapshotHashInfoChecksumFile(snapshotName string) error
- func GetSnapshotChangeTime(snapshotName string) (string, error)
- func GetSnapshotHashInfoFromChecksumFile(snapshotName string) (*xattrType.SnapshotHashInfo, error)
- func LoadDiffDiskLocationList(diffDisk *diffDisk, disk types.DiffDisk, currentFileIndex byte) error
- func SetSnapshotHashInfoToChecksumFile(snapshotName string, info *xattrType.SnapshotHashInfo) error
- type BackupStatus
- func (rb *BackupStatus) CloseSnapshot(snapID, volumeID string) error
- func (rb *BackupStatus) CompareSnapshot(snapID, compareSnapID, volumeID string) (*btypes.Mappings, error)
- func (rb *BackupStatus) HasSnapshot(snapID, volumeID string) bool
- func (rb *BackupStatus) OpenSnapshot(snapID, volumeID string) error
- func (rb *BackupStatus) ReadSnapshot(snapID, volumeID string, start int64, data []byte) error
- func (rb *BackupStatus) UpdateBackupStatus(snapID, volumeID string, state string, progress int, url string, ...) error
- type DiskInfo
- type Info
- type PrepareRemoveAction
- type ProgressState
- type Replica
- func (r *Replica) Chain() ([]string, error)
- func (r *Replica) Close() error
- func (r *Replica) CloseWithoutWritingMetaData()
- func (r *Replica) Delete() error
- func (r *Replica) DisplayChain() ([]string, error)
- func (r *Replica) Expand(size int64) (err error)
- func (r *Replica) GetDataLayout(ctx context.Context) (<-chan sparse.FileInterval, <-chan error, error)
- func (r *Replica) GetRemainSnapshotCounts() int
- func (r *Replica) GetReplicaStat() (int64, int64)
- func (r *Replica) GetRevisionCounter() int64
- func (r *Replica) GetSnapshotCountUsage() int
- func (r *Replica) GetSnapshotSizeUsage() int64
- func (r *Replica) GetUnmapMarkDiskChainRemoved() bool
- func (r *Replica) Info() Info
- func (r *Replica) IsRevCounterDisabled() bool
- func (r *Replica) ListDisks() map[string]DiskInfo
- func (r *Replica) MarkDiskAsRemoved(name string) error
- func (r *Replica) Preload(includeBackingFileLayer bool) error
- func (r *Replica) PrepareRemoveDisk(name string) ([]PrepareRemoveAction, error)
- func (r *Replica) ReadAt(buf []byte, offset int64) (int, error)
- func (r *Replica) Reload() (*Replica, error)
- func (r *Replica) RemoveDiffDisk(name string, force bool) error
- func (r *Replica) ReplaceDisk(target, source string) error
- func (r *Replica) Revert(name, created string) (*Replica, error)
- func (r *Replica) SetRebuilding(rebuilding bool) error
- func (r *Replica) SetRevisionCounter(counter int64) error
- func (r *Replica) SetSnapshotMaxCount(count int)
- func (r *Replica) SetSnapshotMaxSize(size int64)
- func (r *Replica) SetUnmapMarkDiskChainRemoved(enabled bool)
- func (r *Replica) Snapshot(name string, userCreated bool, created string, labels map[string]string) error
- func (r *Replica) UnmapAt(length uint32, offset int64) (n int, err error)
- func (r *Replica) WriteAt(buf []byte, offset int64) (int, error)
- type RestoreStatus
- func (status *RestoreStatus) CloseVolumeDev(volDev *os.File) error
- func (status *RestoreStatus) DeepCopy() *RestoreStatus
- func (status *RestoreStatus) FinishRestore()
- func (status *RestoreStatus) GetStopChan() chan struct{}
- func (status *RestoreStatus) OpenVolumeDev(volDevName string) (*os.File, string, error)
- func (status *RestoreStatus) Revert(previousStatus *RestoreStatus)
- func (status *RestoreStatus) StartNewRestore(backupURL, currentRestoringBackup, toFileName, snapshotDiskName string, ...)
- func (status *RestoreStatus) Stop()
- func (status *RestoreStatus) UpdateRestoreStatus(snapshot string, rp int, re error)
- type Server
- func (s *Server) Close() error
- func (s *Server) Create(size int64) error
- func (s *Server) Delete() error
- func (s *Server) Expand(size int64) error
- func (s *Server) MarkDiskAsRemoved(name string) error
- func (s *Server) Open() error
- func (s *Server) PingResponse() error
- func (s *Server) PrepareRemoveDisk(name string) ([]PrepareRemoveAction, error)
- func (s *Server) ReadAt(buf []byte, offset int64) (int, error)
- func (s *Server) Reload() error
- func (s *Server) RemoveDiffDisk(name string, force bool) error
- func (s *Server) ReplaceDisk(target, source string) error
- func (s *Server) Replica() *Replica
- func (s *Server) Revert(name, created string) error
- func (s *Server) SetRebuilding(rebuilding bool) error
- func (s *Server) SetRevisionCounter(counter int64) error
- func (s *Server) SetSnapshotMaxCount(count int)
- func (s *Server) SetSnapshotMaxSize(size int64)
- func (s *Server) SetUnmapMarkDiskChainRemoved(enabled bool)
- func (s *Server) Snapshot(name string, userCreated bool, createdTime string, labels map[string]string) error
- func (s *Server) Status() (types.ReplicaState, Info)
- func (s *Server) UnmapAt(length uint32, off int64) (int, error)
- func (s *Server) WriteAt(buf []byte, offset int64) (int, error)
- type SnapshotHashJob
- type SnapshotHashStatus
Constants ¶
const ( FileLockDirectory = "/host/var/lib/longhorn/.lock" HashLockFileName = "hash" )
const ( OpCoalesce = "coalesce" // Source is parent, target is child OpRemove = "remove" OpReplace = "replace" OpPrune = "prune" // Remove overlapping chunks from the source. )
const ( ProgressStateInProgress = ProgressState("in_progress") ProgressStateComplete = ProgressState("complete") ProgressStateError = ProgressState("error") )
const MaxExtentsBuffer = 1024
Variables ¶
This section is empty.
Functions ¶
func DeleteSnapshotHashInfoChecksumFile ¶ added in v1.4.0
func GetSnapshotChangeTime ¶ added in v1.4.0
func GetSnapshotHashInfoFromChecksumFile ¶ added in v1.4.0
func GetSnapshotHashInfoFromChecksumFile(snapshotName string) (*xattrType.SnapshotHashInfo, error)
func LoadDiffDiskLocationList ¶ added in v1.1.2
func SetSnapshotHashInfoToChecksumFile ¶ added in v1.4.0
func SetSnapshotHashInfoToChecksumFile(snapshotName string, info *xattrType.SnapshotHashInfo) error
Types ¶
type BackupStatus ¶
type BackupStatus struct { Name string SnapshotID string Error string Progress int BackupURL string State ProgressState IsIncremental bool IsOpened bool // contains filtered or unexported fields }
func NewBackup ¶
func NewBackup(name, volumeID, snapID string, backingFile *backingfile.BackingFile) *BackupStatus
func (*BackupStatus) CloseSnapshot ¶
func (rb *BackupStatus) CloseSnapshot(snapID, volumeID string) error
func (*BackupStatus) CompareSnapshot ¶
func (rb *BackupStatus) CompareSnapshot(snapID, compareSnapID, volumeID string) (*btypes.Mappings, error)
func (*BackupStatus) HasSnapshot ¶
func (rb *BackupStatus) HasSnapshot(snapID, volumeID string) bool
func (*BackupStatus) OpenSnapshot ¶
func (rb *BackupStatus) OpenSnapshot(snapID, volumeID string) error
func (*BackupStatus) ReadSnapshot ¶
func (rb *BackupStatus) ReadSnapshot(snapID, volumeID string, start int64, data []byte) error
func (*BackupStatus) UpdateBackupStatus ¶
func (rb *BackupStatus) UpdateBackupStatus(snapID, volumeID string, state string, progress int, url string, errString string) error
UpdateBackupStatus updates the backup status. The state is first-respected, but if - The errString is not empty, the state will be set to error. - The progress is 100, the state will be set to complete.
type Info ¶
type Info struct { Size int64 Head string Dirty bool Rebuilding bool Error string Parent string SectorSize int64 BackingFilePath string BackingFile *backingfile.BackingFile `json:"-"` }
type PrepareRemoveAction ¶
type ProgressState ¶
type ProgressState string
type Replica ¶
func NewReadOnly ¶
func NewReadOnly(ctx context.Context, dir, head string, backingFile *backingfile.BackingFile) (*Replica, error)
func OpenSnapshot ¶ added in v1.2.0
func (*Replica) CloseWithoutWritingMetaData ¶ added in v1.2.0
func (r *Replica) CloseWithoutWritingMetaData()
func (*Replica) DisplayChain ¶
func (*Replica) GetDataLayout ¶ added in v1.2.0
func (*Replica) GetRemainSnapshotCounts ¶
func (*Replica) GetReplicaStat ¶ added in v1.1.0
func (*Replica) GetRevisionCounter ¶
func (*Replica) GetSnapshotCountUsage ¶ added in v1.6.0
func (*Replica) GetSnapshotSizeUsage ¶ added in v1.6.0
func (*Replica) GetUnmapMarkDiskChainRemoved ¶ added in v1.4.0
func (*Replica) IsRevCounterDisabled ¶ added in v1.1.0
func (*Replica) MarkDiskAsRemoved ¶
func (*Replica) PrepareRemoveDisk ¶
func (r *Replica) PrepareRemoveDisk(name string) ([]PrepareRemoveAction, error)
func (*Replica) ReplaceDisk ¶
func (*Replica) SetRebuilding ¶
func (*Replica) SetRevisionCounter ¶
SetRevisionCounter can be invoked only when there is no pending IO. Typically, its caller, the engine process, will hold the lock before calling this function. And the engine lock holding means all writable replicas finished their IO. In other words, the engine lock holding means there is no pending IO.
func (*Replica) SetSnapshotMaxCount ¶ added in v1.6.0
func (*Replica) SetSnapshotMaxSize ¶ added in v1.6.0
func (*Replica) SetUnmapMarkDiskChainRemoved ¶ added in v1.4.0
type RestoreStatus ¶
type RestoreStatus struct { sync.RWMutex Progress int Error string BackupURL string State ProgressState // The file that (temporarily) stores the data during the restoring. ToFileName string // The snapshot file that stores the restored data in the end. SnapshotDiskName string LastRestored string CurrentRestoringBackup string // contains filtered or unexported fields }
func NewRestore ¶
func NewRestore(snapshotName, replicaAddress, backupURL, currentRestoringBackup string) *RestoreStatus
func (*RestoreStatus) CloseVolumeDev ¶ added in v1.5.4
func (status *RestoreStatus) CloseVolumeDev(volDev *os.File) error
func (*RestoreStatus) DeepCopy ¶ added in v1.0.1
func (status *RestoreStatus) DeepCopy() *RestoreStatus
func (*RestoreStatus) FinishRestore ¶
func (status *RestoreStatus) FinishRestore()
func (*RestoreStatus) GetStopChan ¶ added in v1.5.4
func (status *RestoreStatus) GetStopChan() chan struct{}
func (*RestoreStatus) OpenVolumeDev ¶ added in v1.5.4
func (*RestoreStatus) Revert ¶ added in v1.1.0
func (status *RestoreStatus) Revert(previousStatus *RestoreStatus)
Revert is used for reverting the current restore status to the previous status. This function will be invoked when:
- The new restore is failed before the actual restore is performed.
- The existing files are not modified.
- The current status has been updated/initialized for the new restore.
If there is no modification applied on the existing replica disk files after the restore failure, it means the replica is still available. In order to make sure the replica work fine for the next restore and the status is not messed up, the revert is indispensable.
func (*RestoreStatus) StartNewRestore ¶ added in v1.1.0
func (status *RestoreStatus) StartNewRestore(backupURL, currentRestoringBackup, toFileName, snapshotDiskName string, validLastRestoredBackup bool)
func (*RestoreStatus) Stop ¶ added in v1.5.4
func (status *RestoreStatus) Stop()
func (*RestoreStatus) UpdateRestoreStatus ¶
func (status *RestoreStatus) UpdateRestoreStatus(snapshot string, rp int, re error)
type Server ¶
func NewServer ¶
func NewServer(ctx context.Context, dir string, backing *backingfile.BackingFile, sectorSize int64, disableRevCounter, unmapMarkDiskChainRemoved bool, snapshotMaxCount int, snapshotMaxSize int64) *Server
func (*Server) MarkDiskAsRemoved ¶
func (*Server) PingResponse ¶
func (*Server) PrepareRemoveDisk ¶
func (s *Server) PrepareRemoveDisk(name string) ([]PrepareRemoveAction, error)
func (*Server) ReplaceDisk ¶
func (*Server) SetRebuilding ¶
func (*Server) SetRevisionCounter ¶
func (*Server) SetSnapshotMaxCount ¶ added in v1.6.0
func (*Server) SetSnapshotMaxSize ¶ added in v1.6.0
func (*Server) SetUnmapMarkDiskChainRemoved ¶ added in v1.4.0
type SnapshotHashJob ¶ added in v1.4.0
type SnapshotHashJob struct { sync.Mutex Ctx context.Context CancelFunc context.CancelFunc SnapshotName string Rehash bool SnapshotHashStatus }
func NewSnapshotHashJob ¶ added in v1.4.0
func NewSnapshotHashJob(ctx context.Context, cancel context.CancelFunc, snapshotName string, rehash bool) *SnapshotHashJob
func (*SnapshotHashJob) Execute ¶ added in v1.4.0
func (t *SnapshotHashJob) Execute() (err error)
func (*SnapshotHashJob) LockFile ¶ added in v1.4.0
func (t *SnapshotHashJob) LockFile() (fileLock *flock.Flock, err error)
func (*SnapshotHashJob) UnlockFile ¶ added in v1.4.0
func (t *SnapshotHashJob) UnlockFile(fileLock *flock.Flock)