Documentation
¶
Index ¶
- Constants
- Variables
- func CloneFile(dst, src *os.File) error
- func CreateSubVolume(path string) error
- func DeleteSubVolume(path string) error
- func IsReadOnly(path string) (bool, error)
- func IsSubVolume(path string) (bool, error)
- func Receive(r io.Reader, dstDir string) error
- func Send(w io.Writer, parent string, subvols ...string) error
- func SetCompression(path string, v Compression) error
- func SnapshotSubVolume(subvol, dst string, ro bool) error
- type BalanceFlags
- type BalanceProgress
- type BalanceState
- type Compression
- type DevInfo
- type DevStats
- type DevStatsFlags
- type ErrCode
- type ErrNotBtrfs
- type FS
- func (f *FS) Balance(flags BalanceFlags) (BalanceProgress, error)
- func (f *FS) Close() error
- func (f *FS) CreateSubVolume(name string) error
- func (f *FS) DeleteSubVolume(name string) error
- func (f *FS) GetDevInfo(id uint64) (out DevInfo, err error)
- func (f *FS) GetDevStats(id uint64) (out DevStats, err error)
- func (f *FS) GetDevStatsWithFlags(id uint64, flags uint64) (out DevStats, err error)
- func (f *FS) GetFeatures() (out FSFeatureFlags, err error)
- func (f *FS) GetFlags() (SubvolFlags, error)
- func (f *FS) GetSupportedFeatures() (out FSFeatureFlags, err error)
- func (f *FS) Info() (out Info, err error)
- func (f *FS) ListSubvolumes(filter func(SubvolInfo) bool) ([]SubvolInfo, error)
- func (f *FS) Receive(r io.Reader) error
- func (f *FS) ReceiveTo(r io.Reader, mount string) error
- func (f *FS) ResetDevStats(id uint64) (err error)
- func (f *FS) Resize(size int64) error
- func (f *FS) ResizeToMax() error
- func (f *FS) ScrubCancel(dev uint64) error
- func (f *FS) ScrubStart(dev uint64, start uint64, end uint64) error
- func (f *FS) ScrubStatus(dev uint64) (ScrubProgress, error)
- func (f *FS) Send(w io.Writer, parent string, subvols ...string) error
- func (f *FS) SetFlags(flags SubvolFlags) error
- func (f *FS) Snapshot(dst string, ro bool) error
- func (f *FS) SnapshotSubVolume(name string, dst string, ro bool) error
- func (f *FS) SubVolumeID() (uint64, error)
- func (f *FS) SubvolumeByPath(path string) (*SubvolInfo, error)
- func (f *FS) SubvolumeByReceivedUUID(uuid UUID) (*SubvolInfo, error)
- func (f *FS) SubvolumeByUUID(uuid UUID) (*SubvolInfo, error)
- func (f *FS) Sync() (err error)
- func (f *FS) Usage() (UsageInfo, error)
- type FSFeatureFlags
- type FSID
- type FeatureFlags
- type IncompatFeatures
- type Info
- type ScrubProgress
- type SubvolFlags
- type SubvolInfo
- type UUID
- type UsageInfo
Constants ¶
const ( FeatureIncompatMixedBackRef = IncompatFeatures(1 << 0) FeatureIncompatDefaultSubvol = IncompatFeatures(1 << 1) FeatureIncompatMixedGroups = IncompatFeatures(1 << 2) FeatureIncompatCompressLZO = IncompatFeatures(1 << 3) // Some patches floated around with a second compression method // lets save that incompat here for when they do get in. // Note we don't actually support it, we're just reserving the number. FeatureIncompatCompressLZOv2 = IncompatFeatures(1 << 4) // Older kernels tried to do bigger metadata blocks, but the // code was pretty buggy. Lets not let them try anymore. FeatureIncompatBigMetadata = IncompatFeatures(1 << 5) FeatureIncompatExtendedIRef = IncompatFeatures(1 << 6) FeatureIncompatRAID56 = IncompatFeatures(1 << 7) FeatureIncompatSkinnyMetadata = IncompatFeatures(1 << 8) FeatureIncompatNoHoles = IncompatFeatures(1 << 9) )
const ( BalanceData = BalanceFlags(1 << 0) BalanceSystem = BalanceFlags(1 << 1) BalanceMetadata = BalanceFlags(1 << 2) BalanceMask = (BalanceData | BalanceSystem | BalanceMetadata) BalanceForce = BalanceFlags(1 << 3) BalanceResume = BalanceFlags(1 << 4) )
Restriper's general type filter.
const ( ErrDevRAID1MinNotMet = ErrCode(iota + 1) ErrDevRAID10MinNotMet ErrDevRAID5MinNotMet ErrDevRAID6MinNotMet ErrDevTargetReplace ErrDevMissingNotFound ErrDevOnlyWritable ErrDevExclRunInProgress )
const ( FSIDSize = 16 UUIDSize = 16 )
const ( SubvolRootReadOnly = SubvolFlags(1 << 0) // BTRFS_ROOT_SUBVOL_RDONLY, only present in search result copies SubvolReadOnly = SubvolFlags(1 << 1) // BTRFS_SUBVOL_RDONLY )
flags for subvolumes
Used by: struct btrfs_ioctl_vol_args_v2.flags
BTRFS_SUBVOL_RDONLY is also provided/consumed by the following ioctls: - BTRFS_IOC_SUBVOL_GETFLAGS - BTRFS_IOC_SUBVOL_SETFLAGS
const ( CompressionNone = Compression("") LZO = Compression("lzo") ZLIB = Compression("zlib") )
const (
FeatureCompatROFreeSpaceTree = FeatureFlags(1 << 0)
)
const SuperMagic uint32 = 0x9123683E
Variables ¶
var (
ErrNotFound = errors.New("not found")
)
Functions ¶
func CreateSubVolume ¶
func DeleteSubVolume ¶
func IsReadOnly ¶
func IsSubVolume ¶
func SetCompression ¶
func SetCompression(path string, v Compression) error
func SnapshotSubVolume ¶
Types ¶
type BalanceProgress ¶
type BalanceProgress struct {
Expected uint64 // estimated # of chunks that will be relocated to fulfill the request
Considered uint64 // # of chunks we have considered so far
Completed uint64 // # of chunks relocated so far
}
Report balance progress to userspace.
btrfs_balance_progress
type BalanceState ¶
type BalanceState uint64
const ( BalanceStateRunning BalanceState = (1 << 0) BalanceStatePauseReq BalanceState = (1 << 1) BalanceStateCancelReq BalanceState = (1 << 2) )
type Compression ¶
type Compression string
func GetCompression ¶
func GetCompression(path string) (Compression, error)
type DevStats ¶
type DevStats struct {
WriteErrs uint64
ReadErrs uint64
FlushErrs uint64
// Checksum error, bytenr error or contents is illegal: this is an
// indication that the block was damaged during read or write, or written to
// wrong location or read from wrong location.
CorruptionErrs uint64
// An indication that blocks have not been written.
GenerationErrs uint64
Unknown []uint64
}
type DevStatsFlags ¶
type DevStatsFlags = uint64
const (
DevStatsFlagsReset DevStatsFlags = _BTRFS_DEV_STATS_RESET
)
type ErrNotBtrfs ¶
type ErrNotBtrfs struct {
Path string
}
func (ErrNotBtrfs) Error ¶
func (e ErrNotBtrfs) Error() string
type FS ¶
type FS struct {
// contains filtered or unexported fields
}
func (*FS) Balance ¶
func (f *FS) Balance(flags BalanceFlags) (BalanceProgress, error)
func (*FS) CreateSubVolume ¶
func (*FS) DeleteSubVolume ¶
func (*FS) GetDevStatsWithFlags ¶
func (*FS) GetFeatures ¶
func (f *FS) GetFeatures() (out FSFeatureFlags, err error)
func (*FS) GetFlags ¶
func (f *FS) GetFlags() (SubvolFlags, error)
func (*FS) GetSupportedFeatures ¶
func (f *FS) GetSupportedFeatures() (out FSFeatureFlags, err error)
func (*FS) ListSubvolumes ¶
func (f *FS) ListSubvolumes(filter func(SubvolInfo) bool) ([]SubvolInfo, error)
func (*FS) ResetDevStats ¶
func (*FS) ResizeToMax ¶
func (*FS) ScrubCancel ¶
Cancel a scrub on the given device Scrub operations requiere CAP_SYSADMIN or root
func (*FS) ScrubStart ¶
Start a scrub on the given device, starting at start blocks and ending on end blocks If you want to scan the whole device, set start to 0 and end to the maximal value of uint64( for example via math.MaxUint64) Another option is to resume a earlier interrupted scrub, by setting the start to the same value as reported in LastPhysical (can be retrieved via .ScrubStatus) WARNING: This method WILL BLOCK until the scrub is done, or the scrub is cancelled Scrub operations requiere CAP_SYSADMIN or root
func (*FS) ScrubStatus ¶
func (f *FS) ScrubStatus(dev uint64) (ScrubProgress, error)
Get the progress of a scrub on the given device Scrub operations requiere CAP_SYSADMIN or root
func (*FS) SetFlags ¶
func (f *FS) SetFlags(flags SubvolFlags) error
func (*FS) SnapshotSubVolume ¶
func (*FS) SubVolumeID ¶
func (*FS) SubvolumeByPath ¶
func (f *FS) SubvolumeByPath(path string) (*SubvolInfo, error)
func (*FS) SubvolumeByReceivedUUID ¶
func (f *FS) SubvolumeByReceivedUUID(uuid UUID) (*SubvolInfo, error)
func (*FS) SubvolumeByUUID ¶
func (f *FS) SubvolumeByUUID(uuid UUID) (*SubvolInfo, error)
type FSFeatureFlags ¶
type FSFeatureFlags struct {
Compatible FeatureFlags
CompatibleRO FeatureFlags
Incompatible IncompatFeatures
}
type FeatureFlags ¶
type FeatureFlags uint64
type IncompatFeatures ¶
type IncompatFeatures uint64
func (IncompatFeatures) String ¶
func (f IncompatFeatures) String() string
type ScrubProgress ¶
type ScrubProgress struct {
DataExtentsScrubbed uint64 // # of data extents scrubbed
TreeExtentsScrubbed uint64 // # of tree extents scrubbed
DataBytesScrubbed uint64 // # of data bytes scrubbed
TreeBytesScrubbed uint64 // # of tree bytes scrubbed
ReadErrors uint64 // # of read errors encountered (EIO)
CsumErrors uint64 // # of failed csum checks
// # of occurences, where the metadata of a tree block did not match the expected values, like generation or logical
VerifyErrors uint64
// # of 4k data block for which no csum is present, probably the result of data written with nodatasum
NoCsum uint64
CsumDiscards uint64 // # of csum for which no data was found in the extent tree.
SuperErrors uint64 // # of bad super blocks encountered
MallocErrors uint64 // # of internal kmalloc errors. These will likely cause an incomplete scrub
UncorrectableErrors uint64 // # of errors where either no intact copy was found or the writeback failed
CorrectedErrors uint64 // # of errors corrected
// last physical address scrubbed. In case a scrub was aborted, this can be used to restart the scrub
LastPhysical uint64
// # of occurences where a read for a full (64k) bio failed, but the re-
// check succeeded for each 4k piece. Intermittent error.
UnverifiedErrors uint64
}
type SubvolFlags ¶
type SubvolFlags uint64
func GetFlags ¶
func GetFlags(path string) (SubvolFlags, error)
func (SubvolFlags) ReadOnly ¶
func (f SubvolFlags) ReadOnly() bool
func (SubvolFlags) String ¶
func (f SubvolFlags) String() string
type SubvolInfo ¶
type UsageInfo ¶
type UsageInfo struct {
Total uint64
TotalUnused uint64
TotalUsed uint64
TotalChunks uint64
FreeEstimated uint64
FreeMin uint64
LogicalDataChunks uint64
RawDataChunks uint64
RawDataUsed uint64
LogicalMetaChunks uint64
RawMetaChunks uint64
RawMetaUsed uint64
SystemUsed uint64
SystemChunks uint64
DataRatio float64
MetadataRatio float64
GlobalReserve uint64
GlobalReserveUsed uint64
}