Module Name:    src
Committed By:   sborrill
Date:           Tue Oct 29 10:04:12 UTC 2013

Modified Files:
        src/sys/ufs/ffs [netbsd-5]: ffs_alloc.c

Log Message:
Pull up the following revisions(s) (requested by bad in ticket #1888):
        sys/ufs/ffs/ffs_alloc.c:        revision 1.144 via patch

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.


To generate a diff of this commit:
cvs rdiff -u -r1.113.4.2 -r1.113.4.3 src/sys/ufs/ffs/ffs_alloc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/ffs/ffs_alloc.c
diff -u src/sys/ufs/ffs/ffs_alloc.c:1.113.4.2 src/sys/ufs/ffs/ffs_alloc.c:1.113.4.3
--- src/sys/ufs/ffs/ffs_alloc.c:1.113.4.2	Thu May  7 00:25:37 2009
+++ src/sys/ufs/ffs/ffs_alloc.c	Tue Oct 29 10:04:12 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_alloc.c,v 1.113.4.2 2009/05/07 00:25:37 snj Exp $	*/
+/*	$NetBSD: ffs_alloc.c,v 1.113.4.3 2013/10/29 10:04:12 sborrill Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.113.4.2 2009/05/07 00:25:37 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.113.4.3 2013/10/29 10:04:12 sborrill Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -913,14 +913,17 @@ ffs_dirpref(struct inode *pip)
 	/*
 	 * 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 - 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) {
@@ -929,7 +932,7 @@ ffs_dirpref(struct inode *pip)
 			dirsize = curdsz;
 	}
 	if (cgsize < dirsize * 255)
-		maxcontigdirs = cgsize / dirsize;
+		maxcontigdirs = (avgbfree * fs->fs_bsize) / dirsize;
 	else
 		maxcontigdirs = 255;
 	if (fs->fs_avgfpdir > 0)

Reply via email to