# HG changeset patch # User Ron Minnich # Date 1319578291 25200 # Node ID 0fffba1fdc932bd06c9ebb2cdbc35e5b90c9f929 # Parent 5ba3ce9308a6bce0af2e3d56e082aa818617e3d0 vtvacfs snapshot for us to look at. Write is not supported but readonly mounts via 9p are. R=nixiedev, nemo.mbox CC=nix-dev http://codereview.appspot.com/5323049 diff -r 5ba3ce9308a6 -r 0fffba1fdc93 sys/src/cmd/vac/file.c --- a/sys/src/cmd/vac/file.c Wed Oct 12 13:05:42 2011 +0200 +++ b/sys/src/cmd/vac/file.c Tue Oct 25 14:31:31 2011 -0700 @@ -1284,6 +1284,8 @@ * Okay, time to actually create something. Lock the two * halves of the directory and create a file. */ + if (chattyventi) + fprint(2, "vacfilecreate: about to lock two halves, create file\n"); if(vtfilelock2(fp->source, fp->msource, -1) < 0) goto Err1; ff = filealloc(fp->fs); diff -r 5ba3ce9308a6 -r 0fffba1fdc93 sys/src/cmd/vtvacfs/mkfile --- a/sys/src/cmd/vtvacfs/mkfile Wed Oct 12 13:05:42 2011 +0200 +++ b/sys/src/cmd/vtvacfs/mkfile Tue Oct 25 14:31:31 2011 -0700 @@ -4,6 +4,7 @@ vacfile\ # patch\ vacfs\ + vtfile\ vtcache #V=/sys/src/libventi @@ -21,7 +22,7 @@ # ${VC}/graph.$O\ # ${VC}/ifile.$O\ -VLIB=libvs.a$O +VLIB=/sys/src/cmd/venti/srv/libvs.a$O LIB=${MYLIBFILES:%=%.$O} ${VLIB} /sys/src/cmd/vac/pack.$O /sys/src/cmd/vac/error.$O @@ -47,3 +48,4 @@ default:V: all source, fp->msource, -1) < 0) goto Err1; ff = filealloc(fp->fs); @@ -1294,6 +1295,7 @@ if(mode & ModeDir) type = VtDirType; mr = nil; +fprint(2, "vtfilecreate...\n"); if((r = vtfilecreate(pr, pr->psize, pr->dsize, type)) == nil) goto Err; if(mode & ModeDir) @@ -1406,25 +1408,37 @@ int vacfilewrite(VacFile *f, void *buf, int cnt, vlong offset) { + int i = 0; if(vacfileisdir(f)){ werrstr(ENotFile); return -1; } + fprint(2, "vacfilewrite%d.", i++); if(filelock(f) < 0) return -1; + if (1) + fprint(2, "vacfilewrite%d.", i++); if(f->source->mode != VtORDWR){ werrstr(EReadOnly); goto Err; } + if (1) + fprint(2, "vacfilewrite%d.", i++); if(offset < 0){ werrstr(EBadOffset); goto Err; } + if (1) + fprint(2, "vacfilewrite%d.", i++); if(vtfilelock(f->source, -1) < 0) goto Err; + if (1) + fprint(2, "vacfilewrite%d.", i++); if(f->dir.mode & ModeAppend) offset = vtfilegetsize(f->source); + if (1) + fprint(2, "vacfilewrite%d.", i++); if(vtfilewrite(f->source, buf, cnt, offset) != cnt || vtfileflushbefore(f->source, offset) < 0){ vtfileunlock(f->source); @@ -1432,6 +1446,8 @@ } vtfileunlock(f->source); fileunlock(f); + if (1) + fprint(2, "vacfilewriteret%d.", cnt); return cnt; Err: diff -r 5ba3ce9308a6 -r 0fffba1fdc93 sys/src/cmd/vtvacfs/vtfile.c --- a/sys/src/cmd/vtvacfs/vtfile.c Wed Oct 12 13:05:42 2011 +0200 +++ b/sys/src/cmd/vtvacfs/vtfile.c Tue Oct 25 14:31:31 2011 -0700 @@ -520,7 +520,9 @@ /*print("walk from %V/%d ty %d to %V ty %d\n", p->score, index, p->type, score, type); */ if(mode == VtOWRITE && vtglobaltolocal(score) == NilBlock){ + print("VtOWRITE && NilBlock\n"); b = vtcacheallocblock(c, type); + print("vtcachealloblcok returns %p\n", b); if(b) goto HaveCopy; }else @@ -716,8 +718,10 @@ /* mode for intermediate block */ m = mode; + /* why is this here? * if(m == VtOWRITE) m = VtORDWR; + * well we disable it */ for(i=DEPTH(e.type); i>=0; i--){ bb = blockwalk(b, index[i], r->c, i==0 ? mode : m, &e); @@ -834,6 +838,28 @@ switch(r->mode){ default: assert(0); + case VtOWRITE: + assert(r->mode == VtORDWR); + if(r->local == 1){ + b = vtcacheglobal(r->c, r->score, VtDirType); + if(b == nil) + return nil; + b->pc = getcallerpc(&r); + return b; + } + assert(r->parent != nil); + if(vtfilelock(r->parent, VtORDWR) < 0) + return nil; + b = vtfileblock(r->parent, r->offset/r->epb, VtORDWR); + if(b == nil) + b = vtfileblock(r->parent, r->offset/r->epb, VtOWRITE); + vtfileunlock(r->parent); + if(b == nil) + return nil; + memmove(r->score, b->score, VtScoreSize); + r->local = 1; + return b; + case VtORDWR: assert(r->mode == VtORDWR); if(r->local == 1){ diff -r 5ba3ce9308a6 -r 0fffba1fdc93 sys/src/cmd/vtvacfs/vtvacfs.c --- a/sys/src/cmd/vtvacfs/vtvacfs.c Wed Oct 12 13:05:42 2011 +0200 +++ b/sys/src/cmd/vtvacfs/vtvacfs.c Tue Oct 25 14:31:31 2011 -0700 @@ -283,12 +283,15 @@ { void vacfs(void); char *haddr, *vaddr, *webroot, *file; - + extern int chattyventi; + chattyventi = 16; traceinit(); threadsetname("main"); vaddr = nil; haddr = "tcp!*!9000"; webroot = nil; + extern int vttracelevel; + vttracelevel = 1; ARGBEGIN{ case 'a': vaddr = EARGF(usage());