?? yaffs2.htm
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0041)http://www.aleph1.co.uk/yaffs/yaffs2.html -->
<HTML><HEAD><TITLE></TITLE>
<META content="text/html; charset=iso-8859-1" http-equiv=CONTENT-TYPE>
<META content="MSHTML 5.00.3700.6699" name=GENERATOR>
<META content=" " name=AUTHOR>
<META content=20021004;15061000 name=CREATED>
<META content=" " name=CHANGEDBY>
<META content=20021104;13435900 name=CHANGED></HEAD>
<BODY>
<H1>YAFFS2</H1>
<H4>Summary</H4>
<P>The original motivation for YAFFS 2 was to add support for the new NAND with
2kB pages instead of 512-byte pages and strictly sequential page writing order.
</P>
<P>To achieve this, a new design is used which also realises the following
benefits:</P>
<UL>
<LI>
<P>zero page rewrites means faster operation. (YAFFS1 uses a single rewrite in
the spare area to delete a page).</P>
<LI>
<P>ability to exploit simultaneous page programming on some chips.</P>
<LI>
<P>improves performance relative to YAFFS1 speed(write:1.5x to 5x, delete: 4x,
garbage collection: 2x)</P>
<LI>
<P>lower RAM footprint (approx. 25% to 50% of YAFFS1).</P>
<LI>
<P>Can support Toshiba/Sandisk MLC parts.</P></LI></UL>
<P>Most of YAFFS and YAFFS2 code is common, therefore the code will likely be
kept common with YAFFS vs YAFFS2 being run-time selected.</P>
<H4>Method</H4>
<P>The main philosophical difference between YAFFS and YAFFS2 is how discarded
status is tracked. Since we can't do any re-writing, we can't use the
"discarded" flags in YAFFS2.</P>
<P><BR><BR></P>
<P>Instead YAFFS2 uses two mechanisms to resolve data state.</P>
<UL>
<LI>
<P>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 for all
chunks in the system.</P>
<LI>
<P>The above helps us track stale -vs- fresh data, but does not help determine
when a file/object is deleted. Deletion is achieved by moving the object to
the "unlinked" directory. We also keep track of the number of chunks (both
stale and current) in the 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. </P>
<LI>
<P>Since there is no deletion, a resize (shrinking) of a file will still have
valid data chunks past the end of file on the NAND. However, we write a new
ObjectHeader at the time of the resize, therefore this shows the shrunken file
size.</P></LI></UL>
<P>This changes erasure slightly:</P>
<UL>
<LI>
<P>During garbage collection we can't just look at chunk state flags, instead
we must read the tags of each chunk to determine which object's chunk count we
must decrement. This step must also be performed when a block is erased (as
part of deletion).</P></LI></UL>
<P>This makes erasure & garbage collection more expensive (by adding reads),
but remember that ion YAFFS2 we don't need to do page deletions which are much
more expensive operations. Thus, all-up YAFFS2 wins.</P>
<H4>Tag structure</H4>
<P>Each chunk in YAFFS2 has the following information:</P>
<TABLE border=1 cellPadding=4 cellSpacing=3 width="100%">
<COLGROUP>
<COL width=45>
<COL width=83>
<COL width=64>
<COL width=64>
<THEAD>
<TR vAlign=top>
<TH width="18%">
<P>Field</P></TH>
<TH width="32%">
<P>Comment</P></TH>
<TH width="25%">
<P>Size for 1kb chunks</P></TH>
<TH width="25%">
<P>Size for 2kB chunks</P></TH></TR></THEAD>
<TBODY>
<TR vAlign=top>
<TD width="18%">
<P>blockState</P></TD>
<TD width="32%">
<P>Block state. non-0xFF for bad block</P></TD>
<TD width="25%">
<P>1 byte</P></TD>
<TD width="25%">
<P>1 byte</P></TD></TR>
<TR vAlign=top>
<TD width="18%">
<P>chunkId</P></TD>
<TD width="32%">
<P>32-bit chunk Id</P></TD>
<TD width="25%">
<P>4 bytes</P></TD>
<TD width="25%">
<P>4 bytes</P></TD></TR>
<TR vAlign=top>
<TD width="18%">
<P>objectId</P></TD>
<TD width="32%">
<P>32-bit object Id</P></TD>
<TD width="25%">
<P>4 bytes</P></TD>
<TD width="25%">
<P>4 bytes</P></TD></TR>
<TR vAlign=top>
<TD width="18%">
<P>nBytes</P></TD>
<TD width="32%">
<P>Number of data bytes in this chunk</P></TD>
<TD width="25%">
<P>2 bytes</P></TD>
<TD width="25%">
<P>2 bytes</P></TD></TR>
<TR vAlign=top>
<TD width="18%">
<P>blockSequence</P></TD>
<TD width="32%">
<P>sequence number for this block</P></TD>
<TD width="25%">
<P>4 bytes</P></TD>
<TD width="25%">
<P>4 bytes</P></TD></TR>
<TR vAlign=top>
<TD width="18%">
<P>tagsEcc</P></TD>
<TD width="32%">
<P>ECC on tags area</P></TD>
<TD width="25%">
<P>3 bytes</P></TD>
<TD width="25%">
<P>3 bytes</P></TD></TR>
<TR vAlign=top>
<TD width="18%">
<P>ecc</P></TD>
<TD width="32%">
<P>ECC, 3 bytes/256 bytes of data</P></TD>
<TD width="25%">
<P>12 bytes</P></TD>
<TD width="25%">
<P>24 bytes</P></TD></TR>
<TR vAlign=top>
<TD width="18%">
<P><B>Total</B></P></TD>
<TD width="32%">
<P><BR></P></TD>
<TD width="25%">
<P align=left><B>30 bytes</B></P></TD>
<TD width="25%">
<P><B>42 bytes</B></P></TD></TR></TBODY></TABLE>
<P><BR><BR></P>
<P>To get enough spare bytes for this tagging structure requires a chunk-size of
at least 1kB.</P>
<P>The blockSequence increments each time a block is allocated. (ie. the first
block allocated is block 1, and so on).</P>
<H4>Scanning</H4>
<P>The only reason we need to keep track of data status on NAND is to be able to
recreate the file system state during scanning. Since we no longer have chunk
deletion status flags we use a slightly different process for scanning a YAFFS2
system.</P>
<P>In effect, YAFFS2 recreates its state by "replaying the tape". ie. it scans
the chunks in their allocation order (block sequence Id order) rather than in
their order on the media. This implies that at start up, the blocks must be read
and their block sequence determined.</P>
<H4>Performance</H4>
<P>Times for 2kB read(units of 1uS).</P>
<TABLE border=1 cellPadding=4 cellSpacing=3 width=937>
<COLGROUP>
<COL width=175>
<COL width=176>
<COL width=177>
<COL width=176>
<COL width=173>
<THEAD>
<TR vAlign=top>
<TH width=175>
<P>Operation</P></TH>
<TH width=176>
<P>YAFFS1</P></TH>
<TH width=177>
<P>YAFFS2 (512b pages)</P></TH>
<TH width=176>
<P>YAFFS2 (2kB pages)</P></TH>
<TH width=173>
<P>YAFFS2(2kB pages, x16)</P></TH></TR></THEAD>
<TBODY>
<TR>
<TD vAlign=top width=175>
<P>Seek </P></TD>
<TD vAlign=bottom width=176 SDNUM="5129;" SDVAL="40">
<P align=right>40</P></TD>
<TD vAlign=bottom width=177 SDNUM="5129;" SDVAL="40">
<P align=right>40</P></TD>
<TD vAlign=bottom width=176 SDNUM="5129;" SDVAL="10">
<P align=right>10</P></TD>
<TD vAlign=bottom width=173 SDNUM="5129;" SDVAL="10">
<P align=right>10</P></TD></TR>
<TR>
<TD vAlign=top width=175>
<P>Read</P></TD>
<TD vAlign=bottom width=176 SDNUM="5129;" SDVAL="220">
<P align=right>220</P></TD>
<TD vAlign=bottom width=177 SDNUM="5129;" SDVAL="220">
<P align=right>220</P></TD>
<TD vAlign=bottom width=176 SDNUM="5129;" SDVAL="220">
<P align=right>220</P></TD>
<TD vAlign=bottom width=173 SDNUM="5129;" SDVAL="110">
<P align=right>110</P></TD></TR>
<TR>
<TD vAlign=top width=175>
<P>Total</P></TD>
<TD vAlign=bottom width=176 SDNUM="5129;" SDVAL="260">
<P align=right>260</P></TD>
<TD vAlign=bottom width=177 SDNUM="5129;" SDVAL="260">
<P align=right>260</P></TD>
<TD vAlign=bottom width=176 SDNUM="5129;" SDVAL="230">
<P align=right>230</P></TD>
<TD vAlign=bottom width=173 SDNUM="5129;" SDVAL="120">
<P align=right>120</P></TD></TR>
<TR>
<TD vAlign=top width=175>
<P>MB/s</P></TD>
<TD vAlign=bottom width=176 SDNUM="5129;" SDVAL="7.6">
<P align=right>7.6</P></TD>
<TD vAlign=bottom width=177 SDNUM="5129;" SDVAL="7.6">
<P align=right>7.6</P></TD>
<TD vAlign=bottom width=176 SDNUM="5129;" SDVAL="8.7">
<P align=right>8.7</P></TD>
<TD vAlign=bottom width=173 SDNUM="5129;" SDVAL="16.7">
<P align=right>16.7</P></TD></TR>
<TR>
<TD vAlign=top width=175>
<P>Relative speed</P></TD>
<TD vAlign=bottom width=176 SDNUM="5129;" SDVAL="1">
<P align=right>1</P></TD>
<TD vAlign=bottom width=177 SDNUM="5129;" SDVAL="1">
<P align=right>1</P></TD>
<TD vAlign=bottom width=176 SDNUM="5129;" SDVAL="1.1">
<P align=right>1.1</P></TD>
<TD vAlign=bottom width=173 SDNUM="5129;" SDVAL="2.2">
<P align=right>2.2</P></TD></TR></TBODY></TABLE>
<P><BR><BR></P>
<P>Times for 2kB writes(units of 1uS).</P>
<TABLE border=1 cellPadding=4 cellSpacing=3 width="100%">
<COLGROUP>
<COL width=51>
<COL width=51>
<COL width=51>
<COL width=51>
<COL width=51>
<THEAD>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -