JFFS2 - Design

Design

As with JFFS, changes to files and directories are "logged" to flash in nodes, of which there are two types:

  • inodes: a header with file metadata, followed by a payload of file data (if any). Compressed payloads are limited to one page.
  • dirent nodes: directory entries each holding a name and an inode number. Hard links are represented as different names with the same inode number. The special inode number 0 represents an unlink.

As with JFFS, nodes start out as valid when they are created, and become obsolete when a newer version has been created elsewhere.

Unlike JFFS, however, there is no circular log. Instead, JFFS2 deals in blocks, a unit the same size as the erase segment of the flash medium. Blocks are filled, one at a time, with nodes from bottom up. A clean block is one that contains only valid nodes. A dirty block contains at least one obsolete node. A free block contains no nodes.

The garbage collector runs in the background, turning dirty blocks into free blocks. It does this by copying valid nodes to a new block and skipping obsolete ones. That done, it erases the dirty block and tags it with a special marker designating it as a free block (to prevent confusion if power is lost during an erase operation).

To make wear-levelling more even and prevent erasures from being too concentrated on mostly-static file systems, the garbage collector will occasionally also consume clean blocks.

Read more about this topic:  JFFS2

Famous quotes containing the word design:

    Westerners inherit
    A design for living
    Deeper into matter—
    Not without due patter
    Of a great misgiving.
    Robert Frost (1874–1963)

    Teaching is the perpetual end and office of all things. Teaching, instruction is the main design that shines through the sky and earth.
    Ralph Waldo Emerson (1803–1882)

    If I knew for a certainty that a man was coming to my house with the conscious design of doing me good, I should run for my life ... for fear that I should get some of his good done to me,—some of its virus mingled with my blood.
    Henry David Thoreau (1817–1862)