Readme-linux yaffs2

 

Welcome to YAFFS, the first file system developed specifically for NAND flash.
欢迎来到YAFFS,这是第一个专门为NAND flash特定开发的文件系统。
It is now YAFFS2 - original YAFFS (AYFFS1) only supports 512-byte page
NAND and is now deprectated. YAFFS2 supports 512b page in 'YAFFS1
compatibility' mode (CONFIG_YAFFS_YAFFS1) and 2K or larger page NAND
in YAFFS2 mode (CONFIG_YAFFS_YAFFS2).
现在是YAFFS2-最开始的YAFFS1只支持512-BYRE页NAND现在没有了。YAFFS2支持512b的页在YAFFS1兼容模式(CONFIG_YAFFS_YAFFS1)和2K或者更大的页NAND在YAFFS2模式(CONFIG_YAFFS_YAFFS2).

A note on licencing
一个许可证的注释
-------------------
YAFFS is available under the GPL and via alternative licensing
arrangements with Aleph One. If you're using YAFFS as a Linux kernel
file system then it will be under the GPL. For use in other situations
you should discuss licensing issues with Aleph One.


Terminology术语
-----------
Page - NAND addressable unit (normally 512b or 2Kbyte size) - can
be read, written, marked bad. Has associated OOB.
页-NAND地质单元(通常是52B或者2K大小)-可以被读、写、标记为坏块。被联合OOB。
Block - Eraseable unit. 64 Pages. (128K on 2K NAND, 32K on 512b NAND)
块-可擦单元。64页。(128K在2K NAND,32K 在512B NAND)
OOB - 'spare area' of each page for ECC, bad block marked and YAFFS
tags. 16 bytes per 512b - 64 bytes for 2K page size.
OOB-空余的区域在每一个页上对于ECC。坏块被标记和YAFFS标签。每512B16字节-2K页大小有64字节。
Chunk - Basic YAFFS addressable unit. Same size as Page.
大块-基础YAFFS可设地址单元。同样的大小如同页一样。
Object - YAFFS Object: File, Directory, Link, Device etc.
对象-YAFFS对象文件,目录,链接,驱动等。

YAFFS design
YAFFS设计
------------

YAFFS is a log-structured filesystem. It is designed particularly for
YAFFS是一个LOG-STRUCTURED文件系统。
NAND (as opposed to NOR) flash, to be flash-friendly, robust due to
他被特别的为了NAND FLASH设计的,
journalling, and to have low RAM and boot time overheads. File data is
具有低存储器和启动时间。
stored in 'chunks'. Chunks are the same size as NAND pages. Each page
文件数据被存放在大块里面。
is marked with file id and chunk number. These marking 'tags' are
每页被标记包括文件ID和大块序列号。
stored in the OOB (or 'spare') region of the flash. The chunk number
这些标记标示被储存在FLASH的OOB区域。
is determined by dividing the file position by the chunk size. Each
大块序列号的确定由大块的大小及文件的分区位置。
chunk has a number of valid bytes, which equals the page size for all
每一个块有许多的正确的字节,
except the last chunk in a file.
在一个文件里除了最后一个块,都是相同的页大小。

File 'headers' are stored as the first page in a file, marked as a
文件存储的第一页被作作为文件的头部,被标记为不同类型的数据页。
different type to data pages. The same mechanism is used to store
同样的结构被用在存储目录,驱动文件,链接等。
directories, device files, links etc. The first page describes which
第一页用来形容文件是那种类型的对象。
type of object it is.

YAFFS2 never re-writes a page, because the spec of NAND chips does not
YAFFS2从来不重写一个页,应为NAND的片结构不允许。
allow it. (YAFFS1 used to mark a block 'deleted' in the OOB). Deletion
YAFFS1被标记一个删除的块在OOB里面。
is managed by moving deleted objects to the special, hidden 'unlinked'
删除被管理通过移动被删除的对象到特殊的隐藏的没有被连接的目录。
directory. These records are preserved until all the pages containing
这些记录被保存直到所有的页包含的对象被擦除。
the object have been erased (We know when this happen by keeping a
count of chunks remaining on the system for each object - when it
reaches zero the object really is gone).

When data in a file is overwritten, the relevant chunks are replaced
当文件中的数据被重写,相关的块被代替,通过写新的页新的数据但是相同
by writing new pages to flash containing the new data but the same
标签的形式。
tags.

Pages are also marked with a short (2 bit) serial number that
页也被用一个短的序列号标记,序列号每次增加在页在这个位置增加的时候。
increments each time the page at this position is incremented. The
reason for this is that if power loss/crash/other act of demonic
理由是:当掉电等其他恶性情况发生的时候,在页还没有被更新之前,被标记为丢失。
forces happens before the replaced page is marked as discarded, it is
possible to have two pages with the same tags. The serial number is
这样可能存在两个页拥有相同的标签,序列号可以用来判断。
used to arbitrate.

A block containing only discarded pages (termed a dirty block) is an
一个只包含丢弃页的块是一个显然的碎片帐集的候选人。
obvious candidate for garbage collection. Otherwise valid pages can be
另外正确的页可以被拷贝出一个块,从而描写整个的块被丢弃和为
copied off a block thus rendering the whole block discarded and ready
碎片帐集准备好。
for garbage collection.

In theory you don't need to hold the file structure in RAM... you
理论上你不需要掌握RAM里的文件结构……
could just scan the whole flash looking for pages when you need them.
你可以仅仅扫描整个FLASH来寻找页当你需要他们的时候。
In practice though you'd want better file access times than that! The
在实践中尽管你更希望快的文件访问时间。
mechanism proposed here is to have a list of __u16 page addresses
这个机制被在这里提出来使用一个一栏_U16页地址联合,在每一个文件里。
associated with each file. Since there are 2^18 pages in a 128MB NAND,
因为那里有2^18个页在128MB NAND,
a __u16 is insufficient to uniquely identify a page but is does
一个_U16不能够唯一的对应一个页,但是可以对应4页一组的-用尽一切的
identify a group of 4 pages - a small enough region to search
搜索足够小的区域。
exhaustively. This mechanism is clearly expandable to larger NAND
这种机制被明显的扩大到更大的NAND设备-内部原因。
devices - within reason. The RAM overhead with this approach is approx
RAM上面用这种方法大约2BYTES每页-一个128MB的NAND有512KB的RAM。
2 bytes per page - 512kB of RAM for a whole 128MB NAND.

Boot-time scanning to build the file structure lists only requires
导入时间扫描来建立文件结构列表仅需要一页,通过读NAND。
one pass reading NAND. If proper shutdowns happen the current RAM
如果合适的关闭发生在当前的RAM,文件系统状态概要被保存在FLASH里面,
summary of the filesystem status is saved to flash, called
称为检查点。
'checkpointing'. This saves re-scanning the flash on startup, and gives
这节省了在启动时重新扫描FALSH,和让出了很大的引导/挂载时间储蓄。
huge boot/mount time savings.

YAFFS regenerates its state by 'replaying the tape' - i.e. by
YAFFS更新它的状态通过‘重新播放磁带’
scanning the chunks in their allocation order (i.e. block sequence ID
比如通过扫描块在他们的分配顺序(比如块的叠置次序ID)
order), which is usually different form the media block order. Each
经常用来区分媒体块顺序。
block is still only read once - starting from the end of the media and
每一个块仍然被读一次-从媒质的最后开始,向后的方式。
working back.

YAFFS tags in YAFFS1 mode:
YAFFS标签在YAFFS1模式:
18-bit Object ID (2^18 files, i.e. > 260,000 files). File id 0- is not
18位的对象ID(2^18个文件,262144个文件)。文件ID 0是不正确的。
valid and indicates a deleted page. File od 0x3ffff is also not valid.
并且指出一个被删除的页。文件ID03XFFFF也是不正确的。
Synonymous with inode.
和节点是同义的。
2-bit serial number
2个位的序列号
20-bit Chunk ID within file. Limit of 2^20 chunks/pages per file (i.e.
20个位的大块ID在文件里。每个文件限制2^20的大块
> 500MB max file size). Chunk ID 0 is the file header for the file.
块ID0是文件的头。
10-bit counter of the number of bytes used in the page.
10个位的计数器,在每页中表示被使用的字节的数量。
12 bit ECC on tags
12个位的ECC作为标签。

YAFFS tags in YAFFS2 mode:
YAFFS标签再YAFFS2模式:
4 bytes 32-bit chunk ID
4字节,32位大块ID
4 bytes 32-bit object ID
4字节,32位对象ID
2 bytes Number of data bytes in this chunk
2字节,块中数据字节数量
4 bytes Sequence number for this block
4字节,块的序号
3 bytes ECC on tags
3字节ECC的标签
12 bytes ECC on data (3 bytes per 256 bytes of data)
12字节ECC 在表示数据上(每256字节数据-3字节)


Page allocation and garbage collection
页分配和碎片帐集

Pages are allocated sequentially from the currently selected block.
页被连续的分配从当前被选中的块。
When all the pages in the block are filled, another clean block is
当所有的页在块中被填满时,另一个干净的块被选中。
selected for allocation. At least two or three clean blocks are
至少2到3个干净的块被保留给碎片帐集功能 。
reserved for garbage collection purposes. If there are insufficient
如果有不足的干净的块,那么一个脏块被擦除用来作为干净的块。
clean blocks available, then a dirty block ( ie one containing only
(比如仅仅包括丢弃的页)
discarded pages) is erased to free it up as a clean block. If no dirty
如果只有脏块可用,那么最脏的块被选中给碎片帐集功能。
blocks are available, then the dirtiest block is selected for garbage
collection.

Garbage collection is performed by copying the valid data pages into
碎片帐集被执行通过拷贝正确的数据页到新的数据页,从而表现所有的页在这个块
new data pages thus rendering all the pages in this block dirty and
中是脏的,并且解除他们给擦除。
freeing it up for erasure. I also like the idea of selecting a block
我也喜欢随即选取一个块,在很少的时候-从而减少穿戴不同的机会。
at random some small percentage of the time - thus reducing the chance
of wear differences.

YAFFS is single-threaded. Garbage-collection is done as a parasitic
YAFFS是一个单线的。碎片帐集被完成作为写数据的一个寄生工作。
task of writing data. So each time some data is written, a bit of
所以每次一些数据被写入,一点未决的碎片帐集被做好。
pending garbage collection is done. More pages are garbage-collected
更多的页被碎片帐集当空余空间紧张的时候。
when free space is tight.


Flash writing
闪存写入

YAFFS only ever writes each page once, complying with the requirements
YAFFS仅仅被写每页一次,大多数NAND设备都是按照要求做的。
of the most restricitve NAND devices.

Wear levelling
磨损等级

This comes as a side-effect of the block-allocation strategy. Data is
这个的由来作为块分配策略的副作用。
always written on the next free block, so they are all used equally.
数据总被写在下一个空闲的块,所以他们全部被平等的使用。
Blocks containing data that is written but never erased will not get

back into the free list, so wear is levelled over only blocks which

are free or become free, not blocks which never change.



Some helpful info
一些有用的信息
-----------------

Formatting a YAFFS device is simply done by erasing it.
格式化一个YAFFS设备可以简单的通过擦除它来完成。

Making an initial filesystem can be tricky because YAFFS uses the OOB
制作一个原始的文件系统可以TRICKY因为YAFFS使用OOB并且
and thus the bytes that get written depend on the YAFFS data (tags),
因而被写入的字节取决于YAFFS数据(标签)。
and the ECC bytes and bad block markers which are dictated by the

hardware and/or the MTD subsystem. The data layout also depends on the
device page size (512b or 2K). Because YAFFS is only responsible for
some of the OOB data, generating a filesystem offline requires
detailed knowledge of what the other parts (MTD and NAND
driver/hardware) are going to do.

To make a YAFFS filesystem you have 3 options:

1) Boot the system with an empty NAND device mounted as YAFFS and copy
stuff on.

2) Make a filesystem image offline, then boot the system and use
MTDutils to write an image to flash.

3) Make a filesystem image offline and use some tool like a bootloader to
write it to flash.

Option 1 avoids a lot of issues because all the parts
(YAFFS/MTD/hardware) all take care of their own bits and (if you have
put things together properly) it will 'just work'. YAFFS just needs to
know how many bytes of the OOB it can use. However sometimes it is not
practical.

Option 2 lets MTD/hardware take care of the ECC so the filesystem
image just had to know which bytes to use for YAFFS Tags.

Option 3 is hardest as the image creator needs to know exactly what
ECC bytes, endianness and algorithm to use as well as which bytes are
available to YAFFS.

mkyaffs2image creates an image suitable for option 3 for the
particular case of yaffs2 on 2K page NAND with default MTD layout.

mkyaffsimage creates an equivalent image for 512b page NAND (i.e.
yaffs1 format).

Bootloaders
引导装入
-----------

A bootloader using YAFFS needs to know how MTD is laying out the OOB
so that it can skip bad blocks.
一个引导装入使用YAFFS需要知道MTD如何布置OOB,从而可以跳过坏的块。
YAFFS Tracing
-------------

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值