reiserfs 日志结构

1. 日志的结构

reiserfs的日志由一组连续的块组成,并且是固定大小的8192 + 1块 , 结构如下:

Transaction0 | Transaction1 | Transaction2 | ....| TransactionN | Journal Header

2. Journal Header是日志的头部,大小是12个字节,并且固定占据一个块, 结构如下 :

 

The journal header

NameSizeDescription
Last flush ID 4 The transaction ID of the last fully flushed transaction
Unflushed offset 4 The offset (in blocks) of the next transaction in the journal
Mount ID 4 The mount ID of the flushed transaction

 

3. 一个Transation记录一次原子的文件系统操作, 一个Trasaction 由三部分组成:

a. 描述块 (Description block)

b. 一组连续的映射块

c. 提交块 (Commit block)

The journal transaction layout 

4. Description Block 的结构如下:

The journal transaction layout 

5. 结合3,4解释下如何记录一次操作.

假如有一次操作,改变了块 10001,  20001, 30001,40001 , 用一个Trasaction 来记录这次操作,则:

Transaction ID : XXXX

Len : 4 (记录了四个块的操作)

Mount ID: xxxx

Real blocks: 10001, 20001,30001,40001

Magic : ReIsErLB

 

紧跟着 Description Block 后面有4个 Real block (假设分别为 8001,8002,8003,8004), 分别记录了 块 10001,20001,30001,40001的信息。

当这个提交这个 Transaction时:

块8001的内容写到块10001;

块8002的内容写到块20001;

块8003的内容写到块30001;

块8004的内容写到块40001;

 

然后标志这个Transation完成.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章