[Yaffs-archive] [YAFFS] Caching fix and improvement

Charles Manning manningc2@actrix.gen.nz
Fri, 4 Apr 2003 06:03:03 +1200


Hi YAFFSers

The problems addressed here only apply to those using WinCE and YAFFS direct 
with caching enabled. They don't apply to Linux since Linux provides its own 
caching.


Problem 1: Cache bypass bug.

The cache is only used for "short operations" ie those which are not page 
(512 byte)  aligned. For example, if you read 1000 bytes from position 50, 
the read would span three pages. The first and last page accesses are not 
page aligned and would go into the cache.

The problem with this is that you'd get inconsistencies if you mix short and 
aligned accesses. eg:

	// Write a short sequence to the file.
	// This will go into the cache.
	yaffs_lseek(a,0,SEEK_SET);
	yaffs_write(a,"abcdefghijklmnopqrstuvwxyz",20); 

	// Read a short sequence from the file.
	// This will come from the cache.
	yaffs_lseek(a,0,SEEK_SET);
	yaffs_read(a,buffer1,30); 

	// Read a page size sequence from the file.
	yaffs_lseek(a,0,SEEK_SET);
	yaffs_read(a,buffer2,512); 

The first few bytes of buffer1 and buffer2 should be the same but they are 
not.

Simple fix: always read from cache if the data is cached.

This fix is now in CVS.

Improvement: Cache push-out policy change

The cache push-out policy decides which pages to push out of the cache to 
make way for a new cache page.

The current push-out policy favoured clean unmodified pages over modified 
pages. Under certain circumstances, this could result in excessive page 
thrashing. 

The policy has been modified to prevent (or at least reduce) this thrashing.

This improvement is now in CVS.

-- CHarles

---------------------------------------------------------------------------------------
This mailing list is hosted by Toby Churchill open software (www.toby-churchill.org).
If mailing list membership is no longer wanted you can remove yourself from the list by 
sending an email to yaffs-request@toby-churchill.org with the text "unsubscribe" 
(without the quotes) as the subject.