summaryrefslogtreecommitdiffstats
path: root/sys/ufs
diff options
context:
space:
mode:
authortruckman <truckman@FreeBSD.org>2003-10-31 07:25:06 +0000
committertruckman <truckman@FreeBSD.org>2003-10-31 07:25:06 +0000
commita0e6a8adf88add3099981d0aeb9715120e59e5ff (patch)
tree9fa0604addbcf5b9594e420fb8afafc2cfa64657 /sys/ufs
parentbe1f9cb5027c840f6e192245618e1a2c74c50a89 (diff)
downloadFreeBSD-src-a0e6a8adf88add3099981d0aeb9715120e59e5ff.zip
FreeBSD-src-a0e6a8adf88add3099981d0aeb9715120e59e5ff.tar.gz
Tweak the calculation of minbfree in ffs_dirpref() so that only
those cylinder groups that have at least 75% of the average free space per cylinder group for that file system are considered as candidates for the creation of a new directory. The previous formula for minbfree would set it to zero if the file system was more than 75% full, which allowed cylinder groups with no free space at all to be chosen as candidates for directory creation, which resulted in an expensive search for free blocks for each file that was subsequently created in that directory. Modify the calculation of minifree in the same way. Decrease maxcontigdirs as the file system fills to decrease the likelyhood that a cluster of directories will overflow the available space in a cylinder group. Reviewed by: mckusick Tested by: kmarx@vicor.com MFC after: 2 weeks
Diffstat (limited to 'sys/ufs')
-rw-r--r--sys/ufs/ffs/ffs_alloc.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c
index 288050c..15b81dc 100644
--- a/sys/ufs/ffs/ffs_alloc.c
+++ b/sys/ufs/ffs/ffs_alloc.c
@@ -954,18 +954,18 @@ ffs_dirpref(pip)
* optimal allocation of a directory inode.
*/
maxndir = min(avgndir + fs->fs_ipg / 16, fs->fs_ipg);
- minifree = avgifree - fs->fs_ipg / 4;
- if (minifree < 0)
- minifree = 0;
- minbfree = avgbfree - fs->fs_fpg / fs->fs_frag / 4;
- if (minbfree < 0)
- minbfree = 0;
+ minifree = avgifree - avgifree / 4;
+ if (minifree < 1)
+ minifree = 1;
+ minbfree = avgbfree - avgbfree / 4;
+ if (minbfree < 1)
+ minbfree = 1;
cgsize = fs->fs_fsize * fs->fs_fpg;
dirsize = fs->fs_avgfilesize * fs->fs_avgfpdir;
curdirsize = avgndir ? (cgsize - avgbfree * fs->fs_bsize) / avgndir : 0;
if (dirsize < curdirsize)
dirsize = curdirsize;
- maxcontigdirs = min(cgsize / dirsize, 255);
+ maxcontigdirs = min((avgbfree * fs->fs_bsize) / dirsize, 255);
if (fs->fs_avgfpdir > 0)
maxcontigdirs = min(maxcontigdirs,
fs->fs_ipg / fs->fs_avgfpdir);
OpenPOWER on IntegriCloud