Documentation
¶
Index ¶
Constants ¶
const ( // PageSize is the directio block size PageSize = directio.BlockSize // PageSizeInt64 is the int64 conversion of directio block size PageSizeInt64 = int64(directio.BlockSize) // Introduce a constant for int64 conversion of PageSize HBDiskSignature = "\x3d\xc1\x3c\x87\xc0\x5b\xe3\xb6" HBDiskVersion = 1 HBCrcOffset = 0 HBMagicOffset = HBCrcOffset + 4 HBVersionOffset = HBMagicOffset + len(HBDiskSignature) HBPageSizeOffset = HBVersionOffset + 4 HBSlotSizeOffset = HBPageSizeOffset + 4 HBUUIDOffset = HBSlotSizeOffset + 4 HBHeaderSize = HBUUIDOffset + 16 )
Variables ¶
var ( // SlotSize is the data size reserved for a single node SlotSize = 1024 * 1024 SlotSizeInt64 = int64(SlotSize) CRC32CTable = crc32.MakeTable(crc32.Castagnoli) ErrWrongSignature = errors.New("wrong signature") ErrLegacySignature = errors.New("legacy signature format detected") ErrChecksumMismatch = errors.New("checksum mismatch") ErrBlockTooSmall = errors.New("block size too small for heartbeat disk header") )
var ( // ErrForeignSignature is the error of a sign refused on a disk // holding a signature not of a heartbeat. ErrForeignSignature = errors.New("the disk holds a signature not of a heartbeat") // ErrNotProbed is the error of a sign refused on a disk no tool could // tell the signatures of, blkid not installed: the sign would erase // what it holds unseen. ErrNotProbed = errors.New("the signatures of the disk can not be read") // ErrTooSmall is the error of a sign refused on a disk too small for // the slots of the heartbeat. ErrTooSmall = errors.New("the disk is too small for the heartbeat") )
Functions ¶
func EnsureSignature ¶
func MinSize ¶
MinSize returns the size of a disk heartbeat of maxSlots slots for nodes nodes: the metadata area, a page per slot, then a data slot per node after the unused slot 0.
func Sign ¶
func Sign(path string, opts SignOptions) error
Sign writes the heartbeat header on the disk at path, and returns once the disk holds it.
A disk with no heartbeat header, never a heartbeat disk or wiped, gets its metadata area zeroed first: the nodes take a page whose first byte is zero as a free slot, and on a disk holding what it held before, as a filesystem, they claimed slots past the end of the disk and never beat. Such a disk holding a signature, as a filesystem, is refused unless forced, as the sign erases opts.MaxSlots pages of it.
A disk with a heartbeat header, valid, of the earlier format, or damaged, keeps its metadata: the slots of the nodes, and of the other clusters sharing it.
func VerifyHeader ¶
func Wipe ¶
Wipe erases the heartbeat header of the disk at path, then its metadata area of maxSlots pages, and returns once the disk no longer holds them.
The header goes first, so the streams suspend before their slots go. The metadata goes too, so a sign after the wipe starts from free slots, as it does on a disk never signed.
Types ¶
type SignOptions ¶
type SignOptions struct {
// MaxSlots is the number of pages of the metadata area of the disk,
// the header the first, which the slots of the nodes follow: the
// max_slots of the heartbeat.
MaxSlots int
// MinSize is the size a disk smaller than is refused, zero for no
// check: the metadata area and a data slot per node, plus the unused
// slot 0.
MinSize int64
// Force signs a disk holding a signature, as a filesystem or a lvm
// physical volume, that is not of a heartbeat.
Force bool
}
SignOptions tells Sign how to sign a disk.