summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_export.c
diff options
context:
space:
mode:
authortanimura <tanimura@FreeBSD.org>2001-04-18 11:19:50 +0000
committertanimura <tanimura@FreeBSD.org>2001-04-18 11:19:50 +0000
commit546a3cb874c001d7ef459f0d56d33c3d3c2f89d4 (patch)
tree3c85ac2d85714898cf967675dc383f1eb999408d /sys/kern/vfs_export.c
parentad298e18d8fa14520b294f335934f7f3a839a8d2 (diff)
downloadFreeBSD-src-546a3cb874c001d7ef459f0d56d33c3d3c2f89d4.zip
FreeBSD-src-546a3cb874c001d7ef459f0d56d33c3d3c2f89d4.tar.gz
Reclaim directory vnodes held in namecache if few free vnodes are
available. Only directory vnodes holding no child directory vnodes held in v_cache_src are recycled, so that directory vnodes near the root of the filesystem hierarchy remain in namecache and directory vnodes are not reclaimed in cascade. The period of vnode reclaiming attempt and the number of vnodes attempted to reclaim can be tuned via sysctl(2). Suggested by: tegge Approved by: phk
Diffstat (limited to 'sys/kern/vfs_export.c')
-rw-r--r--sys/kern/vfs_export.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c
index 29dec8a..853bf76 100644
--- a/sys/kern/vfs_export.c
+++ b/sys/kern/vfs_export.c
@@ -122,6 +122,21 @@ SYSCTL_LONG(_debug, OID_AUTO, wantfreevnodes, CTLFLAG_RW, &wantfreevnodes, 0, ""
/* Number of vnodes in the free list. */
static u_long freevnodes = 0;
SYSCTL_LONG(_debug, OID_AUTO, freevnodes, CTLFLAG_RD, &freevnodes, 0, "");
+/* Number of vnode allocation. */
+static u_long vnodeallocs = 0;
+SYSCTL_LONG(_debug, OID_AUTO, vnodeallocs, CTLFLAG_RD, &vnodeallocs, 0, "");
+/* Period of vnode recycle from namecache in vnode allocation times. */
+static u_long vnoderecycleperiod = 1000;
+SYSCTL_LONG(_debug, OID_AUTO, vnoderecycleperiod, CTLFLAG_RW, &vnoderecycleperiod, 0, "");
+/* Minimum number of total vnodes required to invoke vnode recycle from namecache. */
+static u_long vnoderecyclemintotalvn = 2000;
+SYSCTL_LONG(_debug, OID_AUTO, vnoderecyclemintotalvn, CTLFLAG_RW, &vnoderecyclemintotalvn, 0, "");
+/* Minimum number of free vnodes required to invoke vnode recycle from namecache. */
+static u_long vnoderecycleminfreevn = 2000;
+SYSCTL_LONG(_debug, OID_AUTO, vnoderecycleminfreevn, CTLFLAG_RW, &vnoderecycleminfreevn, 0, "");
+/* Number of vnodes attempted to recycle at a time. */
+static u_long vnoderecyclenumber = 3000;
+SYSCTL_LONG(_debug, OID_AUTO, vnoderecyclenumber, CTLFLAG_RW, &vnoderecyclenumber, 0, "");
/*
* Various variables used for debugging the new implementation of
@@ -553,6 +568,7 @@ getnewvnode(tag, mp, vops, vpp)
if (vp == NULL || vp->v_usecount)
panic("getnewvnode: free vnode isn't");
TAILQ_REMOVE(&vnode_free_list, vp, v_freelist);
+
/*
* Don't recycle if active in the namecache or
* if it still has cached pages or we cannot get
@@ -632,9 +648,19 @@ getnewvnode(tag, mp, vops, vpp)
*vpp = vp;
vp->v_usecount = 1;
vp->v_data = 0;
+
splx(s);
vfs_object_create(vp, p, p->p_ucred);
+
+ vnodeallocs++;
+ if (vnodeallocs % vnoderecycleperiod == 0 &&
+ freevnodes < vnoderecycleminfreevn &&
+ vnoderecyclemintotalvn < numvnodes) {
+ /* Recycle vnodes. */
+ cache_purgeleafdirs(vnoderecyclenumber);
+ }
+
return (0);
}
OpenPOWER on IntegriCloud