Android filesystem journaling
Asked Answered
U

1

6

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.

Unorganized answered 20/9, 2011 at 2:29 Comment(2)
My guess is that they chose not to use full journaling due to the limited write cycles of flash memory. If you really want to wear out your flash though, you should be able to re-compile the kernel with whatever options you want. This obviously requires some way to flash the kernel back onto your device - which may or may not be possible or easy, depending on what device you have.Filmdom
Any idea how to re-compile the kernel with the full journal option? As noted above, there are currently only two options in Kconfig. As for limited write cycles, I'm using eMMC which does wear leveling, but I agree, full journaling will cause more wear. I'm able to flash the kernel onto the device since my company is actually building the device.Unorganized
U
1

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
Unorganized answered 22/2, 2012 at 16:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.