 yaffs 2 specification yaffs 2 specification summary the original motivation for yaffs 2 was to add support for the new nand with 2kb pages instead of 512byte pages and strictly sequential page writing order to achieve this a new design is used which also realises the following benefits zero page rewrites means faster operation yaffs1 uses a single rewrite in the spare area to delete a page ability to exploit simultaneous page programming on some chips improves performance relative to yaffs1 speed write 15x to 5x delete 4x garbage collection 2x lower ram footprint approx 25 to 50 of yaffs1 can support toshiba sandisk mlc parts most of yaffs1 and yaffs2 code is common therefore the code will likely be kept common with yaffs1 vs yaffs2 being runtime selected method the main philosophical difference between yaffs and yaffs2 is how discarded status is tracked since we can t do any rewriting we can t use the discarded flags in yaffs2 instead yaffs2 uses two mechanisms to resolve data state 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 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 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 this changes erasure slightly 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 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 allup yaffs2 wins tag structure each chunk in yaffs2 has the following information field comment size for 1kb chunks size for 2kb chunks blockstate block state non0xff for bad block 1 byte 1 byte chunkid 32bit chunk id 4 bytes 4 bytes objectid 32bit object id 4 bytes 4 bytes nbytes number of data bytes in this chunk 2 bytes 2 bytes blocksequence sequence number for this block 4 bytes 4 bytes tagsecc ecc on tags area 3 bytes 3 bytes ecc ecc 3 bytes 256 bytes of data 12 bytes 24 bytes total   30 bytes 42 bytes  to get enough spare bytes for this tagging structure requires a chunksize of at least 1kb the blocksequence increments each time a block is allocated ie the first block allocated is block 1 and so on  scanning 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 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 performance times for 2kb read units of 1us operation yaffs1 yaffs2 512b pages yaffs2 2kb pages yaffs22kb pages x16 seek 40 40 10 10 read 220 220 220 110 total 260 260 230 120 mb s 76 76 87 167 relative speed 1 1 11 22 times for 2kb writes units of 1us operation yaffs1 yaffs2 512b pages yaffs2 2kb pages yaffs22kb pages x16 seek 40 40 10 10 program 800 800 200 200 seek 40 40 10 10 read 220 220 220 110 total 1320 1320 660 440 mb s 15 15 3 45 relative speed 1 1 2 3 times for 1mb delete units of 1us operation yaffs1 yaffs2 512b pages yaffs2 2kb pages yaffs22kb pages x16 seek 20480    program 409600    erase 128000 128000 16000 16000 total 558080 128000 16000 16000 mb s 18 78 625 625 relative speed 1 4 34 34 times for 1mb of garbage collection at 50 dirty units of 1us operation yaffs1 yaffs2 512b pages yaffs2 2kb pages yaffs22kb pages x16 delete 1mb 558080 128000 16000 16000 write 05mb 337920 337920 168960 112640 total 896000 465920 184960 128640 mb s 11 21 54 77 relative speed 1 19 49 7 wookey 23 may 2005 1233pm  