[Yaffs] Re: CONFIG_YAFFS_USE_GENERIC_RW ==> caching

Charles Manning manningc2@actrix.gen.nz
Fri, 15 Oct 2004 16:17:35 +1300


Perhaps you're getting confused between the Linux cache and the cache ins=
ide=20
YAFFS.

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

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

will do 500 writes into YAFFS.

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

Thus the above code will just write into the cache. The cache only writes=
 to=20
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 do=
es=20
not have a page cache like linix does) and writing was added shortly=20
thereafter. Since Linux has the page cache, and I thought it was a "write=
=20
into" cache, I didn't enable the cache for Linux. However, some time late=
r=20
someone was using code like the above and complained. I turned on caching=
 for=20
Linux and everything went much faster. One happy camper saying lots of ni=
ce=20
things on the list!

Perhaps that is the discussion you recall?

Using YAFFS under Linux without generic_rw has been broken for  a while=20
(broke during/around the addition of the softdelete speedups a year or mo=
re =20
ago). I have not heard complaints as such, only comments when people have=
 had=20
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 t=
hat
> > 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 us=
ing
> > 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 defi=
ning
> > 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 pu=
ll
> > 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-cas=
e,
> as I recall.
>
> Maybe what we need is some better docs about what the various defines d=
o
> 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 fe=
els
> enthused....
>
> Wookey