mkfs and disk performance

Peter Brouwer pb at idca.tds.PHILIPS.nl
Fri Aug 24 17:31:43 AEST 1990


 In article <536 at fciva.FRANKLIN.COM> dag at fciva.UUCP (Daniel A. Graifer) writes:
>In article <1990Aug21.050638.15737 at cimcor.mn.org> det at cimcor.mn.org (Derek Terveer) writes:
>>I believe that he gap is the interleave on your drive.  
>I believe this is incorrect.  The interleave is the physical numbering
>modulus for sectors on your drive.  This a function of drive controller/
>format.
>
>The 'gap' is parameter of the file system, and tells the file system how
>to map 'contiguous' logical blocks of filespace to physical blocks.  Since
>the standard file system buffers reads one block at a time, proper
>gapping will cause a set of sequential reads to synchonize efficiently
>with the availability of physical blocks on the drive.

To be precise, the gap determines the way the free block space is organised.
There is a pitfall however. The gap size specified for mkfs and fsck 
is related to 512 disk sector size. The first thing mkfs and fsck does is 
determine the unix blocksize and recalculate the gap value.
So if you specify a gap of 4 for a 1024 byte block file system the logical
gap value used will be 2.

Here is an example: lets asume the gap value is 4 and there are 20 blocks.
Then the folowing sequence will be used in the free block list.
0 3 7 11 15 19 4 8 12 16 1 5 9 13 17 2 6 10 14 18

So when a file is created on the file system free block are taken in sequence
from the free block list and the file has the same gap in the block sequence
as is used in the free block list.
Now when a file is removed the blocks are put at the begin of the free block
list. This will disturb the organisation of the free block list. So if this
is going on for a lost of files with different sizes the free block lists
and the new created files get fragmented. The only way to defragment a file
system with the 'standard tools' is to copy the filesystem to a new created
file system. There are however a few 'defragment tools'. There was one 
posted on the net about a year ago. This one could would created new
files with a gap of 1.

An other approach would be to use fsck at regular intervals to recreate the
free block list. Fsck will then create a new block list with blocks in the
correct sequence. This will not defragment the already excisting files.
I have forced a fsck on each monday during the boot process of the machine.

I hope this will help to clear things up a bit.
-- 
Peter Brouwer,                # Philips Information Systems,
NET  : pb at idca.tds.philips.nl # Department SSP-P9000 Building V2,
UUCP : ....!mcsun!philapd!pb  # P.O.Box 245, 7300AE Apeldoorn, The Netherlands.
PHONE:ext [+31] [0]55 432523, # 



More information about the Comp.unix.i386 mailing list