Re: [PATCH v4 08/19] kho: block: Add the feature header to blocks
From: David Matlack
Date: Tue Nov 10 2026 - 12:13:56 EST
On Tue Nov 10, 2026 at 5:01 AM UTC, Tarun Sahu wrote:
> Precede struct kho_block_header_ser with struct kho_ser_hdr using
> DECLARE_KHO_SER. Each block in a block set starts with struct
> kho_ser_hdr followed by struct kho_block_header_ser. Serialized entries
> start immediately after the header payload at offset fhdr->size.
This adds a feature header to every block in the set, but the layout it
describes is a property of the whole set: all blocks are written by the
same kernel with the same header.
Blocks are only ever added and removed at the tail, so the head block
is stable for the lifetime of the set. I'd put a single set-wide
header in the first block only, e.g. a struct kho_block_set_ser with
its own feature header, and keep the per-block header to next and
count.
entry_size (added in patch 2) is another set-wide property that belongs
there. All blocks in a set have the same entry size, so recording it in
every block is redundant, and restore has to check that the copies
agree.
[...]
> entry_size = ser->entry_size;
> bs->entry_size = entry_size;
> - capacity = (KHO_BLOCK_SIZE - sizeof(*ser)) / bs->entry_size;
> + capacity = (KHO_BLOCK_SIZE - fhdr->size) / bs->entry_size;
> bs->count_per_block = capacity;
Nothing checks that the blocks agree. Each block's entries start at its
own fhdr->size, and count_per_block ends up being whatever the last
block implies. With a single set-wide header this can't happen.