diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2010-08-11 14:35:35 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2010-08-11 14:35:35 +0000 |
commit | 6288cbca766267e7a4a44cac6180151d6bed0c38 (patch) | |
tree | f1139ce4c051636fcdceae25226246da70d01701 /sys | |
parent | 603e66a0b40a52aae27b013637d8b26bcfca5572 (diff) |
Make the number of vnodes to correspond to the number of buffers in
buffer cache - we grow them dynamically, but do not attempt to shrink
them if the buffer cache shrinks after growing.
Tested by very many for a long time.
ok oga@ todd@ phessler@ tedu@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/vfs_subr.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 61fc62d20b4..588e255d328 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.187 2010/06/29 04:09:32 tedu Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.188 2010/08/11 14:35:34 beck Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -108,8 +108,10 @@ void vfs_free_addrlist(struct netexport *); void vputonfreelist(struct vnode *); int vflush_vnode(struct vnode *, void *); +extern struct bcachestats bcasts; int maxvnodes; + #ifdef DEBUG void printlockedvnodes(void); #endif @@ -136,7 +138,7 @@ void 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); @@ -318,6 +320,13 @@ getnewvnode(enum vtagtype tag, struct mount *mp, int (**vops)(void *), 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 @@ -333,7 +342,7 @@ getnewvnode(enum vtagtype tag, struct mount *mp, int (**vops)(void *), * referencing buffers. */ toggle ^= 1; - if (numvnodes > 2 * maxvnodes) + if (numvnodes / 2 > maxvnodes) toggle = 0; s = splbio(); @@ -757,7 +766,7 @@ vdrop(struct vnode *vp) { #ifdef DIAGNOSTIC if (vp->v_holdcnt == 0) - panic("vdrop: zero holdcnt"); + panic("vdrop: zero holdcnt"); #endif vp->v_holdcnt--; @@ -843,7 +852,7 @@ vflush_vnode(struct vnode *vp, void *arg) { vgonel(vp, p); return (0); } - + /* * If FORCECLOSE is set, forcibly close the vnode. * For block or character devices, revert to an |