Whamcloud - gitweb
e2freefrag: print 64bit free blocks count
authorKazuya Mio <k-mio@sx.jp.nec.com>
Tue, 5 Dec 2017 00:15:38 +0000 (00:15 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 5 Dec 2017 03:17:51 +0000 (22:17 -0500)
e2freefrag prints incorrect free blocks count when the number of free blocks
is larger than 2^32.
To fix this problem, e2freefrag uses ext2fs_free_blocks_count(),
not fs->super->s_free_blocks_count.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/e2freefrag.c

index 90acb7e..8d805a0 100644 (file)
@@ -154,9 +154,10 @@ static errcode_t get_chunk_info(ext2_filsys fs, struct chunk_info *info,
 
        scan_block_bitmap(fs, info);
 
-       fprintf(f, "Total blocks: %llu\nFree blocks: %u (%0.1f%%)\n",
-               ext2fs_blocks_count(fs->super), fs->super->s_free_blocks_count,
-               (double)fs->super->s_free_blocks_count * 100 /
+       fprintf(f, "Total blocks: %llu\nFree blocks: %llu (%0.1f%%)\n",
+               ext2fs_blocks_count(fs->super),
+               ext2fs_free_blocks_count(fs->super),
+               (double)ext2fs_free_blocks_count(fs->super) * 100 /
                ext2fs_blocks_count(fs->super));
 
        if (info->chunkbytes) {
@@ -200,7 +201,7 @@ static errcode_t get_chunk_info(ext2_filsys fs, struct chunk_info *info,
                                info->histogram.fc_chunks[i],
                                info->histogram.fc_blocks[i],
                                (double)info->histogram.fc_blocks[i] * 100 /
-                               fs->super->s_free_blocks_count);
+                               ext2fs_free_blocks_count(fs->super));
                }
                start = end;
                if (start == 1<<10) {