plan 9 kernel history: overview | file list | diff list

2001/0527/port/cache.c (diff list | history)

2001/0203/sys/src/9/port/cache.c:26,322001/0527/sys/src/9/port/cache.c:26,32 (short | long | prev | next)
1993/1013    
typedef struct Mntcache Mntcache; 
struct Mntcache 
{ 
1993/1011    
	Qid; 
2001/0527    
	Qid	qid; 
1993/1013    
	int	dev; 
	int	type; 
1993/1014    
	QLock; 
2001/0203/sys/src/9/port/cache.c:111,1202001/0527/sys/src/9/port/cache.c:111,120
1993/1014    
	m = cache.head; 
1998/0512    
 
2000/0609    
	/* a better algorithm would be nice */ 
2001/0203    
//	if(conf.npage*BY2PG > 200*MB) 
//		maxcache = 10*MAXCACHE; 
//	if(conf.npage*BY2PG > 400*MB) 
//		maxcache = 50*MAXCACHE; 
2001/0527    
	if(conf.npage*BY2PG > 200*MB) 
		maxcache = 10*MAXCACHE; 
	if(conf.npage*BY2PG > 400*MB) 
		maxcache = 50*MAXCACHE; 
1999/0903    
 
1993/1016    
	for(i = 0; i < NFILE-1; i++) { 
1993/1014    
		m->next = m+1; 
2001/0203/sys/src/9/port/cache.c:148,1542001/0527/sys/src/9/port/cache.c:148,154
1993/1018    
		o = e->start+e->len; 
	} 
	pprint("%s: 0x%lux.0x%lux %d %d %s (%d %c)\n", 
1999/0629    
	s, m->path, m->vers, m->type, m->dev, c->name, nb, ct ? 'C' : 'N'); 
2001/0527    
	s, m->qid.path, m->qid.vers, m->type, m->dev, c->name, nb, ct ? 'C' : 'N'); 
1993/1014    
 
1993/1018    
	for(e = m->list; e; e = e->next) { 
1993/1103    
		pprint("\t%4d %5d %4d %lux\n", 
2001/0203/sys/src/9/port/cache.c:216,2282001/0527/sys/src/9/port/cache.c:216,230
1993/1018    
	Extent *e, *next; 
1993/1013    
	Mntcache *m, *f, **l; 
 
1993/1018    
	if(c->qid.path&CHDIR) 
2001/0527    
	/* directories aren't cacheable and append-only files confuse us */ 
	if(c->qid.type&(QTDIR|QTAPPEND)) 
1993/1015    
		return; 
 
1993/1018    
	h = c->qid.path%NHASH; 
1993/1016    
	lock(&cache); 
1993/1018    
	for(m = cache.hash[h]; m; m = m->hash) { 
1993/1016    
		if(m->path == c->qid.path) 
2001/0527    
		if(m->qid.path == c->qid.path) 
		if(m->qid.type == c->qid.type) 
1993/1016    
		if(m->dev == c->dev && m->type == c->type) { 
			c->mcp = m; 
			ctail(m); 
2001/0203/sys/src/9/port/cache.c:229,2362001/0527/sys/src/9/port/cache.c:231,238
1993/1016    
			unlock(&cache); 
1993/1015    
 
1993/1016    
			/* File was updated, invalidate cache */ 
			if(m->vers != c->qid.vers) { 
1993/1018    
				m->vers = c->qid.vers; 
2001/0527    
			if(m->qid.vers != c->qid.vers) { 
				m->qid.vers = c->qid.vers; 
1993/1016    
				qlock(m); 
				cnodata(m); 
				qunlock(m); 
2001/0203/sys/src/9/port/cache.c:241,2472001/0527/sys/src/9/port/cache.c:243,249
1993/1013    
 
	/* LRU the cache headers */ 
	m = cache.head; 
1993/1014    
	l = &cache.hash[m->path%NHASH]; 
2001/0527    
	l = &cache.hash[m->qid.path%NHASH]; 
1993/1016    
	for(f = *l; f; f = f->hash) { 
1993/1013    
		if(f == m) { 
1993/1018    
			*l = m->hash; 
2001/0203/sys/src/9/port/cache.c:250,2562001/0527/sys/src/9/port/cache.c:252,258
1993/1016    
		l = &f->hash; 
1993/1013    
	} 
1993/1015    
 
1993/1014    
	m->Qid = c->qid; 
2001/0527    
	m->qid = c->qid; 
1993/1013    
	m->dev = c->dev; 
	m->type = c->type; 
1993/1018    
 
2001/0203/sys/src/9/port/cache.c:276,2882001/0527/sys/src/9/port/cache.c:278,292
1993/1013    
static int 
cdev(Mntcache *m, Chan *c) 
{ 
1993/1014    
	if(m->path != c->qid.path) 
2001/0527    
	if(m->qid.path != c->qid.path) 
1993/1013    
		return 0; 
2001/0527    
	if(m->qid.type != c->qid.type) 
		return 0; 
1993/1013    
	if(m->dev != c->dev) 
		return 0; 
	if(m->type != c->type) 
		return 0; 
1993/1018    
	if(m->vers != c->qid.vers) 
2001/0527    
	if(m->qid.vers != c->qid.vers) 
1993/1018    
		return 0; 
1993/1013    
	return 1; 
} 
2001/0203/sys/src/9/port/cache.c:573,5792001/0527/sys/src/9/port/cache.c:577,583
1993/1015    
	} 
 
1998/0327    
	offset = off; 
1993/1015    
	m->vers++; 
2001/0527    
	m->qid.vers++; 
1993/1017    
	c->qid.vers++; 
1993/1015    
 
	p = 0; 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)