tcleanup - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 07029cdbbd9be6ad780bd594c98d26babec7ee67
 (DIR) parent 8d271d6cc3e14e5f7817dfbad2148ca86a6097a6
 (HTM) Author: rsc <devnull@localhost>
       Date:   Mon, 23 Apr 2007 14:40:54 +0000
       
       cleanup
       
       Diffstat:
         M src/cmd/venti/srv/dat.h             |       4 ----
         M src/cmd/venti/srv/fmtindex.c        |       4 ++--
         M src/cmd/venti/srv/icachewrite.c     |      17 ++++++++++++++---
         M src/cmd/venti/srv/index.c           |       4 +---
         M src/cmd/venti/srv/printarenapart.c  |       5 -----
         M src/cmd/venti/srv/tester            |       4 ++--
         M src/cmd/venti/srv/zblock.c          |      13 ++++++++-----
       
       7 files changed, 27 insertions(+), 24 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/venti/srv/dat.h b/src/cmd/venti/srv/dat.h
       t@@ -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 */
 (DIR) diff --git a/src/cmd/venti/srv/fmtindex.c b/src/cmd/venti/srv/fmtindex.c
       t@@ -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);
 (DIR) diff --git a/src/cmd/venti/srv/icachewrite.c b/src/cmd/venti/srv/icachewrite.c
       t@@ -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;
       t@@ -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);
       t@@ -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;
 (DIR) diff --git a/src/cmd/venti/srv/index.c b/src/cmd/venti/srv/index.c
       t@@ -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){
       t@@ -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){
       t@@ -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);
 (DIR) diff --git a/src/cmd/venti/srv/printarenapart.c b/src/cmd/venti/srv/printarenapart.c
       t@@ -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++;
       t@@ -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);
 (DIR) diff --git a/src/cmd/venti/srv/tester b/src/cmd/venti/srv/tester
       t@@ -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)
       t@@ -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
        }
 (DIR) diff --git a/src/cmd/venti/srv/zblock.c b/src/cmd/venti/srv/zblock.c
       t@@ -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 *
       t@@ -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");
       t@@ -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;
       t@@ -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;
        }
        
       t@@ -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);
                }
        }