Skip to content

Instantly share code, notes, and snippets.

@ronin13
Created April 29, 2015 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ronin13/9cec3aa3cfae86bb7348 to your computer and use it in GitHub Desktop.
Save ronin13/9cec3aa3cfae86bb7348 to your computer and use it in GitHub Desktop.
Effects of hole punching on fragmentation and size (on XFS)
dd if=/dev/urandom of=abc.ibd bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 10.5109 s, 10.0 MB/s
dd if=/dev/urandom of=abc.ibd bs=1M count=100 0.00s user 10.48s system 99% cpu 10.512 total
filefrag -v abc.ibd
Filesystem type is: 58465342
File size of abc.ibd is 104857600 (25600 blocks of 4096 bytes)
ext: logical_offset: physical_offset: length: expected: flags:
0: 0.. 8175: 2426211.. 2434386: 8176:
1: 8176.. 25599: 0.. 17423: 17424: 2434387: last,unknown_loc,delalloc,eof
abc.ibd: 2 extents found
fallocate -p -o 10M -l 4k abc.ibd
fallocate -p -o 20M -l 4k abc.ibd
fallocate -p -o 30M -l 4k abc.ibd
fallocate -p -o 40M -l 4k abc.ibd
fallocate -p -o 5M -l 4k abc.ibd
fallocate -p -o 75M -l 4k abc.ibd
(/var/A)~10:33-0
filefrag -v abc.ibd
Filesystem type is: 58465342
File size of abc.ibd is 104857600 (25600 blocks of 4096 bytes)
ext: logical_offset: physical_offset: length: expected: flags:
0: 0.. 1279: 2426211.. 2427490: 1280:
1: 1281.. 2559: 2427492.. 2428770: 1279: 2427491:
2: 2561.. 5119: 2428772.. 2431330: 2559: 2428771:
3: 5121.. 7679: 2431332.. 2433890: 2559: 2431331:
4: 7681.. 8175: 2433892.. 2434386: 495: 2433891:
5: 8176.. 10239: 2377024.. 2379087: 2064: 2434387:
6: 10241.. 19199: 2379089.. 2388047: 8959: 2379088:
7: 19201.. 25599: 2388049.. 2394447: 6399: 2388048: last,eof
abc.ibd: 8 extents found
ls -lash abc.ibd
100M -rw-r--r-- 1 raghu raghu 100M Apr 29 10:33 abc.ibd
fallocate -p -o 80M -l 5M abc.ibd
ls -lash abc.ibd
95M -rw-r--r-- 1 raghu raghu 100M Apr 29 10:35 abc.ibd
filefrag -v abc.ibd
Filesystem type is: 58465342
File size of abc.ibd is 104857600 (25600 blocks of 4096 bytes)
ext: logical_offset: physical_offset: length: expected: flags:
0: 0.. 1279: 2426211.. 2427490: 1280:
1: 1281.. 2559: 2427492.. 2428770: 1279: 2427491:
2: 2561.. 5119: 2428772.. 2431330: 2559: 2428771:
3: 5121.. 7679: 2431332.. 2433890: 2559: 2431331:
4: 7681.. 8175: 2433892.. 2434386: 495: 2433891:
5: 8176.. 10239: 2377024.. 2379087: 2064: 2434387:
6: 10241.. 19199: 2379089.. 2388047: 8959: 2379088:
7: 19201.. 20479: 2388049.. 2389327: 1279: 2388048:
8: 21760.. 25599: 2390608.. 2394447: 3840: 2389328: last,eof
abc.ibd: 9 extents found
xfs_bmap -v abc.ibd
abc.ibd:
EXT: FILE-OFFSET BLOCK-RANGE AG AG-OFFSET TOTAL
0: [0..10239]: 19409688..19419927 3 (535320..545559) 10240
1: [10240..10247]: hole 8
2: [10248..20479]: 19419936..19430167 3 (545568..555799) 10232
3: [20480..20487]: hole 8
4: [20488..40959]: 19430176..19450647 3 (555808..576279) 20472
5: [40960..40967]: hole 8
6: [40968..61439]: 19450656..19471127 3 (576288..596759) 20472
7: [61440..61447]: hole 8
8: [61448..65407]: 19471136..19475095 3 (596768..600727) 3960
9: [65408..81919]: 19016192..19032703 3 (141824..158335) 16512
10: [81920..81927]: hole 8
11: [81928..153599]: 19032712..19104383 3 (158344..230015) 71672
12: [153600..153607]: hole 8
13: [153608..163839]: 19104392..19114623 3 (230024..240255) 10232
14: [163840..174079]: hole 10240
15: [174080..204799]: 19124864..19155583 3 (250496..281215) 30720
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment