2011-09-20 194 views
6

ext3有3個日誌選項:日記,有序和回寫。根據維基百科entry,這些範圍從風險最小到崩潰恢復風險最大。出於某種原因,Android的Linux版本僅支持後兩種選擇,並且默認爲寫回。 (我正在運行Froyo)Android文件系統日誌記錄

有沒有辦法添加對日誌模式的支持?我想在/ data分區上做到這一點,這是ext3,也是大部分文件寫入發生的地方。我的設備沒有電池,因此當有人斷開電源時,我需要確保它具有防撞功能。

如果有人感興趣,Linux選項在kernel/fs/ext3/Kconfig中定義。具體選項是EXT3_DEFAULTS_TO_ORDERED。

+1

我的猜測是,他們選擇不使用完整的日誌記錄由於閃存的寫週期有限。如果你真的想要消耗你的閃存,你應該可以用你想要的任何選項重新編譯內核。這顯然需要某種方式將內核閃回到設備上 - 根據您擁有的設備不同,這可能也可能不太可能或不容易。 – JesusFreke

+1

任何想法如何用全日誌選項重新編譯內核?如上所述,Kconfig目前只有兩個選項。至於有限的寫入週期,我使用的eMMC會損耗均衡,但我同意,完整的日誌會導致更多的磨損。我能夠將內核刷到設備上,因爲我的公司實際上正在構建設備。 – Ravi

回答

1

解決的辦法是在kernel/fs/ext3/Kconfig中添加以下內容,並用EXT3_DEFAULTS_TO_JOURNAL重建內核。

choice 
    prompt "EXT3 default journal mode" 
    default EXT3_DEFAULTS_TO_ORDERED 
    help 
     The journal mode options for ext3 have different tradeoffs 
     between when data is guaranteed to be on disk and 
     performance. The use of "data=writeback" can cause 
     unwritten data to appear in files after an system crash or 
     power failure, which can be a security issue. However, 
     "data=ordered" mode can also result in major performance 
     problems, including seconds-long delays before an fsync() 
     call returns. "data=journal" is the safest option but possibly 
     the the great perfromance burden. For details, see: 

     http://ext4.wiki.kernel.org/index.php/Ext3_data_mode_tradeoffs 

     If you have been historically happy with ext3's performance, 
     data=ordered mode will be a safe choice. 


config EXT3_DEFAULTS_TO_JOURNAL 
    bool "Default to 'data=journal' in ext3" 
    depends on EXT3_FS 
    help 
     Both data and metadata are journaled. Should be safe 
     against crashes, power failure, etc. 


config EXT3_DEFAULTS_TO_ORDERED 
    bool "Default to 'data=ordered' in ext3" 
    depends on EXT3_FS 
    help 
     Only metadata are journaled. Data is written first and then 
     metadata is update. Mostly safe against crashes, power 
     failures, etc., except if the anomally occurred while a file 
     is being overwritten. Most of the time files are appended and 
     not over written. 

config EXT3_DEFAULTS_TO_WRITEBACK 
    bool "Default to 'data=writeback' in ext3" 
    depends on EXT3_FS 
    help 
     Ext2 with a fast ckfs. Not always safe against crashes, 
     power failure, etc., but has the best preformance 

endchoice