Page cache and write
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?
Thanx
-- Charles.
Quoted 18 lines · Charles Manning
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_readandgeneric_file_writeand 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);
Quoted 8 lines
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 <[email protected]>