JFFS - Design

Design

Flash memory (specifically NOR flash) must be erased prior to writing. The erase process has several limitations:

  • Erasing is very slow (typically 1-100 ms per erase block, which is 103-105 times slower than reading data from the same region)
  • It is only possible to erase flash in large segments (usually 64 KiB or more), whereas it can be read or written in smaller blocks (often 512 bytes)
  • Flash memory can only be erased a limited number of times (typically 103-106) before it becomes worn out

These constraints combine to produce a profound asymmetry between patterns of read and write access to flash memory. In contrast, magnetic hard disk drives offer nearly symmetrical read and write access: read speed and write speed are nearly identical (as both are constrained by the rate at which the disk spins), it is possible to both read and write small blocks or sectors (typically 512 bytes), and there is no practical limit to the number of times magnetic media can be written and rewritten.

Traditional file systems, such as ext2 or FAT which were designed for use on magnetic media typically update their data structures in-place, with data structures like inodes and directories updated on-disk after every modification. This concentrated lack of wear-levelling makes conventional file systems unsuitable for read-write use on flash devices.

JFFS enforces wear levelling by treating the flash device as a circular log. All changes to files and directories are written to the tail of the log in nodes. In each node, a header containing metadata is written first, followed by file data, if any. Nodes are chained together with offset pointers in the header. Nodes start out as valid and then become obsolete when a newer version of them is created.

The free space remaining in the file system is the gap between the log's tail and its head. When this runs low, a garbage collector copies valid nodes from the head to the tail and skips obsolete ones, thus reclaiming space.

Read more about this topic:  JFFS

Famous quotes containing the word design:

    For I choose that my remembrances of him should be pleasing, affecting, religious. I will love him as a glorified friend, after the free way of friendship, and not pay him a stiff sign of respect, as men do to those whom they fear. A passage read from his discourses, a moving provocation to works like his, any act or meeting which tends to awaken a pure thought, a flow of love, an original design of virtue, I call a worthy, a true commemoration.
    Ralph Waldo Emerson (1803–1882)

    If I commit suicide, it will not be to destroy myself but to put myself back together again. Suicide will be for me only one means of violently reconquering myself, of brutally invading my being, of anticipating the unpredictable approaches of God. By suicide, I reintroduce my design in nature, I shall for the first time give things the shape of my will.
    Antonin Artaud (1896–1948)

    With wonderful art he grinds into paint for his picture all his moods and experiences, so that all his forces may be brought to the encounter. Apparently writing without a particular design or responsibility, setting down his soliloquies from time to time, taking advantage of all his humors, when at length the hour comes to declare himself, he puts down in plain English, without quotation marks, what he, Thomas Carlyle, is ready to defend in the face of the world.
    Henry David Thoreau (1817–1862)