Saturday, November 29, 2008

Enable ext4 to run without a journal

This is really useful on flash devices.
According to the kernel documents, there are three kind of journal mode in ext4: writeback, ordered, journal.
(1) writeback mode: ext4 doesn't journal data at all. Only metadata journaling is provided. Data ordering is not preserved. Data may be written into the disk after its metadata has been committed to the journal. A crash-recovery may cause data corruption in files which written shortly before the crash.
(2) ordered mode: ext4 only journals metadata, but logically groups metadata information related to data changes with the data blocks into a single unit called a transaction. When it's time to write the new metadata out to disk, the associated data blocks are written first.
(3) journal mode: ext4 provides full metadata and data journaling. All new data is written to the journal first, and then to its final location. In the event of a crash, the journal can be replayed, bringing both data and metadata into a consistent state.

Basically, the idea is to make use of data writeback mode. In writeback mode, data is written directly to disk, and when it comes to metadata, we need to write it out to disk once a dirty_metadata_buffer_head request is received. Superblock buffer head and inode buffer header are handled separately.

No comments:

Post a Comment