dat.h 19 KB

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