fix: set padding bits at end of inode bitmap in compactext4#2811
Open
lox wants to merge 1 commit into
Open
Conversation
ext4 convention (enforced by e2fsck) is that inode bitmap bits beyond the last real inode in the block are set to 1 so allocators never treat nonexistent inodes as free. compactext4 left these tail bits clear in every group, so e2fsck 1.47.x reports "Padding at end of inode bitmap is not set" and exits 4 on tar2ext4 output. The block bitmap already handles its analogous case (absent blocks in the last group are marked allocated); this adds the inode-bitmap equivalent. Padding bits are not counted in usedInodeCount since free-inode accounting is based on inodesPerGroup real inodes. Found by running e2fsck -f -n against tar2ext4 output with e2fsck 1.47.3. Signed-off-by: Lachlan Donald <lachlan@ljd.cc>
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
compactext4leaves the tail bits of each group's inode bitmap clear. ext4convention (enforced by e2fsck) is that bitmap bits beyond the last real inode
in the block are set to 1 so allocators never treat nonexistent inodes as
free. As a result, e2fsck 1.47.x reports on any tar2ext4 output:
and exits 4 ("filesystem still has errors"). The image is otherwise clean.
Since
bestGroupCountcommonly picks aninodesPerGroupwell belowmaxInodesPerGroup(32768), the unset padding affects every group, not justthe last. The block bitmap already handles its analogous case (blocks absent
from the disk in the last group are marked allocated); this adds the
inode-bitmap equivalent.
Padding bits are deliberately not counted in
usedInodeCount: free-inodeaccounting in the group descriptors and superblock is based on
inodesPerGroupreal inodes. e2fsck reports identical file counts before andafter this change.
Found by running
e2fsck -f -nagainst tar2ext4 output while benchmarking itagainst another ext4 writer implementation (e2fsck 1.47.3). Existing tests
didn't catch this because the
fsck()verification helper is Linux-only andthe per-block inode-bitmap padding check only appears in recent e2fsprogs.
Repro
Changes
inodesPerGrouptoBlockSize*8in every groupin
Writer.Close()TestInodeBitmapPadding, which parses the superblock and groupdescriptors from the emitted image and asserts the padding bits directly
(platform-independent, doesn't depend on the host's e2fsck version), then
runs the existing
fsck()helperCompatibility note
This changes the emitted image bytes. Images remain deterministic (the
existing tar2ext4 determinism test passes), but dm-verity root hashes
computed over newly generated images will differ from those of images
generated before this change.