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

1993/1017/port/cache.c (diff list | history)

1993/1016/sys/src/9/port/cache.c:41,471993/1017/sys/src/9/port/cache.c:41,48 (short | long | prev | next)
1993/1013    
typedef struct Cache Cache; 
struct Cache 
1993/1011    
{ 
1993/1013    
	Ref; 
1993/1017    
	Lock; 
	int		pgno; 
1993/1013    
	Mntcache	*head; 
	Mntcache	*tail; 
	Mntcache	*hash[NHASH]; 
1993/1016/sys/src/9/port/cache.c:54,601993/1017/sys/src/9/port/cache.c:55,60
1993/1014    
	int i; 
	Mntcache *m; 
 
	cache.ref = 1; 
	cache.head = xalloc(sizeof(Mntcache)*NFILE); 
	m = cache.head; 
	 
1993/1016/sys/src/9/port/cache.c:70,841993/1017/sys/src/9/port/cache.c:70,86
1993/1014    
} 
 
1993/1013    
void 
1993/1015    
cprint(Mntcache *m, char *s) 
1993/1017    
cprint(Chan *c, Mntcache *m, char *s) 
1993/1014    
{ 
	Extent *e; 
1993/1017    
	char buf[128]; 
1993/1016    
 
1993/1015    
	print("%s: 0x%lux.0x%lux %d %d\n", 
			s, m->path, m->vers, m->type, m->dev); 
1993/1017    
	ptpath(c->path, buf, sizeof(buf)); 
	pprint("%s: 0x%lux.0x%lux %d %d %s\n", 
			s, m->path, m->vers, m->type, m->dev, buf); 
1993/1014    
 
1993/1015    
	for(e = m->list; e; e = e->next) 
1993/1014    
		print("\t%4d %5d %4d %lux\n", 
1993/1017    
		pprint("\t%4d %5d %4d %lux\n", 
1993/1014    
			e->bid, e->start, e->len, e->cache); 
} 
 
1993/1016/sys/src/9/port/cache.c:138,1441993/1017/sys/src/9/port/cache.c:140,146
1993/1013    
{ 
	Mntcache *m, *f, **l; 
 
1993/1015    
	if(c->qid.path & CHDIR) 
1993/1017    
	if((c->qid.path&CHDIR) || (c->flag&CTEXT)) 
1993/1015    
		return; 
 
1993/1016    
	lock(&cache); 
1993/1016/sys/src/9/port/cache.c:207,2131993/1017/sys/src/9/port/cache.c:209,215
1993/1013    
	Page *p; 
	Mntcache *m; 
1993/1014    
	Extent *e, **t; 
	int o, l, total, end; 
1993/1017    
	int o, l, total; 
1993/1013    
 
1993/1015    
	if(c->qid.path & CHDIR) 
		return 0; 
1993/1016/sys/src/9/port/cache.c:222,2361993/1017/sys/src/9/port/cache.c:224,233
1993/1013    
		return 0; 
	} 
 
	end = offset+len; 
1993/1014    
	t = &m->list; 
	for(e = *t; e; e = e->next) { 
1993/1016    
		if(offset > e->start && offset < e->start+e->len) 
1993/1013    
			break; 
1993/1016    
		if(offset < e->start) { 
			qunlock(m); 
			return 0; 
		}	 
1993/1014    
		t = &e->next; 
1993/1013    
	} 
 
1993/1016/sys/src/9/port/cache.c:277,2821993/1017/sys/src/9/port/cache.c:274,280
1993/1013    
		if(e == 0 || e->start != offset) 
			break; 
	} 
1993/1017    
if(len) print("P"); else print("F"); 
1993/1014    
	qunlock(m); 
1993/1013    
	return total; 
} 
1993/1016/sys/src/9/port/cache.c:309,3151993/1017/sys/src/9/port/cache.c:307,316
1993/1015    
		e->cache = p; 
		e->start = offset; 
		e->len = l; 
1993/1014    
		e->bid = incref(&cache); 
1993/1017    
		lock(&cache); 
		e->bid = cache.pgno; 
		cache.pgno += BY2PG; 
		unlock(&cache); 
1993/1014    
		p->daddr = e->bid; 
		k = kmap(p); 
		memmove((void*)VA(k), buf, l); 
1993/1016/sys/src/9/port/cache.c:460,4661993/1017/sys/src/9/port/cache.c:461,466
1993/1016    
cupdate(Chan *c, uchar *buf, int len, ulong offset) 
{ 
	cxupdate(c, buf, len, offset); 
	cprint(c->mcp, "cupdate"); 
} 
 
void 
1993/1016/sys/src/9/port/cache.c:485,4941993/1017/sys/src/9/port/cache.c:485,495
1993/1015    
	} 
 
	m->vers++; 
1993/1017    
	c->qid.vers++; 
1993/1015    
 
	p = 0; 
	for(f = m->list; f; f = f->next) { 
		if(offset >= f->start) 
1993/1017    
		if(f->start >= offset) 
1993/1015    
			break; 
		p = f;		 
	} 
1993/1016/sys/src/9/port/cache.c:501,5061993/1017/sys/src/9/port/cache.c:502,522
1993/1016    
			if(p->len == 0) 
1993/1015    
				panic("del empty extent"); 
		} 
1993/1017    
		if(ee == offset && p->len < BY2PG) { 
			o = len; 
			if(o > BY2PG - p->len) 
				o = BY2PG - p->len; 
			if(cpgmove(p, buf, p->len, o)) { 
				p->len += o; 
				buf += o; 
				len -= o; 
				offset += o; 
				if(len <= 0) { 
					qunlock(m); 
					return; 
				} 
			} 
		} 
1993/1015    
	} 
 
	eblock = offset+len; 
1993/1016/sys/src/9/port/cache.c:521,5251993/1017/sys/src/9/port/cache.c:537,540
1993/1016    
			tail->next = f; 
	} 
1993/1015    
	qunlock(m); 
cprint(m, "cwrite"); 
1993/1011    
} 


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