Subject: Re: unintended consequences of ffs_dirpref()?
To: Bill Sommerfeld <sommerfeld@netbsd.org>
From: Jason R Thorpe <thorpej@zembu.com>
List: tech-kern
Date: 01/16/2001 09:11:42
On Tue, Jan 16, 2001 at 08:00:02AM -0500, Bill Sommerfeld wrote:

 > 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..
 > 
 > Herb reports that this fix indeed causes his problem to disappear.
 > 
 > now, there's one possible bad consequence of this: when a filesystem
 > gets very full, it may only have fragments left and ffs_dirpref will
 > end up returning zero all the time.
 > 
 > Thoughts?

Yes.  How about doing the loop twice -- if you don't find anything
the first time, then do it again without checking cs_nbfree.

-- 
        -- Jason R. Thorpe <thorpej@zembu.com>