Author: kib
Date: Mon Jan 14 05:44:47 2013
New Revision: 245408
URL: http://svnweb.freebsd.org/changeset/base/245408

Log:
  The current default size of the nullfs hash table used to lookup the
  existing nullfs vnode by the lower vnode is only 16 slots.  Since the
  default mode for the nullfs is to cache the vnodes, hash has extremely
  huge chains.
  
  Size the nullfs hashtbl based on the current value of
  desiredvnodes. Use vfs_hash_index() to calculate the hash bucket for a
  given vnode.
  
  Pointy hat to:            kib
  Diagnosed and reviewed by:    peter
  Tested by:    peter, pho (previous version)
  Sponsored by: The FreeBSD Foundation
  MFC after:    5 days

Modified:
  head/sys/fs/nullfs/null_subr.c

Modified: head/sys/fs/nullfs/null_subr.c
==============================================================================
--- head/sys/fs/nullfs/null_subr.c      Mon Jan 14 05:42:54 2013        
(r245407)
+++ head/sys/fs/nullfs/null_subr.c      Mon Jan 14 05:44:47 2013        
(r245408)
@@ -46,9 +46,6 @@
 
 #include <fs/nullfs/null.h>
 
-#define LOG2_SIZEVNODE 8               /* log2(sizeof struct vnode) */
-#define        NNULLNODECACHE 16
-
 /*
  * Null layer cache:
  * Each cache entry holds a reference to the lower vnode
@@ -57,12 +54,11 @@
  * alias is removed the lower vnode is vrele'd.
  */
 
-#define        NULL_NHASH(vp) \
-       (&null_node_hashtbl[(((uintptr_t)vp)>>LOG2_SIZEVNODE) & null_node_hash])
+#define        NULL_NHASH(vp) (&null_node_hashtbl[vfs_hash_index(vp) & 
null_hash_mask])
 
 static LIST_HEAD(null_node_hashhead, null_node) *null_node_hashtbl;
-static u_long null_node_hash;
-struct mtx null_hashmtx;
+static struct mtx null_hashmtx;
+static u_long null_hash_mask;
 
 static MALLOC_DEFINE(M_NULLFSHASH, "nullfs_hash", "NULLFS hash table");
 MALLOC_DEFINE(M_NULLFSNODE, "nullfs_node", "NULLFS vnode private part");
@@ -77,8 +73,8 @@ nullfs_init(vfsp)
        struct vfsconf *vfsp;
 {
 
-       NULLFSDEBUG("nullfs_init\n");           /* printed during system boot */
-       null_node_hashtbl = hashinit(NNULLNODECACHE, M_NULLFSHASH, 
&null_node_hash);
+       null_node_hashtbl = hashinit(desiredvnodes, M_NULLFSHASH,
+           &null_hash_mask);
        mtx_init(&null_hashmtx, "nullhs", NULL, MTX_DEF);
        return (0);
 }
@@ -89,7 +85,7 @@ nullfs_uninit(vfsp)
 {
 
        mtx_destroy(&null_hashmtx);
-       hashdestroy(null_node_hashtbl, M_NULLFSHASH, null_node_hash);
+       hashdestroy(null_node_hashtbl, M_NULLFSHASH, null_hash_mask);
        return (0);
 }
 
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to