dat.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. typedef struct Config Config;
  2. typedef struct AMap AMap;
  3. typedef struct AMapN AMapN;
  4. typedef struct Arena Arena;
  5. typedef struct AState AState;
  6. typedef struct ArenaCIG ArenaCIG;
  7. typedef struct ArenaHead ArenaHead;
  8. typedef struct ArenaPart ArenaPart;
  9. typedef struct ArenaTail ArenaTail;
  10. typedef struct ATailStats ATailStats;
  11. typedef struct CIBlock CIBlock;
  12. typedef struct Clump Clump;
  13. typedef struct ClumpInfo ClumpInfo;
  14. typedef struct Graph Graph;
  15. typedef struct IAddr IAddr;
  16. typedef struct IBucket IBucket;
  17. typedef struct IEStream IEStream;
  18. typedef struct IEntry IEntry;
  19. typedef struct IFile IFile;
  20. typedef struct ISect ISect;
  21. typedef struct Index Index;
  22. typedef struct Lump Lump;
  23. typedef struct DBlock DBlock;
  24. typedef struct Part Part;
  25. typedef struct Statbin Statbin;
  26. typedef struct Statdesc Statdesc;
  27. typedef struct Stats Stats;
  28. typedef struct ZBlock ZBlock;
  29. typedef struct Round Round;
  30. typedef struct Bloom Bloom;
  31. #pragma incomplete IEStream
  32. #define TWID32 ((u32int)~(u32int)0)
  33. #define TWID64 ((u64int)~(u64int)0)
  34. #define TWID8 ((u8int)~(u8int)0)
  35. enum
  36. {
  37. ABlockLog = 9, /* log2(512), the quantum for reading arenas */
  38. ANameSize = 64,
  39. MaxDiskBlock = 64*1024, /* max. allowed size for a disk block */
  40. MaxIoSize = 64*1024, /* max. allowed size for a disk io operation */
  41. PartBlank = 256*1024, /* untouched section at beginning of partition */
  42. HeadSize = 512, /* size of a header after PartBlank */
  43. MinArenaSize = 1*1024*1024, /* smallest reasonable arena size */
  44. IndexBase = 1024*1024, /* initial address to use in an index */
  45. MaxIo = 64*1024, /* max size of a single read or write operation */
  46. ICacheBits = 16, /* default bits for indexing icache */
  47. MaxAMap = 2*1024, /* max. allowed arenas in an address mapping; must be < 32*1024 */
  48. /*
  49. * return codes from syncarena
  50. */
  51. SyncDataErr = 1 << 0, /* problem reading the clump data */
  52. SyncCIErr = 1 << 1, /* found erroneous clump directory entries */
  53. SyncCIZero = 1 << 2, /* found unwritten clump directory entries */
  54. SyncFixErr = 1 << 3, /* error writing fixed data */
  55. SyncHeader = 1 << 4, /* altered header fields */
  56. /*
  57. * error severity
  58. */
  59. EOk = 0, /* error expected in normal operation */
  60. EStrange, /* strange error that should be logged */
  61. ECorrupt, /* corrupted data found in arenas */
  62. EICorrupt, /* corrupted data found in index */
  63. EAdmin, /* should be brought to administrators' attention */
  64. ECrash, /* really bad internal error */
  65. EBug, /* a limitation which should be fixed */
  66. EInconsist, /* inconsistencies between index and arena */
  67. EMax,
  68. /*
  69. * internal disk formats for the venti archival storage system
  70. */
  71. /*
  72. * magic numbers on disk
  73. */
  74. _ClumpMagic = 0xd15cb10cU, /* clump header, deprecated */
  75. ClumpFreeMagic = 0, /* free clump; terminates active clump log */
  76. ArenaPartMagic = 0xa9e4a5e7U, /* arena partition header */
  77. ArenaMagic = 0xf2a14eadU, /* arena trailer */
  78. ArenaHeadMagic = 0xd15c4eadU, /* arena header */
  79. BloomMagic = 0xb1004eadU, /* bloom filter header */
  80. BloomMaxHash = 32,
  81. ISectMagic = 0xd15c5ec7U, /* index header */
  82. ArenaPartVersion = 3,
  83. ArenaVersion4 = 4,
  84. ArenaVersion5 = 5,
  85. BloomVersion = 1,
  86. IndexVersion = 1,
  87. ISectVersion1 = 1,
  88. ISectVersion2 = 2,
  89. /*
  90. * encodings of clumps on disk
  91. */
  92. ClumpEErr = 0, /* can't happen */
  93. ClumpENone, /* plain */
  94. ClumpECompress, /* compressed */
  95. ClumpEMax,
  96. /*
  97. * sizes in bytes on disk
  98. */
  99. U8Size = 1,
  100. U16Size = 2,
  101. U32Size = 4,
  102. U64Size = 8,
  103. ArenaPartSize = 4 * U32Size,
  104. ArenaSize4 = 2 * U64Size + 6 * U32Size + ANameSize + U8Size,
  105. ArenaSize5 = ArenaSize4 + U32Size,
  106. ArenaSize5a = ArenaSize5 + 2 * U8Size + 2 * U32Size + 2 * U64Size,
  107. ArenaHeadSize4 = U64Size + 3 * U32Size + ANameSize,
  108. ArenaHeadSize5 = ArenaHeadSize4 + U32Size,
  109. BloomHeadSize = 4 * U32Size,
  110. ISectSize1 = 7 * U32Size + 2 * ANameSize,
  111. ISectSize2 = ISectSize1 + U32Size,
  112. ClumpInfoSize = U8Size + 2 * U16Size + VtScoreSize,
  113. ClumpSize = ClumpInfoSize + U8Size + 3 * U32Size,
  114. MaxBloomSize = 1<<(32-3), /* 2^32 bits */
  115. MaxBloomHash = 32, /* bits per score */
  116. /*
  117. * BUG - The various block copies that manipulate entry buckets
  118. * would be faster if we bumped IBucketSize up to 8 and IEntrySize up to 40,
  119. * so that everything is word-aligned. Buildindex is actually cpu-bound
  120. * by the (byte at a time) copying in qsort.
  121. */
  122. IBucketSize = U32Size + U16Size,
  123. IEntrySize = U64Size + U32Size + 2*U16Size + 2*U8Size + VtScoreSize,
  124. IEntryTypeOff = VtScoreSize + U32Size + U16Size + U64Size + U16Size,
  125. IEntryAddrOff = VtScoreSize + U32Size + U16Size,
  126. MaxClumpBlocks = (VtMaxLumpSize + ClumpSize + (1 << ABlockLog) - 1) >> ABlockLog,
  127. IcacheFrac = 1000000, /* denominator */
  128. SleepForever = 1000000000, /* magic value for sleep time */
  129. /*
  130. * dirty flags - order controls disk write order
  131. */
  132. DirtyArena = 1,
  133. DirtyArenaCib,
  134. DirtyArenaTrailer,
  135. DirtyMax,
  136. ArenaCIGSize = 10*1024, // about 0.5 MB worth of IEntry.
  137. VentiZZZZZZZZ
  138. };
  139. extern char TraceDisk[];
  140. extern char TraceLump[];
  141. extern char TraceBlock[];
  142. extern char TraceProc[];
  143. extern char TraceWork[];
  144. extern char TraceQuiet[];
  145. extern char TraceRpc[];
  146. /*
  147. * results of parsing and initializing a config file
  148. */
  149. struct Config
  150. {
  151. char *index; /* name of the index to initialize */
  152. int naparts; /* arena partitions initialized */
  153. ArenaPart **aparts;
  154. int nsects; /* index sections initialized */
  155. ISect **sects;
  156. Bloom *bloom; /* bloom filter */
  157. u32int bcmem;
  158. u32int mem;
  159. u32int icmem;
  160. int queuewrites;
  161. char* haddr;
  162. char* vaddr;
  163. char* webroot;
  164. };
  165. /*
  166. * a Part is the low level interface to files or disks.
  167. * there are two main types of partitions
  168. * arena paritions, which some number of arenas, each in a sub-partition.
  169. * index partition, which only have one subpartition.
  170. */
  171. struct Part
  172. {
  173. int fd; /* rock for accessing the disk */
  174. int mode;
  175. u64int offset;
  176. u64int size; /* size of the partiton */
  177. u32int blocksize; /* block size for reads and writes */
  178. u32int fsblocksize; /* minimum file system block size */
  179. char *name;
  180. char *filename;
  181. Channel *writechan; /* chan[dcache.nblock](DBlock*) */
  182. };
  183. /*
  184. * a cached block from the partition
  185. * yuck -- most of this is internal structure for the cache
  186. * all other routines should only use data
  187. */
  188. struct DBlock
  189. {
  190. u8int *data;
  191. Part *part; /* partition in which cached */
  192. u64int addr; /* base address on the partition */
  193. u32int size; /* amount of data available, not amount allocated; should go away */
  194. u32int mode;
  195. u32int dirty;
  196. u32int dirtying;
  197. DBlock *next; /* doubly linked hash chains */
  198. DBlock *prev;
  199. u32int heap; /* index in heap table */
  200. u32int used; /* last reference times */
  201. u32int used2;
  202. u32int ref; /* reference count */
  203. RWLock lock; /* for access to data only */
  204. Channel *writedonechan;
  205. void* chanbuf[1]; /* buffer for the chan! */
  206. };
  207. /*
  208. * a cached block from the partition
  209. * yuck -- most of this is internal structure for the cache
  210. * all other routines should only use data
  211. * double yuck -- this is mostly the same as a DBlock
  212. */
  213. struct Lump
  214. {
  215. Packet *data;
  216. Part *part; /* partition in which cached */
  217. u8int score[VtScoreSize]; /* score of packet */
  218. u8int type; /* type of packet */
  219. u32int size; /* amount of data allocated to hold packet */
  220. Lump *next; /* doubly linked hash chains */
  221. Lump *prev;
  222. u32int heap; /* index in heap table */
  223. u32int used; /* last reference times */
  224. u32int used2;
  225. u32int ref; /* reference count */
  226. QLock lock; /* for access to data only */
  227. };
  228. /*
  229. * mapping between names and address ranges
  230. */
  231. struct AMap
  232. {
  233. u64int start;
  234. u64int stop;
  235. char name[ANameSize];
  236. };
  237. /*
  238. * an AMap along with a length
  239. */
  240. struct AMapN
  241. {
  242. int n;
  243. AMap *map;
  244. };
  245. /*
  246. * an ArenaPart is a partition made up of Arenas
  247. * it exists because most os's don't support many partitions,
  248. * and we want to have many different Arenas
  249. */
  250. struct ArenaPart
  251. {
  252. Part *part;
  253. u64int size; /* size of underlying partition, rounded down to blocks */
  254. Arena **arenas;
  255. u32int tabbase; /* base address of arena table on disk */
  256. u32int tabsize; /* max. bytes in arena table */
  257. /*
  258. * fields stored on disk
  259. */
  260. u32int version;
  261. u32int blocksize; /* "optimal" block size for reads and writes */
  262. u32int arenabase; /* base address of first arena */
  263. /*
  264. * stored in the arena mapping table on disk
  265. */
  266. AMap *map;
  267. int narenas;
  268. };
  269. /*
  270. * info about one block in the clump info cache
  271. */
  272. struct CIBlock
  273. {
  274. u32int block; /* blocks in the directory */
  275. int offset; /* offsets of one clump in the data */
  276. DBlock *data;
  277. };
  278. /*
  279. * Statistics kept in the tail.
  280. */
  281. struct ATailStats
  282. {
  283. u32int clumps; /* number of clumps */
  284. u32int cclumps; /* number of compressed clumps */
  285. u64int used;
  286. u64int uncsize;
  287. u8int sealed;
  288. };
  289. /*
  290. * Arena state - represents a point in the data log
  291. */
  292. struct AState
  293. {
  294. Arena *arena;
  295. u64int aa; /* index address */
  296. ATailStats stats;
  297. };
  298. /*
  299. * an Arena is a log of Clumps, preceeded by an ArenaHeader,
  300. * and followed by a Arena, each in one disk block.
  301. * struct on disk is not always up to date, but should be self-consistent.
  302. * to sync after reboot, follow clumps starting at used until ClumpFreeMagic if found.
  303. * <struct name="Arena" type="Arena *">
  304. * <field name="name" val="s->name" type="AName"/>
  305. * <field name="version" val="s->version" type="U32int"/>
  306. * <field name="partition" val="s->part->name" type="AName"/>
  307. * <field name="blocksize" val="s->blocksize" type="U32int"/>
  308. * <field name="start" val="s->base" type="U64int"/>
  309. * <field name="stop" val="s->base+2*s->blocksize" type="U64int"/>
  310. * <field name="created" val="s->ctime" type="U32int"/>
  311. * <field name="modified" val="s->wtime" type="U32int"/>
  312. * <field name="sealed" val="s->sealed" type="Sealed"/>
  313. * <field name="score" val="s->score" type="Score"/>
  314. * <field name="clumps" val="s->clumps" type="U32int"/>
  315. * <field name="compressedclumps" val="s->cclumps" type="U32int"/>
  316. * <field name="data" val="s->uncsize" type="U64int"/>
  317. * <field name="compresseddata" val="s->used - s->clumps * ClumpSize" type="U64int"/>
  318. * <field name="storage" val="s->used + s->clumps * ClumpInfoSize" type="U64int"/>
  319. * </struct>
  320. */
  321. struct Arena
  322. {
  323. QLock lock; /* lock for arena fields, writing to disk */
  324. Part *part; /* partition in which arena lives */
  325. int blocksize; /* size of block to read or write */
  326. u64int base; /* base address on disk */
  327. u64int size; /* total space in the arena */
  328. u8int score[VtScoreSize]; /* score of the entire sealed & summed arena */
  329. int clumpmax; /* ClumpInfos per block */
  330. AState mem;
  331. int inqueue;
  332. /*
  333. * fields stored on disk
  334. */
  335. u32int version;
  336. char name[ANameSize]; /* text label */
  337. ATailStats memstats;
  338. ATailStats diskstats;
  339. u32int ctime; /* first time a block was written */
  340. u32int wtime; /* last time a block was written */
  341. u32int clumpmagic;
  342. ArenaCIG *cig;
  343. int ncig;
  344. };
  345. struct ArenaCIG
  346. {
  347. u64int offset; // from arena base
  348. };
  349. /*
  350. * redundant storage of some fields at the beginning of each arena
  351. */
  352. struct ArenaHead
  353. {
  354. u32int version;
  355. char name[ANameSize];
  356. u32int blocksize;
  357. u64int size;
  358. u32int clumpmagic;
  359. };
  360. /*
  361. * most interesting meta information for a clump.
  362. * stored in each clump's header and in the Arena's directory,
  363. * stored in reverse order just prior to the arena trailer
  364. */
  365. struct ClumpInfo
  366. {
  367. u8int type;
  368. u16int size; /* size of disk data, not including header */
  369. u16int uncsize; /* size of uncompressed data */
  370. u8int score[VtScoreSize]; /* score of the uncompressed data only */
  371. };
  372. /*
  373. * header for an immutable clump of data
  374. */
  375. struct Clump
  376. {
  377. ClumpInfo info;
  378. u8int encoding;
  379. u32int creator; /* initial client which wrote the block */
  380. u32int time; /* creation at gmt seconds since 1/1/1970 */
  381. };
  382. /*
  383. * index of all clumps according to their score
  384. * this is just a wrapper to tie together the index sections
  385. * <struct name="Index" type="Index *">
  386. * <field name="name" val="s->name" type="AName"/>
  387. * <field name="version" val="s->version" type="U32int"/>
  388. * <field name="blocksize" val="s->blocksize" type="U32int"/>
  389. * <field name="tabsize" val="s->tabsize" type="U32int"/>
  390. * <field name="buckets" val="s->buckets" type="U32int"/>
  391. * <field name="buckdiv" val="s->div" type="U32int"/>
  392. * <field name="bitblocks" val="s->div" type="U32int"/>
  393. * <field name="maxdepth" val="s->div" type="U32int"/>
  394. * <field name="bitkeylog" val="s->div" type="U32int"/>
  395. * <field name="bitkeymask" val="s->div" type="U32int"/>
  396. * <array name="sect" val="&s->smap[i]" elems="s->nsects" type="Amap"/>
  397. * <array name="amap" val="&s->amap[i]" elems="s->narenas" type="Amap"/>
  398. * <array name="arena" val="s->arenas[i]" elems="s->narenas" type="Arena"/>
  399. * </struct>
  400. * <struct name="Amap" type="AMap *">
  401. * <field name="name" val="s->name" type="AName"/>
  402. * <field name="start" val="s->start" type="U64int"/>
  403. * <field name="stop" val="s->stop" type="U64int"/>
  404. * </struct>
  405. */
  406. struct Index
  407. {
  408. u32int div; /* divisor for mapping score to bucket */
  409. u32int buckets; /* last bucket used in disk hash table */
  410. u32int blocksize;
  411. u32int tabsize; /* max. bytes in index config */
  412. int mapalloc; /* first arena to check when adding a lump */
  413. Arena **arenas; /* arenas in the mapping */
  414. ISect **sects; /* sections which hold the buckets */
  415. Bloom *bloom; /* bloom filter */
  416. /*
  417. * fields stored in config file
  418. */
  419. u32int version;
  420. char name[ANameSize]; /* text label */
  421. int nsects;
  422. AMap *smap; /* mapping of buckets to index sections */
  423. int narenas;
  424. AMap *amap; /* mapping from index addesses to arenas */
  425. QLock writing;
  426. };
  427. /*
  428. * one part of the bucket storage for an index.
  429. * the index blocks are sequentially allocated
  430. * across all of the sections.
  431. */
  432. struct ISect
  433. {
  434. Part *part;
  435. int blocklog; /* log2(blocksize) */
  436. int buckmax; /* max. entries in a index bucket */
  437. u32int tabbase; /* base address of index config table on disk */
  438. u32int tabsize; /* max. bytes in index config */
  439. Channel *writechan;
  440. Channel *writedonechan;
  441. void *ig; /* used by buildindex only */
  442. int ng;
  443. /*
  444. * fields stored on disk
  445. */
  446. u32int version;
  447. u32int bucketmagic;
  448. char name[ANameSize]; /* text label */
  449. char index[ANameSize]; /* index owning the section */
  450. u32int blocksize; /* size of hash buckets in index */
  451. u32int blockbase; /* address of start of on disk index table */
  452. u32int blocks; /* total blocks on disk; some may be unused */
  453. u32int start; /* first bucket in this section */
  454. u32int stop; /* limit of buckets in this section */
  455. };
  456. /*
  457. * externally interesting part of an IEntry
  458. */
  459. struct IAddr
  460. {
  461. u64int addr;
  462. u16int size; /* uncompressed size */
  463. u8int type; /* type of block */
  464. u8int blocks; /* arena io quanta for Clump + data */
  465. };
  466. /*
  467. * entries in the index
  468. * kept in IBuckets in the disk index table,
  469. * cached in the memory ICache.
  470. */
  471. struct IEntry
  472. {
  473. /* on disk data - 32 bytes*/
  474. u8int score[VtScoreSize];
  475. IAddr ia;
  476. IEntry *nexthash;
  477. IEntry *nextdirty;
  478. IEntry *next;
  479. IEntry *prev;
  480. u8int state;
  481. };
  482. enum {
  483. IEClean = 0,
  484. IEDirty = 1,
  485. IESummary = 2,
  486. };
  487. /*
  488. * buckets in the on disk index table
  489. */
  490. struct IBucket
  491. {
  492. u16int n; /* number of active indices */
  493. u32int buck; /* used by buildindex/checkindex only */
  494. u8int *data;
  495. };
  496. /*
  497. * temporary buffers used by individual threads
  498. */
  499. struct ZBlock
  500. {
  501. u32int len;
  502. u32int _size;
  503. u8int *data;
  504. u8int *free;
  505. };
  506. /*
  507. * simple input buffer for a '\0' terminated text file
  508. */
  509. struct IFile
  510. {
  511. char *name; /* name of the file */
  512. ZBlock *b; /* entire contents of file */
  513. u32int pos; /* current position in the file */
  514. };
  515. struct Statdesc
  516. {
  517. char *name;
  518. ulong max;
  519. };
  520. /* keep in sync with stats.c:/statdesc and httpd.c:/graphname*/
  521. enum
  522. {
  523. StatRpcTotal,
  524. StatRpcRead,
  525. StatRpcReadOk,
  526. StatRpcReadFail,
  527. StatRpcReadBytes,
  528. StatRpcReadTime,
  529. StatRpcReadCached,
  530. StatRpcReadCachedTime,
  531. StatRpcReadUncached,
  532. StatRpcReadUncachedTime,
  533. StatRpcWrite,
  534. StatRpcWriteNew,
  535. StatRpcWriteOld,
  536. StatRpcWriteFail,
  537. StatRpcWriteBytes,
  538. StatRpcWriteTime,
  539. StatRpcWriteNewTime,
  540. StatRpcWriteOldTime,
  541. StatLcacheHit,
  542. StatLcacheMiss,
  543. StatLcacheRead,
  544. StatLcacheWrite,
  545. StatLcacheSize,
  546. StatLcacheStall,
  547. StatLcacheReadTime,
  548. StatDcacheHit,
  549. StatDcacheMiss,
  550. StatDcacheLookup,
  551. StatDcacheRead,
  552. StatDcacheWrite,
  553. StatDcacheDirty,
  554. StatDcacheSize,
  555. StatDcacheFlush,
  556. StatDcacheStall,
  557. StatDcacheLookupTime,
  558. StatDblockStall,
  559. StatLumpStall,
  560. StatIcacheHit,
  561. StatIcacheMiss,
  562. StatIcacheRead,
  563. StatIcacheWrite,
  564. StatIcacheFill,
  565. StatIcachePrefetch,
  566. StatIcacheDirty,
  567. StatIcacheSize,
  568. StatIcacheFlush,
  569. StatIcacheStall,
  570. StatIcacheReadTime,
  571. StatIcacheLookup,
  572. StatScacheHit,
  573. StatScachePrefetch,
  574. StatBloomHit,
  575. StatBloomMiss,
  576. StatBloomFalseMiss,
  577. StatBloomLookup,
  578. StatBloomOnes,
  579. StatBloomBits,
  580. StatBloomLookupTime,
  581. StatApartRead,
  582. StatApartReadBytes,
  583. StatApartWrite,
  584. StatApartWriteBytes,
  585. StatIsectRead,
  586. StatIsectReadBytes,
  587. StatIsectWrite,
  588. StatIsectWriteBytes,
  589. StatSumRead,
  590. StatSumReadBytes,
  591. StatCigLoad,
  592. StatCigLoadTime,
  593. NStat
  594. };
  595. extern Statdesc statdesc[NStat];
  596. /*
  597. * statistics about the operation of the server
  598. * mainly for performance monitoring and profiling.
  599. */
  600. struct Stats
  601. {
  602. ulong now;
  603. ulong n[NStat];
  604. };
  605. struct Statbin
  606. {
  607. uint nsamp;
  608. uint min;
  609. uint max;
  610. uint avg;
  611. };
  612. struct Graph
  613. {
  614. long (*fn)(Stats*, Stats*, void*);
  615. void *arg;
  616. long t0;
  617. long t1;
  618. long min;
  619. long max;
  620. long wid;
  621. long ht;
  622. int fill;
  623. };
  624. /*
  625. * for kicking background processes that run one round after another after another
  626. */
  627. struct Round
  628. {
  629. QLock lock;
  630. Rendez start;
  631. Rendez finish;
  632. Rendez delaywait;
  633. int delaytime;
  634. int delaykick;
  635. char* name;
  636. int last;
  637. int current;
  638. int next;
  639. int doanother;
  640. };
  641. /*
  642. * Bloom filter of stored block hashes
  643. */
  644. struct Bloom
  645. {
  646. RWLock lk; /* protects nhash, nbits, tab, mb */
  647. QLock mod; /* one marker at a time, protects nb */
  648. int nhash;
  649. ulong size; /* bytes in tab */
  650. ulong bitmask; /* to produce bit index */
  651. u8int *data;
  652. Part *part;
  653. Channel *writechan;
  654. Channel *writedonechan;
  655. };
  656. extern Index *mainindex;
  657. extern u32int maxblocksize; /* max. block size used by any partition */
  658. extern int paranoid; /* should verify hashes on disk read */
  659. extern int queuewrites; /* put all lump writes on a queue and finish later */
  660. extern int readonly; /* only allowed to read the disk data */
  661. extern Stats stats;
  662. extern u8int zeroscore[VtScoreSize];
  663. extern int compressblocks;
  664. extern int writestodevnull; /* dangerous - for performance debugging */
  665. extern int collectstats;
  666. extern QLock memdrawlock;
  667. extern int icachesleeptime;
  668. extern int minicachesleeptime;
  669. extern int arenasumsleeptime;
  670. extern int manualscheduling;
  671. extern int l0quantum;
  672. extern int l1quantum;
  673. extern int ignorebloom;
  674. extern int icacheprefetch;
  675. extern int syncwrites;
  676. extern Stats *stathist;
  677. extern int nstathist;
  678. extern ulong stattime;
  679. #ifndef PLAN9PORT
  680. #pragma varargck type "V" uchar*
  681. #define ODIRECT 0
  682. #endif