VM: simplify slab allocator
[minix.git] / servers / ext2 / buf.h
blob4f5f0759e53e282b66a9b783ec6790a46dca1512
1 /* Buffer (block) cache. To acquire a block, a routine calls get_block(),
2 * telling which block it wants. The block is then regarded as "in use"
3 * and has its 'b_count' field incremented. All the blocks that are not
4 * in use are chained together in an LRU list, with 'front' pointing
5 * to the least recently used block, and 'rear' to the most recently used
6 * block. A reverse chain, using the field b_prev is also maintained.
7 * Usage for LRU is measured by the time the put_block() is done. The second
8 * parameter to put_block() can violate the LRU order and put a block on the
9 * front of the list, if it will probably not be needed soon. If a block
10 * is modified, the modifying routine must set b_dirt to DIRTY, so the block
11 * will eventually be rewritten to the disk.
14 #ifndef EXT2_BUF_H
15 #define EXT2_BUF_H
17 #include <dirent.h>
19 union fsdata_u {
20 char b__data[_MAX_BLOCK_SIZE]; /* ordinary user data */
21 /* indirect block */
22 block_t b__ind[_MAX_BLOCK_SIZE/sizeof(block_t)];
23 /* bit map block */
24 bitchunk_t b__bitmap[FS_BITMAP_CHUNKS(_MAX_BLOCK_SIZE)];
27 /* A block is free if b_dev == NO_DEV. */
29 /* These defs make it possible to use to bp->b_data instead of bp->b.b__data */
30 #define b_data bp->b__data
31 #define b_ind bp->b__ind
32 #define b_ino bp->b__ino
33 #define b_bitmap bp->b__bitmap
35 #define BUFHASH(b) ((b) % nr_bufs)
37 EXTERN struct buf *front; /* points to least recently used free block */
38 EXTERN struct buf *rear; /* points to most recently used free block */
39 EXTERN unsigned int bufs_in_use; /* # bufs currently in use (not on free list)*/
41 /* When a block is released, the type of usage is passed to put_block(). */
42 #define WRITE_IMMED 0100 /* block should be written to disk now */
43 #define ONE_SHOT 0200 /* set if block not likely to be needed soon */
45 #define INODE_BLOCK 0 /* inode block */
46 #define DIRECTORY_BLOCK 1 /* directory block */
47 #define INDIRECT_BLOCK 2 /* pointer block */
48 #define MAP_BLOCK 3 /* bit map */
49 #define FULL_DATA_BLOCK 5 /* data, fully used */
50 #define PARTIAL_DATA_BLOCK 6 /* data, partly used*/
52 #endif /* EXT2_BUF_H */