Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Jun 1996 23:33:50 GMT
From:      James Raynard <fqueries@jraynard.demon.co.uk>
To:        gpalmer@FreeBSD.ORG
Cc:        valtech@caribnet.net, terry@lambert.org, questions@FreeBSD.ORG
Subject:   Re: defrags
Message-ID:  <199606162333.XAA00571@jraynard.demon.co.uk>
In-Reply-To: <21696.834938615@palmer.demon.co.uk> (message from Gary Palmer on Sun, 16 Jun 1996 16:23:35 %2B0100)

next in thread | previous in thread | raw e-mail | index | archive | help
> > You guys said I shouldn't worry about the 0.7% but its now
> > 0.9% and increasing each time I shutdown the software down
> > and restart.
> 
> This is because you are using more disk space, no doubt ... I REALLY
> wouldn't worry. I think you are getting confused between DOS
> fragmentation and FFS fragmentation ...

It's unfortunate that they use the same word is used for rather
different things.

DOS fragmentation means that a file is split into parts because DOS
wasn't intelligent enough to work out how to write it as a single,
contiguous file.

FFS fragmentation means that, instead of being wasted, unused space in
a block is used for storing small files, which would otherwise need a
block of their own and waste even more space. Let's look at an
example:-

Suppose we have to write two files. File A is 15360 bytes long and
file B 512 bytes. Blocks are normally 4096 bytes on FFF, so file A
needs four blocks to be stored - three full blocks and 3072 bytes of
the fourth block.

Now without fragmentation, the other 1024 bytes in the fourth block
would be wasted. The file B would have to go in a block of its own,
using only 512 out of the 4096 bytes available. By my arithmetic, that
makes five blocks in use, of which 4608 bytes are wasted.

Block:    1      2      3      4       5
       ------ ------ ------ ------  ------
       |XXXX| |XXXX| |XXXX| |XXX |  |X   |
       |XXXX| |XXXX| |XXXX| |XXX |  |X   |
       |XXXX| |XXXX| |XXXX| |XXX |  |    |
       |XXXX| |XXXX| |XXXX| |XXX |  |    |
       -----  ------ ------ ------  ------
         File A is stored here      File B

However, if we allow fragmentation, we can put file B in the spare
bytes at the end of the fourth block:-

Block:   1      2      3      4
       ------ ------ ------ ------
       |XXXX| |XXXX| |XXXX| |XXXX|
       |XXXX| |XXXX| |XXXX| |XXXX|
       |XXXX| |XXXX| |XXXX| |XXX |
       |XXXX| |XXXX| |XXXX| |XXX |
       -----  ------ ------ ------
         File A is stored here  |
                                |--------- File B goes in the free
                                           space at the end of block 4

Now we're using four blocks, instead of five, and the wasted space is
only 512 bytes. If we can find another 512 byte file to put in it,
even that space doesn't have to be wasted!

Hope this helps.

-- 
James Raynard, Edinburgh, Scotland
james@jraynard.demon.co.uk



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199606162333.XAA00571>