Deleted Added
full compact
vfs_cache.c (12820) vfs_cache.c (12968)
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1995
5 * Poul-Henning Kamp. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 19 unchanged lines hidden (view full) ---

28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * @(#)vfs_cache.c 8.3 (Berkeley) 8/22/94
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1995
5 * Poul-Henning Kamp. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 19 unchanged lines hidden (view full) ---

28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * @(#)vfs_cache.c 8.3 (Berkeley) 8/22/94
36 * $Id: vfs_cache.c,v 1.17 1995/10/29 15:31:18 phk Exp $
36 * $Id: vfs_cache.c,v 1.18 1995/12/14 09:52:47 phk Exp $
37 */
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/kernel.h>
42#include <sys/sysctl.h>
43#include <sys/time.h>
44#include <sys/mount.h>

--- 29 unchanged lines hidden (view full) ---

74 */
75static LIST_HEAD(nchashhead, namecache) *nchashtbl; /* Hash Table */
76static TAILQ_HEAD(, namecache) nclruhead; /* LRU chain */
77static u_long nchash; /* size of hash table */
78struct nchstats nchstats; /* cache effectiveness statistics */
79static struct vnode nchENOENT; /* our own "novnode" */
80static int doingcache = 1; /* 1 => enable the cache */
81SYSCTL_INT(_debug, OID_AUTO, vfscache, CTLFLAG_RW, &doingcache, 0, "");
37 */
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/kernel.h>
42#include <sys/sysctl.h>
43#include <sys/time.h>
44#include <sys/mount.h>

--- 29 unchanged lines hidden (view full) ---

74 */
75static LIST_HEAD(nchashhead, namecache) *nchashtbl; /* Hash Table */
76static TAILQ_HEAD(, namecache) nclruhead; /* LRU chain */
77static u_long nchash; /* size of hash table */
78struct nchstats nchstats; /* cache effectiveness statistics */
79static struct vnode nchENOENT; /* our own "novnode" */
80static int doingcache = 1; /* 1 => enable the cache */
81SYSCTL_INT(_debug, OID_AUTO, vfscache, CTLFLAG_RW, &doingcache, 0, "");
82u_long nextvnodeid;
83static u_long numcache;
84u_long numvnodes;
85
86#ifdef NCH_STATISTICS
87u_long nchnbr;
88#define NCHNBR(ncp) (ncp)->nc_nbr = ++nchnbr;
89#define NCHHIT(ncp) (ncp)->nc_hits++
90#else

--- 159 unchanged lines hidden (view full) ---

250 */
251
252void
253nchinit()
254{
255
256 TAILQ_INIT(&nclruhead);
257 nchashtbl = phashinit(desiredvnodes, M_CACHE, &nchash);
82static u_long numcache;
83u_long numvnodes;
84
85#ifdef NCH_STATISTICS
86u_long nchnbr;
87#define NCHNBR(ncp) (ncp)->nc_nbr = ++nchnbr;
88#define NCHHIT(ncp) (ncp)->nc_hits++
89#else

--- 159 unchanged lines hidden (view full) ---

249 */
250
251void
252nchinit()
253{
254
255 TAILQ_INIT(&nclruhead);
256 nchashtbl = phashinit(desiredvnodes, M_CACHE, &nchash);
258 nchENOENT.v_id = 1;
257 cache_purge(&nchENOENT); /* Initialize v_id */
259}
260
261/*
258}
259
260/*
262 * Invalidate a all entries to particular vnode.
261 * Invalidate all entries to a particular vnode.
263 *
262 *
264 * We actually just increment the v_id, that will do it. The entries will
265 * be purged by lookup as they get found.
263 * We actually just increment the v_id, that will do it. The stale entries
264 * will be purged by lookup as they get found.
266 * If the v_id wraps around, we need to ditch the entire cache, to avoid
267 * confusion.
268 * No valid vnode will ever have (v_id == 0).
269 */
270
271void
272cache_purge(vp)
273 struct vnode *vp;
274{
275 struct nchashhead *ncpp;
265 * If the v_id wraps around, we need to ditch the entire cache, to avoid
266 * confusion.
267 * No valid vnode will ever have (v_id == 0).
268 */
269
270void
271cache_purge(vp)
272 struct vnode *vp;
273{
274 struct nchashhead *ncpp;
275 static u_long nextvnodeid;
276
277 vp->v_id = ++nextvnodeid;
278 if (nextvnodeid != 0)
279 return;
280 for (ncpp = &nchashtbl[nchash - 1]; ncpp >= nchashtbl; ncpp--) {
281 while(ncpp->lh_first)
282 PURGE(ncpp->lh_first);
283 }
276
277 vp->v_id = ++nextvnodeid;
278 if (nextvnodeid != 0)
279 return;
280 for (ncpp = &nchashtbl[nchash - 1]; ncpp >= nchashtbl; ncpp--) {
281 while(ncpp->lh_first)
282 PURGE(ncpp->lh_first);
283 }
284 nchENOENT.v_id = ++nextvnodeid;
284 vp->v_id = ++nextvnodeid;
285}
286
287/*
288 * Flush all entries referencing a particular filesystem.
289 *
290 * Since we need to check it anyway, we will flush all the invalid
285 vp->v_id = ++nextvnodeid;
286}
287
288/*
289 * Flush all entries referencing a particular filesystem.
290 *
291 * Since we need to check it anyway, we will flush all the invalid
291 * entriess at the same time.
292 * entries at the same time.
292 *
293 * If we purge anything, we scan the hash-bucket again. There is only
294 * a handful of entries, so it cheap and simple.
295 */
296
297void
298cache_purgevfs(mp)
299 struct mount *mp;

--- 19 unchanged lines hidden ---
293 *
294 * If we purge anything, we scan the hash-bucket again. There is only
295 * a handful of entries, so it cheap and simple.
296 */
297
298void
299cache_purgevfs(mp)
300 struct mount *mp;

--- 19 unchanged lines hidden ---