Thread (2 messages) 2 messages, 2 authors, 2003-05-19

Re: Page cache and write

From: Jan Hudec <hidden>
Date: 2003-05-19 20:14:38

On Tue, May 20, 2003 at 08:13:45AM +1200, Charles Manning wrote:
When writing the YAFFS NAND file system, I added an internal caching layer 
that caches both short reads and writes. This is used in most situations, but 
not in Linux.

Under Linux, YAFFS uses generic_file_read and generic_file_write and thus any 
caching is provided bythe page cache. It was my understanding that the page 
cache will cache up writes. However, from the experiences of some YAFFS users 
this is not the case and enabling the YAFFS internal caching resulted in 
dramatic speedup (eg 15 seconds-> 3 seconds for a certain code sequence).

I now want to understand whether I should enable internal caching in YAFFS or 
whether I should be using the page cache differently.

Consider the code

  for(i=0; i < 1000; i++)
       write(f,b,1);

On a flash file system this would take a long time if each write goes all the 
way to the fs. I assume too that this code does not result in 1000 disk 
writes on a regular file system (eg ext2).

Questions: Does the page cache do anything to help in this case?

Question: Assuming ext2 does not do 1000 physical writes to disk, where does 
the consolidation happen?
Writes through page-cache work like this: When a page should be written
to, it is first read. Then the modification is made in memory and the
page is marked dirty. When something gets to it, it writes the page to
disk. The something might be either memory allocator when it desperately
needs a page or a bdflush when it decides the page is dirty for too
long. (Hope I don't remember it too wrong).

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec [off-list ref]
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help