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

exp. dirhash patch



first off, this patch isn't for everyone.  it's more of a "it may be nice" 
thing for some people.

dirhash really helps when you have a lot of files in one directory.  
unfortunately, in the case of maildir, something like this happens:
open dir 1.  hash created.  slight pause while this happens.
look at files.  fast.
open dir 2.  hash created.  both 1 and 2 are hashed now.
mua stats all the files.  lots of vnode pressure forces dir 1 to be 
recycled.  hash is freed.
open dir 1 again.  hash is recreated.

it's a pretty bad cycle.  this patch keeps a ref on all hashed directories 
so that they won't be recycled.  there's already a limit on how much mem 
is used for hashing; however, this patch does interfere with reclaiming 
it.  that's why it's not for everybody.

Index: ufs_dirhash.c
===================================================================
RCS file: /home/tedu/cvs/src/sys/ufs/ufs/ufs_dirhash.c,v
retrieving revision 1.8
diff -u -r1.8 ufs_dirhash.c
--- ufs_dirhash.c	21 Jul 2004 12:10:20 -0000	1.8
+++ ufs_dirhash.c	6 Nov 2004 17:55:01 -0000
@@ -204,6 +204,7 @@
 	dh->dh_seqopt = 0;
 	dh->dh_seqoff = 0;
 	dh->dh_score = DH_SCOREINIT;
+	vref(vp);
 	ip->i_dirhash = dh;
 
 	bmask = VFSTOUFS(vp->v_mount)->um_mountp->mnt_stat.f_iosize - 1;
@@ -256,6 +257,7 @@
 		free(dh->dh_blkfree, M_DIRHASH);
 	FREE(dh, M_DIRHASH);
 	ip->i_dirhash = NULL;
+	vrele(vp);
 	DIRHASHLIST_LOCK();
 	ufs_dirhashmem -= memreqd;
 	DIRHASHLIST_UNLOCK();
@@ -294,6 +296,7 @@
 	}
 	FREE(dh, M_DIRHASH);
 	ip->i_dirhash = NULL;
+	vrele(ITOV(ip));
 
 	DIRHASHLIST_LOCK();
 	ufs_dirhashmem -= mem;


-- 
we fear that pop-culture
is the only kind of culture we're ever going to have



Visit your host, monkey.org