The structure of the Reiser file system
The inode generation number is a counter that denotes the current generation of inodes. The counter is increased every time the tree gets re-balanced.
Example:
The following is the start of the superblock of a 256MB reiserfs partition on an Intel based system: 00000000 66 00 01 00 93 18 00 00 82 40 00 00 12 00 00 00 f........@......
00000010 00 00 00 00 00 20 00 00 00 04 00 00 ac 34 11 57 ..... ......¬4.W
00000020 84 03 00 00 1e 00 00 00 00 00 00 00 00 10 cc 03 ..............Ì.
00000030 08 00 02 00 52 65 49 73 45 72 32 46 73 00 00 00 ....ReIsEr2Fs...
00000040 03 00 00 00 04 00 03 00 02 00 00 00 dc 52 00 00 ............ÜR..
Block count: 65638 Free blocks: 6291 Root block: 16514 Journal block: 18 Journal device: 0 Original journal size: 8192 Journal trans. max: 1024 Journal magic: 1460745388 Journal max. batch: 900 Journal max. commit age: 30 Journal max. trans. age: 0 Blocksize: 4096 OID max. size: 972 OID current size: 8 State: 2 (error) Magic String: ReIsEr2Fs Hash function code: 3 Tree height: 4 Bitmap number: 3 Version: 2 Inode generation: 21212
Bitmap blocks The bitmap blocks are simple bitmaps, where every bit stands for a block number. One bitmap block can address (8 * block size) number of blocks. Byte 0 of the bitmap maps to the first eight blocks, the second byte to the next eight, and so on. Within a byte, the low order bits map to the the lower number blocks. Bit 0 maps to the first block, bit 1 to the second, etc. A set bit indicates that the block is in use, a zero bit that the block is free.
Example: 00000400 ff ff f7 ff 7f 00 00 00 00 00 00 00 00 80 cb bd ÿÿ÷ÿ..........˽
These 16 bytes of bitmap block 0 describe block numbers 8192 to 8319.
Blocks 8192-8210: |
used |
Block 8211: |
free (f7 is 11110111 binary) |
Blocks 8212-8230: |
used |
Blocks 8231-8302: |
free |
Blocks 8303-8305: |
used |
Block 8306: |
free |
Block 8307: |
used |
Blocks 8308-8309: |
free |
Blocks 8310-8312: |
used |
Block 8313: |
free |
Blocks 8314-8317: |
used |
Block 8318: |
free |
Block 8319: |
used |
Had the above entry been from a bitmap block other than bitmap block 0, then (bitmap block # * block size * 8) needs to be added for the proper block number. By bitmap block # we understand the ordinal number (0 for the 1st, 1 for the second, ...) not the block number of the bitmap block.
Given a block number b, one can determine its status as follows:
b div (8 * block size) : bitmap block # (integer division)
Let r = b mod (8* block size), then
r div 8: byte within bitmap block, and r mod 8: bit within byte
The File System Tree The Reiser file system is made up of a balanced tree (B+ or S+ tree as it is called in the reiserfs documentation). The tree is composed of internal nodes and leaf nodes. Each node is a disk block. Each object (called an item) in reiserfs (file, directory, or stat item) is assigned a unique key, which can be compared to an inode node number in other file systems. The internal nodes are mainly composed of keys and pointers to their child nodes. There is always one more pointer than there are keys. P0 points to the objects that have keys smaller than K0, P1 to those K0<=obj |