]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commit - tests/m_64bit_flexbg/expect.1
libext2fs: fix free block accounting for 64-bit file systems
authorTheodore Ts'o <tytso@mit.edu>
Sat, 26 Jul 2014 13:25:40 +0000 (09:25 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 26 Jul 2014 13:25:40 +0000 (09:25 -0400)
commita30a4e93f3fd51d81687de82ab96e57a3694d71c
treeef7aea678ff614b1e863212895ac4e17eb7a3351
parent1e33a8b408123a4e02a6b9135807f6fd61f3e235
libext2fs: fix free block accounting for 64-bit file systems

We rely on a nasty hack to adjust the free block count where we pass
signed value into ext2fs_free_blocks_count_add(), which takes an
64-bit unsigned value, and relies on overflow and C's signed->unsigned
semantics to do the subtraction.  This works, so long as a 64-bit
signed value is used.

Unfortunately, ext2fs_block_alloc_stats2() and
ext2fs_block_alloc_stats_range(), this is not true, so on a 64-bit
file system, the free blocks accounting can get screwed up.

A simple way to demonstrate the problem is:

mke2fs -F -t ext4 -O 64bit /tmp/foo.img 1M
e2fsck -fy /tmp/foo.img

... which will result in the following e2fsck complaint:

Pass 5: Checking group summary information
Free blocks count wrong (4294968278, counted=982).
Fix? yes

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/alloc_stats.c
tests/m_64bit_flexbg/expect.1 [new file with mode: 0644]
tests/m_64bit_flexbg/script [new file with mode: 0644]