UBIFS on XO
Problem Statement
The current file system used on the XO ([JFFS2]) was developed in the days of 32/64MiB NOR flash devices and does not scale well to the 1GiB NAND devices we are using today and certainly will not deal well with larger devices in gen 1.5 and gen 2 systems. The main issues we have seen with JFFS2 are as follows:
- JFFS2 needs to scan all blocks to mount the filesystem and the time do so scales linearly as the file system fills up. This can can result in up to 30s mount times on very full devices. (Note: Need to quantify this)
- The JFFS2 garbage collection algorithm increasingly consumes CPU cycles as the system fills up to the point of making the system unusable.
- JFFS2 does not provide a method to enable/disable compression on a per-inode basis leading to the CPU wasting cycles in an attempt to compress already compressed data such as multimedia (mp3, mpg4, ogg) and web-downloaded data (activity bundles, tar.gz, etc).
In the time since the XO was initially developed, several NAND file system alternatives have matured to the point of being considered viable alternatives. Those of primary interest are:
- YAFFS2 : This file system has been around for several years and in active use in the embedded space. It does not provide compression out of the box as the devices that use it often carry already compressed data such as MP3 and MPG files. YAFFS is not upstream and the primary developer has not expressed interest in pushing it upstream. While YAFFS has been proven on the field, the lack of compression and the fact that is not upstream are major demerits towards it replacing JFFS2 on the XO.
- UBIFS: A new file system recently merged into the kernel designed for use on large NAND flash devices. UBIFS supports a per-inode compression flag, fast mount times, power-failure safe updates, and other features that are important for the XO. UBIFS was developed by Nokia and IBM and is actively maintained in the upstream kernel.org tree.
UBIFS Overview
Unlike JFFS2, which sits on top of the kernel's block layer via the mtdblock driver, UBIFS sits on top of the Unsorted Block Image ([1]) layer which does not present itself as a block device. UBI was designed to handle wear-leveling and bad blocks on modern NAND devices efficiently and to release the file system above from any knowledge of these operations. UBI creates a mapping of Physical Erase Blocks (PEBs) to Logical Erase Blocks (LEBs), moving LEBs to different PEBs as needed to deal with wear leveling and bad blocks
(To be continued)