Try this. 

We used to do this, but perhaps prematurely. I've now killed several of
the nfs bugs this used to tickle. 

This lets you make more effective use of your larger buffer cache, if
you are using it for lots of small files (like /usr/src, and the like)
since you can cache more than the default of about 5000 odd files with
the old code since you'd run out of vnodes and start recycling them. 

Please let me know if you see any problems, or if you notice
speedups/slowdowns with this on things you like to do. 

-Bob


Index: kern/vfs_subr.c
===================================================================
RCS file: /cvs/src/sys/kern/vfs_subr.c,v
retrieving revision 1.184
diff -u -r1.184 vfs_subr.c
--- kern/vfs_subr.c     17 Dec 2009 16:44:12 -0000      1.184
+++ kern/vfs_subr.c     9 Jan 2010 10:41:06 -0000
@@ -108,8 +108,10 @@
 void vputonfreelist(struct vnode *);
 
 int vflush_vnode(struct vnode *, void *);
+extern struct bcachestats bcstats;
 int maxvnodes;
 
+
 #ifdef DEBUG
 void printlockedvnodes(void);
 #endif
@@ -136,7 +138,7 @@
 vntblinit(void)
 {
        /* buffer cache may need a vnode for each buffer */
-       maxvnodes = desiredvnodes;
+       maxvnodes = 2 * desiredvnodes;
        pool_init(&vnode_pool, sizeof(struct vnode), 0, 0, 0, "vnodes",
            &pool_allocator_nointr);
        TAILQ_INIT(&vnode_hold_list);
@@ -190,7 +192,7 @@
 }
 
 int
-vfs_isbusy(struct mount *mp) 
+vfs_isbusy(struct mount *mp)
 {
        if (RWLOCK_OWNER(&mp->mnt_lock) > 0)
                return (1);
@@ -335,6 +337,13 @@
        int s;
 
        /*
+        * allow maxvnodes to increase if the buffer cache itself
+        * is big enough to justify it. (we don't shrink it ever)
+        */
+       maxvnodes = maxvnodes < bcstats.numbufs ? bcstats.numbufs
+           : maxvnodes;
+
+       /*
         * We must choose whether to allocate a new vnode or recycle an
         * existing one. The criterion for allocating a new one is that
         * the total number of vnodes is less than the number desired or
@@ -350,7 +359,7 @@
         * referencing buffers.
         */
        toggle ^= 1;
-       if (numvnodes > 2 * maxvnodes)
+       if (numvnodes / 2 > maxvnodes)
                toggle = 0;
 
        s = splbio();
@@ -774,7 +783,7 @@
 {
 #ifdef DIAGNOSTIC
        if (vp->v_holdcnt == 0)
-               panic("vdrop: zero holdcnt"); 
+               panic("vdrop: zero holdcnt");
 #endif
 
        vp->v_holdcnt--;
@@ -860,7 +869,7 @@
                vgonel(vp, p);
                return (0);
        }
-               
+
        /*
         * If FORCECLOSE is set, forcibly close the vnode.
         * For block or character devices, revert to an

Reply via email to