summaryrefslogtreecommitdiffstats
path: root/sys/fs/nullfs/null_subr.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2013-01-14 05:44:47 +0000
committerkib <kib@FreeBSD.org>2013-01-14 05:44:47 +0000
commit169c0a0a9fc5b0a5ac93ac03566a157372ff18e0 (patch)
treea99d952a5303bc41a83ac48106aea16df1cf57c3 /sys/fs/nullfs/null_subr.c
parentcef86179d2638a11b0d1650a4ab6ac5a856bce57 (diff)
downloadFreeBSD-src-169c0a0a9fc5b0a5ac93ac03566a157372ff18e0.zip
FreeBSD-src-169c0a0a9fc5b0a5ac93ac03566a157372ff18e0.tar.gz
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
Diffstat (limited to 'sys/fs/nullfs/null_subr.c')
-rw-r--r--sys/fs/nullfs/null_subr.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/sys/fs/nullfs/null_subr.c b/sys/fs/nullfs/null_subr.c
index 0b72249..90e56ea 100644
--- a/sys/fs/nullfs/null_subr.c
+++ b/sys/fs/nullfs/null_subr.c
@@ -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);
}
OpenPOWER on IntegriCloud