Advertisement

Journaling file system

From Academic Kids

A journaling file system is a file system that logs changes to a journal (usually a circular log in a specially-allocated area) before actually writing them to the main file system.

Rationale

File systems tend to be very large data structures; updating them to reflect changes to files and directories usually requires many separate write operations. This introduces a race condition, in which an interruption (like a power failure or system crash) can leave data structures in an invalid intermediate state.

For example, deleting a file on a Unix file system involves two steps:

  1. removing its directory entry
  2. marking the file's inode as free space in the free space map

If step 1 occurs just before a crash, there will be an orphaned inode and hence a storage leak. On the other hand, if step 2 is performed first before the crash, the not-yet-deleted inode will be marked free and possibly be overwritten by something else.

One way to recover is to do a complete walk of the file system's structures when it is next mounted to detect and correct any inconsistencies. This can be very slow for large file systems, and is likely to become slower yet, given that the ratio of storage capacity to I/O bandwidth on modern computer systems is rising.

Another way to recover is to for the file system can keep a journal of the changes it intends to make, ahead of time. Recovery then simply involves a forward replay of changes until the file system is consistent again. In this sense, the changes are said to be atomic (or indivisible) in that they will have either:

  • have succeeded originally
  • be replayed completely during recovery
  • not be replayed at all

Log-structured file systems are those which the journal is itself the entire filesystem. As of 2005, none of the most popular general-purpose filesystems are log-structured, although log-structured file system concepts influenced the development of WAFL and Reiser4.

Databases use more rigorous versions of the same journaling techniques to ensure data integrity.

Metadata-only journaling

Journaling can have a severe impact on performance because it requires that all data be written twice. Metadata-only journaling is a compromise between reliability and performance that stores only changes to file metadata (which is usually relatively small and hence less of a drain on performance) in the journal. This still ensures that the file system can recover quickly on next mount, but cannot guarantee complete consistency because unjournaled file data already committed to disk may out of sync with the metadata.

For example, when appending to a file on a Unix file system typically requires three steps:

  1. increasing the size of the file in its inode
  2. allocating space for the extension in the free space map
  3. actually writing the appended data to the newly-allocated space

In a metadata-only journal, it is not clear whether step 3 has happened, because it was not logged.

To avoid this out-of-order write hazard, file data must committed to storage before writing its associated metadata to the journal. This has generally tricky to implement because it requires coordination within the operating system kernel between the file system and memory cache, which traditionally uses elevator sorting (or some similar discipline) to maximize write throughput.

Soft updates take a variation of this approach by dispensing with a journal but imposing an order on all writes to ensure that the file system never becomes inconsistent to begin with, or that the only inconsistency that ever happens is a storage leak. Recovery then simply becomes a matter of running a background walk of the file system to garbage collect orphaned metadata.

See also

cs:urnlovn de:Journaling-Dateisystem fr:Journal (systme de fichier) ja:ジャーナリングファイルシステム pl:Journalling

Navigation

Academic Kids Menu

  • Art and Cultures
    • Art (http://www.academickids.com/encyclopedia/index.php/Art)
    • Architecture (http://www.academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (http://www.academickids.com/encyclopedia/index.php/Cultures)
    • Music (http://www.academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
  • Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
    • Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
    • Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
    • Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
  • History (http://www.academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
    • United States (http://www.academickids.com/encyclopedia/index.php/United_States)
    • Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
    • World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
  • Science (http://www.academickids.com/encyclopedia/index.php/Science)
    • Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
    • Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
    • Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
    • Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
    • Government (http://www.academickids.com/encyclopedia/index.php/Government)
    • Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
    • Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
  • Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
  • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
  • Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
  • US States (http://www.academickids.com/encyclopedia/index.php/US_States)

Information

  • Home Page (http://academickids.com/encyclopedia/index.php)
  • Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (http://classroomclipart.com)
Toolbox
Personal tools