?? buf.h
字號(hào):
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/fs/buf.h
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
20100 /* Buffer (block) cache. To acquire a block, a routine calls get_block(),
20101 * telling which block it wants. The block is then regarded as "in use"
20102 * and has its 'b_count' field incremented. All the blocks that are not
20103 * in use are chained together in an LRU list, with 'front' pointing
20104 * to the least recently used block, and 'rear' to the most recently used
20105 * block. A reverse chain, using the field b_prev is also maintained.
20106 * Usage for LRU is measured by the time the put_block() is done. The second
20107 * parameter to put_block() can violate the LRU order and put a block on the
20108 * front of the list, if it will probably not be needed soon. If a block
20109 * is modified, the modifying routine must set b_dirt to DIRTY, so the block
20110 * will eventually be rewritten to the disk.
20111 */
20112
20113 #include <sys/dir.h> /* need struct direct */
20114
20115 EXTERN struct buf {
20116 /* Data portion of the buffer. */
20117 union {
20118 char b__data[BLOCK_SIZE]; /* ordinary user data */
20119 struct direct b__dir[NR_DIR_ENTRIES]; /* directory block */
20120 zone1_t b__v1_ind[V1_INDIRECTS]; /* V1 indirect block */
20121 zone_t b__v2_ind[V2_INDIRECTS]; /* V2 indirect block */
20122 d1_inode b__v1_ino[V1_INODES_PER_BLOCK]; /* V1 inode block */
20123 d2_inode b__v2_ino[V2_INODES_PER_BLOCK]; /* V2 inode block */
20124 bitchunk_t b__bitmap[BITMAP_CHUNKS]; /* bit map block */
20125 } b;
20126
20127 /* Header portion of the buffer. */
20128 struct buf *b_next; /* used to link all free bufs in a chain */
20129 struct buf *b_prev; /* used to link all free bufs the other way */
20130 struct buf *b_hash; /* used to link bufs on hash chains */
20131 block_t b_blocknr; /* block number of its (minor) device */
20132 dev_t b_dev; /* major | minor device where block resides */
20133 char b_dirt; /* CLEAN or DIRTY */
20134 char b_count; /* number of users of this buffer */
20135 } buf[NR_BUFS];
20136
20137 /* A block is free if b_dev == NO_DEV. */
20138
20139 #define NIL_BUF ((struct buf *) 0) /* indicates absence of a buffer */
20140
20141 /* These defs make it possible to use to bp->b_data instead of bp->b.b__data */
20142 #define b_data b.b__data
20143 #define b_dir b.b__dir
20144 #define b_v1_ind b.b__v1_ind
20145 #define b_v2_ind b.b__v2_ind
20146 #define b_v1_ino b.b__v1_ino
20147 #define b_v2_ino b.b__v2_ino
20148 #define b_bitmap b.b__bitmap
20149
20150 EXTERN struct buf *buf_hash[NR_BUF_HASH]; /* the buffer hash table */
20151
20152 EXTERN struct buf *front; /* points to least recently used free block */
20153 EXTERN struct buf *rear; /* points to most recently used free block */
20154 EXTERN int bufs_in_use; /* # bufs currently in use (not on free list)*/
20155
20156 /* When a block is released, the type of usage is passed to put_block(). */
20157 #define WRITE_IMMED 0100 /* block should be written to disk now */
20158 #define ONE_SHOT 0200 /* set if block not likely to be needed soon */
20159
20160 #define INODE_BLOCK (0 + MAYBE_WRITE_IMMED) /* inode block */
20161 #define DIRECTORY_BLOCK (1 + MAYBE_WRITE_IMMED) /* directory block */
20162 #define INDIRECT_BLOCK (2 + MAYBE_WRITE_IMMED) /* pointer block */
20163 #define MAP_BLOCK (3 + MAYBE_WRITE_IMMED) /* bit map */
20164 #define ZUPER_BLOCK (4 + WRITE_IMMED + ONE_SHOT) /* super block */
20165 #define FULL_DATA_BLOCK 5 /* data, fully used */
20166 #define PARTIAL_DATA_BLOCK 6 /* data, partly used*/
20167
20168 #define HASH_MASK (NR_BUF_HASH - 1) /* mask for hashing block numbers */
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -