LogFS
Developer(s) | Jörn Engel |
---|---|
Other | |
Supported operating systems | Linux |
LogFS is a Linux log-structured and scalable flash file system, intended for use on large devices of flash memory. It is written by Jörn Engel and in part sponsored by the CE Linux Forum.
LogFS is included in the mainline Linux kernel and was introduced in version 2.6.34, released on May 16, 2010.
In contrast to JFFS2, YAFFS and UBIFS, LogFS also provides a (very) basic, slow support for use with block devices like Solid-state drives (SSDs), USB flash drives and memory cards.[1]
History
As of November 2008[update], LogFS finally was capable of passing all test cases of its test suite - indicating the start of maturing. LogFS was included in the mainline Linux kernel, marked as 'experimental', in version 2.6.34 released on May 16, 2010.
Operation
LogFS was motivated by the difficulties of JFFS2 with larger flash-memory drives. LogFS stores the inode tree on the drive; JFFS2 does not, which requires it to scan the entire drive at mount and cache the entire tree in RAM. For larger drives, the scan can take tens of seconds and the tree can take a significant amount of main memory. LogFS avoids these penalties, but it does do more work while the system is running and uses some of the drive's space for holding the inode tree.
LogFS stores a file's inode tree on the drive, which means on a write to the file, each ancestor node in the tree must be rewritten. This is done by a "wandering tree" update. The lowest node in the tree (i.e., the data) is written first, each node is written ascending the tree, until the root inode is updated. Writing the root last maintains atomicity of the update.
A flash-memory block is the unit for erasures and is usually larger than the file-system block. LogFS handles this disparity by packing multiple file-system blocks into a single flash-memory block. A "sum" entry at the end of the flash-memory block records what data is stored in it. When the flash-memory block has all its file-system blocks moved or deleted, it can be erased and used for new data.
For peak usage of the flash-memory drive, it is necessary to compact data so that flash-memory blocks are full of useful data. This is accomplished by garbage collection. LogFS's garbage collection strategy relies on file data being placed in a certain way into flash-memory blocks: a flash-memory block will hold only file data from the same level in the inode tree. LogFS can garbage collect the top level of the trees using just 1 empty flash-memory block. It can garbage collect the top 2 levels of the trees using 2 empty flash-memory blocks. And can garbage collect all N levels of the trees using N empty flash memory blocks. The algorithm is exponential time in the worst case, but the worst case is rare and the algorithm requires reserving only a handful of flash-memory blocks.
Logfs in Action
You can get the latest logfs source from logfs git tree. For using logfs with mtd devices, make sure your kernel is compiled with MTD_CONFIG=y.
Using logfs with nandsim
1. sudo modprobe mtd
2. sudo modprobe mtdblock
3. sudo modprobe nandsim
4. sudo flash_eraseall /dev/mtd0
5. sudo logfsprogs/mklogfs -s15 /dev/mtdblock0
(download logfsprogs from "http://logfs-tools.sourcearchive.com/")
6. sudo modprobe zlib_deflate
7. sudo modprobe logfs
8. sudo mount -t logfs /dev/mtdblock0 /mnt/flash_drive/
9. do some test
8. sudo umount /mnt/flash_drive/
See also
External links
References
- ^ LogFS news (see 9.7.07)