JFFS2 introduced:
As with JFFS, changes to files and directories are "logged" to flash in nodes, of which there are two types:
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.3
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).4
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.5
Due to its log-structured design, JFFS2's disadvantages include the following:6
"Memory Technology Device (MTD) Subsystem for Linux". www.linux-mtd.infradead.org. Retrieved 2021-05-15. http://www.linux-mtd.infradead.org/faq/jffs2.html#L_hdd_jffs2 ↩
"The OpenWrt Flash Layout - OpenWrt Wiki". Wiki.openwrt.org. 18 January 2010. Retrieved 2014-03-04. http://wiki.openwrt.org/doc/techref/flash.layout ↩
"Software Profile: Journaling Flash File System, Version 2 (JFFS2)" (PDF). micron.com. 2011. Archived from the original (PDF) on 2014-03-07. Retrieved 2014-03-04. https://web.archive.org/web/20140307004309/http://www.micron.com/~/media/Documents/Products/Software%20Article/SWNL_jffs2_profile.pdf ↩