Date: Fri, 25 Apr 1997 18:36:20 +0200 From: Poul-Henning Kamp <phk@dk.tfs.com> To: fs@freebsd.org Subject: patch to be benchmarked. Message-ID: <230.861986180@critter>
next in thread | raw e-mail | index | archive | help
This patch removes all the ".." entries from the namei cache, and instead stores the information in the vnode. This is a "freebie" since we allocate 128 bytes for the vnode and only use less of it currently. Benchmark results will be most appreciated ! Poul-Henning Index: kern/vfs_cache.c =================================================================== RCS file: /home/ncvs/src/sys/kern/vfs_cache.c,v retrieving revision 1.24 diff -u -r1.24 vfs_cache.c --- vfs_cache.c 1997/03/08 15:22:14 1.24 +++ vfs_cache.c 1997/04/25 16:23:28 @@ -78,7 +78,13 @@ (&nchashtbl[((dvp)->v_id + (cnp)->cn_hash) % nchash]) static LIST_HEAD(nchashhead, namecache) *nchashtbl; /* Hash Table */ static u_long nchash; /* size of hash table */ + static u_long numcache; /* number of cache entries allocated */ +SYSCTL_INT(_debug, OID_AUTO, vfscachesize, CTLFLAG_RD, &numcache, 0, ""); + +static u_long cachelimit; +SYSCTL_INT(_debug, OID_AUTO, vfscachelimit, CTLFLAG_RW, &cachelimit, 0, ""); + static TAILQ_HEAD(, namecache) nclruhead; /* LRU chain */ struct nchstats nchstats; /* cache effectiveness statistics */ @@ -151,6 +157,18 @@ return (0); } + if (cnp->cn_namelen == 2 && + cnp->cn_nameptr[0] == '.' && cnp->cn_nameptr[1] == '.') { + if (dvp->v_dd->v_id != dvp->v_ddid) + return (0); + if ((cnp->cn_flags & MAKEENTRY) == 0) { + dvp->v_dd = dvp; + return (0); + } + *vpp = dvp->v_dd; + return (-1); + } + ncpp = NCHHASH(dvp, cnp); for (ncp = ncpp->lh_first; ncp != 0; ncp = nnp) { nnp = ncp->nc_hash.le_next; @@ -230,12 +248,18 @@ return; } + if (cnp->cn_namelen == 2 && + cnp->cn_nameptr[0] == '.' && cnp->cn_nameptr[1] == '.') { + dvp->v_dd = vp; + dvp->v_ddid = vp->v_id; + } + /* * We allocate a new entry if we are less than the maximum * allowed and the one at the front of the LRU list is in use. * Otherwise we use the one at the front of the LRU list. */ - if (numcache < desiredvnodes && + if (numcache < (cachelimit ? cachelimit : desiredvnodes) && ((ncp = nclruhead.tqh_first) == NULL || ncp->nc_hash.le_prev != 0)) { /* Add one more entry */ Index: kern/vfs_subr.c =================================================================== RCS file: /home/ncvs/src/sys/kern/vfs_subr.c,v retrieving revision 1.82 diff -u -r1.82 vfs_subr.c --- vfs_subr.c 1997/04/04 17:46:16 1.82 +++ vfs_subr.c 1997/04/25 16:04:31 @@ -361,6 +361,7 @@ vp = (struct vnode *) malloc((u_long) sizeof *vp, M_VNODE, M_WAITOK); bzero((char *) vp, sizeof *vp); + vp->v_dd = vp; /* Always point to some vnode */ numvnodes++; } else { for (vp = vnode_free_list.tqh_first; Index: sys/vnode.h =================================================================== RCS file: /home/ncvs/src/sys/sys/vnode.h,v retrieving revision 1.43 diff -u -r1.43 vnode.h --- vnode.h 1997/04/04 17:43:32 1.43 +++ vnode.h 1997/04/25 15:55:55 @@ -110,6 +110,8 @@ struct lock *v_vnlock; /* used for non-locking fs's */ enum vtagtype v_tag; /* type of underlying data */ void *v_data; /* private data for fs */ + struct vnode *v_dd; /* ".." vnode */ + u_long v_ddid; /* ".." vnode.v_id */ }; #define v_mountedhere v_un.vu_mountedhere #define v_socket v_un.vu_socket -- Poul-Henning Kamp | phk@FreeBSD.ORG FreeBSD Core-team. http://www.freebsd.org/~phk | phk@login.dknet.dk Private mailbox. whois: [PHK] | phk@tfs.com TRW Financial Systems, Inc. Future will arrive by its own means, progress not so.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?230.861986180>