--- ./misc/e2freefrag.c 2009-07-23 11:02:38.000000000 -0600 +++ ./misc/e2freefrag.c.new 2009-07-23 10:52:22.000000000 -0600 @@ -60,8 +60,10 @@ void init_chunk_info(ext2_filsys fs, str info->max = info->avg = 0; info->real_free_chunks = 0; - for (i = 0; i < MAX_HIST; i++) - info->histogram.fc_buckets[i] = 0; + for (i = 0; i < MAX_HIST; i++) { + info->histogram.fc_chunks[i] = 0; + info->histogram.fc_blocks[i] = 0; + } } void scan_block_bitmap(ext2_filsys fs, struct chunk_info *info) @@ -101,7 +103,9 @@ void scan_block_bitmap(ext2_filsys fs, s unsigned long index; index = ul_log2(last_chunk_size) + 1; - info->histogram.fc_buckets[index]++; + info->histogram.fc_chunks[index]++; + info->histogram.fc_blocks[index] += + last_chunk_size; if (last_chunk_size > info->max) info->max = last_chunk_size; @@ -137,7 +141,7 @@ errcode_t get_chunk_info(ext2_filsys fs, printf("\nChunksize: %u bytes (%u blocks)\n", info->chunkbytes, info->blks_in_chunk); total_chunks = (fs->super->s_blocks_count + info->blks_in_chunk) >> - (info->chunkbits - info->blocksize_bits); + (info->chunkbits - info->blocksize_bits); printf("Total chunks: %lu\nFree chunks: %lu (%0.1f%%)\n", total_chunks, info->free_chunks, (double)info->free_chunks * 100 / total_chunks); @@ -156,12 +160,17 @@ errcode_t get_chunk_info(ext2_filsys fs, "Avg free chunk: %lu KB\n", info->min, info->max, info->avg); printf("\nHISTOGRAM OF FREE CHUNK SIZES:\n"); - printf("%15s\t\t%10s\n", "Range", "Free chunks"); + printf("%s : %12s %12s %7s\n", "Chunk Size Range", "Free chunks", + "Free Blocks", "Percent"); for (i = 0; i < MAX_HIST; i++) { end = 1 << (i + info->blocksize_bits - units); - if (info->histogram.fc_buckets[i] != 0) - printf("%5lu%c...%5lu%c- : %10lu\n", start, *unitp, - end, *unitp, info->histogram.fc_buckets[i]); + if (info->histogram.fc_chunks[i] != 0) + printf("%5lu%c...%5lu%c- : %12lu %12lu %6.1f%%\n", + start, *unitp, end, *unitp, + info->histogram.fc_chunks[i], + info->histogram.fc_blocks[i], + (double)info->histogram.fc_blocks[i] * 100 / + fs->super->s_free_blocks_count); start = end; if (start == 1<<10) { start = 1; --- ./misc/e2freefrag.h 2009-07-23 11:02:38.000000000 -0600 +++ ./misc/e2freefrag.h.new 2009-07-23 10:52:26.000000000 -0600 @@ -4,7 +4,8 @@ #define MAX_HIST 32 struct free_chunk_histogram { - unsigned long fc_buckets[MAX_HIST]; + unsigned long fc_chunks[MAX_HIST]; + unsigned long fc_blocks[MAX_HIST]; }; struct chunk_info { --- ./misc/e2freefrag.8.in 2009-07-23 11:02:38.000000000 -0600 +++ ./misc/e2freefrag.8.in.new 2009-07-23 11:05:13.000000000 -0600 @@ -44,53 +44,53 @@ is specified on the command line, then t .br Blocksize: 4096 bytes .br -Total blocks: 5120710 +Total blocks: 1504085 .br -Free blocks: 831744 (16.2%) +Free blocks: 292995 (19.5%) .br Chunk size: 1048576 bytes (256 blocks) .br -Total chunks: 20003 +Total chunks: 5876 .br -Free chunks: 2174 (10.9%) +Free chunks: 463 (7.9%) .br Min free chunk: 4 KB .br -Max free chunk: 24576 KB +Max free chunk: 24008 KB .br -Avg. free chunk: 340 KB +Avg free chunk: 252 KB .br HISTOGRAM OF FREE CHUNK SIZES: .br - Range Free chunks +Chunk Size Range : Free chunks Free Blocks Percent .br - 4K... 8K- : 2824 + 4K... 8K- : 704 704 0.2% .br - 8K... 16K- : 1760 + 8K... 16K- : 810 1979 0.7% .br - 16K... 32K- : 1857 + 16K... 32K- : 843 4467 1.5% .br - 32K... 64K- : 1003 + 32K... 64K- : 579 6263 2.1% .br - 64K... 128K- : 616 + 64K... 128K- : 493 11067 3.8% .br - 128K... 256K- : 479 + 128K... 256K- : 394 18097 6.2% .br - 256K... 512K- : 302 + 256K... 512K- : 281 25477 8.7% .br - 512K... 1024K- : 238 + 512K... 1024K- : 253 44914 15.3% .br - 1M... 2M- : 213 + 1M... 2M- : 143 51897 17.7% .br - 2M... 4M- : 173 + 2M... 4M- : 73 50683 17.3% .br - 4M... 8M- : 287 + 4M... 8M- : 37 52417 17.9% .br - 8M... 16M- : 4 + 8M... 16M- : 7 19028 6.5% .br - 16M... 32M- : 1 + 16M... 32M- : 1 6002 2.0% .SH AUTHOR This version of e2freefrag was written by Rupesh Thakare, and modified by Andreas Dilger , and Kalpak Shah.