Skip to content

ext4: fix wrong span for an internal node's last child - #420

Merged
deitch merged 1 commit into
diskfs:masterfrom
austinvazquez:fix/ext4-internal-node-child-count
Aug 3, 2026
Merged

ext4: fix wrong span for an internal node's last child#420
deitch merged 1 commit into
diskfs:masterfrom
austinvazquez:fix/ext4-internal-node-child-count

Conversation

@austinvazquez

Copy link
Copy Markdown
Contributor

extentInternalNode.findBlocks and .blocks() called parseExtents with an inclusive end block in its count argument, but parseExtents' internal-node branch treats that argument as an actual count (start+count marks one past the end) when deriving the span of a node's last child -- real ext4 index entries don't store a count on disk, so the last entry's span has to come from the caller. The mismatch silently dropped the final file block of any range reaching the last child of a node loaded this way.

.blocks() reads were unaffected in practice: leaf-node parsing ignores the start/count arguments entirely, so a wrong count only mattered when it was also passed down to a child's own findBlocks call. findBlocks itself isn't wired up to any current caller, so this had no observable effect until something exercises it directly (e.g. a range read added on top of the existing full-file read path).

Pass the child's actual count instead of computing an end block, matching the one caller (loadChildNode) that already did this correctly.

extentInternalNode.findBlocks and .blocks() called parseExtents with an
inclusive end block in its count argument, but parseExtents' internal-node
branch treats that argument as an actual count (start+count marks one past
the end) when deriving the span of a node's last child -- real ext4 index
entries don't store a count on disk, so the last entry's span has to come
from the caller. The mismatch silently dropped the final file block of any
range reaching the last child of a node loaded this way.

.blocks() reads were unaffected in practice: leaf-node parsing ignores the
start/count arguments entirely, so a wrong count only mattered when it was
also passed down to a child's own findBlocks call. findBlocks itself isn't
wired up to any current caller, so this had no observable effect until
something exercises it directly (e.g. a range read added on top of the
existing full-file read path).

Pass the child's actual count instead of computing an end block, matching
the one caller (loadChildNode) that already did this correctly.

Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>

@deitch deitch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch.

@deitch
deitch merged commit 36bae97 into diskfs:master Aug 3, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants