The diary of a filesystem – the concept of journaling
A filesystem uses complex structures to organize data on the physical disk. In the case of a system crash or abrupt failure, a filesystem is unable to finish off its operations in a graceful manner, which can corrupt its organizational structures. When the system is powered up the next time, the user will need to run a consistency or integrity check of some sort against the filesystem to detect and repair those damaged structures.
When explaining VFS data structures in Chapter 2, we discussed that one of the fundamental principles followed in Linux is the separation of metadata from actual data. The metadata of a file is defined in an independent structure, called an inode. We also saw how a directory is treated as a special file and it contains the mapping of filenames to their inode numbers. Keeping this in mind, let’s say we’re creating a simple file to add some text to it. To go through with this, the...