strange values displayed by e2freefrag
Hi!
Today i run e2freefrag on ext4 partition and i saw:
Device: /dev/mapper/vg--bez--raidu-lvarchiwumnowe
Blocksize: 4096 bytes
Total blocks: 52166656
Free blocks: 57254 (0.1%)
Min. free extent: 4 KB
Max. free extent: 128120 KB
Avg. free extent: 3396 KB
HISTOGRAM OF FREE EXTENT SIZES:
Extent Size Range : Free extents Free Blocks Percent
4K... 8K- : 1500 1500 2.62%
8K... 16K- : 1566 3933 6.87%
16K... 32K- : 1112 5707 9.97%
32K... 64K- : 228 2480 4.33%
64K... 128K- : 222 5061 8.84%
128K... 256K- : 269 12364 21.59%
256K... 512K- : 307 28279 49.39%
512K... 1024K- : 487 84412 147.43%
1M... 2M- : 621 240621 420.27%
2M... 4M- : 780 574302 1003.08%
4M... 8M- : 803 1162903 2031.13%
8M... 16M- : 488 1317526 2301.19%
16M... 32M- : 312 1728598 3019.17%
32M... 64M- : 119 1269059 2216.54%
64M... 128M- : 49 1088111 1900.50%And i'm suprised when i can see so high percents, i don't know hot to interpret this values.
e2fsprogs-1.41.12
Regards!
Marcin
After reboot, values are correct:
Device: /dev/mapper/vg--bez--raidu-lvarchiwumnowe
Blocksize: 4096 bytes
Total blocks: 52166656
Free blocks: 7632537 (14.6%)
Min. free extent: 4 KB
Max. free extent: 128120 KB
Avg. free extent: 3444 KB
HISTOGRAM OF FREE EXTENT SIZES:
Extent Size Range : Free extents Free Blocks Percent
4K... 8K- : 1506 1506 0.02%
8K... 16K- : 1564 3924 0.05%
16K... 32K- : 1112 5710 0.07%
32K... 64K- : 228 2474 0.03%
64K... 128K- : 222 5058 0.07%
128K... 256K- : 266 12227 0.16%
256K... 512K- : 305 28058 0.37%
512K... 1024K- : 487 84407 1.11%
1M... 2M- : 600 232959 3.05%
2M... 4M- : 769 566341 7.42%
4M... 8M- : 790 1141959 14.96%
8M... 16M- : 499 1352032 17.71%
16M... 32M- : 337 1870576 24.51%
32M... 64M- : 126 1345245 17.63%
64M... 128M- : 44 979274 12.83%I was completly full partition, then i freed 15% space (about 30G), then i saw strange values from first post.
I can't reproduce this problem, i filled up partition, removed files and problem doesn't apper.
Regards,
Marcin
PATCH 1/1 fix strange values displayed by e2freefrag
In reply to horheQuoted 5 lines · horhe
Today i run e2freefrag on ext4 partition and i saw:
Device: /dev/mapper/vg--bez--raidu-lvarchiwumnowe Blocksize: 4096 bytes Total blocks: 52166656 Free blocks: 57254 (0.1%)
Here is the problem ^^^^^^^^^^^^^^^
Quoted 22 lines
Min. free extent: 4 KB
Max. free extent: 128120 KB
Avg. free extent: 3396 KBHISTOGRAM OF FREE EXTENT SIZES:
Extent Size Range : Free extents Free Blocks Percent 4K... 8K- : 1500 1500 2.62% 8K... 16K- : 1566 3933 6.87% 16K... 32K- : 1112 5707 9.97% 32K... 64K- : 228 2480 4.33% 64K... 128K- : 222 5061 8.84% 128K... 256K- : 269 12364 21.59% 256K... 512K- : 307 28279 49.39% 512K... 1024K- : 487 84412 147.43% 1M... 2M- : 621 240621 420.27% 2M... 4M- : 780 574302 1003.08% 4M... 8M- : 803 1162903 2031.13% 8M... 16M- : 488 1317526 2301.19% 16M... 32M- : 312 1728598 3019.17% 32M... 64M- : 119 1269059 2216.54% 64M... 128M- : 49 1088111 1900.50%
Quoted 4 lines
And I'm suprised when I can see so high percents, I don't know how to interpret this values.
I was completly full partition, then i freed 15% space (about 30G), then I saw strange values. I can't reproduce this problem, i filled up partition, removed files and problem doesn't appear.
That's because the kernel does not update the "free blocks" summary value in the superblock on disk. It only updates the per-group free blocks counters in the group descriptor table. That means the "free blocks" value read from the filesystem is totally incorrect (too low in your case) and caused the percentage to be incorrect.
For a while, when calling statfs() to get the free blocks information, it would also write out the superblock summary values. However, this confused the journal checksum code because the modification wasn't being checksummed correctly.
It is possible to change the e2freefrag code to count the number of free blocks it finds, instead of depending on the value in the superblock (which may be slightly out of date no matter how often it is updated). A patch to fix this, and to make e2freefrag work properly on filesystems with more than 2^32 free blocks, is attached.
I'd still like some way for userspace to update the superblock, or have the kernel do it periodically, so that "dumpe2fs -h" and other tools that look at the superblock are at least close instead of having values from the time of last mount.
Cheers, Andreas
misc/Makefile.in +3 -2
@@ -301,9 +301,10 @@ logsave.profiled: profiled/logsave.o $(E) " LD $@" $(Q) $(CC) $(ALL_LDFLAGS) -g -pg -o logsave.profiled profiled/logsave.o -e2freefrag: $(E2FREEFRAG_OBJS) +e2freefrag: $(E2FREEFRAG_OBJS) $(DEP_LIBSE2P) $(E) " LD $@" - $(Q) $(CC) $(ALL_LDFLAGS) -o e2freefrag $(E2FREEFRAG_OBJS) $(LIBS) + $(Q) $(CC) $(ALL_LDFLAGS) -o e2freefrag $(E2FREEFRAG_OBJS) $(LIBS) \ + $(LIBS_E2P) filefrag: $(FILEFRAG_OBJS) $(E) " LD $@"
misc/e2freefrag.c +31 -33
172 lines not on this page · raw message
misc/e2freefrag.h +11 -8
@@ -4,17 +4,20 @@#define MAX_HIST 32struct free_chunk_histogram { -unsigned long fc_chunks[MAX_HIST ]; -unsigned long fc_blocks[MAX_HIST ]; +unsigned long long fc_chunks[MAX_HIST ]; +unsigned long long fc_blocks[MAX_HIST ]; };struct chunk_info {unsigned long chunkbytes;/* chunk size in bytes */ -int chunkbits;/* chunk size in bits */ -unsigned long free_chunks;/* total free chunks of given size */ -unsigned long real_free_chunks;/* free chunks of any size */ -int blocksize_bits;/* fs blocksize in bits */ -int blks_in_chunk;/* number of blocks in a chunk */ -unsigned long min, max, avg;/* chunk size stats */ +unsigned long blks_in_chunk;/* number of blocks in a chunk */ +unsigned chunkbits;/* chunk size in bits */ +unsigned blocksize_bits;/* fs blocksize in bits */ +unsigned long long free_blocks;/* free blocks (sb is not uptodate) */ +unsigned long long free_chunks;/* total free chunks of given size */ +unsigned long long real_free_chunks;/* free chunks of any size */ +unsigned long long sum;/* sum of whole free chunk blocks */ +unsigned long min;/* minimum free chunk size (blocks) */ +unsigned long max;/* maximum free chunk size (blocks) */ struct free_chunk_histogram histogram;/* histogram of all chunk sizes*/ };
Re: [PATCH] fix strange values displayed by e2freefrag
W dniu 2010-07-30 02:03, Andreas Dilger pisze:
Quoted 7 lines
That's because the kernel does not update the "free blocks" summary value in the superblock on disk. It only updates the per-group free blocks counters in the group descriptor table. That means the "free blocks" value read from the filesystem is totally incorrect (too low in your case) and caused the percentage to be incorrect.
For a while, when calling
statfs()to get the free blocks information, it would also write out the superblock summary values. However, this confused the journal checksum code because the modification wasn't being checksummed correctly.It is possible to change the e2freefrag code to count the number of free blocks it finds, instead of depending on the value in the superblock (which may be slightly out of date no matter how often it is updated). A patch to fix this, and to make e2freefrag work properly on filesystems with more than 2^32 free blocks, is attached.
I'd still like some way for userspace to update the superblock, or have the kernel do it periodically, so that "dumpe2fs -h" and other tools that look at the superblock are at least close instead of having values from the time of last mount.
Hello!
Thank you much for explanation! Now i know how to reproduce this problem ;) I couldn't try your patch (didn't apply clean on e2fsprogs-1.41.12 , gentoo :
patching file misc/e2freefrag.c
Hunk #8 FAILED at 142.
Hunk #9 FAILED at 170. ) but i suppose is working.
Sorry for delay, i was away from keys :)
Regards!
Marcin