Jump to content

Operating System Design/File Systems/Journal

From Wikibooks, open books for an open world

Journaling is a technique for fault tolerance in file systems. It works by keeping track of all changes in a log (a "journal") before committing the changes themselves to disk. This makes crashes and power failures easier to recover from and less likely to cause permanent data loss or space leakage.

Because filesystem operations (read, write, delete, etc.) can not often be completed atomically, a halt in the middle of one can cause any number of problems. For example, consider a write operation that requires the filesystem to:

  1. Update the file's inode
  2. Write the new data to the disk

Now, consider what would happen if step 1 was completed but the system failed before step 2 could be. We would have an inode that describes a file as having a certain last modified time, size, etc. But the file itself would not reflect these changes! By recording all changes before they happen, journaling filesystems like ext4 can be more fault tolerant than others, like FAT.