JFFS
The Journaling Flash File System is a log-structured file system for use on NOR flash memory devices on the Linux operating system. It has been superseded by JFFS2.
Design
Flash memory must be erased prior to writing. The erase process has several limitations:- Erasing is very slow.
- It is only possible to erase flash in large segments, whereas it can be read or written in smaller blocks.
- Flash memory can only be erased a limited number of times before it becomes worn out.
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.