Re: [Yaffs] Re: CONFIG_YAFFS_USE_GENERIC_RW ==> caching

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Charles Manning
Date:  
To: Wookey, yaffs
Old-Topics: [Yaffs] Re: CONFIG_YAFFS_USE_GENERIC_RW
Subject: Re: [Yaffs] Re: CONFIG_YAFFS_USE_GENERIC_RW ==> caching
Perhaps you're getting confused between the Linux cache and the cache inside
YAFFS.

The Linux page cache is pretty efficient for both read and write. However,
it is a "write through" cache, not a "write into" cache. This means that any
writes get written all the way through to the file system, so the code

for(i = 0; i < 500; i++) write(f,"a",1);

will do 500 writes into YAFFS.

YAFFS has an internal "write into" "short op" cache. This cache only operates
on read/writes that are smaller than a NAND page .

Thus the above code will just write into the cache. The cache only writes to
NAND when:
* the file flushes or closes
* the cache "spills" ie. gets full and some space must be retrieved.

The caching code was originally written for WinCE reading (since WinCE does
not have a page cache like linix does) and writing was added shortly
thereafter. Since Linux has the page cache, and I thought it was a "write
into" cache, I didn't enable the cache for Linux. However, some time later
someone was using code like the above and complained. I turned on caching for
Linux and everything went much faster. One happy camper saying lots of nice
things on the list!

Perhaps that is the discussion you recall?

Using YAFFS under Linux without generic_rw has been broken for a while
(broke during/around the addition of the softdelete speedups a year or more
ago). I have not heard complaints as such, only comments when people have had
a play and YAFFS bit back (like this thread from Ulla).

-- Charles


On Friday 15 October 2004 13:45, Wookey wrote:
> +++ Charles Manning [04-10-14 12:12 +1300]:
> > This is a historic thing.
> > USE_GENERIC_RW uses the Linux page cache for read/write. This means that
> > the Linux generic_read and generic_write functions are used which and
> > YAFFS supplies the read_page write_page calls.
> >
> > Not defining USE_GENERIC_RW directly implements read/write without using
> > the page cache.
> >
> > The direct read/write stuff was iimplemented first, and I followed it by
> > generic read/write when memory mapping was implemented. During the
> > transition both options worked. Things have now moved on and not defining
> > USE_GENERIC_RW is broken, with no real motivation to fix it.
> >
> > Ie. You should always define USE_GENERIC_RW.
> >
> > This comes up every couple of months on the list. I guess I should pull
> > it out.
>
> We did find one person who found that it was useful to avoid the cache as
> it gave them a significant speedup in their fairly pathological use-case,
> as I recall.
>
> Maybe what we need is some better docs about what the various defines do
> and when you would want to use them....
>
> There has been a lot of useful info on this list in the last couple of
> weeks - it just needs collecting together and putting on the web/in the
> docs.
>
> I've been meaning to updatethe docs for a while - but if anyone else feels
> enthused....
>
> Wookey