ext4: fix journal superblock maxLen exceeding allocated blocks#365
Merged
deitch merged 1 commit intodiskfs:masterfrom Apr 3, 2026
Merged
ext4: fix journal superblock maxLen exceeding allocated blocks#365deitch merged 1 commit intodiskfs:masterfrom
deitch merged 1 commit intodiskfs:masterfrom
Conversation
When creating a filesystem larger than ~4 GB with 4096-byte blocks, journalBlocks is computed as blockCount/32 which can exceed 32768 (the number of blocks in journalMaxSize=128MB). The journal size is correctly capped to 128 MB, but the original journalBlocks value was passed to NewJournalSuperblock as maxLen. This caused e2fsck to report "journal too short" because the superblock claimed more blocks than were allocated. Recompute journalBlocks after capping journalSize so maxLen matches the actual allocation. Add TestCreateLargeFilesystemJournal which creates a 5 GB filesystem (the smallest size that triggers the bug) and validates it with e2fsck. Without the fix, e2fsck reports: e2fsck: The journal superblock is corrupt: journal too short Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Apr 2, 2026
deitch
approved these changes
Apr 3, 2026
Collaborator
deitch
left a comment
There was a problem hiding this comment.
That simple? Thanks for fixing this.
Collaborator
|
This really needs all of of |
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.
I found this while benchmarking creating 20GB ext4 disks (I'll make a separate PR for the benchmark, in case you want it!)
I'm not familiar with ext4 (yet), but Claude claims
(running regression tests with
e2fsckis very nice!)