| 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,47 – 1993/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 |
| |
| 1993/1017 | Lock; int pgno; | |
| 1993/1013 | Mntcache *head; Mntcache *tail; Mntcache *hash[NHASH]; | |
| 1993/1016/sys/src/9/port/cache.c:54,60 – 1993/1017/sys/src/9/port/cache.c:55,60 | ||
| 1993/1014 | int i; Mntcache *m; | |
| 1993/1016/sys/src/9/port/cache.c:70,84 – 1993/1017/sys/src/9/port/cache.c:70,86 | ||
| 1993/1014 | } | |
| 1993/1013 | void | |
| 1993/1015 |
| |
| 1993/1017 | cprint(Chan *c, Mntcache *m, char *s) | |
| 1993/1014 | { Extent *e; | |
| 1993/1017 | char buf[128]; | |
| 1993/1016 | ||
| 1993/1015 |
| |
| 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 |
| |
| 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,144 – 1993/1017/sys/src/9/port/cache.c:140,146 | ||
| 1993/1013 | { Mntcache *m, *f, **l; | |
| 1993/1015 |
| |
| 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,213 – 1993/1017/sys/src/9/port/cache.c:209,215 | ||
| 1993/1013 | Page *p; Mntcache *m; | |
| 1993/1014 | Extent *e, **t; | |
| 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,236 – 1993/1017/sys/src/9/port/cache.c:224,233 | ||
| 1993/1013 | return 0; } | |
| 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 |
| |
| 1993/1014 | t = &e->next; | |
| 1993/1013 | } | |
| 1993/1016/sys/src/9/port/cache.c:277,282 – 1993/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,315 – 1993/1017/sys/src/9/port/cache.c:307,316 | ||
| 1993/1015 | e->cache = p; e->start = offset; e->len = l; | |
| 1993/1014 |
| |
| 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,466 – 1993/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); | |
| 1993/1016/sys/src/9/port/cache.c:485,494 – 1993/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) { | |
| 1993/1017 | if(f->start >= offset) | |
| 1993/1015 | break; p = f; } | |
| 1993/1016/sys/src/9/port/cache.c:501,506 – 1993/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,525 – 1993/1017/sys/src/9/port/cache.c:537,540 | ||
| 1993/1016 | tail->next = f; } | |
| 1993/1015 | qunlock(m); | |
| 1993/1011 | } | |