JFFS
Encyclopedia
The Journaling Flash File System (or JFFS) is a log-structured file system
for use on NOR flash memory
devices on the Linux
operating system. It has been superseded by JFFS2
.
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.
Log-structured file system
A log-structured filesystem is a file system design first proposed in 1988 by John K. Ousterhout and Fred Douglis. Designed for high write throughput, all updates to data and metadata are written sequentially to a continuous stream, called a log...
for use on NOR flash memory
Flash memory
Flash memory is a non-volatile computer storage chip that can be electrically erased and reprogrammed. It was developed from EEPROM and must be erased in fairly large blocks before these can be rewritten with new data...
devices on the Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...
operating system. It has been superseded by JFFS2
JFFS2
Journalling Flash File System version 2 or JFFS2 is a log-structured file system for use with flash memory devices. It is the successor to JFFS. JFFS2 has been included in the Linux kernel since the 2.4.10 release. JFFS2 is also available for a couple of bootloaders like Das U-Boot, Open...
.
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
Ext2
The ext2 or second extended filesystem is a file system for the Linux kernel. It was initially designed by Rémy Card as a replacement for the extended file system ....
or FAT
File Allocation Table
File Allocation Table is a computer file system architecture now widely used on many computer systems and most memory cards, such as those used with digital cameras. FAT file systems are commonly found on floppy disks, flash memory cards, digital cameras, and many other portable devices because of...
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
Wear levelling
Wear leveling is a technique for prolonging the service life of some kinds of erasable computer storage media, such as Flash memory used in solid-state drives and USB Flash drives...
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
Garbage collection (computer science)
In computer science, garbage collection is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program...
copies valid nodes from the head to the tail and skips obsolete ones, thus reclaiming space.
Disadvantages
- At mount time, the file system driver must read the entire inode chain and then keep it in memory. This can be very slow. Memory consumption of JFFS is also proportional to the number of files in the file system.
- The circular log design means all data in the filesystem is re-written, regardless of whether it is static or not. This generates many unnecessary erase cycles and reduces the life of the flash medium.