Subject: Re: Bizarre "df" output on /dev/sd0g
To: None <port-mac68k@NetBSD.org>
From: Juliusz Chroboczek <jch@pps.jussieu.fr>
List: port-mac68k
Date: 02/24/2005 08:30:02
> FFS (v1, at least) behaves rather badly when it gets very close to full

I believe this is also true for FFSv2, which really doesn't improve
much on FFS.

> (where how close "very close" is depends on a number of factors

The below description is true in 4.4BSD; I don't know to what extent
it applies to the modern BSDs.

In order to avoid large seeks, an FFS filesystem is divided into
equal-sized chunks called /cylinder groups/.  When FFS needs to expand
a file, it first looks for contiguous space; then it looks for space
in the same cylinder group; then it does a quick search of the other
cylinder groups using some rather heuristics that are meant to avoid
``clustering'' of full cylinder groups; and finally it does an
exhaustive search of all the cylinder groups.

When a filesystem has plenty of free space, the first steps of this
search are very likely to be successful, so file allocation happens
contiguosly or at least in the same cylinder group.  When the disk is
near full, it is very likely that you'll need to search in other
cylinder groups; hence, files will get badly fragmented and allocation
takes longer.

Thus, there's no fixed point when performance degrades; as your
filesystem fills up, you get smooth degradation from the point when
all files can be expanded contiguosly, up to the point where most
allocations require an exhaustive search of all cylinder groups.
Deciding on the amount of space that you want to reserve to root
(tunefs -m) depends both on the amount of speed degradation you're
willing to accept, and the amount of disk space you're willing to give
up.

                                        Juliusz