【问题标题】:Android filesystem journalingAndroid 文件系统日志
【发布时间】:2011-09-20 02:29:25
【问题描述】:

ext3 有 3 个日志选项:日志、有序和写回。根据维基百科entry,这些范围从风险最小到崩溃恢复风险最大。由于某种原因,Android 的 Linux 版本只支持后两种选项,并且默认为 writeback。 (我正在运行 Froyo)

有没有办法增加对日志模式的支持?我想在 /data 分区上执行此操作,即 ext3,也是大多数文件写入发生的地方。我的设备没有电池,所以我需要确保它在有人断开电源时能够防撞。

如果有人感兴趣,Linux 选项在 kernel/fs/ext3/Kconfig 中定义。具体选项是EXT3_DEFAULTS_TO_ORDERED。

【问题讨论】:

  • 我的猜测是,由于闪存的写入周期有限,他们选择不使用完整日志。如果你真的想用掉你的闪存,你应该能够用你想要的任何选项重新编译内核。这显然需要某种方式将内核刷回您的设备 - 这可能或不可能或容易,具体取决于您拥有的设备。
  • 知道如何使用完整日志选项重新编译内核吗?如上所述,目前 Kconfig 中只有两个选项。至于有限的写入周期,我使用的是进行磨损均衡的 eMMC,但我同意,完整的日志记录会导致更多的磨损。由于我的公司实际上正在构建设备,因此我能够将内核闪存到设备上。

标签: android linux filesystems ext3 journaling


【解决方案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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-21
    • 2014-04-22
    • 2012-08-03
    • 1970-01-01
    • 1970-01-01
    • 2019-07-17
    • 2017-02-09
    • 2017-11-06
    相关资源
    最近更新 更多