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完成.

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