1 a0d146ed 2005-07-12 devnull #include "stdinc.h"
2 a0d146ed 2005-07-12 devnull #include "dat.h"
3 a0d146ed 2005-07-12 devnull #include "fns.h"
5 a0d146ed 2005-07-12 devnull static int verbose;
7 a0d146ed 2005-07-12 devnull usage(void)
9 a0d146ed 2005-07-12 devnull fprint(2, "usage: syncindex [-fv] [-B blockcachesize] config\n");
10 a0d146ed 2005-07-12 devnull threadexitsall("usage");
13 a0d146ed 2005-07-12 devnull Config conf;
16 a0d146ed 2005-07-12 devnull threadmain(int argc, char *argv[])
18 a0d146ed 2005-07-12 devnull u32int bcmem, icmem;
22 a0d146ed 2005-07-12 devnull bcmem = 0;
23 a0d146ed 2005-07-12 devnull icmem = 0;
24 a0d146ed 2005-07-12 devnull ARGBEGIN{
25 a0d146ed 2005-07-12 devnull case 'B':
26 a0d146ed 2005-07-12 devnull bcmem = unittoull(EARGF(usage()));
28 a0d146ed 2005-07-12 devnull case 'I':
29 a0d146ed 2005-07-12 devnull icmem = unittoull(EARGF(usage()));
31 a0d146ed 2005-07-12 devnull case 'f':
34 a0d146ed 2005-07-12 devnull case 'v':
35 a0d146ed 2005-07-12 devnull verbose++;
43 a0d146ed 2005-07-12 devnull readonly = 1;
45 a0d146ed 2005-07-12 devnull if(argc != 1)
48 d67cd5c3 2005-07-19 devnull ventifmtinstall();
49 a0d146ed 2005-07-12 devnull if(initventi(argv[0], &conf) < 0)
50 a0d146ed 2005-07-12 devnull sysfatal("can't init venti: %r");
52 a0d146ed 2005-07-12 devnull if(bcmem < maxblocksize * (mainindex->narenas + mainindex->nsects * 4 + 16))
53 a0d146ed 2005-07-12 devnull bcmem = maxblocksize * (mainindex->narenas + mainindex->nsects * 4 + 16);
54 a0d146ed 2005-07-12 devnull if(0) fprint(2, "initialize %d bytes of disk block cache\n", bcmem);
55 a0d146ed 2005-07-12 devnull initdcache(bcmem);
56 a0d146ed 2005-07-12 devnull initlumpcache(1*1024*1024, 1024/8);
57 a0d146ed 2005-07-12 devnull icmem = u64log2(icmem / (sizeof(IEntry)+sizeof(IEntry*)) / ICacheDepth);
58 a0d146ed 2005-07-12 devnull if(icmem < 4)
59 a0d146ed 2005-07-12 devnull icmem = 4;
60 a0d146ed 2005-07-12 devnull if(1) fprint(2, "initialize %d bytes of index cache for %d index entries\n",
61 a0d146ed 2005-07-12 devnull (sizeof(IEntry)+sizeof(IEntry*)) * (1 << icmem) * ICacheDepth,
62 a0d146ed 2005-07-12 devnull (1 << icmem) * ICacheDepth);
63 a0d146ed 2005-07-12 devnull initicache(icmem, ICacheDepth);
64 a0d146ed 2005-07-12 devnull initicachewrite();
65 a0d146ed 2005-07-12 devnull if(mainindex->bloom)
66 a0d146ed 2005-07-12 devnull startbloomproc(mainindex->bloom);
68 a0d146ed 2005-07-12 devnull if(verbose)
69 a0d146ed 2005-07-12 devnull printindex(2, mainindex);
70 a0d146ed 2005-07-12 devnull if(syncindex(mainindex, fix, 1, 0) < 0)
71 a0d146ed 2005-07-12 devnull sysfatal("failed to sync index=%s: %r\n", mainindex->name);
73 a0d146ed 2005-07-12 devnull threadexitsall(0);