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
flagsword at offset 84.
Structs§
- Checkpoint
Entry - 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.