Kowning YAFFS

 

YAFFS (Yet Another Flash File System)

 

YAFFS1: A first version file system work on NAND chips that have 512 bytes pages + 16 byte spare areas.
The advantage is that dirty pages are marked by writting to a special spare area byte. Newer NAND flash chips have larger page, 2048 bytes + 64 bytes spare areas, each page within a block must be written in sequential order and each page must be written only once. YAFFS is a robust log-structured file syetem that holds data integrity as high priority and high performance. It is designed for Linux, WinCE, oSOS, eCos, ThreadX and various special-purpose OSes. It follows mark 5th byte of spare area of each block as bad block status flag. (0xFF 可用, 反之为坏)

 

To write file data, YAFFS initially writes a whole page (chunk in YAFFS) that describes the file timestamps, name, path, etc. The new file is assigned a unique Object ID, every data chunk within the file will contain this unique ID within the spare area. (for example, supposed 1 page = 512 bytes + 16 bytes, then the unique Object ID is record in that 16 bytes).

 

garbage collection -

YAFFS maintains a tree structure in memory of the physical location of chip. When a chunk is no longer valid (the file was delete or the file was overwritten), YAFFS marks a particular byte in the spare area of the chunk as 'dirty'.

When an entire block (32 pages) is marked as dirty, YAFFS can erase the block and reclaim the space. If the free space on the device is low, YAFFS may need to choose a block that has some number of dirty pages and some number of good pages, move the good pages to a new block, mark the old pages as dirty and erase the block.

 

YAFFS2:

To support 2K bytes + 64 bytes as a chunk and the YAFFS2 code base supports of YAFFS1 data formats through backward compatibility. The main difference is that YAFFS2 needs to jump through significant hoops to meet 'write once' requirement of modern NAND flash. It provide the following benefits,

 

1. zero page rewrites means faster operation (write:1.5x, delete: 4x, garbage collection: 2x) and add chip valid life.

2. lower RAM footpoint (approx 25% to 50% of YAFFS1)

3. can support Toshiba/Sandisk MLC parts.

 

YAFFS2 chunks have more tag information, including a block sequence id, from that we can determine the chunk sequence id since the chunks are allocated sequentially in a block. Thus we always know the patch order fir all chunks in the system.

 

Deletion is achieved by moving the object to the "unlink" directory. We also keep the track of the number of chunks in system for each object. While this number indicates that there are still chunks associated with this object we keep the deletion record. When the last trace of the object has been really erased from NAND, we can forget about the deletion record too.

 

Tag structure:

 

 

 

 

 

Flash File System Evaluation:

 

 

mount time: time mount -t <filesystem> /dev/mtdblock0 <target-dir>

 

write time: time tar xf <some-tar-compressed-file> with 81MB size and extract out 1865 files.

 

read time: time du -shc <target-dir>

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值