Whamcloud - gitweb
Properly calculate overhead in ext2fs_initialize()
authorTheodore Ts'o <tytso@mit.edu>
Sun, 22 Jul 2007 19:07:13 +0000 (15:07 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 22 Jul 2007 19:14:38 +0000 (15:14 -0400)
commit5a92a627f1e067ecfaa2478cfafeca2817cdc69f
tree716cc14d552f3e4a7fa55efd805dcde66dc7c85c
parentf54176369ee376c1a35fdaee8b42bb7997682e60
Properly calculate overhead in ext2fs_initialize()

For some odd geometries*, mkfs will try to allocate inode tables off
the end of the block group and fail, rather than warning that too
many inodes have been requested.

This is because when ext2fs_initialize calculates metadata overhead,
it is only adding in group descriptor blocks and the superblock
if the *last* bg contains them - but the first bg also has all of
the various metadata bits taking up space.

We need to calculate the overhead both for the first block group and
the last block groups separately, since the two different tests need
to know what the overheads are for those two cases, which may be
different.

*for example "mke2fs  -b 1024 -m 0 -g 256 -N 3745 fsfile 1024"

(Note, the test here is a little funky; the expected output is
actually a mkfs failure - but a proper failure instead of the
allocator catching the problem at the last minute)

Addresses-Red-Hat-Bugzilla: #241767

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ext2fs/initialize.c
tests/m_mkfs_overhead/expect.1 [new file with mode: 0644]
tests/m_mkfs_overhead/script [new file with mode: 0644]