diff options
author | Thordur I. Bjornsson <thib@cvs.openbsd.org> | 2007-09-10 20:59:01 +0000 |
---|---|---|
committer | Thordur I. Bjornsson <thib@cvs.openbsd.org> | 2007-09-10 20:59:01 +0000 |
commit | df58f470ea4ca0ee9ea2a64cb2b556f7a4176034 (patch) | |
tree | fe174c68db038e475607b8e1c55648469ccbec5f /sys/ufs/ffs/ffs_alloc.c | |
parent | e58fc146313c511c51ba88774b1dcbfe0a60f35c (diff) |
When selecting cylinder groups as candidates for new directory creation
make sure that theres a minimum amount of free blocks in that cylinder
group by tweaking the minbfree calculation. Without this, cylinder groups
with no free blocks could be chosen which resaults in expensive searches
for free blocks each time a new file is created in the directory.
Tweak the calculation of minifree (minimum free inodes) in the same
way. Also decrease the maxcontigdirs as the file system fills up to
lessen the chance of directory clusters overflowing the available
space in the cylinder group.
From FreeBSD (Rev 1.116 of sys/ufs/ffs/ffs_alloc.c);
ok miod@
Diffstat (limited to 'sys/ufs/ffs/ffs_alloc.c')
-rw-r--r-- | sys/ufs/ffs/ffs_alloc.c | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index c0fe153c52b..143a53e0ec1 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_alloc.c,v 1.78 2007/06/22 13:59:12 thib Exp $ */ +/* $OpenBSD: ffs_alloc.c,v 1.79 2007/09/10 20:59:00 thib Exp $ */ /* $NetBSD: ffs_alloc.c,v 1.11 1996/05/11 18:27:09 mycroft Exp $ */ /* @@ -926,7 +926,6 @@ ffs_dirpref(struct inode *pip) avgifree = fs->fs_cstotal.cs_nifree / fs->fs_ncg; avgbfree = fs->fs_cstotal.cs_nbfree / fs->fs_ncg; avgndir = fs->fs_cstotal.cs_ndir / fs->fs_ncg; -#if 1 /* * Force allocation in another cg if creating a first level dir. @@ -953,33 +952,25 @@ ffs_dirpref(struct inode *pip) goto end; } else prefcg = ino_to_cg(fs, pip->i_number); -#else - prefcg = ino_to_cg(fs, pip->i_number); -#endif /* * Count various limits which used for * optimal allocation of a directory inode. */ -#if 1 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; -#else - maxndir = avgndir + (fs->fs_ipg - avgndir) / 16; - minifree = avgifree * 3 / 4; - minbfree = avgbfree * 3 / 4; -#endif + 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); |