mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-27 11:52:03 +00:00
cleanup
This commit is contained in:
parent
8d271d6cc3
commit
07029cdbbd
7 changed files with 27 additions and 24 deletions
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue