Support partial last EXT4 block group - #717
Conversation
dd22578 to
5c0fe36
Compare
|
@wlan0 |
|
@zeel2104 thanks for the PR! I think this still has an edge-case layout bug for very short final groups. The new code allows any non-zero remainder in the final block group, but this loop still places the added group’s bitmap blocks at: For the 160 MiB case the final group has 8192 blocks, so this is fine. But for a size like Could we either:
Please add a regression test around the boundary, e.g. |
wlan0
left a comment
There was a problem hiding this comment.
There is still a layout bug
There was a problem hiding this comment.
Thank you for the contribution!
Below are the test results across the size/content matrix, cross-checked with e2fsck:
Requested Size: 32KiB
Content: none
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 64MiB
Content: none
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 128MiB
Content: none
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 128MiB+4KiB
Content: none
Size: FAIL
audit.imageSize == audit.blocksCount * 4.kib() = false; audit.imageSize = 136323072; audit.blocksCount * 4.kib() = 134221824
audit.imageSize == testCase.requested = false; audit.imageSize = 136323072; testCase.requested = 134221824
e2fsck: FAIL rc=8
ext2fs_check_desc: Corrupt group descriptor: bad block for block bitmap
Note: if several inode or block bitmap blocks or part
of the inode table require relocation, you may wish to try
may lie only with the primary block group descriptors, and
----------------------------------------
Requested Size: 130MiB+8KiB
Content: none
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 160MiB
Content: none
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 256MiB
Content: none
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 1GiB
Content: none
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 4GiB
Content: none
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 63x128MiB
Content: none
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 63x128MiB+4KiB
Content: none
Size: FAIL
audit.imageSize == audit.blocksCount * 4.kib() = false; audit.imageSize = 8457822208; audit.blocksCount * 4.kib() = 8455720960
audit.imageSize == testCase.requested = false; audit.imageSize = 8457822208; testCase.requested = 8455720960
e2fsck: FAIL rc=8
ext2fs_check_desc: Corrupt group descriptor: bad block for block bitmap
Note: if several inode or block bitmap blocks or part
of the inode table require relocation, you may wish to try
may lie only with the primary block group descriptors, and
----------------------------------------
Requested Size: 8GiB
Content: none
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 16GiB
Content: none
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 160MiB
Content: 10MiB
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 128MiB
Content: 50MiB
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 160MiB
Content: 120MiB
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 160MiB
Content: 124MiB
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 160MiB
Content: 126MiB
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 256MiB
Content: 130MiB
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 1GiB
Content: 200MiB
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 300MiB
Content: 260MiB
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 4GiB
Content: 260MiB
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 63x128MiB
Content: 500MiB
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 8GiB
Content: 300MiB
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 16GiB
Content: 1000MiB
Size: PASS
e2fsck: PASS
----------------------------------------
Summary
Fixes #647 by supporting a partial final EXT4 block group.
The formatter previously rounded filesystem sizes up to the next block group boundary, so a requested 160 MiB filesystem became 256 MiB. This change keeps the requested size, reports the actual filesystem block count, and marks blocks outside a short final group as used in the bitmap without counting them as filesystem blocks.
Testing
swift test --filter ContainerizationEXT4Tests