Skip to main content

Module superblock

Module superblock 

Source
Expand description

The superblock, its two slots, the run length encoded shard table and the per shard checkpoint entries.

07 sections 2 and 3. The superblock is the only thing in the file that is overwritten in place, which is why there are two of them and why the choice between them is a sequence number guarded by a checksum. Everything else in a .yo file is append only.

One thing worth stating because it is easy to get wrong: the slot checksum covers all 16380 bytes before it, which means the shard table and the checkpoint entries are inside it. So the order is always write the header, write the table, write the entries, then seal, and only then hand the 16 KiB to the kernel.

Modules§

superblock_flags
The flags word at offset 84.

Structs§

CheckpointEntry
One shard’s position in its log, as of the last checkpoint.
Superblock
The header half of a superblock slot, decoded.

Constants§

CHECKPOINT_ENTRY_LEN
A per shard checkpoint entry, in bytes.
CRC_OFFSET
Where the checksum lives, and therefore how much of the slot it covers.
DEFAULT_SHARD_TABLE_OFF
The default offset of the shard table, which is the end of the header.

Functions§

decode_shard_table
Expands a run length encoded shard table into out.
encode_shard_table
Run length encodes a slot to shard mapping into out.
pick
Picks the live slot out of the two.
seal
Computes the slot checksum, stores it, and returns it.