plan9port/src/cmd/venti/srv/syncindex.c

65 lines
1.2 KiB
C
Raw Normal View History

2005-07-12 15:23:36 +00:00
#include "stdinc.h"
#include "dat.h"
#include "fns.h"
static int verbose;
void
usage(void)
{
fprint(2, "usage: syncindex [-v] [-B blockcachesize] config\n");
2005-07-12 15:23:36 +00:00
threadexitsall("usage");
}
Config conf;
void
threadmain(int argc, char *argv[])
{
u32int bcmem, icmem;
bcmem = 0;
icmem = 0;
ARGBEGIN{
case 'B':
bcmem = unittoull(EARGF(usage()));
break;
case 'I':
icmem = unittoull(EARGF(usage()));
break;
case 'v':
verbose++;
break;
default:
usage();
break;
}ARGEND
if(argc != 1)
usage();
2005-07-19 16:02:31 +00:00
ventifmtinstall();
2005-07-12 15:23:36 +00:00
if(initventi(argv[0], &conf) < 0)
sysfatal("can't init venti: %r");
2006-07-18 15:26:33 +00:00
if(mainindex->bloom && loadbloom(mainindex->bloom) < 0)
sysfatal("can't load bloom filter: %r");
2005-07-12 15:23:36 +00:00
if(bcmem < maxblocksize * (mainindex->narenas + mainindex->nsects * 4 + 16))
bcmem = maxblocksize * (mainindex->narenas + mainindex->nsects * 4 + 16);
if(0) fprint(2, "initialize %d bytes of disk block cache\n", bcmem);
initdcache(bcmem);
initlumpcache(1*1024*1024, 1024/8);
2007-09-25 09:47:31 -04:00
initicache(icmem);
2005-07-12 15:23:36 +00:00
initicachewrite();
if(mainindex->bloom)
startbloomproc(mainindex->bloom);
if(verbose)
printindex(2, mainindex);
if(syncindex(mainindex) < 0)
sysfatal("failed to sync index=%s: %r", mainindex->name);
flushicache();
flushdcache();
2005-07-12 15:23:36 +00:00
threadexitsall(0);
}