Re: [Yaffs] Chunk Cache BUG

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Charles Manning
Date:  
To: yaffs
CC: Gennady Dagman
Subject: Re: [Yaffs] Chunk Cache BUG
Folks

Sorry I thought I had checked in a fix, but I had not.

It is now sorted in cvs

http://www.aleph1.co.uk/cgi-bin/viewcvs.cgi/yaffs2/yaffs_guts.c?r1=1.35&r2=1.36

On Wednesday 06 September 2006 08:24, Gennady Dagman wrote:
> Bingo !
>
> After applying proposed fix we were able to get rid of various long
> chased yaffs file-system corruptions (yaffs tragedy messages in boot
> time, strange objects in lost+found, kernel Oops'es, lost data in files
> etc). The trigger for all these problems were system reset/reboot
> WITHOUT unmounting yaffs partitions.


The problem that was occurring would only happen if you did a modification
like a chmod just before closing the file, then a reset. The chmod would say
that the file was no longer dirty (but it was, because there's still dirty in
the cache.

The solution is to only mark the file clean if the cache is also empty. I
chose to do this rather than Artis' fix because that can result in far more
writes (when you might not be expecting them).

-- Charles


>
> Thanks a lot.
>
> I believe this fix should be applied ASAP to yaffs code in repository.
>
> Gennady Dagman.
>
> Artis Kugevics wrote:
> >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
>
> _______________________________________________
> yaffs mailing list
>
> http://lists.aleph1.co.uk/cgi-bin/mailman/listinfo/yaffs