 yaffs tuning yaffs tuning admin 22 july 2012 823pm yaffstuningpdf 9147 kb  1 yaffs direct configuration yaffs behaviour is dictated by compile time and runtime flags 11 initialisation parameters each yaffs device is configured by a yaffsdeviceparameterstruct structure which is part of the yaffsdevicestruct structure this contains the following fields name an optional name for the device totalbytesperchunk the number of bytes in the data area of the flash page if inbandtags is not set then this whole area will be used to store data and the tags will be stored in the spare area if inbandtags is set then part of this area will be used to store tags and the rest will be used to store data sparebytesperchunk the number of available bytes in the spare area of the flash page this excludes space used by ecc bad block markers etc startblock the first block in the partition to be used  for first block endblock the last block in the partition to be used nreservedblocks number of good blocks blocks reserved for garbage collection etc needs to be at least 2 but 5 would be a more typical number inbandtags yaffs2 only flag indicating whether tags should be stored in the data area if inbandtags is set then the short op cache must be enabled ie nshortopcaches must be nonzero usenandecc yaffs1 only flag indicating whether the driver performs ecc if this is zero then yaffs will perform ecc notagsecc yaffs2 only flag indicating whether the tags have ecc attached to them isyaffs2 flag indicating if this is using the yaffs2 mechanism if this is not set then yaffs1 mode of operation is provided nshortopcaches number of chunks to store in the short operation cache zero disables caching typical value is 10 to 20 or so caching is required for inband tags emptylostandfound flag to delete all files in lost and found on mount skipcheckpointread yaffs2 only flag to skip reading checkpoint on mount if set then a rescan is forced skipcheckpointwrite yaffs2 only flag to skip writing checkpoint on sync or unmount refreshperiod yaffs2 only how often yaffs should do a block refresh values less than 10 disable block refreshing typical values would be1000 initialisenand pointer to function to initialise flash driver deinitialisenand pointer to function to deinitialise flash driver eraseblockinnand pointer to function to erase a flash block writechunktonand yaffs1 only pointer to function to write a chunk readchunkfromnand yaffs1 only pointer to function to read a chunk writechunkwithtagstonand yaffs2 only pointer to function to write a chunk plus tags readchunkwithtagsfromnand yaffs2 only pointer to function to read a chunk plus tags marknandblockbad yaffs2 only function to mark a block bad querynandblock yaffs2 only function to query a block state gccontrol callback function that returns the garbage collector control flags this is optional removeobjectcallback callback function called when an object is removed this is set by the wrapper marksuperblockdirty callback function that is called when a clean file system is first modified this is set by the wrapper disablesoftdelete yaffs1 only debug only disables soft deletion if nonzero useheaderfilesize debug only leave as zero disablelazyloading debug only leave as zero widetnodedisabled debug only leave as zero deferdirectoryupdate used to defer directory updates  12 compiletime settings these setting are used to apply compiletime configurations configyaffsalwayscheckchunkerased normally yaffs checks that chunks are erased only on the first chunk write to each block this flag allows you to force all chunks to be checked this is slower but is worth using when doing early debugging configyaffscaseinsensitive when selected case insensitive name comparisons are used note that this will not magically change yaffs to be case insensitive in a case sensitive os this needs to be set according to the os policy typically this is only used in windows ce configyaffsdirect used when compiling yaffs direct configyaffsdisablelazyload lazy loading is used to defer loading up object details until the objects are accessed this makes mount time faster this flag can disable lazy loading debug only configyaffseccwrongorder this flag should only be used with old linux mtd code which had a bug in the ecc byte ordering configyaffsnoyaffs1 used to say that only yaffs2 operation should be compiled in not currently supported configyaffsshortnamesinram set to configure yaffs to store short object names in ram this is faster but uses up more memory configyaffsunicode set to configure yaffs to use unicode file names eg with wince configyaffsuseownsort by default yaffs uses qsort for sorting blocks at mount scanning time this is faster using this flag forces yaffs to use a slow internal sort instead debug only configyaffsutil used when compiling yaffs for utilities configyaffswince set when compiling yaffs for wince configyaffsyaffs2 set when using yaffs2 mode at present this must always be set configyaffsfsprovidevalues used when compiling yaffs direct only 2 tracing mechanism yaffs has a lot of built in tracing to help debug and integrate the tracing is controlled by yaffstracemask bitmask which allows various sets of tracing to be disabled or enabled at runtime the trace bits are specified in the yaffstraceh file the tracing mechanism has also been hijacked to provide a control mask for extra verification code when the yaffstraceverifyxxx trace bits are selected the tracing mechanism is readily integrated into the system via printflike statements tracing is all done through macros which allow the strings to be converted into unicode or similar if need be 3 linux 31 linux compiletime flags the linux compile time flags are documented in the kconfig file and will not be duplicated here 32 linux proc yaffs trace adjustment under linux the tracing mechanism is hooked up to both the proc yaffs and the sys interface the proc yaffs interface is very user friendly cat os proc yaffs enables yaffstraceos cat all gc proc yaffs disables everything then enable yaffstracegc cat 0xf000 proc yaffs set trace mask to specified bitmask 33 linux sys interface the linux sys interface is used by many linux os components to access the state of control variables some yaffs variables are available via sys module yaffs2 parameters values can be read and modified using standard shell commands or from application programs ls sys module yaffs2 parameters yaffsautocheckpoint yaffstracemask yaffswrattempts cat sys module yaffs2 parameters yaffsautocheckpoint 1 echo 2 sys module yaffs2 parameters yaffsautocheckpoint cat sys module yaffs2 parameters yaffsautocheckpoint 2 yaffs currently supports the following variables yaffsautocheckpoint controls when checkpoints should be written yaffstracemask an alternative and less user friendly interface to modify tracing yaffswrattempts the number of attempts that yaffs will make to write a chunk yaffsgccontrol controls the garbage collector 34 linux proc yaffs state dumping some of the state of yaffs mounts can be determined by reading the proc yaffs entry cat proc yaffs charles charleslaptop opt y cvs yaffs2 cat proc yaffs yaffs built mar 16 2010 115225 id yaffsfsc v 1101 20100315 222715 charles exp id yaffsgutsc v 1119 20100312 24834 charles exp device  nand simulator partition  startblock  endblock 511 totalbytesperchunk 2048 usenandecc 1 notagsecc  isyaffs2 1 inbandtags  emptylostandfound 1 disablelazyload  refreshperiod 10000 nshortopcaches 10 nreservedblocks 5 ndatabytesperchunk 2048 chunkgroupbits  chunkgroupsize 1 nerasedblocks 152 blocksincheckpoint  ntnodescreated 2300 nfreetnodes 1852 nobjectscreated 2300 nfreeobjects 1842 nfreechunks 27843 npagewrites 65993 npagereads 19631 nblockerasures 1133 ngccopies 37 garbagecollections 161 passivegcs 137 nretriedwrites  nretireblocks  eccfixed  eccunfixed  tagseccfixed  tagseccunfixed  cachehits 44110 ndeletedfiles  nunlinkedfiles 42917 refreshcount 1 nbackgrouddeletions   4 conclusions yaffs includes many options for changing speed or memory use with specific flags for the yaffs direct interface as well as linux under linux many of the control variables can be altered using standard linux systems  