A journaling file system is a type of file system that keeps journalled metadata to avoid filesystem errors and corruption.
Problems with traditional file systems
In the process of writing data to the hard disk, a file system must write out metadata, which is information about the data on the disk, for example, the location of the data or the names of the files. If, while the file system is writing this metadata, the hard disk is interrupted by, for example, a loss of power, the metadata is not completely written out and the filesystem may be in an inconsistent state, in which the description of the data does not fully match the data itself.
One approach to fixing this problem is to run a program that scans the entire hard disk when the system is restarted, to fix any inconsistencies. Such programs include scandisk on Microsoft Windows, vrepair on Netware, and fsck on Unix and Unix-like systems (including Apple Mac OS X systems). Unfortunately this method has two problems. First, rescanning the entire disk is very time consuming. Second, there is the possibility that the scanning program will encounter errors that it cannot fix and that data will be lost.
An answer: journaling file systems
Journaling file systems approach this problem by writing out a special file called a "journal", which keeps track of the transactions to the disk. Updates to the disk are then committed atomically.
If power is suddenly interrupted, a given set of updates will have either been fully committed to the filesystem, in which case there is not a problem, and the filesystem can be used immediately, or will be marked as not yet fully committed, in which case the file system driver can read the journal and fix any inconsistencies that occurred.
This is much quicker than a scan of the hard disk, and guarantees that the structure of the filesystem is always self-consistent, even if power is interrupted or the system crashes at random times, providing that the journal rollback or commit process is carried out when re-mounting the filesystem.
Note that this does not guarantee zero data loss: data or file-system changes written between the last commit and a crash may be lost, with the filesystem being effectively rolled back to the last commit point.
Some journaling filesystems journal all data, others only journal filesystem metadata. Also, some filesystems that can journal all data can be configured to journal metadata only; metadata-only journaling often provides a performance boost.
Log-structured filesystems
Some systems go one step beyond being a conventional filesystem with an added journal; they use the journal log itself as the fundamental basis for the filesystem. These types of systems are called log-structured filesystems. As of 2003, none of the most popular filesystems are log-structured, although log-structured filesystem concepts influenced the development of the WAFL filesystem.
Alternatives to journaling
Soft updates work by properly ordering the metadata writes to guarantee consistency after a crash. Softupdates are the commonly used approach in the BSD operating systems, primarily using the FFS UFS filesystem variant. Note that, like journaling, softupdates do not guarantee that there will be no loss of data — they however guarantee consistency of the file system.
It is also important to know that Softupdates were primarily implemented with performance enhancement goals in mind; It allows many small files to be created or deleted in a short amount of time compared to plain UFS, due to the asynchroneous nature of metadata updates. The metadata can be queued in a buffer instead of having to be synchronized to disk for every created file or written segment, minimizing the physical worse-case condition of the drives (due to heads constantly in movement between several portions of the disk, commonly called disk thrashing ). Journaling filesystems can usually also take advantage of such strategies.
List of journaling file systems
Supported by the AIX operating system:
Supported by the Apple Macintosh operating systems:
- HFS Plus (Journaling was added to Mac OS X 10.2.2.)
Supported by HP-UX:
- VxFS (known to the HP system as "JFS", but differs from the IBM JFS)
Supported by the IRIX operating system:
Supported by the Linux operating system kernel:
Supported by the Microsoft Windows NT and later operating systems:
Supported by Novell Netware 5.0 and up:
Supported by the OpenVMS operating system:
Supported by the OS/2 operating system:
Supported by the Solaris Operating Environment:
Notes
- NSS was ported to SUSE Linux by Novell in 2005. [1]
- Note 2: Recent Linux versions such as 2.6.10-r1 have limited and safe NTFS write support. (File and directory creation are unsupported. Deletion and renaming support also do not exist. Files can be written to, provided the file size does not change. Files < 500 bytes are unlikely candidates for modifying.) Kernel version 2.5.10 and lesser versions have unsafe write support including the above limitations. Commercial NTFS write support exists, but programs like Captive, which uses windows binaries and WINE emulation for full R/W support, are favored due to their GNU GPL-v2 licensing.
See also