vfs_cache.c (90786) | vfs_cache.c (91690) |
---|---|
1/* 2 * Copyright (c) 1989, 1993, 1995 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Poul-Henning Kamp of the FreeBSD Project. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 20 unchanged lines hidden (view full) --- 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 * @(#)vfs_cache.c 8.5 (Berkeley) 3/22/95 | 1/* 2 * Copyright (c) 1989, 1993, 1995 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Poul-Henning Kamp of the FreeBSD Project. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 20 unchanged lines hidden (view full) --- 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * 36 * @(#)vfs_cache.c 8.5 (Berkeley) 3/22/95 |
37 * $FreeBSD: head/sys/kern/vfs_cache.c 90786 2002-02-17 20:40:29Z phk $ | 37 * $FreeBSD: head/sys/kern/vfs_cache.c 91690 2002-03-05 15:38:49Z eivind $ |
38 */ 39 40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/kernel.h> 43#include <sys/lock.h> 44#include <sys/mutex.h> 45#include <sys/sysctl.h> --- 45 unchanged lines hidden (view full) --- 91#define NCHHASH(hash) \ 92 (&nchashtbl[(hash) & nchash]) 93static LIST_HEAD(nchashhead, namecache) *nchashtbl; /* Hash Table */ 94static TAILQ_HEAD(, namecache) ncneg; /* Hash Table */ 95static u_long nchash; /* size of hash table */ 96SYSCTL_ULONG(_debug, OID_AUTO, nchash, CTLFLAG_RD, &nchash, 0, ""); 97static u_long ncnegfactor = 16; /* ratio of negative entries */ 98SYSCTL_ULONG(_debug, OID_AUTO, ncnegfactor, CTLFLAG_RW, &ncnegfactor, 0, ""); | 38 */ 39 40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/kernel.h> 43#include <sys/lock.h> 44#include <sys/mutex.h> 45#include <sys/sysctl.h> --- 45 unchanged lines hidden (view full) --- 91#define NCHHASH(hash) \ 92 (&nchashtbl[(hash) & nchash]) 93static LIST_HEAD(nchashhead, namecache) *nchashtbl; /* Hash Table */ 94static TAILQ_HEAD(, namecache) ncneg; /* Hash Table */ 95static u_long nchash; /* size of hash table */ 96SYSCTL_ULONG(_debug, OID_AUTO, nchash, CTLFLAG_RD, &nchash, 0, ""); 97static u_long ncnegfactor = 16; /* ratio of negative entries */ 98SYSCTL_ULONG(_debug, OID_AUTO, ncnegfactor, CTLFLAG_RW, &ncnegfactor, 0, ""); |
99static u_long numneg; /* number of cache entries allocated */ | 99static u_long numneg; /* number of cache entries allocated */ |
100SYSCTL_ULONG(_debug, OID_AUTO, numneg, CTLFLAG_RD, &numneg, 0, ""); 101static u_long numcache; /* number of cache entries allocated */ 102SYSCTL_ULONG(_debug, OID_AUTO, numcache, CTLFLAG_RD, &numcache, 0, ""); 103static u_long numcachehv; /* number of cache entries with vnodes held */ 104SYSCTL_ULONG(_debug, OID_AUTO, numcachehv, CTLFLAG_RD, &numcachehv, 0, ""); 105#if 0 106static u_long numcachepl; /* number of cache purge for leaf entries */ 107SYSCTL_ULONG(_debug, OID_AUTO, numcachepl, CTLFLAG_RD, &numcachepl, 0, ""); 108#endif 109struct nchstats nchstats; /* cache effectiveness statistics */ 110 111static int doingcache = 1; /* 1 => enable the cache */ 112SYSCTL_INT(_debug, OID_AUTO, vfscache, CTLFLAG_RW, &doingcache, 0, ""); | 100SYSCTL_ULONG(_debug, OID_AUTO, numneg, CTLFLAG_RD, &numneg, 0, ""); 101static u_long numcache; /* number of cache entries allocated */ 102SYSCTL_ULONG(_debug, OID_AUTO, numcache, CTLFLAG_RD, &numcache, 0, ""); 103static u_long numcachehv; /* number of cache entries with vnodes held */ 104SYSCTL_ULONG(_debug, OID_AUTO, numcachehv, CTLFLAG_RD, &numcachehv, 0, ""); 105#if 0 106static u_long numcachepl; /* number of cache purge for leaf entries */ 107SYSCTL_ULONG(_debug, OID_AUTO, numcachepl, CTLFLAG_RD, &numcachepl, 0, ""); 108#endif 109struct nchstats nchstats; /* cache effectiveness statistics */ 110 111static int doingcache = 1; /* 1 => enable the cache */ 112SYSCTL_INT(_debug, OID_AUTO, vfscache, CTLFLAG_RW, &doingcache, 0, ""); |
113 114/* Export size information to userland */ |
|
113SYSCTL_INT(_debug, OID_AUTO, vnsize, CTLFLAG_RD, 0, sizeof(struct vnode), ""); 114SYSCTL_INT(_debug, OID_AUTO, ncsize, CTLFLAG_RD, 0, sizeof(struct namecache), ""); 115 116/* 117 * The new name cache statistics 118 */ 119SYSCTL_NODE(_vfs, OID_AUTO, cache, CTLFLAG_RW, 0, "Name cache statistics"); 120#define STATNODE(mode, name, var) \ --- 499 unchanged lines hidden (view full) --- 620 621#ifndef _SYS_SYSPROTO_H_ 622struct __getcwd_args { 623 u_char *buf; 624 u_int buflen; 625}; 626#endif 627 | 115SYSCTL_INT(_debug, OID_AUTO, vnsize, CTLFLAG_RD, 0, sizeof(struct vnode), ""); 116SYSCTL_INT(_debug, OID_AUTO, ncsize, CTLFLAG_RD, 0, sizeof(struct namecache), ""); 117 118/* 119 * The new name cache statistics 120 */ 121SYSCTL_NODE(_vfs, OID_AUTO, cache, CTLFLAG_RW, 0, "Name cache statistics"); 122#define STATNODE(mode, name, var) \ --- 499 unchanged lines hidden (view full) --- 622 623#ifndef _SYS_SYSPROTO_H_ 624struct __getcwd_args { 625 u_char *buf; 626 u_int buflen; 627}; 628#endif 629 |
630/* 631 * XXX All of these sysctls would probably be more productive dead. 632 */ |
|
628static int disablecwd; | 633static int disablecwd; |
629SYSCTL_INT(_debug, OID_AUTO, disablecwd, CTLFLAG_RW, &disablecwd, 0, ""); | 634SYSCTL_INT(_debug, OID_AUTO, disablecwd, CTLFLAG_RW, &disablecwd, 0, 635 "Disable the getcwd syscall"); |
630 | 636 |
637/* Various statistics for the getcwd syscall */ |
|
631static u_long numcwdcalls; STATNODE(CTLFLAG_RD, numcwdcalls, &numcwdcalls); 632static u_long numcwdfail1; STATNODE(CTLFLAG_RD, numcwdfail1, &numcwdfail1); 633static u_long numcwdfail2; STATNODE(CTLFLAG_RD, numcwdfail2, &numcwdfail2); 634static u_long numcwdfail3; STATNODE(CTLFLAG_RD, numcwdfail3, &numcwdfail3); 635static u_long numcwdfail4; STATNODE(CTLFLAG_RD, numcwdfail4, &numcwdfail4); 636static u_long numcwdfound; STATNODE(CTLFLAG_RD, numcwdfound, &numcwdfound); | 638static u_long numcwdcalls; STATNODE(CTLFLAG_RD, numcwdcalls, &numcwdcalls); 639static u_long numcwdfail1; STATNODE(CTLFLAG_RD, numcwdfail1, &numcwdfail1); 640static u_long numcwdfail2; STATNODE(CTLFLAG_RD, numcwdfail2, &numcwdfail2); 641static u_long numcwdfail3; STATNODE(CTLFLAG_RD, numcwdfail3, &numcwdfail3); 642static u_long numcwdfail4; STATNODE(CTLFLAG_RD, numcwdfail4, &numcwdfail4); 643static u_long numcwdfound; STATNODE(CTLFLAG_RD, numcwdfound, &numcwdfound); |
644 645/* Implementation of the getcwd syscall */ |
|
637int 638__getcwd(td, uap) 639 struct thread *td; 640 struct __getcwd_args *uap; 641{ 642 char *bp, *buf; 643 int error, i, slash_prefixed; 644 struct filedesc *fdp; --- 81 unchanged lines hidden (view full) --- 726 */ 727 728#undef STATNODE 729#define STATNODE(name) \ 730 static u_int name; \ 731 SYSCTL_UINT(_vfs_cache, OID_AUTO, name, CTLFLAG_RD, &name, 0, "") 732 733static int disablefullpath; | 646int 647__getcwd(td, uap) 648 struct thread *td; 649 struct __getcwd_args *uap; 650{ 651 char *bp, *buf; 652 int error, i, slash_prefixed; 653 struct filedesc *fdp; --- 81 unchanged lines hidden (view full) --- 735 */ 736 737#undef STATNODE 738#define STATNODE(name) \ 739 static u_int name; \ 740 SYSCTL_UINT(_vfs_cache, OID_AUTO, name, CTLFLAG_RD, &name, 0, "") 741 742static int disablefullpath; |
734SYSCTL_INT(_debug, OID_AUTO, disablefullpath, CTLFLAG_RW, 735 &disablefullpath, 0, ""); | 743SYSCTL_INT(_debug, OID_AUTO, disablefullpath, CTLFLAG_RW, &disablefullpath, 0, 744 "Disable the vn_fullpath function"); |
736 737STATNODE(numfullpathcalls); 738STATNODE(numfullpathfail1); 739STATNODE(numfullpathfail2); 740STATNODE(numfullpathfail3); 741STATNODE(numfullpathfail4); 742STATNODE(numfullpathfound); 743 | 745 746STATNODE(numfullpathcalls); 747STATNODE(numfullpathfail1); 748STATNODE(numfullpathfail2); 749STATNODE(numfullpathfail3); 750STATNODE(numfullpathfail4); 751STATNODE(numfullpathfound); 752 |
753/* 754 * Retrieve the full filesystem path that correspond to a vnode from the name 755 * cache (if available) 756 */ |
|
744int 745vn_fullpath(struct thread *td, struct vnode *vn, char **retbuf, char **freebuf) 746{ 747 char *bp, *buf; 748 int i, slash_prefixed; 749 struct filedesc *fdp; 750 struct namecache *ncp; 751 struct vnode *vp; --- 75 unchanged lines hidden --- | 757int 758vn_fullpath(struct thread *td, struct vnode *vn, char **retbuf, char **freebuf) 759{ 760 char *bp, *buf; 761 int i, slash_prefixed; 762 struct filedesc *fdp; 763 struct namecache *ncp; 764 struct vnode *vp; --- 75 unchanged lines hidden --- |