*** empty log message ***
[yaffs/.git] / Documentation / yaffs2.html
index e83dcc667d8474087320b10245b8e2e97bc082f0..8dd694f38bc99573b98b63cc822722b1c67d2277 100644 (file)
@@ -7,7 +7,7 @@
        <META NAME="AUTHOR" CONTENT=" ">
        <META NAME="CREATED" CONTENT="20021004;15061000">
        <META NAME="CHANGEDBY" CONTENT=" ">
-       <META NAME="CHANGED" CONTENT="20021126;13574600">
+       <META NAME="CHANGED" CONTENT="20030906;14584300">
 </HEAD>
 <BODY>
 <H1>YAFFS2</H1>
@@ -54,19 +54,59 @@ can't use the &quot;discarded&quot; flags in YAFFS2.</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>
+       therefore this shows the shrunken file size. The ObjectHeader also
+       carries information to say that this is a shrink, for some special
+       handling in the garbage collector.</P>
 </UL>
+<P><BR><BR>
+</P>
 <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>
+       performed when a block is erased (as part of deletion). This is
+       already done in YAFFS by<I> soft deletion.</I></P>
 </UL>
 <P>This makes erasure &amp; 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>Resize Handling</H4>
+<P>In YAFFS, soft deletion is ued for everything but resizing
+(shrinking) a file which has some particularly ugly cases that can
+complicate garbage collection.</P>
+<P>As mentioned before, we write a new ObjectHeader to indicate the
+shrinking.  However, it is important that this ObjectHeader does not
+get destroyed (erased) before the data chunks that were discarded
+during the shrink are destroyed (erased). If this precaution is not
+taken then it is possible that the deleted chunks might be brought
+back to life.</P>
+<P>The modification to the garbage collector is as follows:</P>
+<UL>
+       <LI><P>The block info flags are expanded as follows:</P>
+       <LI><P>containsShrinkObjectHeader: Indicates that one or more of the
+       chunks in the block are object headers to indicate a file shrink.</P>
+       <LI><P>containsShrinkDataChunks: Indicates that one or more of the
+       chunks in the block are data chunks discarded by a file shrink.</P>
+</UL>
+<UL>
+       <LI><P>Before we allow a block with containsShrinkObjectHeader set
+       to be erased (garbage collected), we must first ensure that all the
+       earlier blocks (ie according to the block sequence number) that have
+       containsShrinkDataChunks set are erased (garbage collected) which
+       ensures that the shrunk data chunks are deleted. The mechanisms to
+       do this are as follows:</P>
+       <LI><P>If the garbage collector attempts to select a block with
+       containsShrinkObjectHeader set, we check that the above criterion in
+       met before selecting the block.</P>
+       <LI><P>Periodically select the oldest block with
+       containsShrinkDataChunks for garbage collection.</P>
+</UL>
+<P><BR><BR>
+</P>
+<P><BR><BR>
+</P>
 <H4>Tag structure</H4>
 <P>Each chunk in YAFFS2 has the following information:</P>
 <TABLE WIDTH=100% BORDER=1 CELLPADDING=4 CELLSPACING=3>
@@ -224,7 +264,7 @@ 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>These  numbers are indicative of relative performance. These only
+<P>These numbers are indicative of relative performance. These only
 apply to the NAND data transfer and do not include other overheads.</P>
 <P>As an example, read/write cycle times of 100nS are used (though
 NAND can typically do 50nS), &quot;seek time&quot; of 10uS and
@@ -747,7 +787,41 @@ transfer time relative to an 8-bit bus.</P>
 </TABLE>
 <P><BR><BR>
 </P>
-<P>$Id: yaffs2.html,v 1.1 2002-11-26 01:15:37 charles Exp $</P>
+<H2>MTD Interface</H2>
+<P>As mentioned before, YAFFS2 requires a chunk-size of at least 1kB
+to get a large enough spare area to support the increased size of the
+tags. This is not really a disadvantage, but should rather be viewed
+as an opportunity to exploit the NAND hardware more effectively. In
+particular:</P>
+<UL>
+       <LI><P>Newer, larger, NAND with 2kB pages can be used in chunks of
+       2kB. Keeping the relationship of one chunk per page improves
+       robustness and performance (rather than say trying to &quot;fake&quot;
+       512byte pages). A block comprises 64x2kB pages.</P>
+       <LI><P>Some devices have 512byte pages, but are arranged as multiple
+       &quot;bit planes&quot; which can be programmed and erased in
+       parallel. For example, the Samsung K9K1G08U0M can support 4
+       simultaneous operations. YAFFS2 can exploit this by using 2kB chunks
+       by using groups of 4 pages - one on each bitplane. Virtual blocks
+       would be built which comprise 32x2kB chunks.</P>
+</UL>
+<P>To this end, yaffs_guts is being re-crafted to support arbitrary
+chunk size (power of 2, &gt;= 1024), with arbitrary block size.</P>
+<P>Currently, YAFFS also makes some other assumptions which will need
+to be changed:</P>
+<UL>
+       <LI><P>Spare layout. Might need to be changed. This is relatively
+       simple to shuffle around.</P>
+       <LI><P>Bad block detection. Currently YAFFS uses the SmartMedia
+       detection (checks first two pages for bad block markers). Needs to
+       be more flexible. eg. Sandisk/Toshiba MLC parts mark the last two
+       pages in a block.</P>
+       <LI><P>ECC was on this list, but now seems flexible enough. Thanx
+       Thomas.</P>
+</UL>
+<P>Some of these differences can be absorbed in the yaffs_mtd layer.
+Some will need to be handles inside the mtd itself.</P>
+<P>$Id: yaffs2.html,v 1.3 2003-09-16 06:48:38 charles Exp $</P>
 <P><BR><BR>
 </P>
 <P><BR><BR>