aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/venti
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2007-04-23 14:40:54 +0000
committerrsc <devnull@localhost>2007-04-23 14:40:54 +0000
commit07029cdbbd9be6ad780bd594c98d26babec7ee67 (patch)
tree55c1a64414faa236c67ae710c9aaf2b99aed8be7 /src/cmd/venti
parent8d271d6cc3e14e5f7817dfbad2148ca86a6097a6 (diff)
downloadplan9port-07029cdbbd9be6ad780bd594c98d26babec7ee67.tar.gz
plan9port-07029cdbbd9be6ad780bd594c98d26babec7ee67.tar.bz2
plan9port-07029cdbbd9be6ad780bd594c98d26babec7ee67.zip
cleanup
Diffstat (limited to 'src/cmd/venti')
-rw-r--r--src/cmd/venti/srv/dat.h4
-rw-r--r--src/cmd/venti/srv/fmtindex.c4
-rw-r--r--src/cmd/venti/srv/icachewrite.c17
-rw-r--r--src/cmd/venti/srv/index.c4
-rw-r--r--src/cmd/venti/srv/printarenapart.c5
-rwxr-xr-xsrc/cmd/venti/srv/tester4
-rw-r--r--src/cmd/venti/srv/zblock.c13
7 files changed, 27 insertions, 24 deletions
diff --git a/src/cmd/venti/srv/dat.h b/src/cmd/venti/srv/dat.h
index ede27798..1c9dce3d 100644
--- a/src/cmd/venti/srv/dat.h
+++ b/src/cmd/venti/srv/dat.h
@@ -439,10 +439,6 @@ struct Index
u32int buckets; /* last bucket used in disk hash table */
u32int blocksize;
u32int tabsize; /* max. bytes in index config */
- u32int bitblocks; /* XXX remove these fields */
- u32int maxdepth;
- u32int bitkeylog;
- u32int bitkeymask;
int mapalloc; /* first arena to check when adding a lump */
Arena **arenas; /* arenas in the mapping */
diff --git a/src/cmd/venti/srv/fmtindex.c b/src/cmd/venti/srv/fmtindex.c
index a0eb6b16..d24e0619 100644
--- a/src/cmd/venti/srv/fmtindex.c
+++ b/src/cmd/venti/srv/fmtindex.c
@@ -103,8 +103,8 @@ threadmain(int argc, char *argv[])
if(0){
fprint(2, "configured index=%s with arenas=%d and storage=%lld\n",
ix->name, n, addr - IndexBase);
- fprint(2, "\tbitblocks=%d maxdepth=%d buckets=%d\n",
- ix->bitblocks, ix->maxdepth, ix->buckets);
+ fprint(2, "\tbuckets=%d\n",
+ ix->buckets);
}
fprint(2, "fmtindex: %,d arenas, %,d index buckets, %,lld bytes storage\n",
n, ix->buckets, addr-IndexBase);
diff --git a/src/cmd/venti/srv/icachewrite.c b/src/cmd/venti/srv/icachewrite.c
index 003abb18..2d3ed47c 100644
--- a/src/cmd/venti/srv/icachewrite.c
+++ b/src/cmd/venti/srv/icachewrite.c
@@ -110,7 +110,7 @@ icachewritesect(Index *ix, ISect *is, u8int *buf)
trace(TraceProc, "icachewritesect readpart 0x%llux+0x%ux", addr, nbuf);
if(readpart(is->part, addr, buf, nbuf) < 0){
- /* XXX */
+ /* XXX more details here */
fprint(2, "icachewriteproc readpart: %r\n");
err = -1;
continue;
@@ -154,7 +154,18 @@ icachewritesect(Index *ix, ISect *is, u8int *buf)
break;
}
packibucket(&ib, buf+off, is->bucketmagic);
- /* XXX not right - must update cache after writepart */
+ /* XXX
+ * This is not quite right - it's good that we
+ * update the cached block (if any) here, but
+ * since the block doesn't get written until writepart
+ * below, we also need to make sure that the cache
+ * doesn't load the stale block before we write it to
+ * disk below. We could lock the disk cache during
+ * the writepart, but that's pretty annoying.
+ * Another possibility would be never to cache
+ * index partition blocks. The hit rate on those is
+ * miniscule anyway.
+ */
if((b = _getdblock(is->part, naddr, ORDWR, 0)) != nil){
memmove(b->data, buf+off, bsize);
putdblock(b);
@@ -165,7 +176,7 @@ icachewritesect(Index *ix, ISect *is, u8int *buf)
trace(TraceProc, "icachewritesect writepart", addr, nbuf);
if(writepart(is->part, addr, buf, nbuf) < 0){
- /* XXX */
+ /* XXX more details here */
fprint(2, "icachewriteproc writepart: %r\n");
err = -1;
continue;
diff --git a/src/cmd/venti/srv/index.c b/src/cmd/venti/srv/index.c
index 87361aa9..16b37a07 100644
--- a/src/cmd/venti/srv/index.c
+++ b/src/cmd/venti/srv/index.c
@@ -243,7 +243,7 @@ newindex(char *name, ISect **sects, int n)
Index *ix;
AMap *smap;
u64int nb;
- u32int div, ub, xb, fb, start, stop, blocksize, tabsize;
+ u32int div, ub, xb, start, stop, blocksize, tabsize;
int i, j;
if(n < 1){
@@ -292,7 +292,6 @@ newindex(char *name, ISect **sects, int n)
return nil;
}
- fb = 0;
div = (((u64int)1 << 32) + nb - 1) / nb;
ub = (((u64int)1 << 32) - 1) / div + 1;
if(div < 100){
@@ -347,7 +346,6 @@ newindex(char *name, ISect **sects, int n)
ix->buckets = ub;
ix->tabsize = tabsize;
ix->div = div;
- ix->bitblocks = fb;
if(initindex1(ix) < 0){
free(smap);
diff --git a/src/cmd/venti/srv/printarenapart.c b/src/cmd/venti/srv/printarenapart.c
index 25418beb..ed642c95 100644
--- a/src/cmd/venti/srv/printarenapart.c
+++ b/src/cmd/venti/srv/printarenapart.c
@@ -106,18 +106,14 @@ threadmain(int argc, char *argv[])
ap.tabbase = (PartBlank+HeadSize+ap.blocksize-1)&~(ap.blocksize-1);
ap.tabsize = ap.arenabase - ap.tabbase;
-print("A");
table = malloc(ap.tabsize+1);
if(readpart(part, ap.tabbase, (uchar*)table, ap.tabsize) < 0)
sysfatal("read %s: %r", file);
table[ap.tabsize] = 0;
-print("A");
partblocksize(part, ap.blocksize);
initdcache(8 * MaxDiskBlock);
-print("A");
-/* XXX - read the number of arenas from the first line */
for(p=table; p && *p; p=strchr(p, '\n')){
if(*p == '\n')
p++;
@@ -127,7 +123,6 @@ print("A");
fprint(2, "bad line: %s\n", name);
break;
}
-print("%p\n", p);
offset = strtoull(p, nil, 0);
if(readpart(part, offset, buf, sizeof buf) < 0){
fprint(2, "%s: read %s: %r\n", argv0, file);
diff --git a/src/cmd/venti/srv/tester b/src/cmd/venti/srv/tester
index 8e63a20b..6e0edd7f 100755
--- a/src/cmd/venti/srv/tester
+++ b/src/cmd/venti/srv/tester
@@ -8,7 +8,7 @@ fn reformat {
if(! test -f $vtmp/arena)
dd bs'='1048576 count'='100 if'='/dev/zero of'='$vtmp/arena
if(! test -f $vtmp/bloom)
- dd bs'='1048576 count'='10 if'='/dev/zero of'='$vtmp/bloom
+ dd bs'='1048576 count'='128 if'='/dev/zero of'='$vtmp/bloom
if(! test -f $vtmp/isect)
dd bs'='1048576 count'='10 if'='/dev/zero of'='$vtmp/isect
if(! test -f $vtmp/check)
@@ -29,7 +29,7 @@ fn reformat {
' >$vtmp/vtmp.conf
./o.fmtarenas -a 40M -b 8k arenas $vtmp/arena
- ./o.fmtbloom -s 10M $vtmp/bloom
+ ./o.fmtbloom $vtmp/bloom
./o.fmtisect -b 8k isect $vtmp/isect
./o.fmtindex vtmp.conf
}
diff --git a/src/cmd/venti/srv/zblock.c b/src/cmd/venti/srv/zblock.c
index 87c31765..afff0801 100644
--- a/src/cmd/venti/srv/zblock.c
+++ b/src/cmd/venti/srv/zblock.c
@@ -16,6 +16,9 @@ fmtzbinit(Fmt *f, ZBlock *b)
#define ROUNDUP(p, n) ((void*)(((uintptr)(p)+(n)-1)&~(uintptr)((n)-1)))
+enum {
+ OverflowCheck = 32
+};
static char zmagic[] = "1234567890abcdefghijklmnopqrstuvxyz";
ZBlock *
@@ -29,7 +32,7 @@ alloczblock(u32int size, int zeroed, uint blocksize)
if(blocksize == 0)
blocksize = 32; /* try for cache line alignment */
- n = size+32/*XXX*/+sizeof(ZBlock)+blocksize+8;
+ n = size+OverflowCheck+sizeof(ZBlock)+blocksize+8;
p = malloc(n);
if(p == nil){
seterr(EOk, "out of memory");
@@ -37,7 +40,7 @@ alloczblock(u32int size, int zeroed, uint blocksize)
}
data = ROUNDUP(p, blocksize);
- b = ROUNDUP(data+size+32/*XXX*/, 8);
+ b = ROUNDUP(data+size+OverflowCheck, 8);
if(0) fprint(2, "alloc %p-%p data %p-%p b %p-%p\n",
p, p+n, data, data+size, b, b+1);
*b = z;
@@ -47,7 +50,7 @@ alloczblock(u32int size, int zeroed, uint blocksize)
b->_size = size;
if(zeroed)
memset(b->data, 0, size);
- memmove(b->data+size, zmagic, 32/*XXX*/);
+ memmove(b->data+size, zmagic, OverflowCheck);
return b;
}
@@ -55,9 +58,9 @@ void
freezblock(ZBlock *b)
{
if(b){
- if(memcmp(b->data+b->_size, zmagic, 32) != 0)
+ if(memcmp(b->data+b->_size, zmagic, OverflowCheck) != 0)
abort();
- memset(b->data+b->_size, 0, 32);
+ memset(b->data+b->_size, 0, OverflowCheck);
free(b->free);
}
}