diff options
author | Russ Cox <rsc@swtch.com> | 2007-10-29 14:33:17 -0400 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2007-10-29 14:33:17 -0400 |
commit | 45ac814c8609174199cadb6f1bbb4baf7c12c94a (patch) | |
tree | 49f4b2120a36b080a0ffe8f9988c21db7b97656c /src/cmd/venti/srv/buildindex.c | |
parent | c5a183de108e5685305734d5cf984b58bb0d614a (diff) | |
download | plan9port-45ac814c8609174199cadb6f1bbb4baf7c12c94a.tar.gz plan9port-45ac814c8609174199cadb6f1bbb4baf7c12c94a.tar.bz2 plan9port-45ac814c8609174199cadb6f1bbb4baf7c12c94a.zip |
venti: fix sync deadlock, add /proc stub
Diffstat (limited to 'src/cmd/venti/srv/buildindex.c')
-rw-r--r-- | src/cmd/venti/srv/buildindex.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/cmd/venti/srv/buildindex.c b/src/cmd/venti/srv/buildindex.c index 917780b4..4b7b9bdd 100644 --- a/src/cmd/venti/srv/buildindex.c +++ b/src/cmd/venti/srv/buildindex.c @@ -36,7 +36,7 @@ static void arenapartproc(void*); void usage(void) { - fprint(2, "usage: buildindex [-b] [-i isect]... [-M imem] venti.conf\n"); + fprint(2, "usage: buildindex [-bd] [-i isect]... [-M imem] venti.conf\n"); threadexitsall("usage"); } @@ -54,13 +54,13 @@ threadmain(int argc, char *argv[]) case 'b': bloom = 1; break; + case 'd': /* debugging - make sure to run all 3 passes */ + dumb = 1; + break; case 'i': isect = vtrealloc(isect, (nisect+1)*sizeof(isect[0])); isect[nisect++] = EARGF(usage()); break; - case 'd': /* debugging - make sure to run all 3 passes */ - dumb = 1; - break; case 'M': imem = unittoull(EARGF(usage())); break; @@ -222,22 +222,28 @@ arenapartproc(void *v) if(a->memstats.clumps) fprint(2, "%T arena %s: %d entries\n", a->name, a->memstats.clumps); - addr = ix->amap[i].start; - for(clump=0; clump<a->memstats.clumps; clump+=n){ + /* + * Running the loop backwards accesses the + * clump info blocks forwards, since they are + * stored in reverse order at the end of the arena. + * This speeds things slightly. + */ + addr = ix->amap[i].start + a->memstats.used; + for(clump=a->memstats.clumps; clump > 0; clump-=n){ n = ClumpChunks; - if(n > a->memstats.clumps - clump) - n = a->memstats.clumps - clump; - if(readclumpinfos(a, clump, cis, n) != n){ + if(n > clump) + n = clump; + if(readclumpinfos(a, clump-n, cis, n) != n){ fprint(2, "%T arena %s: directory read: %r\n", a->name); errors = 1; break; } - for(j=0; j<n; j++){ + for(j=n-1; j>=0; j--){ ci = &cis[j]; ie.ia.type = ci->type; ie.ia.size = ci->uncsize; + addr -= ci->size + ClumpSize; ie.ia.addr = addr; - addr += ci->size + ClumpSize; ie.ia.blocks = (ci->size + ClumpSize + (1<<ABlockLog)-1) >> ABlockLog; scorecp(ie.score, ci->score); if(ci->type == VtCorruptType) @@ -253,6 +259,8 @@ arenapartproc(void *v) } } } + if(addr != ix->amap[i].start) + fprint(2, "%T arena %s: clump miscalculation %lld != %lld\n", a->name, addr, ix->amap[i].start); } add(&arenaentries, tot); add(&skipentries, nskip); |