UFFS mounting process

UFFS文件系统的一个显著特点是能够实现快速启动。在ARM7 CPU上,加载包含8192块、每页512字节的1GB NAND闪存通常只需要不到一秒钟的时间。启动过程包括扫描NAND闪存、随机选择擦除块列表的起始点及处理孤儿节点等步骤。

One of the most important feature of UFFS is that it can boot up very fast.How fast is it ? Typically, mounting a full loaded 1Gb(with 8192 blocks, page size 512) NAND flash cost less than 1 seconds on ARM7 CPU.

Mounting a UFFS partition needs three steps:

* Step one: scan the NAND flash
On this step, UFFS will read the first page spare of every block, which tells the block attribute one of:
* Marked bad block
* Erased(free) block
* Dir block
* File block
* File data block

UFFS will build a in-memory tree during this step, every block will be classified into the hashed tree nodes.

When a file or file data block is scanned, it also need to read one (for full loaded file block) or all (for half-loaded file block) spares on this block to obtain the data length of this block.

It also search the tree nodes to find if the block is an unclean block (If the system is power off during writing to a block, then it could result two blocks having the same serial number, one of them is unclean block). If an unclean block is found, UFFS will check the timestamps and erase the unclean block.

TIME COST:
(reading 1 spare) x (total_blocks + total-file-data-blocks - 1) +
(readin <pages_per_block>g 1 to pages_per_blocks - 1 spare) x total-files + </pages_per_block>
(1 tree scan) x non-free-blocks +
(erasing block) x (0 or 1)


* Step two: randomize the start point of erased blocks list.

In order to implement ware-leveling across power recycle, UFFS randomly choose a start point for erased block list.
The time cost depends on the random number generation method, it should be very fast for most system.

* Step three: process the orphan nodes.

In this step, UFFS will scan the file data nodes in tree, find the orphan nodes(which can be produced when power lost in the middle of deleting/truncating a file) and erase it.

TIME COST: (1 tree scan) * file-data-blocks

* Summary:

The total time cost when mounting an UFFS partition is:

(reading 1 spare) x (total_blocks + total-file-data-blocks - 1) +
(readin <pages_per_block>g 1 to pages_per_blocks - 1 spare) x total-files + </pages_per_block>
(1 tree scan) x (non-free-blocks + file-data-blocks)

* For unclean power off, it may need to erase 1 block when mounting.
* The in-memory tree is a hash tree with key composed from serial number, so scan the tree with a given serial number is very fast.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值