sign

package
v3.0.0-rc67 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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

View Source
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")
)
View Source
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 EnsureSignature(path string) (bool, error)

func MinSize

func MinSize(maxSlots, nodes int) int64

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 VerifyHeader(block []byte) error

func Wipe

func Wipe(path string, maxSlots int) error

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 Header struct {
	Signature [8]byte
	Version   uint32
	BlockSize uint32
	SlotSize  uint32
	UUID      [16]byte
}

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.

Jump to

Keyboard shortcuts

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