The structure of the Reiser file system
The structure of the Reiser file systemby Florian Buchholz
The Reiser file system was created by Hans Reiser. The design objectives were to increase performance over the ext2 file system, offer a space efficient file system, and to improve handling of large directories compared to existing file systems. Reiserfs uses balanced trees to store files and directories and it also offers journaling.
This document describes the on-disk structure of the Reiser file system version 3.6. This document does not describe how the file system tree is balanced, how the journaling is performed, or how files and directories are managed within an implementation of the file system.
Blocks The reiserfs partition is divided into blocks of a fixed size. The blocks are numbered sequentially starting with block 0. There is a maximum number of 2^32 possible blocks in one partition.
The partition starts with the first 64k unused to leave enough room for partition labels or boot loaders. After that follows the superblock. The superblock contains important information about the partition such as the block size and the block numbers of the root and journal nodes. The superblock block number differs depending on the block size, but always starts at byte 65536 of the partition. The default block size for reiserfs under Linux is 4096 bytes. This makes the superblock block number 16. There is only one instance of the superblock for the entire partition.
Directly following the superblock is a block containing a bitmap of free blocks. The number of blocks mapped in the bitmap depends directly on the block size. If a bitmap can map k blocks, then every k-th block will be a new bitmap block.
Block size |
4,096 |
512 |
1,024 |
8,192 |
#blocks in bitmap |
32,768 |
4,096 |
8,192 |
65,536 |
superblock |
16 |
128 |
64 |
8 |
1st bitmap |
17 |
129 |
65 |
9 |
2nd bitmap |
32,768 |
4,096 |
8,192 |
65,536 |
3rd bitmap |
65,536 |
8,192 |
16,384 |
131,072 |
4th bitmap |
98,304 |
12,288 |
24,576 |
196,608 | ... (assuming that the partition is large enough to have 2nd, 3rd, 4th bitmap)
Following the first bitmap block should be the journal, but the information in the superblock is the authorative source for that information.
The Superblock
Name |
Size |
Description |
Block count |
4 |
The number of blocks in the partition |
Free blocks |
4 |
The number of free blocks in the partition |
Root block |
4 |
The block number of the block containing the root node |
Journal block |
4 |
The block number of the block containing the first journal node < tr>
|
Journal device |
4 |
Journal device number (not sure what for) |
Orig. journal size |
4 |
Original journal size. Needed when using partition on systems with different default journal sizes. |
Journal trans. max |
4 |
The maximum number of blocks in a transaction |
Journal magic |
4 |
A random magic number |
Journal max batch |
4 |
The maximum number of blocks in a transaction |
Journal max commit age |
4 |
Time in seconds of how old an asynchronous commit can be |
Journal max trans. age |
4 |
Time in seconds of how old a transaction can be |
Blocksize |
2 |
The size in bytes of a block |
OID max size |
2 |
The maximum size of the object id array |
OID current size |
2 |
The current size of the object id array |
State |
2 |
State of the partition: valid (1) or error (2) |
Magic string |
12 |
The reiserfs magic string, should be "ReIsEr2Fs" |
Hash function code |
4 |
The hash function that is being used to sort names in a directory |
Tree Height |
2 |
The current height of the disk tree |
Bitmap number |
2 |
The amount of bitmap blocks needed to address each block of the file system |
Version |
2 |
The reiserfs version number |
Reserved |
2 |
|
Inode Generation |
4 |
Number of the current inode generation. |
|