Skip to content

[Bug]: Support a partial last block group to avoid expanding the EXT4 filesystem size #647

Description

@dkovba

I have done the following

  • I have searched the existing issues
  • If possible, I've reproduced the issue using the 'main' branch of this project

Steps to reproduce

Create an EXT4 filesystem with 160 MiB:

container volume create -s 160M size-test
stat -f%z ~/Library/Application\ Support/com.apple.container/volumes/size-test/volume.img

Current behavior

When creating an EXT4 filesystem, the requested size is expanded to the nearest block group boundary. A filesystem whose requested size falls between two block group boundaries ends up larger than requested - 256 MiB:

268435456

Expected behavior

The fix is to support a partial last block group so the filesystem uses exactly the requested size - 160 MiB:

167772160

Environment

N/A

Relevant log output

Test results across the size/content matrix, cross-checked with e2fsck:

Requested Size: 32KiB
Content: none
Size: FAIL
audit.imageSize == testCase.requested = false; audit.imageSize = 134217728; testCase.requested = 32768
e2fsck: PASS
----------------------------------------
Requested Size: 64MiB
Content: none
Size: FAIL
audit.imageSize == testCase.requested = false; audit.imageSize = 134217728; testCase.requested = 67108864
e2fsck: PASS
----------------------------------------
Requested Size: 128MiB
Content: none
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 128MiB+4KiB
Content: none
Size: FAIL
audit.imageSize == testCase.requested = false; audit.imageSize = 268435456; testCase.requested = 134221824
e2fsck: PASS
----------------------------------------
Requested Size: 130MiB+8KiB
Content: none
Size: FAIL
audit.imageSize == testCase.requested = false; audit.imageSize = 268435456; testCase.requested = 136323072
e2fsck: PASS
----------------------------------------
Requested Size: 160MiB
Content: none
Size: FAIL
audit.imageSize == testCase.requested = false; audit.imageSize = 268435456; testCase.requested = 167772160
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 == testCase.requested = false; audit.imageSize = 8589934592; testCase.requested = 8455720960
e2fsck: PASS
----------------------------------------
Requested Size: 8GiB
Content: none
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 16GiB
Content: none
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 160MiB
Content: 10MiB
Size: FAIL
audit.imageSize == testCase.requested = false; audit.imageSize = 268435456; testCase.requested = 167772160
e2fsck: PASS
----------------------------------------
Requested Size: 128MiB
Content: 50MiB
Size: PASS
e2fsck: PASS
----------------------------------------
Requested Size: 160MiB
Content: 120MiB
Size: FAIL
audit.imageSize == testCase.requested = false; audit.imageSize = 268435456; testCase.requested = 167772160
e2fsck: PASS
----------------------------------------
Requested Size: 160MiB
Content: 124MiB
Size: FAIL
audit.imageSize == testCase.requested = false; audit.imageSize = 268435456; testCase.requested = 167772160
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: FAIL
audit.imageSize == testCase.requested = false; audit.imageSize = 402653184; testCase.requested = 314572800
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
----------------------------------------

Code of Conduct

  • I agree to follow this project's Code of Conduct

Related to #640.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions