1 7a4ee46d 2003-11-23 devnull typedef struct Config Config;
2 7a4ee46d 2003-11-23 devnull typedef struct AMap AMap;
3 7a4ee46d 2003-11-23 devnull typedef struct AMapN AMapN;
4 7a4ee46d 2003-11-23 devnull typedef struct Arena Arena;
5 7a4ee46d 2003-11-23 devnull typedef struct ArenaHead ArenaHead;
6 7a4ee46d 2003-11-23 devnull typedef struct ArenaPart ArenaPart;
7 7a4ee46d 2003-11-23 devnull typedef struct CIBlock CIBlock;
8 7a4ee46d 2003-11-23 devnull typedef struct Clump Clump;
9 7a4ee46d 2003-11-23 devnull typedef struct ClumpInfo ClumpInfo;
10 7a4ee46d 2003-11-23 devnull typedef struct IAddr IAddr;
11 7a4ee46d 2003-11-23 devnull typedef struct IBucket IBucket;
12 7a4ee46d 2003-11-23 devnull typedef struct ICache ICache;
13 7a4ee46d 2003-11-23 devnull typedef struct IEStream IEStream;
14 7a4ee46d 2003-11-23 devnull typedef struct IEntry IEntry;
15 7a4ee46d 2003-11-23 devnull typedef struct IFile IFile;
16 7a4ee46d 2003-11-23 devnull typedef struct ISect ISect;
17 7a4ee46d 2003-11-23 devnull typedef struct Index Index;
18 7a4ee46d 2003-11-23 devnull typedef struct Lump Lump;
19 7a4ee46d 2003-11-23 devnull typedef struct DBlock DBlock;
20 7a4ee46d 2003-11-23 devnull typedef struct Part Part;
21 7a4ee46d 2003-11-23 devnull typedef struct Stats Stats;
22 7a4ee46d 2003-11-23 devnull typedef struct ZBlock ZBlock;
24 7a4ee46d 2003-11-23 devnull #define TWID32 ((u32int)~(u32int)0)
25 7a4ee46d 2003-11-23 devnull #define TWID64 ((u64int)~(u64int)0)
26 7a4ee46d 2003-11-23 devnull #define TWID8 ((u8int)~(u8int)0)
30 7a4ee46d 2003-11-23 devnull ABlockLog = 9, /* log2(512), the quantum for reading arenas */
31 7a4ee46d 2003-11-23 devnull ANameSize = 64,
32 7a4ee46d 2003-11-23 devnull MaxDiskBlock = 64*1024, /* max. allowed size for a disk block */
33 7a4ee46d 2003-11-23 devnull MaxIoSize = 64*1024, /* max. allowed size for a disk io operation */
34 7a4ee46d 2003-11-23 devnull PartBlank = 256*1024, /* untouched section at beginning of partition */
35 7a4ee46d 2003-11-23 devnull HeadSize = 512, /* size of a header after PartBlank */
36 7a4ee46d 2003-11-23 devnull MinArenaSize = 1*1024*1024, /* smallest reasonable arena size */
37 7a4ee46d 2003-11-23 devnull IndexBase = 1024*1024, /* initial address to use in an index */
38 7a4ee46d 2003-11-23 devnull MaxIo = 64*1024, /* max size of a single read or write operation */
39 7a4ee46d 2003-11-23 devnull ICacheBits = 16, /* default bits for indexing icache */
40 7a4ee46d 2003-11-23 devnull ICacheDepth = 4, /* default depth of an icache hash chain */
41 7a4ee46d 2003-11-23 devnull MaxAMap = 2*1024, /* max. allowed arenas in an address mapping; must be < 32*1024 */
44 7a4ee46d 2003-11-23 devnull * return codes from syncarena
46 7a4ee46d 2003-11-23 devnull SyncDataErr = 1 << 0, /* problem reading the clump data */
47 7a4ee46d 2003-11-23 devnull SyncCIErr = 1 << 1, /* found erroneous clump directory entries */
48 7a4ee46d 2003-11-23 devnull SyncCIZero = 1 << 2, /* found unwritten clump directory entries */
49 7a4ee46d 2003-11-23 devnull SyncFixErr = 1 << 3, /* error writing fixed data */
50 7a4ee46d 2003-11-23 devnull SyncHeader = 1 << 4, /* altered header fields */
53 7a4ee46d 2003-11-23 devnull * error severity
55 7a4ee46d 2003-11-23 devnull EOk = 0, /* error expected in normal operation */
56 7a4ee46d 2003-11-23 devnull EStrange, /* strange error that should be logged */
57 7a4ee46d 2003-11-23 devnull ECorrupt, /* corrupted data found in arenas */
58 7a4ee46d 2003-11-23 devnull EICorrupt, /* corrupted data found in index */
59 7a4ee46d 2003-11-23 devnull EAdmin, /* should be brought to administrators' attention */
60 7a4ee46d 2003-11-23 devnull ECrash, /* really bad internal error */
61 7a4ee46d 2003-11-23 devnull EBug, /* a limitation which should be fixed */
62 7a4ee46d 2003-11-23 devnull EInconsist, /* inconsistencies between index and arena */
66 7a4ee46d 2003-11-23 devnull * internal disk formats for the venti archival storage system
69 7a4ee46d 2003-11-23 devnull * magic numbers on disk
71 7a4ee46d 2003-11-23 devnull ClumpMagic = 0xd15cb10c, /* clump header */
72 7a4ee46d 2003-11-23 devnull ClumpFreeMagic = 0, /* free clump; terminates active clump log */
74 7a4ee46d 2003-11-23 devnull ArenaPartMagic = 0xa9e4a5e7, /* arena partition header */
75 7a4ee46d 2003-11-23 devnull ArenaMagic = 0xf2a14ead, /* arena trailer */
76 7a4ee46d 2003-11-23 devnull ArenaHeadMagic = 0xd15c4ead, /* arena header */
78 7a4ee46d 2003-11-23 devnull ISectMagic = 0xd15c5ec7, /* index header */
80 7a4ee46d 2003-11-23 devnull ArenaPartVersion = 3,
81 7a4ee46d 2003-11-23 devnull ArenaVersion = 4,
82 7a4ee46d 2003-11-23 devnull IndexVersion = 1,
83 7a4ee46d 2003-11-23 devnull ISectVersion = 1,
86 7a4ee46d 2003-11-23 devnull * encodings of clumps on disk
88 7a4ee46d 2003-11-23 devnull ClumpEErr = 0, /* can't happen */
89 7a4ee46d 2003-11-23 devnull ClumpENone, /* plain */
90 7a4ee46d 2003-11-23 devnull ClumpECompress, /* compressed */
91 7a4ee46d 2003-11-23 devnull ClumpEMax,
94 7a4ee46d 2003-11-23 devnull * marker for corrupted data on disk
96 7a4ee46d 2003-11-23 devnull VtTypeCorrupt = VtMaxType,
99 7a4ee46d 2003-11-23 devnull * sizes in bytes on disk
101 7a4ee46d 2003-11-23 devnull U8Size = 1,
102 7a4ee46d 2003-11-23 devnull U16Size = 2,
103 7a4ee46d 2003-11-23 devnull U32Size = 4,
104 7a4ee46d 2003-11-23 devnull U64Size = 8,
106 7a4ee46d 2003-11-23 devnull ArenaPartSize = 4 * U32Size,
107 7a4ee46d 2003-11-23 devnull ArenaSize = 2 * U64Size + 6 * U32Size + ANameSize + U8Size,
108 7a4ee46d 2003-11-23 devnull ArenaHeadSize = U64Size + 3 * U32Size + ANameSize,
109 7a4ee46d 2003-11-23 devnull ISectSize = 7 * U32Size + 2 * ANameSize,
110 7a4ee46d 2003-11-23 devnull ClumpInfoSize = U8Size + 2 * U16Size + VtScoreSize,
111 7a4ee46d 2003-11-23 devnull ClumpSize = ClumpInfoSize + U8Size + 3 * U32Size,
112 7a4ee46d 2003-11-23 devnull IBucketSize = U32Size + U16Size,
113 7a4ee46d 2003-11-23 devnull IEntrySize = U64Size + U32Size + 2*U16Size + 2*U8Size + VtScoreSize,
114 7a4ee46d 2003-11-23 devnull IEntryTypeOff = VtScoreSize + U64Size + U32Size + 2 * U16Size,
116 7a4ee46d 2003-11-23 devnull MaxClumpBlocks = (VtMaxLumpSize + ClumpSize + (1 << ABlockLog) - 1) >> ABlockLog,
118 7a4ee46d 2003-11-23 devnull VentiZZZZZZZZ
122 7a4ee46d 2003-11-23 devnull * results of parsing and initializing a config file
124 7a4ee46d 2003-11-23 devnull struct Config
126 7a4ee46d 2003-11-23 devnull char *index; /* name of the index to initialize */
127 7a4ee46d 2003-11-23 devnull int naparts; /* arena partitions initialized */
128 7a4ee46d 2003-11-23 devnull ArenaPart **aparts;
129 7a4ee46d 2003-11-23 devnull int nsects; /* index sections initialized */
130 7a4ee46d 2003-11-23 devnull ISect **sects;
134 7a4ee46d 2003-11-23 devnull * a Part is the low level interface to files or disks.
135 7a4ee46d 2003-11-23 devnull * there are two main types of partitions
136 7a4ee46d 2003-11-23 devnull * arena paritions, which some number of arenas, each in a sub-partition.
137 7a4ee46d 2003-11-23 devnull * index partition, which only have one subpartition.
139 7a4ee46d 2003-11-23 devnull struct Part
141 7a4ee46d 2003-11-23 devnull int fd; /* rock for accessing the disk */
142 7a4ee46d 2003-11-23 devnull u64int size; /* size of the partiton */
143 7a4ee46d 2003-11-23 devnull u32int blocksize; /* block size for reads and writes */
144 7a4ee46d 2003-11-23 devnull char *name;
148 7a4ee46d 2003-11-23 devnull * a cached block from the partition
149 7a4ee46d 2003-11-23 devnull * yuck -- most of this is internal structure for the cache
150 7a4ee46d 2003-11-23 devnull * all other routines should only use data
152 7a4ee46d 2003-11-23 devnull struct DBlock
154 7a4ee46d 2003-11-23 devnull u8int *data;
156 7a4ee46d 2003-11-23 devnull Part *part; /* partition in which cached */
157 7a4ee46d 2003-11-23 devnull u64int addr; /* base address on the partition */
158 7a4ee46d 2003-11-23 devnull u16int size; /* amount of data available, not amount allocated; should go away */
159 7a4ee46d 2003-11-23 devnull DBlock *next; /* doubly linked hash chains */
160 7a4ee46d 2003-11-23 devnull DBlock *prev;
161 7a4ee46d 2003-11-23 devnull u32int heap; /* index in heap table */
162 7a4ee46d 2003-11-23 devnull u32int used; /* last reference times */
163 7a4ee46d 2003-11-23 devnull u32int used2;
164 7a4ee46d 2003-11-23 devnull u32int ref; /* reference count */
165 7a4ee46d 2003-11-23 devnull QLock lock; /* for access to data only */
169 7a4ee46d 2003-11-23 devnull * a cached block from the partition
170 7a4ee46d 2003-11-23 devnull * yuck -- most of this is internal structure for the cache
171 7a4ee46d 2003-11-23 devnull * all other routines should only use data
172 7a4ee46d 2003-11-23 devnull * double yuck -- this is mostly the same as a DBlock
174 7a4ee46d 2003-11-23 devnull struct Lump
176 7a4ee46d 2003-11-23 devnull Packet *data;
178 7a4ee46d 2003-11-23 devnull Part *part; /* partition in which cached */
179 7a4ee46d 2003-11-23 devnull u8int score[VtScoreSize]; /* score of packet */
180 7a4ee46d 2003-11-23 devnull u8int type; /* type of packet */
181 7a4ee46d 2003-11-23 devnull u16int size; /* amount of data allocated to hold packet */
182 7a4ee46d 2003-11-23 devnull Lump *next; /* doubly linked hash chains */
183 7a4ee46d 2003-11-23 devnull Lump *prev;
184 7a4ee46d 2003-11-23 devnull u32int heap; /* index in heap table */
185 7a4ee46d 2003-11-23 devnull u32int used; /* last reference times */
186 7a4ee46d 2003-11-23 devnull u32int used2;
187 7a4ee46d 2003-11-23 devnull u32int ref; /* reference count */
188 7a4ee46d 2003-11-23 devnull QLock lock; /* for access to data only */
192 7a4ee46d 2003-11-23 devnull * mapping between names and address ranges
194 7a4ee46d 2003-11-23 devnull struct AMap
196 7a4ee46d 2003-11-23 devnull u64int start;
197 7a4ee46d 2003-11-23 devnull u64int stop;
198 7a4ee46d 2003-11-23 devnull char name[ANameSize];
202 7a4ee46d 2003-11-23 devnull * an AMap along with a length
204 7a4ee46d 2003-11-23 devnull struct AMapN
207 7a4ee46d 2003-11-23 devnull AMap *map;
211 7a4ee46d 2003-11-23 devnull * an ArenaPart is a partition made up of Arenas
212 7a4ee46d 2003-11-23 devnull * it exists because most os's don't support many partitions,
213 7a4ee46d 2003-11-23 devnull * and we want to have many different Arenas
215 7a4ee46d 2003-11-23 devnull struct ArenaPart
217 7a4ee46d 2003-11-23 devnull Part *part;
218 7a4ee46d 2003-11-23 devnull u64int size; /* size of underlying partition, rounded down to blocks */
219 7a4ee46d 2003-11-23 devnull Arena **arenas;
220 7a4ee46d 2003-11-23 devnull u32int tabbase; /* base address of arena table on disk */
221 7a4ee46d 2003-11-23 devnull u32int tabsize; /* max. bytes in arena table */
224 7a4ee46d 2003-11-23 devnull * fields stored on disk
226 7a4ee46d 2003-11-23 devnull u32int version;
227 7a4ee46d 2003-11-23 devnull u32int blocksize; /* "optimal" block size for reads and writes */
228 7a4ee46d 2003-11-23 devnull u32int arenabase; /* base address of first arena */
231 7a4ee46d 2003-11-23 devnull * stored in the arena mapping table on disk
233 7a4ee46d 2003-11-23 devnull AMap *map;
234 7a4ee46d 2003-11-23 devnull int narenas;
238 7a4ee46d 2003-11-23 devnull * info about one block in the clump info cache
240 7a4ee46d 2003-11-23 devnull struct CIBlock
242 7a4ee46d 2003-11-23 devnull u32int block; /* blocks in the directory */
243 7a4ee46d 2003-11-23 devnull int offset; /* offsets of one clump in the data */
244 7a4ee46d 2003-11-23 devnull DBlock *data;
248 7a4ee46d 2003-11-23 devnull * an Arena is a log of Clumps, preceeded by an ArenaHeader,
249 7a4ee46d 2003-11-23 devnull * and followed by a Arena, each in one disk block.
250 7a4ee46d 2003-11-23 devnull * struct on disk is not always up to date, but should be self-consistent.
251 7a4ee46d 2003-11-23 devnull * to sync after reboot, follow clumps starting at used until ClumpFreeMagic if found.
252 7a4ee46d 2003-11-23 devnull * <struct name="Arena" type="Arena *">
253 7a4ee46d 2003-11-23 devnull * <field name="name" val="s->name" type="AName"/>
254 7a4ee46d 2003-11-23 devnull * <field name="version" val="s->version" type="U32int"/>
255 7a4ee46d 2003-11-23 devnull * <field name="partition" val="s->part->name" type="AName"/>
256 7a4ee46d 2003-11-23 devnull * <field name="blocksize" val="s->blocksize" type="U32int"/>
257 7a4ee46d 2003-11-23 devnull * <field name="start" val="s->base" type="U64int"/>
258 7a4ee46d 2003-11-23 devnull * <field name="stop" val="s->base+2*s->blocksize" type="U64int"/>
259 7a4ee46d 2003-11-23 devnull * <field name="created" val="s->ctime" type="U32int"/>
260 7a4ee46d 2003-11-23 devnull * <field name="modified" val="s->wtime" type="U32int"/>
261 7a4ee46d 2003-11-23 devnull * <field name="sealed" val="s->sealed" type="Sealed"/>
262 7a4ee46d 2003-11-23 devnull * <field name="score" val="s->score" type="Score"/>
263 7a4ee46d 2003-11-23 devnull * <field name="clumps" val="s->clumps" type="U32int"/>
264 7a4ee46d 2003-11-23 devnull * <field name="compressedclumps" val="s->cclumps" type="U32int"/>
265 7a4ee46d 2003-11-23 devnull * <field name="data" val="s->uncsize" type="U64int"/>
266 7a4ee46d 2003-11-23 devnull * <field name="compresseddata" val="s->used - s->clumps * ClumpSize" type="U64int"/>
267 7a4ee46d 2003-11-23 devnull * <field name="storage" val="s->used + s->clumps * ClumpInfoSize" type="U64int"/>
268 7a4ee46d 2003-11-23 devnull * </struct>
270 7a4ee46d 2003-11-23 devnull struct Arena
272 7a4ee46d 2003-11-23 devnull QLock lock; /* lock for arena fields, writing to disk */
273 7a4ee46d 2003-11-23 devnull Part *part; /* partition in which arena lives */
274 7a4ee46d 2003-11-23 devnull int blocksize; /* size of block to read or write */
275 7a4ee46d 2003-11-23 devnull u64int base; /* base address on disk */
276 7a4ee46d 2003-11-23 devnull u64int size; /* total space in the arena */
277 7a4ee46d 2003-11-23 devnull u64int limit; /* storage limit for clumps */
278 7a4ee46d 2003-11-23 devnull u8int score[VtScoreSize]; /* score of the entire sealed & summed arena */
280 7a4ee46d 2003-11-23 devnull int clumpmax; /* ClumpInfos per block */
281 7a4ee46d 2003-11-23 devnull CIBlock cib; /* dirty clump directory block */
284 7a4ee46d 2003-11-23 devnull * fields stored on disk
286 7a4ee46d 2003-11-23 devnull u32int version;
287 7a4ee46d 2003-11-23 devnull char name[ANameSize]; /* text label */
288 7a4ee46d 2003-11-23 devnull u32int clumps; /* number of allocated clumps */
289 7a4ee46d 2003-11-23 devnull u32int cclumps; /* clumps which are compressed; informational only */
290 7a4ee46d 2003-11-23 devnull u32int ctime; /* first time a block was written */
291 7a4ee46d 2003-11-23 devnull u32int wtime; /* last time a block was written */
292 7a4ee46d 2003-11-23 devnull u64int used; /* number of bytes currently used */
293 7a4ee46d 2003-11-23 devnull u64int uncsize; /* total of all clumps's uncsize; informational only */
294 7a4ee46d 2003-11-23 devnull u8int sealed; /* arena all filled up? */
298 7a4ee46d 2003-11-23 devnull * redundant storage of some fields at the beginning of each arena
300 7a4ee46d 2003-11-23 devnull struct ArenaHead
302 7a4ee46d 2003-11-23 devnull u32int version;
303 7a4ee46d 2003-11-23 devnull char name[ANameSize];
304 7a4ee46d 2003-11-23 devnull u32int blocksize;
305 7a4ee46d 2003-11-23 devnull u64int size;
309 7a4ee46d 2003-11-23 devnull * most interesting meta information for a clump.
310 7a4ee46d 2003-11-23 devnull * stored in each clump's header and in the Arena's directory,
311 7a4ee46d 2003-11-23 devnull * stored in reverse order just prior to the arena trailer
313 7a4ee46d 2003-11-23 devnull struct ClumpInfo
315 7a4ee46d 2003-11-23 devnull u8int type;
316 7a4ee46d 2003-11-23 devnull u16int size; /* size of disk data, not including header */
317 7a4ee46d 2003-11-23 devnull u16int uncsize; /* size of uncompressed data */
318 7a4ee46d 2003-11-23 devnull u8int score[VtScoreSize]; /* score of the uncompressed data only */
322 7a4ee46d 2003-11-23 devnull * header for an immutable clump of data
324 7a4ee46d 2003-11-23 devnull struct Clump
326 7a4ee46d 2003-11-23 devnull ClumpInfo info;
327 7a4ee46d 2003-11-23 devnull u8int encoding;
328 7a4ee46d 2003-11-23 devnull u32int creator; /* initial client which wrote the block */
329 7a4ee46d 2003-11-23 devnull u32int time; /* creation at gmt seconds since 1/1/1970 */
333 7a4ee46d 2003-11-23 devnull * index of all clumps according to their score
334 7a4ee46d 2003-11-23 devnull * this is just a wrapper to tie together the index sections
335 7a4ee46d 2003-11-23 devnull * <struct name="Index" type="Index *">
336 7a4ee46d 2003-11-23 devnull * <field name="name" val="s->name" type="AName"/>
337 7a4ee46d 2003-11-23 devnull * <field name="version" val="s->version" type="U32int"/>
338 7a4ee46d 2003-11-23 devnull * <field name="blocksize" val="s->blocksize" type="U32int"/>
339 7a4ee46d 2003-11-23 devnull * <field name="tabsize" val="s->tabsize" type="U32int"/>
340 7a4ee46d 2003-11-23 devnull * <field name="buckets" val="s->buckets" type="U32int"/>
341 7a4ee46d 2003-11-23 devnull * <field name="buckdiv" val="s->div" type="U32int"/>
342 7a4ee46d 2003-11-23 devnull * <array name="sect" val="&s->smap[i]" elems="s->nsects" type="Amap"/>
343 7a4ee46d 2003-11-23 devnull * <array name="amap" val="&s->amap[i]" elems="s->narenas" type="Amap"/>
344 7a4ee46d 2003-11-23 devnull * <array name="arena" val="s->arenas[i]" elems="s->narenas" type="Arena"/>
345 7a4ee46d 2003-11-23 devnull * </struct>
346 7a4ee46d 2003-11-23 devnull * <struct name="Amap" type="AMap *">
347 7a4ee46d 2003-11-23 devnull * <field name="name" val="s->name" type="AName"/>
348 7a4ee46d 2003-11-23 devnull * <field name="start" val="s->start" type="U64int"/>
349 7a4ee46d 2003-11-23 devnull * <field name="stop" val="s->stop" type="U64int"/>
350 7a4ee46d 2003-11-23 devnull * </struct>
352 7a4ee46d 2003-11-23 devnull struct Index
354 7a4ee46d 2003-11-23 devnull u32int div; /* divisor for mapping score to bucket */
355 7a4ee46d 2003-11-23 devnull u32int buckets; /* last bucket used in disk hash table */
356 7a4ee46d 2003-11-23 devnull u32int blocksize;
357 7a4ee46d 2003-11-23 devnull u32int tabsize; /* max. bytes in index config */
358 7a4ee46d 2003-11-23 devnull int mapalloc; /* first arena to check when adding a lump */
359 7a4ee46d 2003-11-23 devnull Arena **arenas; /* arenas in the mapping */
360 7a4ee46d 2003-11-23 devnull ISect **sects; /* sections which hold the buckets */
363 7a4ee46d 2003-11-23 devnull * fields stored in config file
365 7a4ee46d 2003-11-23 devnull u32int version;
366 7a4ee46d 2003-11-23 devnull char name[ANameSize]; /* text label */
367 7a4ee46d 2003-11-23 devnull int nsects;
368 7a4ee46d 2003-11-23 devnull AMap *smap; /* mapping of buckets to index sections */
369 7a4ee46d 2003-11-23 devnull int narenas;
370 7a4ee46d 2003-11-23 devnull AMap *amap; /* mapping from index addesses to arenas */
374 7a4ee46d 2003-11-23 devnull * one part of the bucket storage for an index.
375 7a4ee46d 2003-11-23 devnull * the index blocks are sequentially allocated
376 7a4ee46d 2003-11-23 devnull * across all of the sections.
378 7a4ee46d 2003-11-23 devnull struct ISect
380 7a4ee46d 2003-11-23 devnull Part *part;
381 7a4ee46d 2003-11-23 devnull int blocklog; /* log2(blocksize) */
382 7a4ee46d 2003-11-23 devnull int buckmax; /* max. entries in a index bucket */
383 7a4ee46d 2003-11-23 devnull u32int tabbase; /* base address of index config table on disk */
384 7a4ee46d 2003-11-23 devnull u32int tabsize; /* max. bytes in index config */
387 7a4ee46d 2003-11-23 devnull * fields stored on disk
389 7a4ee46d 2003-11-23 devnull u32int version;
390 7a4ee46d 2003-11-23 devnull char name[ANameSize]; /* text label */
391 7a4ee46d 2003-11-23 devnull char index[ANameSize]; /* index owning the section */
392 7a4ee46d 2003-11-23 devnull u32int blocksize; /* size of hash buckets in index */
393 7a4ee46d 2003-11-23 devnull u32int blockbase; /* address of start of on disk index table */
394 7a4ee46d 2003-11-23 devnull u32int blocks; /* total blocks on disk; some may be unused */
395 7a4ee46d 2003-11-23 devnull u32int start; /* first bucket in this section */
396 7a4ee46d 2003-11-23 devnull u32int stop; /* limit of buckets in this section */
400 7a4ee46d 2003-11-23 devnull * externally interesting part of an IEntry
402 7a4ee46d 2003-11-23 devnull struct IAddr
404 7a4ee46d 2003-11-23 devnull u64int addr;
405 7a4ee46d 2003-11-23 devnull u16int size; /* uncompressed size */
406 7a4ee46d 2003-11-23 devnull u8int type; /* type of block */
407 7a4ee46d 2003-11-23 devnull u8int blocks; /* arena io quanta for Clump + data */
411 7a4ee46d 2003-11-23 devnull * entries in the index
412 7a4ee46d 2003-11-23 devnull * kept in IBuckets in the disk index table,
413 7a4ee46d 2003-11-23 devnull * cached in the memory ICache.
415 7a4ee46d 2003-11-23 devnull struct IEntry
417 7a4ee46d 2003-11-23 devnull u8int score[VtScoreSize];
418 7a4ee46d 2003-11-23 devnull IEntry *next; /* next in hash chain */
419 7a4ee46d 2003-11-23 devnull u32int wtime; /* last write time */
420 7a4ee46d 2003-11-23 devnull u16int train; /* relative train containing the most recent ref; 0 if no ref, 1 if in same car */
421 7a4ee46d 2003-11-23 devnull u8int rac; /* read ahead count */
422 7a4ee46d 2003-11-23 devnull IAddr ia;
426 7a4ee46d 2003-11-23 devnull * buckets in the on disk index table
428 7a4ee46d 2003-11-23 devnull struct IBucket
430 7a4ee46d 2003-11-23 devnull u16int n; /* number of active indices */
431 7a4ee46d 2003-11-23 devnull u32int next; /* overflow bucket */
432 7a4ee46d 2003-11-23 devnull u8int *data;
436 7a4ee46d 2003-11-23 devnull * temporary buffers used by individual threads
438 7a4ee46d 2003-11-23 devnull struct ZBlock
440 7a4ee46d 2003-11-23 devnull u32int len;
441 7a4ee46d 2003-11-23 devnull u8int *data;
445 7a4ee46d 2003-11-23 devnull * simple input buffer for a '\0' terminated text file
447 7a4ee46d 2003-11-23 devnull struct IFile
449 7a4ee46d 2003-11-23 devnull char *name; /* name of the file */
450 7a4ee46d 2003-11-23 devnull ZBlock *b; /* entire contents of file */
451 7a4ee46d 2003-11-23 devnull u32int pos; /* current position in the file */
455 7a4ee46d 2003-11-23 devnull * statistics about the operation of the server
456 7a4ee46d 2003-11-23 devnull * mainly for performance monitoring and profiling.
458 7a4ee46d 2003-11-23 devnull struct Stats
460 7a4ee46d 2003-11-23 devnull QLock lock;
461 7a4ee46d 2003-11-23 devnull long lumpwrites; /* protocol block writes */
462 7a4ee46d 2003-11-23 devnull long lumpreads; /* protocol block reads */
463 7a4ee46d 2003-11-23 devnull long lumphit; /* lump cache hit */
464 7a4ee46d 2003-11-23 devnull long lumpmiss; /* lump cache miss */
465 7a4ee46d 2003-11-23 devnull long clumpwrites; /* clumps to disk */
466 7a4ee46d 2003-11-23 devnull vlong clumpbwrites; /* clump data bytes to disk */
467 7a4ee46d 2003-11-23 devnull vlong clumpbcomp; /* clump bytes compressed */
468 7a4ee46d 2003-11-23 devnull long clumpreads; /* clumps from disk */
469 7a4ee46d 2003-11-23 devnull vlong clumpbreads; /* clump data bytes from disk */
470 7a4ee46d 2003-11-23 devnull vlong clumpbuncomp; /* clump bytes uncompressed */
471 7a4ee46d 2003-11-23 devnull long ciwrites; /* clump directory to disk */
472 7a4ee46d 2003-11-23 devnull long cireads; /* clump directory from disk */
473 7a4ee46d 2003-11-23 devnull long indexwrites; /* index to disk */
474 7a4ee46d 2003-11-23 devnull long indexreads; /* index from disk */
475 7a4ee46d 2003-11-23 devnull long indexwreads; /* for writing a new entry */
476 7a4ee46d 2003-11-23 devnull long indexareads; /* for allocating an overflow block */
477 7a4ee46d 2003-11-23 devnull long diskwrites; /* total disk writes */
478 7a4ee46d 2003-11-23 devnull long diskreads; /* total disk reads */
479 7a4ee46d 2003-11-23 devnull vlong diskbwrites; /* total disk bytes written */
480 7a4ee46d 2003-11-23 devnull vlong diskbreads; /* total disk bytes read */
481 7a4ee46d 2003-11-23 devnull long pchit; /* partition cache hit */
482 7a4ee46d 2003-11-23 devnull long pcmiss; /* partition cache miss */
483 7a4ee46d 2003-11-23 devnull long pcreads; /* partition cache reads from disk */
484 7a4ee46d 2003-11-23 devnull vlong pcbreads; /* partition cache bytes read */
485 7a4ee46d 2003-11-23 devnull long icinserts; /* stores into index cache */
486 7a4ee46d 2003-11-23 devnull long iclookups; /* index cache lookups */
487 7a4ee46d 2003-11-23 devnull long ichits; /* hits in the cache */
488 7a4ee46d 2003-11-23 devnull long icfills; /* successful fills from index */
491 7a4ee46d 2003-11-23 devnull extern Index *mainindex;
492 7a4ee46d 2003-11-23 devnull extern u32int maxblocksize; /* max. block size used by any partition */
493 7a4ee46d 2003-11-23 devnull extern int paranoid; /* should verify hashes on disk read */
494 7a4ee46d 2003-11-23 devnull extern int queuewrites; /* put all lump writes on a queue and finish later */
495 7a4ee46d 2003-11-23 devnull extern int readonly; /* only allowed to read the disk data */
496 7a4ee46d 2003-11-23 devnull extern Stats stats;
497 7a4ee46d 2003-11-23 devnull extern u8int zeroscore[VtScoreSize];