| plan 9 kernel history: overview | file list | diff list |
1993/1016/port/cache.c (diff list | history)
| 1993/1015/sys/src/9/port/cache.c:58,64 – 1993/1016/sys/src/9/port/cache.c:58,64 (short | long | prev | next) | ||
| 1993/1014 | cache.head = xalloc(sizeof(Mntcache)*NFILE); m = cache.head; | |
| 1993/1015 |
| |
| 1993/1016 | for(i = 0; i < NFILE-1; i++) { | |
| 1993/1014 | m->next = m+1; m->prev = m-1; m++; | |
| 1993/1015/sys/src/9/port/cache.c:69,104 – 1993/1016/sys/src/9/port/cache.c:69,79 | ||
| 1993/1014 | cache.head->prev = 0; } | |
| 1993/1013 |
| |
| 1993/1011 |
| |
| 1993/1013 |
| |
| 1993/1014 |
| |
| 1993/1011 | ||
| 1993/1013 |
| |
| 1993/1014 |
| |
| 1993/1013 |
| |
| 1993/1015 | cprint(Mntcache *m, char *s) | |
| 1993/1014 | { Extent *e; | |
| 1993/1015 |
| |
| 1993/1016 | ||
| 1993/1015 | print("%s: 0x%lux.0x%lux %d %d\n", s, m->path, m->vers, m->type, m->dev); | |
| 1993/1014 | ||
| 1993/1015/sys/src/9/port/cache.c:134,144 – 1993/1016/sys/src/9/port/cache.c:109,116 | ||
| 1993/1013 | } void | |
| 1993/1015 |
| |
| 1993/1016 | ctail(Mntcache *m) | |
| 1993/1013 | { | |
| 1993/1015 |
| |
| 1993/1013 |
| |
| 1993/1015/sys/src/9/port/cache.c:159,167 – 1993/1016/sys/src/9/port/cache.c:131,136 | ||
| 1993/1013 | cache.head = cache.tail = m; m->prev = m->next = 0; } | |
| 1993/1015 |
| |
| 1993/1013 | } void | |
| 1993/1015/sys/src/9/port/cache.c:172,218 – 1993/1016/sys/src/9/port/cache.c:141,189 | ||
| 1993/1015 | if(c->qid.path & CHDIR) return; | |
| 1993/1013 |
| |
| 1993/1015 |
| |
| 1993/1016 | lock(&cache); for(m = cache.hash[c->qid.path%NHASH]; m; m = m->hash) { if(m->path == c->qid.path) if(m->dev == c->dev && m->type == c->type) { c->mcp = m; ctail(m); unlock(&cache); | |
| 1993/1015 | ||
| 1993/1013 |
| |
| 1993/1015 |
| |
| 1993/1013 |
| |
| 1993/1015 |
| |
| 1993/1016 | /* File was updated, invalidate cache */ if(m->vers != c->qid.vers) { qlock(m); cnodata(m); m->vers = c->qid.vers; qunlock(m); } return; | |
| 1993/1015 | } | |
| 1993/1013 |
| |
| 1993/1015 |
| |
| 1993/1013 |
| |
| 1993/1014 |
| |
| 1993/1013 |
| |
| 1993/1016 | for(f = *l; f; f = f->hash) { | |
| 1993/1013 | if(f == m) { | |
| 1993/1016 | *l = f->hash; | |
| 1993/1013 | break; } | |
| 1993/1016 | l = &f->hash; | |
| 1993/1013 | } l = &cache.hash[c->qid.path%NHASH]; m->hash = *l; *l = m; | |
| 1993/1015 |
| |
| 1993/1014 |
| |
| 1993/1016 | ctail(m); | |
| 1993/1015 | ||
| 1993/1014 | m->Qid = c->qid; | |
| 1993/1013 | m->dev = c->dev; m->type = c->type; | |
| 1993/1016 | unlock(&cache); qlock(m); cnodata(m); | |
| 1993/1013 | qunlock(m); | |
| 1993/1015 |
| |
| 1993/1013 | } static int | |
| 1993/1015/sys/src/9/port/cache.c:254,261 – 1993/1016/sys/src/9/port/cache.c:225,236 | ||
| 1993/1013 | end = offset+len; | |
| 1993/1014 | t = &m->list; for(e = *t; e; e = e->next) { | |
| 1993/1013 |
| |
| 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/1015/sys/src/9/port/cache.c:288,293 – 1993/1016/sys/src/9/port/cache.c:263,270 | ||
| 1993/1013 | l = e->len-o; | |
| 1993/1014 | memmove(buf, (uchar*)VA(k) + o, l); | |
| 1993/1016 | poperror(); | |
| 1993/1013 | kunmap(k); putpage(p); | |
| 1993/1015/sys/src/9/port/cache.c:313,318 – 1993/1016/sys/src/9/port/cache.c:290,296 | ||
| 1993/1014 | Extent *e, *start, **t; start = 0; | |
| 1993/1016 | *tail = 0; | |
| 1993/1014 | t = &start; while(len) { e = malloc(sizeof(Extent)); | |
| 1993/1015/sys/src/9/port/cache.c:348,353 – 1993/1016/sys/src/9/port/cache.c:326,332 | ||
| 1993/1014 | *tail = e; t = &e->next; } | |
| 1993/1016 | ||
| 1993/1014 | return start; } | |
| 1993/1015/sys/src/9/port/cache.c:370,376 – 1993/1016/sys/src/9/port/cache.c:349,355 | ||
| 1993/1014 | } | |
| 1993/1013 | void | |
| 1993/1014 |
| |
| 1993/1016 | cxupdate(Chan *c, uchar *buf, int len, ulong offset) | |
| 1993/1013 | { Mntcache *m; | |
| 1993/1014 | Extent *tail; | |
| 1993/1015/sys/src/9/port/cache.c:377,385 – 1993/1016/sys/src/9/port/cache.c:356,361 | ||
| 1993/1014 | Extent *e, *f, *p; | |
| 1993/1015 | int o, ee, eblock; | |
| 1993/1013 | ||
| 1993/1015 |
| |
| 1993/1013 |
| |
| 1993/1015 | if(offset > MAXCACHE || len == 0) return; | |
| 1993/1015/sys/src/9/port/cache.c:413,421 – 1993/1016/sys/src/9/port/cache.c:389,399 | ||
| 1993/1014 | } } e = cchain(buf, offset, len, &tail); | |
| 1993/1016 | if(e != 0) { m->list = e; if(tail != 0) tail->next = f; } | |
| 1993/1014 | qunlock(m); return; } | |
| 1993/1015/sys/src/9/port/cache.c:438,447 – 1993/1016/sys/src/9/port/cache.c:416,421 | ||
| 1993/1014 | o = len; if(o > BY2PG - p->len) o = BY2PG - p->len; | |
| 1993/1013 |
| |
| 1993/1014 |
| |
| 1993/1015 | if(cpgmove(p, buf, p->len, o)) { p->len += o; | |
| 1993/1014 | buf += o; | |
| 1993/1015/sys/src/9/port/cache.c:465,475 – 1993/1016/sys/src/9/port/cache.c:439,449 | ||
| 1993/1014 | eblock = offset+len; if(eblock > f->start) { o = eblock - f->start; | |
| 1993/1016 | len -= o; if(len <= 0) { | |
| 1993/1014 | qunlock(m); return; } | |
| 1993/1015 | /* insert a middle block */ | |
| 1993/1015/sys/src/9/port/cache.c:483,488 – 1993/1016/sys/src/9/port/cache.c:457,469 | ||
| 1993/1015 | } void | |
| 1993/1016 | cupdate(Chan *c, uchar *buf, int len, ulong offset) { cxupdate(c, buf, len, offset); cprint(c->mcp, "cupdate"); } void | |
| 1993/1015 | cwrite(Chan* c, uchar *buf, int len, ulong offset) { int o; | |
| 1993/1015/sys/src/9/port/cache.c:517,523 – 1993/1016/sys/src/9/port/cache.c:498,504 | ||
| 1993/1015 | if(ee > offset) { o = ee - offset; p->len -= o; | |
| 1993/1016 | if(p->len == 0) | |
| 1993/1015 | panic("del empty extent"); } } | |
| 1993/1015/sys/src/9/port/cache.c:531,542 – 1993/1016/sys/src/9/port/cache.c:512,525 | ||
| 1993/1015 | } e = cchain(buf, offset, len, &tail); | |
| 1993/1016 | if(e != 0) { if(p == 0) m->list = e; else p->next = e; if(tail != 0) tail->next = f; } | |
| 1993/1015 | qunlock(m); cprint(m, "cwrite"); | |
| 1993/1011 | } | |