Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/ufs/ffs Pull in fix from FreeBSD ffs_alloc.c r121785:



details:   https://anonhg.NetBSD.org/src/rev/d3138ff32347
branches:  trunk
changeset: 790965:d3138ff32347
user:      bad <bad%NetBSD.org@localhost>
date:      Mon Oct 28 21:32:52 2013 +0000

description:
Pull in fix from FreeBSD ffs_alloc.c r121785:
Consider only cylinder groups with at least 75% of the average free space
per cylinder group and 75% of the average free inodes per cylinder group
as candidates for the creation of a new directory.  Avoids excessive I/O
scanning for a suitable cylinder group on relatively full file systems.

Tested by sborril and me.

Pullup: netbsd-6, netbsd-5


Original commit message:

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@localhost
MFC after:      2 weeks

diffstat:

 sys/ufs/ffs/ffs_alloc.c |  21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diffs (51 lines):

diff -r 1e64c2ee9414 -r d3138ff32347 sys/ufs/ffs/ffs_alloc.c
--- a/sys/ufs/ffs/ffs_alloc.c   Mon Oct 28 20:32:14 2013 +0000
+++ b/sys/ufs/ffs/ffs_alloc.c   Mon Oct 28 21:32:52 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs_alloc.c,v 1.143 2013/10/20 00:20:53 christos Exp $ */
+/*     $NetBSD: ffs_alloc.c,v 1.144 2013/10/28 21:32:52 bad Exp $      */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.143 2013/10/20 00:20:53 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.144 2013/10/28 21:32:52 bad Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -720,14 +720,17 @@
        /*
         * Count various limits which used for
         * optimal allocation of a directory inode.
+        * Try cylinder groups with >75% avgifree and avgbfree.
+        * Avoid cylinder groups with no free blocks or inodes as that
+        * triggers an I/O-expensive cylinder group scan.
         */
        maxndir = min(avgndir + fs->fs_ipg / 16, fs->fs_ipg);
-       minifree = avgifree - fs->fs_ipg / 4;
-       if (minifree < 0)
-               minifree = 0;
-       minbfree = avgbfree - ffs_fragstoblks(fs, fs->fs_fpg) / 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 = (int64_t)fs->fs_fsize * fs->fs_fpg;
        dirsize = (int64_t)fs->fs_avgfilesize * fs->fs_avgfpdir;
        if (avgndir != 0) {
@@ -736,7 +739,7 @@
                        dirsize = curdsz;
        }
        if (cgsize < dirsize * 255)
-               maxcontigdirs = cgsize / dirsize;
+               maxcontigdirs = (avgbfree * fs->fs_bsize) / dirsize;
        else
                maxcontigdirs = 255;
        if (fs->fs_avgfpdir > 0)



Home | Main Index | Thread Index | Old Index