?? yaffs2.html
字號(hào):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><HTML><HEAD> <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1"> <TITLE></TITLE> <META NAME="GENERATOR" CONTENT="StarOffice/5.2 (Linux)"> <META NAME="AUTHOR" CONTENT=" "> <META NAME="CREATED" CONTENT="20021004;15061000"> <META NAME="CHANGEDBY" CONTENT=" "> <META NAME="CHANGED" CONTENT="20021206;6000500"></HEAD><BODY><H1>YAFFS2</H1><H4>Summary</H4><P>The original motivation for YAFFS 2 was to add support for the newNAND with 2kB pages instead of 512-byte pages and strictly sequentialpage writing order. </P><P>To achieve this, a new design is used which also realises thefollowing benefits:</P><UL> <LI><P>zero page rewrites, which 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, depending on chunk size used).</P> <LI><P>Can support Toshiba/Sandisk MLC parts.</P> <LI><P>Runtime selection between various chunk sizes.</P></UL><P>Most of YAFFS and YAFFS2 code is common, therefore the code willlikely 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 howdiscarded status is tracked. Since we can't do any re-writing, wecan't use the "discarded" flags in YAFFS2.</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></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></UL><P>This makes erasure & garbage collection more expensive (byadding reads), but remember that ion YAFFS2 we don't need to do pagedeletions which are much more expensive operations. Thus, all-upYAFFS2 wins.</P><H4>Tag structure</H4><P>Each chunk in YAFFS2 has the following information:</P><TABLE WIDTH=100% BORDER=1 CELLPADDING=4 CELLSPACING=3> <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 achunk-size of at least 1kB. YAFFS1 is still used for 512-byte chunksizes.</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 tobe able to recreate the file system state during scanning. Since weno longer have chunk deletion status flags we use a slightlydifferent process for scanning a YAFFS2 system.</P><P>In effect, YAFFS2 recreates its state by "replaying thetape". ie. it scans the chunks in their allocation order (blocksequence Id order) rather than in their order on the media. Thisimplies that at start up, the blocks must be read and their blocksequence determined.</P><H4>Performance</H4><P>These numbers are indicative of relative performance. These onlyapply to the NAND data transfer and do not include other overheads.</P><P>As an example, read/write cycle times of 100nS are used (thoughNAND can typically do 50nS), "seek time" of 10uS andprogram time of 200uS. Mileage will vary.</P><P>NB x16 means using a 16-bit bus. Clearly this cuts down on datatransfer time relative to an 8-bit bus.</P><P>Times for 2kB read(units of 1uS).</P><TABLE WIDTH=937 BORDER=1 CELLPADDING=4 CELLSPACING=3> <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 WIDTH=175 VALIGN=TOP> <P>Seek </P> </TD> <TD WIDTH=176 VALIGN=BOTTOM SDVAL="40" SDNUM="5129;"> <P ALIGN=RIGHT>40</P> </TD> <TD WIDTH=177 VALIGN=BOTTOM SDVAL="40" SDNUM="5129;"> <P ALIGN=RIGHT>40</P> </TD> <TD WIDTH=176 VALIGN=BOTTOM SDVAL="10" SDNUM="5129;"> <P ALIGN=RIGHT>10</P> </TD> <TD WIDTH=173 VALIGN=BOTTOM SDVAL="10" SDNUM="5129;"> <P ALIGN=RIGHT>10</P> </TD> </TR> <TR> <TD WIDTH=175 VALIGN=TOP> <P>Read</P> </TD> <TD WIDTH=176 VALIGN=BOTTOM SDVAL="220" SDNUM="5129;"> <P ALIGN=RIGHT>220</P> </TD> <TD WIDTH=177 VALIGN=BOTTOM SDVAL="220" SDNUM="5129;"> <P ALIGN=RIGHT>220</P> </TD> <TD WIDTH=176 VALIGN=BOTTOM SDVAL="220" SDNUM="5129;"> <P ALIGN=RIGHT>220</P> </TD> <TD WIDTH=173 VALIGN=BOTTOM SDVAL="110" SDNUM="5129;"> <P ALIGN=RIGHT>110</P> </TD> </TR> <TR> <TD WIDTH=175 VALIGN=TOP> <P>Total</P> </TD> <TD WIDTH=176 VALIGN=BOTTOM SDVAL="260" SDNUM="5129;"> <P ALIGN=RIGHT>260</P> </TD> <TD WIDTH=177 VALIGN=BOTTOM SDVAL="260" SDNUM="5129;"> <P ALIGN=RIGHT>260</P> </TD> <TD WIDTH=176 VALIGN=BOTTOM SDVAL="230" SDNUM="5129;"> <P ALIGN=RIGHT>230</P> </TD> <TD WIDTH=173 VALIGN=BOTTOM SDVAL="120" SDNUM="5129;"> <P ALIGN=RIGHT>120</P> </TD> </TR> <TR> <TD WIDTH=175 VALIGN=TOP> <P>MB/s</P> </TD> <TD WIDTH=176 VALIGN=BOTTOM SDVAL="7.6" SDNUM="5129;"> <P ALIGN=RIGHT>7.6</P> </TD> <TD WIDTH=177 VALIGN=BOTTOM SDVAL="7.6" SDNUM="5129;"> <P ALIGN=RIGHT>7.6</P> </TD> <TD WIDTH=176 VALIGN=BOTTOM SDVAL="8.7" SDNUM="5129;"> <P ALIGN=RIGHT>8.7</P> </TD> <TD WIDTH=173 VALIGN=BOTTOM SDVAL="16.7" SDNUM="5129;"> <P ALIGN=RIGHT>16.7</P> </TD> </TR> <TR> <TD WIDTH=175 VALIGN=TOP> <P>Relative speed</P> </TD> <TD WIDTH=176 VALIGN=BOTTOM SDVAL="1" SDNUM="5129;"> <P ALIGN=RIGHT>1</P> </TD> <TD WIDTH=177 VALIGN=BOTTOM SDVAL="1" SDNUM="5129;"> <P ALIGN=RIGHT>1</P> </TD> <TD WIDTH=176 VALIGN=BOTTOM SDVAL="1.1" SDNUM="5129;"> <P ALIGN=RIGHT>1.1</P> </TD> <TD WIDTH=173 VALIGN=BOTTOM SDVAL="2.2" SDNUM="5129;"> <P ALIGN=RIGHT>2.2</P> </TD> </TR> </TBODY></TABLE><P><BR><BR></P><P>Times for 2kB writes(units of 1uS).</P><TABLE WIDTH=100% BORDER=1 CELLPADDING=4 CELLSPACING=3> <COL WIDTH=51*> <COL WIDTH=51*> <COL WIDTH=51*> <COL WIDTH=51*> <COL WIDTH=51*> <THEAD> <TR VALIGN=TOP> <TH WIDTH=20%> <P>Operation</P> </TH> <TH WIDTH=20%> <P>YAFFS1</P> </TH> <TH WIDTH=20%> <P>YAFFS2 (512b pages)</P> </TH> <TH WIDTH=20%> <P>YAFFS2 (2kB pages)</P> </TH> <TH WIDTH=20%> <P>YAFFS2(2kB pages, x16)</P> </TH> </TR> </THEAD> <TBODY> <TR> <TD WIDTH=20% VALIGN=TOP> <P>Seek</P> </TD> <TD WIDTH=20% VALIGN=BOTTOM SDVAL="40" SDNUM="5129;"> <P ALIGN=RIGHT>40</P> </TD> <TD WIDTH=20% VALIGN=BOTTOM SDVAL="40" SDNUM="5129;"> <P ALIGN=RIGHT>40</P> </TD> <TD WIDTH=20% VALIGN=BOTTOM SDVAL="10" SDNUM="5129;"> <P ALIGN=RIGHT>10</P> </TD> <TD WIDTH=20% VALIGN=BOTTOM SDVAL="10" SDNUM="5129;"> <P ALIGN=RIGHT>10</P> </TD> </TR> <TR>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -