[Yaffs] Chunk Cache BUG

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Artis Kugevics
Date:  
To: yaffs
Subject: [Yaffs] Chunk Cache BUG
Hello,

following code should save data safely on NAND flash:

unsigned data = 123456;
int fd = open(any_file_name, O_WRONLY | O_CREAT, 0600);
write(fd, &data, sizeof(data));
fchmod(fd, any_mode);
fsync(fd);
close(fd);

In reality data is still in Chunk Cache. If power is lost, then data is lost
as well. Only on umount() data will be written out by
yaffs_FlushEntireDeviceCache().

The key here is
    fchmod(fd, any_mode);
between data is written and flush is called. Any attribute change on that file 
will call
    yaffs_UpdateObjectHeader()
function. That function will mark object as clean without flushing out data 
from Chunk Cache (dev->srCache).
Following
    yaffs_FlushFile()
will not call
    yaffs_FlushFilesChunkCache() 
as object is already marked clean.


I propose to call
    yaffs_FlushFilesChunkCache(in)
before marking object as clean in yaffs_UpdateObjectHeader() function.


Artis