Android 文件系统日志

发布于 2024-12-05 07:56:20 字数 385 浏览 0 评论 0原文

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

有没有办法添加对日志模式的支持?我想在 /data 分区上执行此操作,该分区是 ext3,也是大多数文件写入发生的地方。我的设备没有电池,因此我需要确保它在有人断开电源时不会崩溃。

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

ext3 has 3 journaling options: journal, ordered, and writeback. According to the wikipedia entry, these range from least risky to most risky for crash recovery. For some reason, Android's version of Linux only supports the latter two options, and defaults to writeback. (I'm running Froyo)

Is there a way to add support for journal mode? I'd like to do this on the /data partition, which is ext3, and also where most of the file writes happen. My device doesn't have a battery, so I need to make sure it's crash proof when someone disconnects power.

In case anyone is interested, the Linux options are defined in kernel/fs/ext3/Kconfig. The specific option is EXT3_DEFAULTS_TO_ORDERED.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

安静 2024-12-12 07:56:20

解决方案是将以下内容添加到 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

The solution was to add the following to kernel/fs/ext3/Kconfig, and rebuild the kernel with 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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文