Module Name:    src
Committed By:   joerg
Date:           Mon Sep  8 20:52:37 UTC 2014

Modified Files:
        src/sys/ufs/ffs: ffs_alloc.c

Log Message:
Prefer cprng_fast32 over random. A good distribution even in the lower
bits beat any minor performance advantage randomo(9) might have,
especially given the disk IO involved.


To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.147 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.146 src/sys/ufs/ffs/ffs_alloc.c:1.147
--- src/sys/ufs/ffs/ffs_alloc.c:1.146	Fri Jul 25 08:24:31 2014
+++ src/sys/ufs/ffs/ffs_alloc.c	Mon Sep  8 20:52:37 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_alloc.c,v 1.146 2014/07/25 08:24:31 dholland Exp $	*/
+/*	$NetBSD: ffs_alloc.c,v 1.147 2014/09/08 20:52:37 joerg 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.146 2014/07/25 08:24:31 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.147 2014/09/08 20:52:37 joerg Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -90,6 +90,7 @@ __KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,
 #include <sys/syslog.h>
 #include <sys/vnode.h>
 #include <sys/wapbl.h>
+#include <sys/cprng.h>
 
 #include <miscfs/specfs/specdev.h>
 #include <ufs/ufs/quota.h>
@@ -697,7 +698,7 @@ ffs_dirpref(struct inode *pip)
 	 * Force allocation in another cg if creating a first level dir.
 	 */
 	if (ITOV(pip)->v_vflag & VV_ROOT) {
-		prefcg = random() % fs->fs_ncg;
+		prefcg = cprng_fast32() % fs->fs_ncg;
 		mincg = prefcg;
 		minndir = fs->fs_ipg;
 		for (cg = prefcg; cg < fs->fs_ncg; cg++)

Reply via email to