2.3 Journaling

Imagine that an operating system is writing a file, and the process is abruptly interrupted. This can be due to a power fail (without the protection of a UPS), controller failure or many other reasons. There is little that an file system can do about events like this.

A non-journaling file system will suffer some data loss and cause the file system to be in an inconsistent state. Most file systems can detect an inconsistent file system during system bootstrap. However, it is another story to find out what is inconsistent and repair the file system. Scanning for an inconsistency in a large file system is very time consuming. Furthermore, most repair of this sort will cause some data loss because the recovery tool cannot figure out what was interrupted that caused the inconsistency.

A journaling file system, however, records what needs to be done at a non-volatile location (typically on the disk itself) before committing the operation. This way, if the operation cannot be completed after the intention is recorded, a recovery tool can simply finish committing the operation.

As a result, a journaling file system can repair an inconsistent state quickly and incur less data loss (because the interrupted operation can finish).