Subject: Re: Why my life is sucking.
To: enami tsugutomo <enami@sm.sony.co.jp>
From: Bill Sommerfeld <sommerfeld@orchard.arlington.ma.us>
List: current-users
Date: 01/16/2001 00:42:41
> As far as reading the source, 3687+7io is 3687 read and 7 write.

So, there's one thing which mkdir() does in ffs which is different
from other sorts of file creation... it tries to put the directory in
a different cylinder group from the one it's parent lives in..

I think what's going on here is that ffs_dirpref() may be screwing up
and always picking an initial cylinder group with few directories,
lots of free inodes..  but no free blocks.. so it winds up hunting all
over the disk for free blocks before it finds one for the directory.

I'm willing to bet that the extra level of indirection required for
mirroring is causing the "hunt" for free blocks to no longer fit into
the buffer cache.

So, the core of ffs_dirpref() in sys/ufs/ffs/ffs_alloc.c is:

        for (cg = 0; cg < fs->fs_ncg; cg++)
                if (fs->fs_cs(fs, cg).cs_ndir < minndir &&
                    fs->fs_cs(fs, cg).cs_nifree >= avgifree) {
                        mincg = cg;
                        minndir = fs->fs_cs(fs, cg).cs_ndir;
                }

maybe it should be something more like:

        for (cg = 0; cg < fs->fs_ncg; cg++)
                if (fs->fs_cs(fs, cg).cs_ndir < minndir &&
		    fs->fs_cs(fs, cg).cs_nbfree > 0 &&		
                    fs->fs_cs(fs, cg).cs_nifree >= avgifree) {
                        mincg = cg;
                        minndir = fs->fs_cs(fs, cg).cs_ndir;
                }

.. but I must admit I'm not an expert on ffs guts..

					- Bill