![]() |
If there is a system crash before buffers have been written to disk, it will cause the system to behave in an inconsistent way after reboot. A file deleted in the cache, may still remain on the hard disk. The fsck recover tool for ext2fs has to scan the entire disk partition in order to get the file system into a consistent state, after a crash. On a very large file system of serveral hundred gigabytes , getting the system back to a consistent state can take a very long time, delaying the availability of the server.
Journaling filesystems use a principal called Atomicity to maintain a consistency. What this means is that all operations belonging to a transaction look as if they are atomic operations that can't be partially performed. After every transaction, there must be a commit operation, making sure the buffers be written to disk. All operations are completed wihout errors, or canceled. All metadata is logged in a journaling file system. Metadata are the control structures inside a file system: i-nodes, free block allocation maps, i-nodes maps, etc. After a system crash, the log can be checked back to the first commit statement, writing the arguments content back to its position on the disk.