Struct PageBaseHeader
The fixed 16-byte header at the start of every storage page: role flags, block type, format/change revisions, a CRC32C checksum, and a seqlock-style modification counter for torn-page detection. Laid out sequentially with 4-byte packing and kept at exactly 16 bytes so page-layout offsets stay stable.
public struct PageBaseHeader
- Inherited Members
Fields
ChangeRevision
The Change Revision is incremented every time the Page is written to disk.
public int ChangeRevision
Field Value
Flags
Combination of one to many flags
public PageBlockFlags Flags
Field Value
FormatRevision
Revision number specific to the Page Block Type, to support basic versioning.
public short FormatRevision
Field Value
ModificationCounter
Seqlock-style modification counter for torn-page detection. Even values indicate the page is quiescent; odd values indicate an in-progress modification. Readers compare before/after to detect torn writes.
public int ModificationCounter
Field Value
Offset
Byte offset of this header within a page — always 0 (the header sits at the page start).
public static readonly int Offset
Field Value
PageChecksum
CRC32C checksum of the page contents, excluding this field itself.
Zero is the sentinel for a page that has not yet been checksummed.
Computed via Crc32CUtil.ComputeSkipping(pageSpan, PageChecksumOffset, PageChecksumSize).
public uint PageChecksum
Field Value
PageChecksumOffset
Byte offset of PageChecksum within the page header.
public const int PageChecksumOffset = 8
Field Value
PageChecksumSize
Size in bytes of PageChecksum (for CRC skip region).
public const int PageChecksumSize = 4
Field Value
PairGenerationOffset
Byte offset of the A/B slot-pairing generation counter (CK-05). 0 = "not a pair slot" (every normal page).
Protected pages (the meta pair; segment-directory twins in C2) stamp a monotonic ulong here; the
higher valid generation among a pair's two slots is the current one. CRC-covered (it is outside the 8–11 skip region).
The offset is 40 — the first 8-aligned slot free on every page type, which CK-05 requires (the same
offset is read/written uniformly regardless of what header the page otherwise carries). The page header zone packs:
[0,16) PageBaseHeader; [16,32) LogicalSegmentHeader on a directory page (so offsets
16–31 are NOT free there — they are the directory's map/raw chain pointers + kind + twin index); [32,36)
ChunkBasedSegmentHeader on a chunk-segment directory page. The intersection of the free regions — meta
[16,64), plain-dir [32,64), chunk-dir [36,64) — first hits an 8-aligned slot at 40. Accessed by
offset rather than a struct field so sizeof(PageBaseHeader) stays 16 and no dependent layout shifts.
public const int PairGenerationOffset = 40
Field Value
Size
Size of the header in bytes.
public static readonly int Size
Field Value
Type
Block Type
public PageBlockType Type
Field Value
Methods
ReadPairGeneration(ReadOnlySpan<byte>)
Reads the CK-05 pair generation (PairGenerationOffset) from a page image.
public static ulong ReadPairGeneration(ReadOnlySpan<byte> page)
Parameters
pageReadOnlySpan<byte>
Returns
WritePairGeneration(Span<byte>, ulong)
Writes the CK-05 pair generation (PairGenerationOffset) into a page image.
public static void WritePairGeneration(Span<byte> page, ulong generation)