LogFS
Encyclopedia
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 drive
s (SSDs), USB flash drive
s and memory card
s.
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.
For using logfs with mtd devices, make sure your kernel is compiled with MTD_CONFIG=y.
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/
Linux kernel
The Linux kernel is an operating system kernel used by the Linux family of Unix-like operating systems. It is one of the most prominent examples of free and open source software....
log-structured
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...
and scalable flash file system, intended for use on large devices of 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...
. It is written by Jörn Engel and in part sponsored by the CE Linux Forum
CE Linux Forum
The Consumer Electronics Linux Forum is a non-profit organization that works to advance Linux as an open source platform for consumer electronics devices...
.
LogFS is included in the mainline Linux kernel
Linux kernel
The Linux kernel is an operating system kernel used by the Linux family of Unix-like operating systems. It is one of the most prominent examples of free and open source software....
and was introduced in version 2.6.34, released on May 16, 2010.
In contrast to 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...
, YAFFS
YAFFS
YAFFS was designed and written by Charles Manning, of Whitecliffs, New Zealand, for the company .Yaffs1 is the first version of this file system and works on NAND chips that have 512 byte pages + 16 byte spare areas. These older chips also generally allow 2 or 3 write cycles per page, which...
and UBIFS
UBIFS
The Unsorted Block Image File System is a successor to JFFS2, and competitor to LogFS, as a file system for use with raw flash memory media. Development began in earnest in 2007, with the first stable release made to Linux kernel 2.6.27 in October 2008.Note that UBIFS works on top of an Unsorted...
, LogFS also provides a (very) basic, slow support for use with block devices like Solid-state drive
Solid-state drive
A solid-state drive , sometimes called a solid-state disk or electronic disk, is a data storage device that uses solid-state memory to store persistent data with the intention of providing access in the same manner of a traditional block i/o hard disk drive...
s (SSDs), USB flash drive
USB flash drive
A flash drive is a data storage device that consists of flash memory with an integrated Universal Serial Bus interface. flash drives are typically removable and rewritable, and physically much smaller than a floppy disk. Most weigh less than 30 g...
s and memory card
Memory card
A memory card or flash card is an electronic flash memory data storage device used for storing digital information. They are commonly used in many electronic devices, including digital cameras, mobile phones, laptop computers, MP3 players, and video game consoles...
s.
History
, 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 treeInode pointer structure
The inode pointer structure is a structure adopted by the inode of a file in the Unix File System or other related file systems to list the addresses of a file's data blocks. In the past, the structure may have consisted of eleven or thirteen pointers, but most modern file systems use fifteen...
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 mtd2. 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/